text:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE eagle SYSTEM "eagle.dtd">
<eagle version="9.4.2">
<drawing>
<settings>
<setting alwaysvectorfont="no"/>
<setting verticaltext="up"/>
</settings>
<grid distance="0.1" unitdist="inch" unit="inch" style="lines" multiple="1" display="no" altdistance="0.01" altunitdist="inch" altunit="inch"/>
<layers>
<layer number="1" name="Top" color="4" fill="1" visible="no" active="no"/>
<layer number="2" name="Route2" color="16" fill="1" visible="no" active="no"/>
<layer number="3" name="Route3" color="17" fill="1" visible="no" active="no"/>
<layer number="4" name="tKeepout" color="0" fill="1" visible="no" active="no"/>
<layer number="5" name="Route5" color="19" fill="1" visible="no" active="no"/>
<layer number="6" name="Route6" color="25" fill="1" visible="no" active="no"/>
<layer number="7" name="Route7" color="26" fill="1" visible="no" active="no"/>
<layer number="8" name="Route8" color="27" fill="1" visible="no" active="no"/>
<layer number="9" name="Route9" color="28" fill="1" visible="no" active="no"/>
<layer number="10" name="Route10" color="29" fill="1" visible="no" active="no"/>
<layer number="11" name="Route11" color="30" fill="1" visible="no" active="no"/>
<layer number="12" name="Route12" color="20" fill="1" visible="no" active="no"/>
<layer number="13" name="Route13" color="21" fill="1" visible="no" active="no"/>
<layer number="14" name="Route14" color="22" fill="1" visible="no" active="no"/>
<layer number="15" name="Route15" color="23" fill="1" visible="no" active="no"/>
<layer number="16" name="Bottom" color="4" fill="1" visible="no" active="no"/>
<layer number="17" name="Pads" color="2" fill="1" visible="no" active="no"/>
<layer number="18" name="Vias" color="2" fill="1" visible="no" active="no"/>
<layer number="19" name="Unrouted" color="6" fill="1" visible="no" active="no"/>
<layer number="20" name="Dimension" color="24" fill="1" visible="no" active="no"/>
<layer number="21" name="tPlace" color="7" fill="1" visible="no" active="no"/>
<layer number="22" name="bPlace" color="7" fill="1" visible="no" active="no"/>
<layer number="23" name="tOrigins" color="15" fill="1" visible="no" active="no"/>
<layer number="24" name="bOrigins" color="15" fill="1" visible="no" active="no"/>
<layer number="25" name="tNames" color="7" fill="1" visible="no" active="no"/>
<layer number="26" name="bNames" color="7" fill="1" visible="no" active="no"/>
<layer number="27" name="tValues" color="7" fill="1" visible="no" active="no"/>
<layer number="28" name="bValues" color="7" fill="1" visible="no" active="no"/>
<layer number="29" name="tStop" color="7" fill="1" visible="no" active="no"/>
<layer number="30" name="bStop" color="7" fill="1" visible="no" active="no"/>
<layer number="31" name="tCream" color="7" fill="1" visible="no" active="no"/>
<layer number="32" name="bCream" color="7" fill="1" visible="no" active="no"/>
<layer number="33" name="tFinish" color="6" fill="3" visible="no" active="no"/>
<layer number="34" name="bFinish" color="6" fill="6" visible="no" active="no"/>
<layer number="35" name="tGlue" color="7" fill="4" visible="no" active="no"/>
<layer number="36" name="bGlue" color="7" fill="5" visible="no" active="no"/>
<layer number="37" name="tTest" color="7" fill="1" visible="no" active="no"/>
<layer number="38" name="bTest" color="7" fill="1" visible="no" active="no"/>
<layer number="39" name="tKeepout" color="4" fill="1" visible="no" active="no"/>
<layer number="40" name="bKeepout" color="4" fill="1" visible="no" active="no"/>
<layer number="41" name="tRestrict" color="0" fill="1" visible="no" active="no"/>
<layer number="42" name="bRestrict" color="0" fill="1" visible="no" active="no"/>
<layer number="43" name="vRestrict" color="2" fill="10" visible="no" active="no"/>
<layer number="44" name="Drills" color="7" fill="1" visible="no" active="no"/>
<layer number="45" name="Holes" color="7" fill="1" visible="no" active="no"/>
<layer number="46" name="Milling" color="3" fill="1" visible="no" active="no"/>
<layer number="47" name="Measures" color="7" fill="1" visible="no" active="no"/>
<layer number="48" name="Document" color="7" fill="1" visible="no" active="no"/>
<layer number="49" name="Reference" color="7" fill="1" visible="no" active="no"/>
<layer number="50" name="dxf" color="7" fill="1" visible="no" active="no"/>
<layer number="51" name="tDocu" color="7" fill="1" visible="no" active="no"/>
<layer number="52" name="bDocu" color="7" fill="1" visible="no" active="no"/>
<layer number="53" name="tGND_GNDA" color="7" fill="1" visible="no" active="no"/>
<layer number="54" name="bGND_GNDA" color="7" fill="1" visible="no" active="no"/>
<layer number="56" name="wert" color="7" fill="1" visible="no" active="no"/>
<layer number="57" name="tCAD" color="7" fill="1" visible="no" active="no"/>
<layer number="59" name="tCarbon" color="7" fill="1" visible="no" active="no"/>
<layer number="60" name="bCarbon" color="7" fill="1" visible="no" active="no"/>
<layer number="88" name="SimResults" color="9" fill="1" visible="yes" active="yes"/>
<layer number="89" name="SimProbes" color="9" fill="1" visible="yes" active="yes"/>
<layer number="90" name="Modules" color="5" fill="1" visible="yes" active="yes"/>
<layer number="91" name="Nets" color="2" fill="1" visible="yes" active="yes"/>
<layer number="92" name="Busses" color="1" fill="1" visible="yes" active="yes"/>
<layer number="93" name="Pins" color="2" fill="1" visible="no" active="yes"/>
<layer number="94" name="Symbols" color="4" fill="1" visible="yes" active="yes"/>
<layer number="95" name="Names" color="7" fill="1" visible="yes" active="yes"/>
<layer number="96" name="Values" color="7" fill="1" visible="yes" active="yes"/>
<layer number="97" name="Info" color="7" fill="1" visible="yes" active="yes"/>
<layer number="98" name="Guide" color="6" fill="1" visible="yes" active="yes"/>
<layer number="99" name="SpiceOrder" color="7" fill="1" visible="yes" active="yes"/>
<layer number="100" name="Muster" color="7" fill="1" visible="yes" active="yes"/>
<layer number="101" name="Patch_Top" color="7" fill="1" visible="yes" active="yes"/>
<layer number="102" name="Vscore" color="7" fill="1" visible="yes" active="yes"/>
<layer number="103" name="tMap" color="7" fill="1" visible="yes" active="yes"/>
<layer number="104" name="Name" color="7" fill="1" visible="yes" active="yes"/>
<layer number="105" name="tPlate" color="7" fill="1" visible="yes" active="yes"/>
<layer number="106" name="bPlate" color="7" fill="1" visible="yes" active="yes"/>
<layer number="107" name="Crop" color="7" fill="1" visible="yes" active="yes"/>
<layer number="108" name="tplace-old" color="7" fill="1" visible="yes" active="yes"/>
<layer number="109" name="ref-old" color="7" fill="1" visible="yes" active="yes"/>
<layer number="110" name="fp0" color="7" fill="1" visible="yes" active="yes"/>
<layer number="111" name="LPC17xx" color="7" fill="1" visible="yes" active="yes"/>
<layer number="112" name="tSilk" color="7" fill="1" visible="yes" active="yes"/>
<layer number="113" name="IDFDebug" color="7" fill="1" visible="yes" active="yes"/>
<layer number="114" name="Badge_Outline" color="7" fill="1" visible="yes" active="yes"/>
<layer number="115" name="ReferenceISLANDS" color="7" fill="1" visible="yes" active="yes"/>
<layer number="116" name="Patch_BOT" color="7" fill="1" visible="yes" active="yes"/>
<layer number="117" name="BACKMAAT1" color="7" fill="1" visible="yes" active="yes"/>
<layer number="118" name="Rect_Pads" color="7" fill="1" visible="yes" active="yes"/>
<layer number="119" name="KAP_TEKEN" color="7" fill="1" visible="yes" active="yes"/>
<layer number="120" name="KAP_MAAT1" color="7" fill="1" visible="yes" active="yes"/>
<layer number="121" name="_tsilk" color="7" fill="1" visible="yes" active="yes"/>
<layer number="122" name="_bsilk" color="7" fill="1" visible="yes" active="yes"/>
<layer number="123" name="tTestmark" color="7" fill="1" visible="yes" active="yes"/>
<layer number="124" name="bTestmark" color="7" fill="1" visible="yes" active="yes"/>
<layer number="125" name="_tNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="126" name="_bNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="127" name="_tValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="128" name="_bValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="129" name="Mask" color="7" fill="1" visible="yes" active="yes"/>
<layer number="130" name="SMDSTROOK" color="7" fill="1" visible="yes" active="yes"/>
<layer number="131" name="tAdjust" color="7" fill="1" visible="yes" active="yes"/>
<layer number="132" name="bAdjust" color="7" fill="1" visible="yes" active="yes"/>
<layer number="133" name="bottom_silk" color="7" fill="1" visible="yes" active="yes"/>
<layer number="134" name="silk_top" color="7" fill="1" visible="yes" active="yes"/>
<layer number="135" name="silk_bottom" color="7" fill="1" visible="yes" active="yes"/>
<layer number="136" name="silktop" color="7" fill="1" visible="yes" active="yes"/>
<layer number="137" name="silkbottom" color="7" fill="1" visible="yes" active="yes"/>
<layer number="138" name="NEw" color="7" fill="1" visible="yes" active="yes"/>
<layer number="139" name="mtKeepout" color="7" fill="1" visible="yes" active="yes"/>
<layer number="140" name="mbKeepout" color="7" fill="1" visible="yes" active="yes"/>
<layer number="141" name="mtRestrict" color="7" fill="1" visible="yes" active="yes"/>
<layer number="142" name="mbRestrict" color="7" fill="1" visible="yes" active="yes"/>
<layer number="143" name="mvRestrict" color="7" fill="1" visible="yes" active="yes"/>
<layer number="144" name="Drill_legend" color="7" fill="1" visible="yes" active="yes"/>
<layer number="145" name="DrillLegend_01-16" color="7" fill="1" visible="yes" active="yes"/>
<layer number="146" name="DrillLegend_01-20" color="7" fill="1" visible="yes" active="yes"/>
<layer number="147" name="mMeasures" color="7" fill="1" visible="yes" active="yes"/>
<layer number="148" name="mDocument" color="7" fill="1" visible="yes" active="yes"/>
<layer number="149" name="mReference" color="7" fill="1" visible="yes" active="yes"/>
<layer number="150" name="Notes" color="7" fill="1" visible="yes" active="yes"/>
<layer number="151" name="HeatSink" color="7" fill="1" visible="yes" active="yes"/>
<layer number="152" name="_bDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="153" name="FabDoc1" color="7" fill="1" visible="yes" active="yes"/>
<layer number="154" name="FabDoc2" color="7" fill="1" visible="yes" active="yes"/>
<layer number="155" name="FabDoc3" color="7" fill="1" visible="yes" active="yes"/>
<layer number="166" name="AntennaArea" color="7" fill="1" visible="yes" active="yes"/>
<layer number="168" name="4mmHeightArea" color="7" fill="1" visible="yes" active="yes"/>
<layer number="191" name="mNets" color="7" fill="1" visible="yes" active="yes"/>
<layer number="192" name="mBusses" color="7" fill="1" visible="yes" active="yes"/>
<layer number="193" name="mPins" color="7" fill="1" visible="yes" active="yes"/>
<layer number="194" name="mSymbols" color="7" fill="1" visible="yes" active="yes"/>
<layer number="195" name="mNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="196" name="mValues" color="7" fill="1" visible="yes" active="yes"/>
<layer number="199" name="Contour" color="7" fill="1" visible="yes" active="yes"/>
<layer number="200" name="200bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="201" name="201bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="202" name="202bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="203" name="203bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="204" name="204bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="205" name="205bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="206" name="206bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="207" name="207bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="208" name="208bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="209" name="209bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="210" name="210bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="211" name="211bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="212" name="212bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="213" name="213bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="214" name="214bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="215" name="215bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="216" name="216bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="217" name="217bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="218" name="218bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="219" name="219bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="220" name="220bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="221" name="221bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="222" name="222bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="223" name="223bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="224" name="224bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="225" name="225bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="226" name="226bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="227" name="227bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="228" name="228bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="229" name="229bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="230" name="230bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="231" name="231bmp" color="7" fill="1" visible="yes" active="yes"/>
<layer number="232" name="Eagle3D_PG2" color="7" fill="1" visible="yes" active="yes"/>
<layer number="233" name="Eagle3D_PG3" color="7" fill="1" visible="yes" active="yes"/>
<layer number="248" name="Housing" color="7" fill="1" visible="yes" active="yes"/>
<layer number="249" name="Edge" color="7" fill="1" visible="yes" active="yes"/>
<layer number="250" name="Descript" color="7" fill="1" visible="yes" active="yes"/>
<layer number="251" name="SMDround" color="7" fill="1" visible="yes" active="yes"/>
<layer number="254" name="cooling" color="7" fill="1" visible="yes" active="yes"/>
<layer number="255" name="routoute" color="7" fill="1" visible="yes" active="yes"/>
</layers>
<schematic xreflabel="%F%N/%S.%C%R" xrefpart="/%S.%C%R">
<libraries>
<library name="SN" urn="urn:adsk.eagle:library:11605008">
<description>Upverter Parts Library

Created by Upverter.com</description>
<packages>
<package name="MICROCHIP_MCP661-E-SN_0" urn="urn:adsk.eagle:footprint:11605012/1" library_version="1" library_locally_modified="yes">
<description>AMP-OPA-MCP601-IL8</description>
<wire x1="-1" y1="-2.5" x2="-1" y2="2.5" width="0.15" layer="21"/>
<wire x1="1" y1="-2.5" x2="1" y2="2.5" width="0.15" layer="21"/>
<wire x1="-1" y1="2.5" x2="1" y2="2.5" width="0.15" layer="21"/>
<wire x1="-1" y1="-2.5" x2="1" y2="-2.5" width="0.15" layer="21"/>
<wire x1="-2" y1="-2.5" x2="-2" y2="2.5" width="0.1" layer="51"/>
<wire x1="2" y1="-2.5" x2="2" y2="2.5" width="0.1" layer="51"/>
<wire x1="-2" y1="2.5" x2="2" y2="2.5" width="0.1" layer="51"/>
<wire x1="-2" y1="-2.5" x2="2" y2="-2.5" width="0.1" layer="51"/>
<wire x1="-3.4" y1="-2.6" x2="-3.4" y2="2.6" width="0.1" layer="39"/>
<wire x1="-3.4" y1="2.6" x2="3.4" y2="2.6" width="0.1" layer="39"/>
<wire x1="3.4" y1="2.6" x2="3.4" y2="-2.6" width="0.1" layer="39"/>
<wire x1="3.4" y1="-2.6" x2="-3.4" y2="-2.6" width="0.1" layer="39"/>
<text x="-4.4" y="2.88" size="1" layer="25">>NAME</text>
<circle x="-2.35" y="2.755" radius="0.125" width="0.25" layer="21"/>
<circle x="-0.2" y="1.7" radius="0.2" width="0.4" layer="21"/>
<circle x="-1.1" y="1.6" radius="0.5" width="0.1" layer="51"/>
<smd name="1" x="-2.35" y="1.905" dx="0.6" dy="1.9" layer="1" roundness="100" rot="R90"/>
<smd name="2" x="-2.35" y="0.635" dx="0.6" dy="1.9" layer="1" roundness="100" rot="R90"/>
<smd name="3" x="-2.35" y="-0.635" dx="0.6" dy="1.9" layer="1" roundness="100" rot="R90"/>
<smd name="4" x="-2.35" y="-1.905" dx="0.6" dy="1.9" layer="1" roundness="100" rot="R90"/>
<smd name="8" x="2.35" y="1.905" dx="0.6" dy="1.9" layer="1" roundness="100" rot="R90"/>
<smd name="7" x="2.35" y="0.635" dx="0.6" dy="1.9" layer="1" roundness="100" rot="R90"/>
<smd name="6" x="2.35" y="-0.635" dx="0.6" dy="1.9" layer="1" roundness="100" rot="R90"/>
<smd name="5" x="2.35" y="-1.905" dx="0.6" dy="1.9" layer="1" roundness="100" rot="R90"/>
</package>
<package name="MICROCHIP_MCP661-E-SN_1" urn="urn:adsk.eagle:footprint:11605011/1" library_version="1" library_locally_modified="yes">
<description>AMP-OPA-MCP601-IL8</description>
<wire x1="-0.9" y1="-2.5" x2="-0.9" y2="2.5" width="0.15" layer="21"/>
<wire x1="0.9" y1="-2.5" x2="0.9" y2="2.5" width="0.15" layer="21"/>
<wire x1="-0.9" y1="2.5" x2="0.9" y2="2.5" width="0.15" layer="21"/>
<wire x1="-0.9" y1="-2.5" x2="0.9" y2="-2.5" width="0.15" layer="21"/>
<wire x1="-2" y1="-2.5" x2="-2" y2="2.5" width="0.1" layer="51"/>
<wire x1="2" y1="-2.5" x2="2" y2="2.5" width="0.1" layer="51"/>
<wire x1="-2" y1="2.5" x2="2" y2="2.5" width="0.1" layer="51"/>
<wire x1="-2" y1="-2.5" x2="2" y2="-2.5" width="0.1" layer="51"/>
<wire x1="-3.75" y1="-2.75" x2="-3.75" y2="2.75" width="0.1" layer="39"/>
<wire x1="-3.75" y1="2.75" x2="3.75" y2="2.75" width="0.1" layer="39"/>
<wire x1="3.75" y1="2.75" x2="3.75" y2="-2.75" width="0.1" layer="39"/>
<wire x1="3.75" y1="-2.75" x2="-3.75" y2="-2.75" width="0.1" layer="39"/>
<text x="-4.75" y="2.88" size="1" layer="25">>NAME</text>
<circle x="-2.4" y="2.755" radius="0.125" width="0.25" layer="21"/>
<circle x="-0.1" y="1.7" radius="0.2" width="0.4" layer="21"/>
<circle x="-1.1" y="1.6" radius="0.5" width="0.1" layer="51"/>
<smd name="1" x="-2.4" y="1.905" dx="0.6" dy="2.2" layer="1" roundness="100" rot="R90"/>
<smd name="2" x="-2.4" y="0.635" dx="0.6" dy="2.2" layer="1" roundness="100" rot="R90"/>
<smd name="3" x="-2.4" y="-0.635" dx="0.6" dy="2.2" layer="1" roundness="100" rot="R90"/>
<smd name="4" x="-2.4" y="-1.905" dx="0.6" dy="2.2" layer="1" roundness="100" rot="R90"/>
<smd name="8" x="2.4" y="1.905" dx="0.6" dy="2.2" layer="1" roundness="100" rot="R90"/>
<smd name="7" x="2.4" y="0.635" dx="0.6" dy="2.2" layer="1" roundness="100" rot="R90"/>
<smd name="6" x="2.4" y="-0.635" dx="0.6" dy="2.2" layer="1" roundness="100" rot="R90"/>
<smd name="5" x="2.4" y="-1.905" dx="0.6" dy="2.2" layer="1" roundness="100" rot="R90"/>
</package>
<package name="MICROCHIP_MCP661-E-SN_2" urn="urn:adsk.eagle:footprint:11605010/2" library_version="2">
<description>AMP-OPA-MCP601-IL8</description>
<wire x1="-0.8" y1="-2.5" x2="0.8" y2="-2.5" width="0.15" layer="21"/>
<wire x1="-0.8" y1="2.5" x2="0.8" y2="2.5" width="0.15" layer="21"/>
<wire x1="0.8" y1="-2.5" x2="0.8" y2="2.5" width="0.15" layer="21"/>
<wire x1="-0.8" y1="-2.5" x2="-0.8" y2="2.5" width="0.15" layer="21"/>
<wire x1="-2" y1="-2.5" x2="2" y2="-2.5" width="0.1" layer="51"/>
<wire x1="-2" y1="2.5" x2="2" y2="2.5" width="0.1" layer="51"/>
<wire x1="2" y1="-2.5" x2="2" y2="2.5" width="0.1" layer="51"/>
<wire x1="-2" y1="-2.5" x2="-2" y2="2.5" width="0.1" layer="51"/>
<text x="-5.2" y="3" size="1" layer="25">>NAME</text>
<circle x="-2.45" y="2.805" radius="0.125" width="0.25" layer="21"/>
<circle x="-1.1" y="1.6" radius="0.5" width="0.1" layer="51"/>
<smd name="5" x="2.45" y="-1.905" dx="0.7" dy="2.5" layer="1" roundness="100" rot="R90"/>
<smd name="6" x="2.45" y="-0.635" dx="0.7" dy="2.5" layer="1" roundness="100" rot="R90"/>
<smd name="7" x="2.45" y="0.635" dx="0.7" dy="2.5" layer="1" roundness="100" rot="R90"/>
<smd name="8" x="2.45" y="1.905" dx="0.7" dy="2.5" layer="1" roundness="100" rot="R90"/>
<smd name="4" x="-2.45" y="-1.905" dx="0.7" dy="2.5" layer="1" roundness="100" rot="R90"/>
<smd name="3" x="-2.45" y="-0.635" dx="0.7" dy="2.5" layer="1" roundness="100" rot="R90"/>
<smd name="2" x="-2.45" y="0.635" dx="0.7" dy="2.5" layer="1" roundness="100" rot="R90"/>
<smd name="1" x="-2.45" y="1.905" dx="0.7" dy="2.5" layer="1" roundness="100" rot="R90"/>
</package>
</packages>
<packages3d>
<package3d name="MICROCHIP_MCP661-E-SN_0" urn="urn:adsk.eagle:package:11605016/1" type="box" library_version="1" library_locally_modified="yes">
<description>AMP-OPA-MCP601-IL8</description>
<packageinstances>
<packageinstance name="MICROCHIP_MCP661-E-SN_0"/>
</packageinstances>
</package3d>
<package3d name="MICROCHIP_MCP661-E-SN_1" urn="urn:adsk.eagle:package:11605015/1" type="box" library_version="1" library_locally_modified="yes">
<description>AMP-OPA-MCP601-IL8</description>
<packageinstances>
<packageinstance name="MICROCHIP_MCP661-E-SN_1"/>
</packageinstances>
</package3d>
<package3d name="SOIC127P550X265-8" urn="urn:adsk.eagle:package:11605014/3" type="model" library_version="2">
<description>AMP-OPA-MCP601-IL8</description>
<packageinstances>
<packageinstance name="MICROCHIP_MCP661-E-SN_2"/>
</packageinstances>
</package3d>
</packages3d>
<symbols>
<symbol name="MICROCHIP_MCP661-E-SN_0_0" urn="urn:adsk.eagle:symbol:11605013/1" library_version="1" library_locally_modified="yes">
<description>AMP-OPA-MCP601-IL8</description>
<wire x1="0" y1="-5.08" x2="10.16" y2="-10.16" width="0.254" layer="94"/>
<wire x1="0" y1="-15.24" x2="10.16" y2="-10.16" width="0.254" layer="94"/>
<wire x1="0" y1="-5.08" x2="0" y2="-15.24" width="0.254" layer="94"/>
<wire x1="1.016" y1="-7.62" x2="2.54" y2="-7.62" width="0.254" layer="94"/>
<wire x1="1.016" y1="-12.7" x2="2.54" y2="-12.7" width="0.254" layer="94"/>
<wire x1="1.778" y1="-11.938" x2="1.778" y2="-13.462" width="0.254" layer="94"/>
<wire x1="5.08" y1="-5.08" x2="5.08" y2="-7.62" width="0.254" layer="94"/>
<wire x1="5.08" y1="-12.7" x2="5.08" y2="-15.24" width="0.254" layer="94"/>
<wire x1="7.62" y1="-11.43" x2="10.16" y2="-15.24" width="0.254" layer="94"/>
<wire x1="2.54" y1="-13.97" x2="0" y2="-17.78" width="0.254" layer="94"/>
<wire x1="2.54" y1="-6.35" x2="0" y2="-2.54" width="0.254" layer="94"/>
<wire x1="5.08" y1="-5.08" x2="5.08" y2="-5.08" width="0.15" layer="94"/>
<wire x1="0" y1="-12.7" x2="0" y2="-12.7" width="0.15" layer="94"/>
<wire x1="0" y1="-7.62" x2="0" y2="-7.62" width="0.15" layer="94"/>
<wire x1="5.08" y1="-15.24" x2="5.08" y2="-15.24" width="0.15" layer="94"/>
<wire x1="10.16" y1="-10.16" x2="10.16" y2="-10.16" width="0.15" layer="94"/>
<wire x1="0" y1="-17.78" x2="0" y2="-17.78" width="0.15" layer="94"/>
<wire x1="10.16" y1="-15.24" x2="10.16" y2="-15.24" width="0.15" layer="94"/>
<wire x1="0" y1="-2.54" x2="0" y2="-2.54" width="0.15" layer="94"/>
<text x="0" y="0" size="2.54" layer="95" align="top-left">>NAME</text>
<text x="0" y="-22.86" size="2.54" layer="95" align="top-left">MCP661-E/SN</text>
<pin name="VDD" x="5.08" y="0" visible="pad" length="middle" direction="pwr" rot="R270"/>
<pin name="VIN+" x="-5.08" y="-12.7" visible="pad" length="middle" direction="in"/>
<pin name="VIN-" x="-5.08" y="-7.62" visible="pad" length="middle" direction="in"/>
<pin name="VSS" x="5.08" y="-20.32" visible="pad" length="middle" direction="pwr" rot="R90"/>
<pin name="VOUT" x="15.24" y="-10.16" visible="pad" length="middle" direction="out" rot="R180"/>
<pin name="1_NC" x="-5.08" y="-17.78" visible="pad" length="middle" direction="pas"/>
<pin name="2_NC" x="15.24" y="-15.24" visible="pad" length="middle" direction="pas" rot="R180"/>
<pin name="3_NC" x="-5.08" y="-2.54" visible="pad" length="middle" direction="pas"/>
</symbol>
</symbols>
<devicesets>
<deviceset name="MICROCHIP_MCP661-E-SN" urn="urn:adsk.eagle:component:11605017/2" prefix="U" library_version="2">
<description>AMP-OPA-MCP601-IL8</description>
<gates>
<gate name="G$0" symbol="MICROCHIP_MCP661-E-SN_0_0" x="0" y="0"/>
</gates>
<devices>
<device name="MICROCHIP_MCP661-E-SN_0_0" package="MICROCHIP_MCP661-E-SN_0">
<connects>
<connect gate="G$0" pin="1_NC" pad="1"/>
<connect gate="G$0" pin="2_NC" pad="5"/>
<connect gate="G$0" pin="3_NC" pad="8"/>
<connect gate="G$0" pin="VDD" pad="7"/>
<connect gate="G$0" pin="VIN+" pad="3"/>
<connect gate="G$0" pin="VIN-" pad="2"/>
<connect gate="G$0" pin="VOUT" pad="6"/>
<connect gate="G$0" pin="VSS" pad="4"/>
</connects>
<package3dinstances>
<package3dinstance package3d_urn="urn:adsk.eagle:package:11605016/1"/>
</package3dinstances>
<technologies>
<technology name="">
<attribute name="CIIVA_IDS" value="1325176"/>
<attribute name="CODE__IPC" value="SOIC127P600-8"/>
<attribute name="CODE__JEDEC" value="MS-012"/>
<attribute name="COMPONENT_LINK_1_DESCRIPTION" value="Manufacturer URL"/>
<attribute name="COMPONENT_LINK_1_URL" value="http://www.microchip.com/"/>
<attribute name="COMPONENT_LINK_3_DESCRIPTION" value="Package Specification"/>
<attribute name="COMPONENT_LINK_3_URL" value="http://www.microchip.com/stellent/groups/techpub_sg/documents/packagingspec/en012702.pdf"/>
<attribute name="DATASHEET" value="http://ww1.microchip.com/downloads/en/DeviceDoc/22194C.pdf"/>
<attribute name="DATASHEET_VERSION" value="revC, Nov-2011"/>
<attribute name="FOOTPRINT_VARIANT_NAME_0" value="Level C"/>
<attribute name="FOOTPRINT_VARIANT_NAME_1" value="Level B"/>
<attribute name="FOOTPRINT_VARIANT_NAME_2" value="Level A"/>
<attribute name="IMPORTED" value="yes"/>
<attribute name="IMPORTED_FROM" value="vault"/>
<attribute name="IMPORT_TS" value="1521851511"/>
<attribute name="MF" value="Microchip"/>
<attribute name="MPN" value="MCP661-E/SN"/>
<attribute name="PACKAGE" value="SOIC-SN8"/>
<attribute name="PACKAGE_DESCRIPTION" value="8-Lead Plastic Small Outline (SN) - Narrow, 3.90mm Body [SOIC]"/>
<attribute name="PACKAGE_VERSION" value="revBB, Aug-2009"/>
<attribute name="PREFIX" value="U"/>
<attribute name="RELEASE_DATE" value="1331952694"/>
<attribute name="VAULT_GUID" value="973559BF-ABD0-425F-8F5C-143CC353DD3C"/>
<attribute name="VAULT_REVISION" value="DF713E88-1BB5-4496-A0BE-75F4F4915CB1"/>
</technology>
</technologies>
</device>
<device name="MICROCHIP_MCP661-E-SN_0_1" package="MICROCHIP_MCP661-E-SN_1">
<connects>
<connect gate="G$0" pin="1_NC" pad="1"/>
<connect gate="G$0" pin="2_NC" pad="5"/>
<connect gate="G$0" pin="3_NC" pad="8"/>
<connect gate="G$0" pin="VDD" pad="7"/>
<connect gate="G$0" pin="VIN+" pad="3"/>
<connect gate="G$0" pin="VIN-" pad="2"/>
<connect gate="G$0" pin="VOUT" pad="6"/>
<connect gate="G$0" pin="VSS" pad="4"/>
</connects>
<package3dinstances>
<package3dinstance package3d_urn="urn:adsk.eagle:package:11605015/1"/>
</package3dinstances>
<technologies>
<technology name="">
<attribute name="CIIVA_IDS" value="1325176"/>
<attribute name="CODE__IPC" value="SOIC127P600-8"/>
<attribute name="CODE__JEDEC" value="MS-012"/>
<attribute name="COMPONENT_LINK_1_DESCRIPTION" value="Manufacturer URL"/>
<attribute name="COMPONENT_LINK_1_URL" value="http://www.microchip.com/"/>
<attribute name="COMPONENT_LINK_3_DESCRIPTION" value="Package Specification"/>
<attribute name="COMPONENT_LINK_3_URL" value="http://www.microchip.com/stellent/groups/techpub_sg/documents/packagingspec/en012702.pdf"/>
<attribute name="DATASHEET" value="http://ww1.microchip.com/downloads/en/DeviceDoc/22194C.pdf"/>
<attribute name="DATASHEET_VERSION" value="revC, Nov-2011"/>
<attribute name="FOOTPRINT_VARIANT_NAME_0" value="Level C"/>
<attribute name="FOOTPRINT_VARIANT_NAME_1" value="Level B"/>
<attribute name="FOOTPRINT_VARIANT_NAME_2" value="Level A"/>
<attribute name="IMPORTED" value="yes"/>
<attribute name="IMPORTED_FROM" value="vault"/>
<attribute name="IMPORT_TS" value="1521851511"/>
<attribute name="MF" value="Microchip"/>
<attribute name="MPN" value="MCP661-E/SN"/>
<attribute name="PACKAGE" value="SOIC-SN8"/>
<attribute name="PACKAGE_DESCRIPTION" value="8-Lead Plastic Small Outline (SN) - Narrow, 3.90mm Body [SOIC]"/>
<attribute name="PACKAGE_VERSION" value="revBB, Aug-2009"/>
<attribute name="PREFIX" value="U"/>
<attribute name="RELEASE_DATE" value="1331952694"/>
<attribute name="VAULT_GUID" value="973559BF-ABD0-425F-8F5C-143CC353DD3C"/>
<attribute name="VAULT_REVISION" value="DF713E88-1BB5-4496-A0BE-75F4F4915CB1"/>
</technology>
</technologies>
</device>
<device name="MICROCHIP_MCP661-E-SN_0_2" package="MICROCHIP_MCP661-E-SN_2">
<connects>
<connect gate="G$0" pin="1_NC" pad="1"/>
<connect gate="G$0" pin="2_NC" pad="5"/>
<connect gate="G$0" pin="3_NC" pad="8"/>
<connect gate="G$0" pin="VDD" pad="7"/>
<connect gate="G$0" pin="VIN+" pad="3"/>
<connect gate="G$0" pin="VIN-" pad="2"/>
<connect gate="G$0" pin="VOUT" pad="6"/>
<connect gate="G$0" pin="VSS" pad="4"/>
</connects>
<package3dinstances>
<package3dinstance package3d_urn="urn:adsk.eagle:package:11605014/3"/>
</package3dinstances>
<technologies>
<technology name="">
<attribute name="CIIVA_IDS" value="1325176"/>
<attribute name="CODE__IPC" value="SOIC127P600-8"/>
<attribute name="CODE__JEDEC" value="MS-012"/>
<attribute name="COMPONENT_LINK_1_DESCRIPTION" value="Manufacturer URL"/>
<attribute name="COMPONENT_LINK_1_URL" value="http://www.microchip.com/"/>
<attribute name="COMPONENT_LINK_3_DESCRIPTION" value="Package Specification"/>
<attribute name="COMPONENT_LINK_3_URL" value="http://www.microchip.com/stellent/groups/techpub_sg/documents/packagingspec/en012702.pdf"/>
<attribute name="DATASHEET" value="http://ww1.microchip.com/downloads/en/DeviceDoc/22194C.pdf"/>
<attribute name="DATASHEET_VERSION" value="revC, Nov-2011"/>
<attribute name="FOOTPRINT_VARIANT_NAME_0" value="Level C"/>
<attribute name="FOOTPRINT_VARIANT_NAME_1" value="Level B"/>
<attribute name="FOOTPRINT_VARIANT_NAME_2" value="Level A"/>
<attribute name="IMPORTED" value="yes"/>
<attribute name="IMPORTED_FROM" value="vault"/>
<attribute name="IMPORT_TS" value="1521851511"/>
<attribute name="MF" value="Microchip"/>
<attribute name="MPN" value="MCP661-E/SN"/>
<attribute name="PACKAGE" value="SOIC-SN8"/>
<attribute name="PACKAGE_DESCRIPTION" value="8-Lead Plastic Small Outline (SN) - Narrow, 3.90mm Body [SOIC]"/>
<attribute name="PACKAGE_VERSION" value="revBB, Aug-2009"/>
<attribute name="PREFIX" value="U"/>
<attribute name="RELEASE_DATE" value="1331952694"/>
<attribute name="VAULT_GUID" value="973559BF-ABD0-425F-8F5C-143CC353DD3C"/>
<attribute name="VAULT_REVISION" value="DF713E88-1BB5-4496-A0BE-75F4F4915CB1"/>
</technology>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
<library name="Bourns - 3006P-1-101LF" urn="urn:adsk.eagle:library:5424097">
<description>Upverter Parts Library

Created by Upverter.com</description>
<packages>
<package name="BOURNS_3006P-1-101LF_0" urn="urn:adsk.eagle:footprint:5424098/1" library_version="1" library_locally_modified="yes">
<description>Trimpot® Trimming Potentiometer</description>
<wire x1="-10.285" y1="-2.415" x2="-10.285" y2="2.415" width="0.15" layer="51"/>
<wire x1="-10.285" y1="2.415" x2="10.285" y2="2.415" width="0.15" layer="51"/>
<wire x1="10.285" y1="2.415" x2="10.285" y2="-2.415" width="0.15" layer="51"/>
<wire x1="10.285" y1="-2.415" x2="-10.285" y2="-2.415" width="0.15" layer="51"/>
<wire x1="-10.51" y1="-2.64" x2="-10.51" y2="2.64" width="0.1" layer="41"/>
<wire x1="-10.51" y1="2.64" x2="10.51" y2="2.64" width="0.1" layer="41"/>
<wire x1="10.51" y1="2.64" x2="10.51" y2="-2.64" width="0.1" layer="41"/>
<wire x1="10.51" y1="-2.64" x2="-10.51" y2="-2.64" width="0.1" layer="41"/>
<wire x1="-10.285" y1="-2.5" x2="-10.285" y2="2.5" width="0.15" layer="21"/>
<wire x1="-10.285" y1="2.5" x2="8.765" y2="2.5" width="0.15" layer="21"/>
<wire x1="8.765" y1="2.5" x2="8.765" y2="-2.5" width="0.15" layer="21"/>
<wire x1="8.765" y1="-2.5" x2="-10.285" y2="-2.5" width="0.15" layer="21"/>
<wire x1="8.765" y1="-1.18" x2="8.765" y2="1.18" width="0.15" layer="21"/>
<wire x1="8.765" y1="1.18" x2="10.285" y2="1.18" width="0.15" layer="21"/>
<wire x1="10.285" y1="1.18" x2="10.285" y2="-1.18" width="0.15" layer="21"/>
<wire x1="10.285" y1="-1.18" x2="8.765" y2="-1.18" width="0.15" layer="21"/>
<text x="-10.25" y="3" size="1" layer="25">>NAME</text>
<circle x="-10.95" y="1.015" radius="0.25" width="0" layer="21"/>
<pad name="3" x="5.465" y="1.015" drill="0.7" diameter="1.2"/>
<pad name="1" x="-7.235" y="1.015" drill="0.7" diameter="1.2" shape="square"/>
<pad name="2" x="0.385" y="-1.525" drill="0.7" diameter="1.2"/>
</package>
</packages>
<packages3d>
<package3d name="BOURNS_3006P-1-101LF_0" urn="urn:adsk.eagle:package:5424100/2" type="model" library_version="1" library_locally_modified="yes">
<description>Trimpot® Trimming Potentiometer</description>
<packageinstances>
<packageinstance name="BOURNS_3006P-1-101LF_0"/>
</packageinstances>
</package3d>
</packages3d>
<symbols>
<symbol name="BOURNS_3006P-1-101LF_0_0" urn="urn:adsk.eagle:symbol:5424099/1" library_version="1" library_locally_modified="yes">
<description>Trimpot® Trimming Potentiometer</description>
<wire x1="2.54" y1="-2.54" x2="3.302" y2="-1.27" width="0.508" layer="94"/>
<wire x1="3.302" y1="-1.27" x2="4.572" y2="-3.81" width="0.508" layer="94"/>
<wire x1="4.572" y1="-3.81" x2="5.842" y2="-1.27" width="0.508" layer="94"/>
<wire x1="5.842" y1="-1.27" x2="7.112" y2="-3.81" width="0.508" layer="94"/>
<wire x1="7.112" y1="-3.81" x2="8.382" y2="-1.27" width="0.508" layer="94"/>
<wire x1="8.382" y1="-1.27" x2="9.652" y2="-3.81" width="0.508" layer="94"/>
<wire x1="9.652" y1="-3.81" x2="10.16" y2="-2.54" width="0.508" layer="94"/>
<wire x1="7.62" y1="-4.318" x2="6.858" y2="-5.334" width="0.508" layer="94"/>
<wire x1="7.62" y1="-4.318" x2="8.382" y2="-5.334" width="0.508" layer="94"/>
<wire x1="2.54" y1="-2.54" x2="2.54" y2="-2.54" width="0.15" layer="94"/>
<wire x1="10.16" y1="-2.54" x2="10.16" y2="-2.54" width="0.15" layer="94"/>
<wire x1="7.62" y1="-5.08" x2="7.62" y2="-4.318" width="0.15" layer="94"/>
<text x="2.286" y="4.064" size="2.54" layer="95" align="top-left">>NAME</text>
<text x="-2.794" y="1.524" size="2.54" layer="95" align="top-left">3006P-1-101LF</text>
<pin name="CCW" x="-2.54" y="-2.54" visible="pad" length="middle"/>
<pin name="CW" x="15.24" y="-2.54" visible="pad" length="middle" rot="R180"/>
<pin name="WIPER" x="7.62" y="-10.16" visible="pad" length="middle" rot="R90"/>
</symbol>
</symbols>
<devicesets>
<deviceset name="BOURNS_3006P-1-101LF" urn="urn:adsk.eagle:component:5424101/1" locally_modified="yes" prefix="VR" library_version="1" library_locally_modified="yes">
<description>Trimpot® Trimming Potentiometer</description>
<gates>
<gate name="G$0" symbol="BOURNS_3006P-1-101LF_0_0" x="0" y="0"/>
</gates>
<devices>
<device name="BOURNS_3006P-1-101LF_0_0" package="BOURNS_3006P-1-101LF_0">
<connects>
<connect gate="G$0" pin="CCW" pad="1"/>
<connect gate="G$0" pin="CW" pad="3"/>
<connect gate="G$0" pin="WIPER" pad="2"/>
</connects>
<package3dinstances>
<package3dinstance package3d_urn="urn:adsk.eagle:package:5424100/2"/>
</package3dinstances>
<technologies>
<technology name="">
<attribute name="CAPACITANCE" value="TRIMMER 100 OHM 0.75W PC PIN"/>
<attribute name="CENTROID_NOT_SPECIFIED" value="No"/>
<attribute name="DATASHEET" value="http://www.bourns.com/docs/Product-Datasheets/3006.pdf"/>
<attribute name="DIGIKEY_DESCRIPTION" value="RES TRIMMER 100 OHM 0.75W PC PIN"/>
<attribute name="DIGIKEY_PART_NUMBER" value="3006P-101LF-ND"/>
<attribute name="LEAD_FREE" value="yes"/>
<attribute name="MF" value="Bourns"/>
<attribute name="MOUSER_PART_NUMBER" value="652-3006P-1-101-LF"/>
<attribute name="MPN" value="3006P-1-101LF"/>
<attribute name="PACKAGE" value="DIP_TRIMMER_19MM05_4MM83"/>
<attribute name="PREFIX" value="VR"/>
<attribute name="RESISTANCE" value="100 Ohms"/>
<attribute name="ROHS" value="yes"/>
<attribute name="TEMPERATURE_RANGE_HIGH" value="+125°C"/>
<attribute name="TEMPERATURE_RANGE_LOW" value="-55°C"/>
</technology>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
<library name="MySparkFun" urn="urn:adsk.eagle:library:10539731">
<packages>
</packages>
<symbols>
<symbol name="VCC2" urn="urn:adsk.eagle:symbol:10539735/1" library_version="2">
<wire x1="0.762" y1="1.27" x2="0" y2="2.54" width="0.254" layer="94"/>
<wire x1="0" y1="2.54" x2="-0.762" y2="1.27" width="0.254" layer="94"/>
<pin name="VCC" x="0" y="0" visible="off" length="short" direction="sup" rot="R90"/>
<text x="-1.016" y="3.556" size="1.778" layer="96">>VALUE</text>
</symbol>
<symbol name="GND" urn="urn:adsk.eagle:symbol:10539738/1" library_version="2">
<wire x1="-1.905" y1="0" x2="1.905" y2="0" width="0.254" layer="94"/>
<pin name="GND" x="0" y="2.54" visible="off" length="short" direction="sup" rot="R270"/>
<text x="-2.54" y="-2.54" size="1.778" layer="96">>VALUE</text>
</symbol>
</symbols>
<devicesets>
<deviceset name="VCC" urn="urn:adsk.eagle:component:10539743/1" prefix="P+" library_version="2">
<description><b>SUPPLY SYMBOL</b></description>
<gates>
<gate name="1" symbol="VCC2" x="0" y="0"/>
</gates>
<devices>
<device name="">
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
<deviceset name="GND" urn="urn:adsk.eagle:component:10539746/1" prefix="GND" library_version="2">
<description><b>SUPPLY SYMBOL</b></description>
<gates>
<gate name="1" symbol="GND" x="0" y="0"/>
</gates>
<devices>
<device name="">
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
<library name="pinhead" urn="urn:adsk.eagle:library:325">
<description><b>Pin Header Connectors</b><p>
<author>Created by librarian@cadsoft.de</author></description>
<packages>
<package name="1X04" urn="urn:adsk.eagle:footprint:22258/1" library_version="3">
<description><b>PIN HEADER</b></description>
<wire x1="0" y1="0.635" x2="0.635" y2="1.27" width="0.1524" layer="21"/>
<wire x1="0.635" y1="1.27" x2="1.905" y2="1.27" width="0.1524" layer="21"/>
<wire x1="1.905" y1="1.27" x2="2.54" y2="0.635" width="0.1524" layer="21"/>
<wire x1="2.54" y1="0.635" x2="2.54" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="2.54" y1="-0.635" x2="1.905" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="1.905" y1="-1.27" x2="0.635" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="0.635" y1="-1.27" x2="0" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="-4.445" y1="1.27" x2="-3.175" y2="1.27" width="0.1524" layer="21"/>
<wire x1="-3.175" y1="1.27" x2="-2.54" y2="0.635" width="0.1524" layer="21"/>
<wire x1="-2.54" y1="0.635" x2="-2.54" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="-2.54" y1="-0.635" x2="-3.175" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="-2.54" y1="0.635" x2="-1.905" y2="1.27" width="0.1524" layer="21"/>
<wire x1="-1.905" y1="1.27" x2="-0.635" y2="1.27" width="0.1524" layer="21"/>
<wire x1="-0.635" y1="1.27" x2="0" y2="0.635" width="0.1524" layer="21"/>
<wire x1="0" y1="0.635" x2="0" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="0" y1="-0.635" x2="-0.635" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="-0.635" y1="-1.27" x2="-1.905" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="-1.905" y1="-1.27" x2="-2.54" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="-5.08" y1="0.635" x2="-5.08" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="-4.445" y1="1.27" x2="-5.08" y2="0.635" width="0.1524" layer="21"/>
<wire x1="-5.08" y1="-0.635" x2="-4.445" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="-3.175" y1="-1.27" x2="-4.445" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="3.175" y1="1.27" x2="4.445" y2="1.27" width="0.1524" layer="21"/>
<wire x1="4.445" y1="1.27" x2="5.08" y2="0.635" width="0.1524" layer="21"/>
<wire x1="5.08" y1="0.635" x2="5.08" y2="-0.635" width="0.1524" layer="21"/>
<wire x1="5.08" y1="-0.635" x2="4.445" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="3.175" y1="1.27" x2="2.54" y2="0.635" width="0.1524" layer="21"/>
<wire x1="2.54" y1="-0.635" x2="3.175" y2="-1.27" width="0.1524" layer="21"/>
<wire x1="4.445" y1="-1.27" x2="3.175" y2="-1.27" width="0.1524" layer="21"/>
<pad name="1" x="-3.81" y="0" drill="1.016" shape="long" rot="R90"/>
<pad name="2" x="-1.27" y="0" drill="1.016" shape="long" rot="R90"/>
<pad name="3" x="1.27" y="0" drill="1.016" shape="long" rot="R90"/>
<pad name="4" x="3.81" y="0" drill="1.016" shape="long" rot="R90"/>
<text x="-5.1562" y="1.8288" size="1.27" layer="25" ratio="10">>NAME</text>
<text x="-5.08" y="-3.175" size="1.27" layer="27">>VALUE</text>
<rectangle x1="1.016" y1="-0.254" x2="1.524" y2="0.254" layer="51"/>
<rectangle x1="-1.524" y1="-0.254" x2="-1.016" y2="0.254" layer="51"/>
<rectangle x1="-4.064" y1="-0.254" x2="-3.556" y2="0.254" layer="51"/>
<rectangle x1="3.556" y1="-0.254" x2="4.064" y2="0.254" layer="51"/>
</package>
<package name="1X04/90" urn="urn:adsk.eagle:footprint:22259/1" library_version="3">
<description><b>PIN HEADER</b></description>
<wire x1="-5.08" y1="-1.905" x2="-2.54" y2="-1.905" width="0.1524" layer="21"/>
<wire x1="-2.54" y1="-1.905" x2="-2.54" y2="0.635" width="0.1524" layer="21"/>
<wire x1="-2.54" y1="0.635" x2="-5.08" y2="0.635" width="0.1524" layer="21"/>
<wire x1="-5.08" y1="0.635" x2="-5.08" y2="-1.905" width="0.1524" layer="21"/>
<wire x1="-3.81" y1="6.985" x2="-3.81" y2="1.27" width="0.762" layer="21"/>
<wire x1="-2.54" y1="-1.905" x2="0" y2="-1.905" width="0.1524" layer="21"/>
<wire x1="0" y1="-1.905" x2="0" y2="0.635" width="0.1524" layer="21"/>
<wire x1="0" y1="0.635" x2="-2.54" y2="0.635" width="0.1524" layer="21"/>
<wire x1="-1.27" y1="6.985" x2="-1.27" y2="1.27" width="0.762" layer="21"/>
<wire x1="0" y1="-1.905" x2="2.54" y2="-1.905" width="0.1524" layer="21"/>
<wire x1="2.54" y1="-1.905" x2="2.54" y2="0.635" width="0.1524" layer="21"/>
<wire x1="2.54" y1="0.635" x2="0" y2="0.635" width="0.1524" layer="21"/>
<wire x1="1.27" y1="6.985" x2="1.27" y2="1.27" width="0.762" layer="21"/>
<wire x1="2.54" y1="-1.905" x2="5.08" y2="-1.905" width="0.1524" layer="21"/>
<wire x1="5.08" y1="-1.905" x2="5.08" y2="0.635" width="0.1524" layer="21"/>
<wire x1="5.08" y1="0.635" x2="2.54" y2="0.635" width="0.1524" layer="21"/>
<wire x1="3.81" y1="6.985" x2="3.81" y2="1.27" width="0.762" layer="21"/>
<pad name="1" x="-3.81" y="-3.81" drill="1.016" shape="long" rot="R90"/>
<pad name="2" x="-1.27" y="-3.81" drill="1.016" shape="long" rot="R90"/>
<pad name="3" x="1.27" y="-3.81" drill="1.016" shape="long" rot="R90"/>
<pad name="4" x="3.81" y="-3.81" drill="1.016" shape="long" rot="R90"/>
<text x="-5.715" y="-3.81" size="1.27" layer="25" ratio="10" rot="R90">>NAME</text>
<text x="6.985" y="-4.445" size="1.27" layer="27" rot="R90">>VALUE</text>
<rectangle x1="-4.191" y1="0.635" x2="-3.429" y2="1.143" layer="21"/>
<rectangle x1="-1.651" y1="0.635" x2="-0.889" y2="1.143" layer="21"/>
<rectangle x1="0.889" y1="0.635" x2="1.651" y2="1.143" layer="21"/>
<rectangle x1="3.429" y1="0.635" x2="4.191" y2="1.143" layer="21"/>
<rectangle x1="-4.191" y1="-2.921" x2="-3.429" y2="-1.905" layer="21"/>
<rectangle x1="-1.651" y1="-2.921" x2="-0.889" y2="-1.905" layer="21"/>
<rectangle x1="0.889" y1="-2.921" x2="1.651" y2="-1.905" layer="21"/>
<rectangle x1="3.429" y1="-2.921" x2="4.191" y2="-1.905" layer="21"/>
</package>
</packages>
<packages3d>
<package3d name="1X04" urn="urn:adsk.eagle:package:22407/2" type="model" library_version="3">
<description>PIN HEADER</description>
<packageinstances>
<packageinstance name="1X04"/>
</packageinstances>
</package3d>
<package3d name="1X04/90" urn="urn:adsk.eagle:package:22404/2" type="model" library_version="3">
<description>PIN HEADER</description>
<packageinstances>
<packageinstance name="1X04/90"/>
</packageinstances>
</package3d>
</packages3d>
<symbols>
<symbol name="PINHD4" urn="urn:adsk.eagle:symbol:22257/1" library_version="3">
<wire x1="-6.35" y1="-5.08" x2="1.27" y2="-5.08" width="0.4064" layer="94"/>
<wire x1="1.27" y1="-5.08" x2="1.27" y2="7.62" width="0.4064" layer="94"/>
<wire x1="1.27" y1="7.62" x2="-6.35" y2="7.62" width="0.4064" layer="94"/>
<wire x1="-6.35" y1="7.62" x2="-6.35" y2="-5.08" width="0.4064" layer="94"/>
<text x="-6.35" y="8.255" size="1.778" layer="95">>NAME</text>
<text x="-6.35" y="-7.62" size="1.778" layer="96">>VALUE</text>
<pin name="1" x="-2.54" y="5.08" visible="pad" length="short" direction="pas" function="dot"/>
<pin name="2" x="-2.54" y="2.54" visible="pad" length="short" direction="pas" function="dot"/>
<pin name="3" x="-2.54" y="0" visible="pad" length="short" direction="pas" function="dot"/>
<pin name="4" x="-2.54" y="-2.54" visible="pad" length="short" direction="pas" function="dot"/>
</symbol>
</symbols>
<devicesets>
<deviceset name="PINHD-1X4" urn="urn:adsk.eagle:component:22499/4" prefix="JP" uservalue="yes" library_version="3">
<description><b>PIN HEADER</b></description>
<gates>
<gate name="A" symbol="PINHD4" x="0" y="0"/>
</gates>
<devices>
<device name="" package="1X04">
<connects>
<connect gate="A" pin="1" pad="1"/>
<connect gate="A" pin="2" pad="2"/>
<connect gate="A" pin="3" pad="3"/>
<connect gate="A" pin="4" pad="4"/>
</connects>
<package3dinstances>
<package3dinstance package3d_urn="urn:adsk.eagle:package:22407/2"/>
</package3dinstances>
<technologies>
<technology name=""/>
</technologies>
</device>
<device name="/90" package="1X04/90">
<connects>
<connect gate="A" pin="1" pad="1"/>
<connect gate="A" pin="2" pad="2"/>
<connect gate="A" pin="3" pad="3"/>
<connect gate="A" pin="4" pad="4"/>
</connects>
<package3dinstances>
<package3dinstance package3d_urn="urn:adsk.eagle:package:22404/2"/>
</package3dinstances>
<technologies>
<technology name=""/>
</technologies>
</device>
</devices>
</deviceset>
</devicesets>
</library>
</libraries>
<attributes>
</attributes>
<variantdefs>
</variantdefs>
<classes>
<class number="0" name="default" width="0.254" drill="0.254">
<clearance class="0" value="0.254"/>
</class>
</classes>
<parts>
<part name="U1" library="SN" library_urn="urn:adsk.eagle:library:11605008" deviceset="MICROCHIP_MCP661-E-SN" device="MICROCHIP_MCP661-E-SN_0_2" package3d_urn="urn:adsk.eagle:package:11605014/3"/>
<part name="VR1" library="Bourns - 3006P-1-101LF" library_urn="urn:adsk.eagle:library:5424097" deviceset="BOURNS_3006P-1-101LF" device="BOURNS_3006P-1-101LF_0_0" package3d_urn="urn:adsk.eagle:package:5424100/2"/>
<part name="P+1" library="MySparkFun" library_urn="urn:adsk.eagle:library:10539731" deviceset="VCC" device=""/>
<part name="P+2" library="MySparkFun" library_urn="urn:adsk.eagle:library:10539731" deviceset="VCC" device=""/>
<part name="GND1" library="MySparkFun" library_urn="urn:adsk.eagle:library:10539731" deviceset="GND" device=""/>
<part name="GND2" library="MySparkFun" library_urn="urn:adsk.eagle:library:10539731" deviceset="GND" device=""/>
<part name="JP3" library="pinhead" library_urn="urn:adsk.eagle:library:325" deviceset="PINHD-1X4" device="" package3d_urn="urn:adsk.eagle:package:22407/2"/>
<part name="JP4" library="pinhead" library_urn="urn:adsk.eagle:library:325" deviceset="PINHD-1X4" device="" package3d_urn="urn:adsk.eagle:package:22407/2"/>
<part name="P+3" library="MySparkFun" library_urn="urn:adsk.eagle:library:10539731" deviceset="VCC" device=""/>
<part name="GND3" library="MySparkFun" library_urn="urn:adsk.eagle:library:10539731" deviceset="GND" device=""/>
</parts>
<sheets>
<sheet>
<plain>
</plain>
<instances>
<instance part="U1" gate="G$0" x="68.58" y="68.58" smashed="yes" rot="MR180">
<attribute name="NAME" x="68.58" y="68.58" size="2.54" layer="95" rot="MR180" align="top-left"/>
</instance>
<instance part="VR1" gate="G$0" x="35.56" y="68.58" smashed="yes" rot="R90">
<attribute name="NAME" x="31.496" y="70.866" size="2.54" layer="95" rot="R90" align="top-left"/>
</instance>
<instance part="P+1" gate="1" x="38.1" y="86.36" smashed="yes">
<attribute name="VALUE" x="37.084" y="89.916" size="1.778" layer="96"/>
</instance>
<instance part="P+2" gate="1" x="73.66" y="88.9" smashed="yes">
<attribute name="VALUE" x="72.644" y="92.456" size="1.778" layer="96"/>
</instance>
<instance part="GND1" gate="1" x="38.1" y="63.5" smashed="yes">
<attribute name="VALUE" x="35.56" y="60.96" size="1.778" layer="96"/>
</instance>
<instance part="GND2" gate="1" x="73.66" y="66.04" smashed="yes">
<attribute name="VALUE" x="71.12" y="63.5" size="1.778" layer="96"/>
</instance>
<instance part="JP3" gate="A" x="-7.62" y="83.82" smashed="yes" rot="R180">
<attribute name="NAME" x="-1.27" y="75.565" size="1.778" layer="95" rot="R180"/>
<attribute name="VALUE" x="-1.27" y="91.44" size="1.778" layer="96" rot="R180"/>
</instance>
<instance part="JP4" gate="A" x="134.62" y="76.2" smashed="yes">
<attribute name="NAME" x="128.27" y="84.455" size="1.778" layer="95"/>
<attribute name="VALUE" x="128.27" y="68.58" size="1.778" layer="96"/>
</instance>
<instance part="P+3" gate="1" x="109.22" y="88.9" smashed="yes">
<attribute name="VALUE" x="108.204" y="92.456" size="1.778" layer="96"/>
</instance>
<instance part="GND3" gate="1" x="114.3" y="66.04" smashed="yes">
<attribute name="VALUE" x="111.76" y="63.5" size="1.778" layer="96"/>
</instance>
</instances>
<busses>
</busses>
<nets>
<net name="VREF" class="0">
<segment>
<wire x1="-5.08" y1="81.28" x2="25.4" y2="81.28" width="0.1524" layer="91"/>
<pinref part="JP3" gate="A" pin="2"/>
<label x="17.78" y="81.28" size="1.778" layer="95"/>
</segment>
<segment>
<pinref part="U1" gate="G$0" pin="VIN-"/>
<pinref part="VR1" gate="G$0" pin="WIPER"/>
<wire x1="45.72" y1="76.2" x2="63.5" y2="76.2" width="0.1524" layer="91"/>
<label x="48.26" y="76.2" size="1.778" layer="95"/>
<label x="78.74" y="60.96" size="1.778" layer="95"/>
</segment>
</net>
<net name="VCC" class="0">
<segment>
<pinref part="VR1" gate="G$0" pin="CW"/>
<pinref part="P+1" gate="1" pin="VCC"/>
<junction x="38.1" y="86.36"/>
<wire x1="38.1" y1="86.36" x2="-5.08" y2="86.36" width="0.1524" layer="91"/>
<pinref part="JP3" gate="A" pin="4"/>
<wire x1="38.1" y1="86.36" x2="38.1" y2="83.82" width="0.1524" layer="91"/>
</segment>
<segment>
<pinref part="U1" gate="G$0" pin="VSS"/>
<pinref part="P+2" gate="1" pin="VCC"/>
</segment>
<segment>
<pinref part="JP4" gate="A" pin="1"/>
<wire x1="132.08" y1="81.28" x2="109.22" y2="81.28" width="0.1524" layer="91"/>
<wire x1="109.22" y1="81.28" x2="109.22" y2="88.9" width="0.1524" layer="91"/>
<pinref part="P+3" gate="1" pin="VCC"/>
</segment>
</net>
<net name="GND" class="0">
<segment>
<pinref part="VR1" gate="G$0" pin="CCW"/>
<pinref part="GND1" gate="1" pin="GND"/>
<wire x1="-5.08" y1="78.74" x2="-5.08" y2="66.04" width="0.1524" layer="91"/>
<wire x1="-5.08" y1="66.04" x2="38.1" y2="66.04" width="0.1524" layer="91"/>
<junction x="38.1" y="66.04"/>
<pinref part="JP3" gate="A" pin="1"/>
</segment>
<segment>
<pinref part="U1" gate="G$0" pin="VDD"/>
<pinref part="GND2" gate="1" pin="GND"/>
</segment>
<segment>
<pinref part="JP4" gate="A" pin="4"/>
<wire x1="132.08" y1="73.66" x2="114.3" y2="73.66" width="0.1524" layer="91"/>
<wire x1="114.3" y1="73.66" x2="114.3" y2="68.58" width="0.1524" layer="91"/>
<pinref part="GND3" gate="1" pin="GND"/>
</segment>
</net>
<net name="IN" class="0">
<segment>
<pinref part="U1" gate="G$0" pin="VIN+"/>
<wire x1="63.5" y1="81.28" x2="48.26" y2="81.28" width="0.1524" layer="91"/>
<label x="48.26" y="81.28" size="1.778" layer="95"/>
</segment>
<segment>
<wire x1="-5.08" y1="83.82" x2="15.24" y2="83.82" width="0.1524" layer="91"/>
<label x="0" y="83.82" size="1.778" layer="95"/>
<pinref part="JP3" gate="A" pin="3"/>
<label x="15.24" y="83.82" size="1.778" layer="95"/>
</segment>
</net>
<net name="OUT" class="0">
<segment>
<pinref part="U1" gate="G$0" pin="VOUT"/>
<pinref part="JP4" gate="A" pin="2"/>
<wire x1="83.82" y1="78.74" x2="114.3" y2="78.74" width="0.1524" layer="91"/>
<pinref part="JP4" gate="A" pin="3"/>
<wire x1="114.3" y1="78.74" x2="132.08" y2="78.74" width="0.1524" layer="91"/>
<wire x1="132.08" y1="76.2" x2="114.3" y2="76.2" width="0.1524" layer="91"/>
<wire x1="114.3" y1="76.2" x2="114.3" y2="78.74" width="0.1524" layer="91"/>
<junction x="114.3" y="78.74"/>
<label x="88.9" y="78.74" size="1.778" layer="95"/>
</segment>
</net>
</nets>
</sheet>
</sheets>
</schematic>
</drawing>
<compatibility>
<note version="8.2" severity="warning">
Since Version 8.2, EAGLE supports online libraries. The ids
of those online libraries will not be understood (or retained)
with this version.
</note>
<note version="8.3" severity="warning">
Since Version 8.3, EAGLE supports URNs for individual library
assets (packages, symbols, and devices). The URNs of those assets
will not be understood (or retained) with this version.
</note>
<note version="8.3" severity="warning">
Since Version 8.3, EAGLE supports the association of 3D packages
with devices in libraries, schematics, and board files. Those 3D
packages will not be understood (or retained) with this version.
</note>
</compatibility>
</eagle>

repository: newdigate/electronics-comparator

repo_name: newdigate/electronics-comparator

extension: sch


text:
package prometheustest

import (
	"context"
	"time"

	"github.com/kiali/kiali/prometheus"
	"github.com/prometheus/client_golang/api/prometheus/v1"
	"github.com/prometheus/common/model"
	"github.com/stretchr/testify/mock"
)

// PromAPIMock for mocking Prometheus API
type PromAPIMock struct {
	mock.Mock
}

func (o *PromAPIMock) Query(ctx context.Context, query string, ts time.Time) (model.Value, error) {
	args := o.Called(ctx, query, ts)
	return args.Get(0).(model.Value), args.Error(1)
}

func (o *PromAPIMock) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error) {
	args := o.Called(ctx, query, r)
	return args.Get(0).(model.Value), args.Error(1)
}

func (o *PromAPIMock) LabelValues(ctx context.Context, label string) (model.LabelValues, error) {
	args := o.Called(ctx, label)
	return args.Get(0).(model.LabelValues), args.Error(1)
}

func (o *PromAPIMock) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error) {
	args := o.Called(ctx, matches, startTime, endTime)
	return args.Get(0).([]model.LabelSet), args.Error(1)
}

// AlwaysReturnEmpty mocks all possible queries to return empty result
func (o *PromAPIMock) AlwaysReturnEmpty() {
	metric := model.Metric{
		"__name__": "whatever",
		"instance": "whatever",
		"job":      "whatever"}
	o.On(
		"Query",
		mock.AnythingOfType("*context.emptyCtx"),
		mock.AnythingOfType("string"),
		mock.AnythingOfType("time.Time"),
	).Return(model.Vector{}, nil)
	matrix := model.Matrix{
		&model.SampleStream{
			Metric: metric,
			Values: []model.SamplePair{}}}
	o.On(
		"QueryRange",
		mock.AnythingOfType("*context.emptyCtx"),
		mock.AnythingOfType("string"),
		mock.AnythingOfType("v1.Range"),
	).Return(matrix, nil)
}

// SpyArgumentsAndReturnEmpty mocks all possible queries to return empty result,
// allowing to spy arguments through input callback
func (o *PromAPIMock) SpyArgumentsAndReturnEmpty(fn func(args mock.Arguments)) {
	metric := model.Metric{
		"__name__": "whatever",
		"instance": "whatever",
		"job":      "whatever"}
	o.On(
		"Query",
		mock.AnythingOfType("*context.emptyCtx"),
		mock.AnythingOfType("string"),
		mock.AnythingOfType("time.Time"),
	).Run(fn).Return(model.Vector{}, nil)
	matrix := model.Matrix{
		&model.SampleStream{
			Metric: metric,
			Values: []model.SamplePair{}}}
	o.On(
		"QueryRange",
		mock.AnythingOfType("*context.emptyCtx"),
		mock.AnythingOfType("string"),
		mock.AnythingOfType("v1.Range"),
	).Run(fn).Return(matrix, nil)
}

type PromClientMock struct {
	mock.Mock
}

func (o *PromClientMock) GetServiceHealth(namespace, servicename string, ports []int32) (prometheus.EnvoyHealth, error) {
	args := o.Called(namespace, servicename, ports)
	return args.Get(0).(prometheus.EnvoyHealth), args.Error(1)
}

func (o *PromClientMock) GetNamespaceServicesRequestRates(namespace, ratesInterval string) (model.Vector, model.Vector, error) {
	args := o.Called(namespace, ratesInterval)
	return args.Get(0).(model.Vector), args.Get(1).(model.Vector), args.Error(2)
}

func (o *PromClientMock) GetServiceRequestRates(namespace, service, ratesInterval string) (model.Vector, model.Vector, error) {
	args := o.Called(namespace, ratesInterval)
	return args.Get(0).(model.Vector), args.Get(1).(model.Vector), args.Error(2)
}

func (o *PromClientMock) GetSourceServices(namespace, servicename string) (map[string][]string, error) {
	args := o.Called(namespace, servicename)
	return args.Get(0).(map[string][]string), args.Error(1)
}

repository: aiminickwong/kiali

license_type: permissive

repo_name: aiminickwong/kiali

branch_name: refs/heads/master

extension: go


text:
require bcmdhd.inc

LIC_FILES_CHKSUM = "file://${M}/dhd_linux.c;endline=29;md5=8a24c5318b99277c9cc40f18dbf7731c"

SRCREV = "38a2e98"

SRC_URI = "https://dreamboxupdate.com/download/opendreambox/${BPN}/${BPN}.${PV}-${SRCREV}.tar.xz \
           file://0001-Makefile-set-default-firmware-path.patch"
SRC_URI[md5sum] = "6c4425868dd86785f1986ce7642685f1"
SRC_URI[sha256sum] = "177af925bc2e7130e59dc56b0e6f13b992fee8ab57e7b221671e5cb2ec37e008"

S = "${WORKDIR}/${BPN}.${PV}"

COMPATIBLE_MACHINE = "^(meson64)$"

license: MIT

repository: opendreambox/opendreambox

repo_name: opendreambox/opendreambox

branch_name: refs/heads/pyro

gha_license_id: NOASSERTION

gha_language: BitBake

extension: bb


text:
SUMMARY = "GNOME Authentication Agent for PolicyKit"
DESCRIPTION = "PolicyKit-gnome provides an Authentication Agent for PolicyKit that integrates well with the GNOME desktop environment"
HOMEPAGE = "http://www.packagekit.org/"
BUGTRACKER = "http://bugzilla.gnome.org/"
DEPENDS = "polkit dbus-glib gconf gtk+ intltool-native gnome-common"
LICENSE = "LGPLv2+"
LIC_FILES_CHKSUM = "file://COPYING;md5=74579fab173e4c5e12aac0cd83ee98ec \
                    file://src/main.c;beginline=1;endline=20;md5=aba145d1802f2329ba561e3e48ecb795"

SRC_URI = "https://download.gnome.org/sources/polkit-gnome/${PV}/polkit-gnome-${PV}.tar.xz \
           file://gtk-doc-check.patch \
"
SRC_URI[md5sum] = "50ecad37c8342fb4a52f590db7530621"
SRC_URI[sha256sum] = "1784494963b8bf9a00eedc6cd3a2868fb123b8a5e516e66c5eda48df17ab9369"

#PNBLACKLIST[polkit-gnome] ?= "Fails to build, m4:configure.ac:125: recursion limit of 1024 exceeded, use -L<N> to change it"

EXTRA_OECONF = "\
    --disable-static \
"

DEPENDS += "gtk+3"

inherit autotools gtk-doc pkgconfig

FILES_${PN} += " ${datadir}/dbus-1 \
                 ${datadir}/PolicyKit \
"

repository: gumstix/meta-gumstix-extras

repo_name: gumstix/meta-gumstix-extras

branch_name: refs/heads/warrior

gha_license_id: MIT

gha_language: C


text:
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package middlewares

import (
	"net/http"
	"net/url"
	"time"

	"code.gitea.io/gitea/modules/setting"
)

// NewCookie creates a cookie
func NewCookie(name, value string, maxAge int) *http.Cookie {
	return &http.Cookie{
		Name:     name,
		Value:    value,
		HttpOnly: true,
		Path:     setting.SessionConfig.CookiePath,
		Domain:   setting.SessionConfig.Domain,
		MaxAge:   maxAge,
		Secure:   setting.SessionConfig.Secure,
	}
}

// SetCookie set the cookies
// TODO: Copied from gitea.com/macaron/macaron and should be improved after macaron removed.
func SetCookie(resp http.ResponseWriter, name string, value string, others ...interface{}) {
	cookie := http.Cookie{}
	cookie.Name = name
	cookie.Value = url.QueryEscape(value)

	if len(others) > 0 {
		switch v := others[0].(type) {
		case int:
			cookie.MaxAge = v
		case int64:
			cookie.MaxAge = int(v)
		case int32:
			cookie.MaxAge = int(v)
		case func(*http.Cookie):
			v(&cookie)
		}
	}

	cookie.Path = "/"
	if len(others) > 1 {
		if v, ok := others[1].(string); ok && len(v) > 0 {
			cookie.Path = v
		} else if v, ok := others[1].(func(*http.Cookie)); ok {
			v(&cookie)
		}
	}

	if len(others) > 2 {
		if v, ok := others[2].(string); ok && len(v) > 0 {
			cookie.Domain = v
		} else if v, ok := others[1].(func(*http.Cookie)); ok {
			v(&cookie)
		}
	}

	if len(others) > 3 {
		switch v := others[3].(type) {
		case bool:
			cookie.Secure = v
		case func(*http.Cookie):
			v(&cookie)
		default:
			if others[3] != nil {
				cookie.Secure = true
			}
		}
	}

	if len(others) > 4 {
		if v, ok := others[4].(bool); ok && v {
			cookie.HttpOnly = true
		} else if v, ok := others[1].(func(*http.Cookie)); ok {
			v(&cookie)
		}
	}

	if len(others) > 5 {
		if v, ok := others[5].(time.Time); ok {
			cookie.Expires = v
			cookie.RawExpires = v.Format(time.UnixDate)
		} else if v, ok := others[1].(func(*http.Cookie)); ok {
			v(&cookie)
		}
	}

	if len(others) > 6 {
		for _, other := range others[6:] {
			if v, ok := other.(func(*http.Cookie)); ok {
				v(&cookie)
			}
		}
	}

	resp.Header().Add("Set-Cookie", cookie.String())
}

repository: lflxp/gitea

repo_name: lflxp/gitea


text:
package spgz

import (
	"bytes"
	"compress/gzip"
	"encoding/binary"
	"errors"
	"fmt"
	"io"
	"os"
	"runtime"
	"sync"
)

const (
	headerMagic = "SPGZ0001"
	headerSize  = 4096

	writeQueueSize = 32
)

const (
	DefBlockSize = 128*1024 - 1
	MinBlockSize = 3*4096 - 1
)

const (
	blkUncompressed byte = iota
	blkCompressed
)

var (
	ErrInvalidFormat         = errors.New("invalid file format")
	ErrFileIsDirectory       = errors.New("file cannot be a directory")
	ErrWriteOnlyNotSupported = errors.New("write only mode is not supported")
)

type compressor interface {
	CompressAsync(src []byte, dst *[]byte, result chan<- error)
}

type gzipCompressor struct {
	writers chan *gzip.Writer
}

func (c *gzipCompressor) CompressAsync(src []byte, dst *[]byte, result chan<- error) {
	go func() {
		zw := <-c.writers
		defer func() {
			c.writers <- zw
		}()

		buf := bytes.NewBuffer(*dst)
		zw.Reset(buf)

		reader := bytes.NewBuffer(src)

		buf.WriteByte(blkCompressed)

		_, err := io.Copy(zw, reader)
		if err != nil {
			result <- err
			return
		}
		err = zw.Close()
		if err != nil {
			result <- err
			return
		}
		*dst = buf.Bytes()
		result <- nil
	}()
}

func newGzipCompressor(writers int) *gzipCompressor {
	c := &gzipCompressor{
		writers: make(chan *gzip.Writer, writers),
	}
	for i := 0; i < writers; i++ {
		c.writers <- gzip.NewWriter(nil)
	}
	return c
}

// ErrCorruptCompressedBlock is returned when a compressed block involved in a read or a write operation is
// corrupt (for example as a result of a partial write). Note, this is not a media error.
//
// Any read operation intersecting with the range specified by Offset() and Size(() will fail.
// Any write operation intersecting, but not fully covering the range, will also fail (therefore in order to make
// the file usable again one must overwrite the entire range in a single write operation).
type ErrCorruptCompressedBlock struct {
	offset, size int64

	err error
}

func (e *ErrCorruptCompressedBlock) Error() string {
	return fmt.Sprintf("corrupted compressed block at %d, size %d: %v", e.offset, e.size, e.err)
}

func (e *ErrCorruptCompressedBlock) Unwrap() error {
	return e.err
}

func (e *ErrCorruptCompressedBlock) Offset() int64 {
	return e.offset
}

func (e *ErrCorruptCompressedBlock) Size() int64 {
	return e.size
}

type block struct {
	f                   *SpgzFile
	num                 int64
	data                []byte
	rawBlock, dataBlock []byte
	ch                  chan error
	// True when data is pointing to rawBlock rather than dataBlock.
	dataIsRaw bool
	dirty     bool
	// When data is written to a block that is currently not loaded it's not loaded immediately
	// (in anticipation that it will be overwritten in full so no loading will be necessary).
	// It's only loaded when it's read or written beyond the current data slice. When it is, this flag is set.
	full bool
}

type SpgzFile struct {
	sync.Mutex
	f         SparseFile
	blockSize int64
	readOnly  bool

	block    block
	tmpBlock block

	gzReader   *gzip.Reader
	compressor compressor

	// Contains a list of consecutive blocks ready to be written. When the queue is flushed, first a single
	// hole is punched across the whole area, then individual blocks are written. This helps reduce the number
	// of fallocate() calls which seem to be quite expensive, at least on btrfs.
	writeQueue []block
	offset     int64
	size       int64
	loaded     bool
}

func (b *block) init(f *SpgzFile) {
	b.f = f
	b.dirty = false
	b.dataIsRaw = false
}

// Completes a partially overwritten block by reading the rest.
// b.data at this point contains the overwritten part.
func (b *block) readTail() error {
	if !b.full && int64(len(b.data)) < b.f.blockSize {
		return b.read(true)
	}
	return nil
}

func (b *block) read(tail bool) error {
	if tail {
		b.prepareWrite()
	}
	if b.rawBlock == nil {
		b.rawBlock = make([]byte, b.f.blockSize+1)
	} else {
		b.rawBlock = b.rawBlock[:b.f.blockSize+1]
	}

	if b.dataBlock == nil {
		b.dataBlock = make([]byte, b.f.blockSize)
	}
	n, err := b.f.f.ReadAt(b.rawBlock, headerSize+b.num*(b.f.blockSize+1))
	if err != nil {
		if err == io.EOF {
			if n > 0 {
				b.rawBlock = b.rawBlock[:n]
				err = nil
			} else {
				b.full = true
				if !tail {
					b.data = b.dataBlock[:0]
					b.dataIsRaw = false
					b.dirty = false
					return err
				} else {
					return nil
				}
			}
		} else {
			if !tail {
				b.data = b.dataBlock[:0]
				b.dataIsRaw = false
			}
			return err
		}
	}

	switch b.rawBlock[0] {
	case blkUncompressed:
		if tail {
			if len(b.rawBlock)-1 > len(b.data) {
				l := len(b.data)
				b.data = b.data[:len(b.rawBlock)-1]
				copy(b.data[l:], b.rawBlock[l+1:])
			}
		} else {
			b.data = b.rawBlock[1:]
			b.dataIsRaw = true
		}
	case blkCompressed:
		err = b.loadCompressed(tail)
	}

	if err == nil {
		b.full = true
	}
	if !tail {
		b.dirty = false
	}

	return err
}

func (b *block) load(num int64) error {
	b.num = num
	return b.read(false)
}

func (b *block) createCorruptBlockError(err error) *ErrCorruptCompressedBlock {
	var size int64
	if int64(len(b.rawBlock)) == b.f.blockSize+1 {
		size = b.f.blockSize
	}
	return &ErrCorruptCompressedBlock{
		offset: b.num * b.f.blockSize,
		size:   size,
		err:    err,
	}
}

func (b *block) loadCompressed(tail bool) error {
	z := b.f.gzReader
	err := z.Reset(bytes.NewBuffer(b.rawBlock[1:]))
	if err != nil {
		return b.createCorruptBlockError(err)
	}
	z.Multistream(false)

	if !tail {
		b.data = b.dataBlock[:0]
		b.dataIsRaw = false
	}
	buf := bytes.NewBuffer(b.data)

	if len(b.data) > 0 {
		_, err := io.CopyN(io.Discard, z, int64(len(b.data)))
		if err != nil && err != io.EOF {
			return b.createCorruptBlockError(err)
		}

	}
	_, err = io.Copy(buf, z)
	if err != nil {
		return b.createCorruptBlockError(err)
	}
	b.data = buf.Bytes()

	l := int64(len(b.data))
	if l < b.f.blockSize {
		lastBlockNum := (b.f.size - headerSize) / (b.f.blockSize + 1)
		if lastBlockNum > b.num {
			b.data = b.data[:b.f.blockSize]
			for i := l; i < b.f.blockSize; i++ {
				b.data[i] = 0
			}
		}
	}

	return nil
}

func (b *block) prepareStore() (err error) {
	var curOffset int64

	if len(b.data) == 0 {
		curOffset = headerSize + b.num*(b.f.blockSize+1)
	} else if IsBlockZero(b.data) {
		curOffset = headerSize + b.num*(b.f.blockSize+1) + int64(len(b.data)) + 1
		if int64(len(b.data)) == b.f.blockSize {
			if b.f.size < curOffset {
				err = b.f.rawTruncate(curOffset)
				if err != nil {
					return
				}
			}
		}
	} else {
		b.prepareWrite()
		if b.rawBlock == nil {
			b.rawBlock = make([]byte, 0, b.f.blockSize+1)
		} else {
			b.rawBlock = b.rawBlock[:0]
		}
		b.ch = make(chan error, 1)
		b.f.compressor.CompressAsync(b.data, &b.rawBlock, b.ch)
		return nil
	}
	b.dirty = false

	if int64(len(b.data)) < b.f.blockSize {
		// last block
		err = b.f.rawTruncate(curOffset)
	}
	return
}

func (b *block) store() (err error) {
	if !b.dirty {
		return
	}
	if b.ch == nil {
		err = b.prepareStore()
		if err != nil {
			return
		}
		if !b.dirty {
			return nil
		}
	}
	err = <-b.ch
	b.ch = nil
	if err != nil {
		return
	}
	n := len(b.rawBlock)
	var curOffset int64
	if n+1 < len(b.data)-2*4096 { // save at least 2 blocks
		curOffset = headerSize + b.num*(b.f.blockSize+1) + int64(n)
	} else {
		b.rawBlock = b.rawBlock[:len(b.data)+1]
		b.rawBlock[0] = blkUncompressed
		copy(b.rawBlock[1:], b.data)
		curOffset = headerSize + b.num*(b.f.blockSize+1) + int64(len(b.data)) + 1
	}
	_, err = b.f.rawWriteAt(b.rawBlock, headerSize+b.num*(b.f.blockSize+1))
	if err != nil {
		return err
	}
	b.dirty = false

	if int64(len(b.data)) < b.f.blockSize {
		// last block
		err = b.f.rawTruncate(curOffset)
	}

	return
}

func (b *block) prepareWrite() {
	if b.dataIsRaw {
		if b.dataBlock == nil {
			b.dataBlock = make([]byte, len(b.data), b.f.blockSize)
		} else {
			b.dataBlock = b.dataBlock[:len(b.data)]
		}
		copy(b.dataBlock, b.data)
		b.data = b.dataBlock
		b.dataIsRaw = false
	}
}

// BlockSize returns the block size for optimal I/O. Reads and writes should be multiples of the block size and
// should be aligned with block boundaries.
func (f *SpgzFile) BlockSize() int64 {
	return f.blockSize
}

func (f *SpgzFile) Read(buf []byte) (n int, err error) {
	f.Lock()
	err = f.loadAt(f.offset)
	if err != nil {
		f.Unlock()
		return 0, err
	}
	o := f.offset - f.block.num*f.blockSize
	n = copy(buf, f.block.data[o:])
	f.offset += int64(n)
	if n == 0 {
		err = io.EOF
	}
	f.Unlock()
	return
}

func (f *SpgzFile) ReadAt(buf []byte, offset int64) (n int, err error) {
	if offset < 0 {
		return 0, os.ErrInvalid
	}
	f.Lock()
	for n < len(buf) {
		err = f.loadAt(offset)
		if err != nil {
			f.Unlock()
			return
		}
		o := offset - f.block.num*f.blockSize
		n1 := copy(buf[n:], f.block.data[o:])
		n += n1
		offset += int64(n1)
	}
	f.Unlock()
	return
}

func (f *SpgzFile) loadBlockFromQueue(num int64, block *block, full bool) (bool, error) {
	if len(f.writeQueue) > 0 {
		// Try to copy from the writeQueue if the block is there
		idx := num - f.writeQueue[0].num
		if idx >= 0 && idx < int64(len(f.writeQueue)) {
			b := &f.writeQueue[idx]
			if full {
				err := b.readTail()
				if err != nil {
					return true, err
				}
			}
			if block.dataBlock == nil {
				block.dataBlock = make([]byte, 0, f.blockSize)
				block.data = block.dataBlock
				block.dataIsRaw = false
			}
			block.data = block.data[:len(b.data)]
			copy(block.data, b.data)
			block.num = num
			block.dirty = false
			block.full = b.full
			return true, nil
		}
	}
	return false, nil
}

func (f *SpgzFile) loadBlock(num int64, block *block) error {
	if found, err := f.loadBlockFromQueue(num, block, true); found {
		return err
	}
	return block.load(num)
}

func (f *SpgzFile) loadNum(num int64) error {
	if f.loaded && f.block.dirty {
		err := f.storeBlock()
		if err != nil {
			return err
		}
	}
	err := f.loadBlock(num, &f.block)
	f.loaded = err == nil || err == io.EOF
	return err
}

func (f *SpgzFile) loadAt(offset int64) error {
	num := offset / f.blockSize
	if num != f.block.num || !f.loaded {
		return f.loadNum(num)
	}
	return f.block.readTail()
}

// moves the data and properties from the other block invalidating it
func (b *block) assign(other *block) {
	b.f = other.f
	b.num = other.num
	b.data, other.data = other.data, b.data
	b.rawBlock, other.rawBlock = other.rawBlock, b.rawBlock
	b.dataBlock, other.dataBlock = other.dataBlock, b.dataBlock
	b.dataIsRaw = other.dataIsRaw
	b.dirty = other.dirty
	b.full = other.full
}

func (f *SpgzFile) flushWriteQueue() error {
	if len(f.writeQueue) > 0 {
		for i := range f.writeQueue {
			b := &f.writeQueue[i]
			err := b.readTail()
			if err != nil {
				return err
			}
			err = b.prepareStore()
			if err != nil {
				return err
			}
		}
		holeStart := headerSize + f.writeQueue[0].num*(f.blockSize+1)
		holeSize := int64(len(f.writeQueue)) * (f.blockSize + 1)
		err := f.f.PunchHole(holeStart, holeSize)
		if err != nil {
			return err
		}
		for i := range f.writeQueue {
			err := f.writeQueue[i].store()
			if err != nil {
				return err
			}
		}
		f.writeQueue = f.writeQueue[:0]
	}
	return nil
}

func (f *SpgzFile) storeBlock() error {
	var idx int64
	if len(f.writeQueue) > 0 {
		idx = f.block.num - f.writeQueue[0].num
		if len(f.writeQueue) == cap(f.writeQueue) || idx < 0 || idx > int64(len(f.writeQueue)) {
			err := f.flushWriteQueue()
			if err != nil {
				return err
			}
			idx = 0
		}
	}
	if idx == int64(len(f.writeQueue)) {
		if len(f.writeQueue) > 0 {
			lastBlock := &f.writeQueue[len(f.writeQueue)-1]
			if int64(len(lastBlock.data)) < f.blockSize {
				err := lastBlock.expandToFullSize()
				if err != nil {
					return err
				}
			}
		}
		f.writeQueue = f.writeQueue[:idx+1]
	}
	f.writeQueue[idx].assign(&f.block)
	f.loaded = false
	return nil
}

func (f *SpgzFile) write(buf []byte, offset int64) (n int, err error) {
	if f.readOnly {
		return 0, os.ErrPermission
	}
	for len(buf) > 0 {
		num := offset / f.blockSize
		o := offset - num*f.blockSize

		if num != f.block.num || !f.loaded {
			if f.loaded && f.block.dirty {
				err = f.storeBlock()
				if err != nil {
					return
				}
			}
			if found, err := f.loadBlockFromQueue(num, &f.block, false); found {
				if err != nil {
					return 0, err
				}
			} else {
				f.block.num = num
				if f.block.dataBlock == nil {
					f.block.dataBlock = make([]byte, 0, f.blockSize)
				}
				f.block.data = f.block.dataBlock[:0]
				f.block.dataIsRaw = false
				f.block.dirty = false
				f.block.full = false
			}
			f.loaded = true
		}
		if o > int64(len(f.block.data)) {
			err = f.block.readTail()
			if err != nil {
				return
			}
		}

		newBlockSize := o + int64(len(buf))
		if newBlockSize > f.blockSize {
			newBlockSize = f.blockSize
		}
		l := int64(len(f.block.data))
		if newBlockSize > l {
			f.block.data = f.block.data[:newBlockSize]
			for i := l; i < o; i++ {
				f.block.data[i] = 0
			}
		}
		nn := copy(f.block.data[o:], buf)
		f.block.dirty = true
		n += nn
		offset += int64(nn)
		buf = buf[nn:]
	}

	return
}

func (f *SpgzFile) Write(buf []byte) (n int, err error) {
	f.Lock()
	n, err = f.write(buf, f.offset)
	f.offset += int64(n)
	f.Unlock()
	return
}

func (f *SpgzFile) WriteAt(buf []byte, offset int64) (n int, err error) {
	if offset < 0 {
		return 0, os.ErrInvalid
	}
	f.Lock()
	n, err = f.write(buf, offset)
	f.Unlock()
	return
}

func (f *SpgzFile) rawTruncate(size int64) error {
	if f.size == size {
		return nil
	}
	err := f.f.Truncate(size)
	if err == nil {
		f.size = size
	}
	return err
}

func (f *SpgzFile) rawWriteAt(b []byte, o int64) (int, error) {
	n, err := f.f.WriteAt(b, o)
	newSize := o + int64(n)
	if newSize > f.size {
		f.size = newSize
	}
	return n, err
}

// When a block is discarded before its contents is written because it falls in a hole we still need to ensure
// the file is expanded to the same size as if the block was actually written.
func (f *SpgzFile) expandToBlockSize(b *block) error {
	if int64(len(b.data)) < f.blockSize {
		return f.rawTruncate(headerSize + b.num*(f.blockSize+1) + int64(len(b.data)) + 1)
	}
	reqSize := headerSize + (b.num+1)*(f.blockSize+1)
	if f.size < reqSize {
		return f.rawTruncate(reqSize)
	}
	return nil
}

func (f *SpgzFile) PunchHole(offset, size int64) error {
	if offset < 0 || size < 0 {
		return os.ErrInvalid
	}
	if size == 0 {
		return nil
	}
	startZeroBlock := offset / f.blockSize
	l := offset - startZeroBlock*f.blockSize
	if l > 0 {
		startZeroBlock++
	}
	endZeroBlock := (offset + size) / f.blockSize
	f.Lock()
	defer f.Unlock()
	if len(f.writeQueue) > 0 {
		// Adjusting the writeQueue either by filling the affected blocks with zeros or by discarding tail blocks
		startIdx := startZeroBlock - f.writeQueue[0].num
		bl := int64(len(f.writeQueue))
		if startIdx < bl {
			if endIdx := endZeroBlock - f.writeQueue[0].num; endIdx > 0 {
				if startIdx < 0 {
					startIdx = 0
				}
				if endIdx >= bl {
					// The tail can be discarded
					err := f.expandToBlockSize(&f.writeQueue[len(f.writeQueue)-1])
					if err != nil {
						return err
					}
					f.writeQueue = f.writeQueue[:startIdx]
				} else {
					sec := f.writeQueue[startIdx:endIdx]
					for i := range sec {
						b := &sec[i]
						for j := range b.data {
							b.data[j] = 0
						}
					}
				}
			}
		}
	}
	if f.loaded && f.block.num >= startZeroBlock && f.block.num < endZeroBlock {
		// The currently loaded block falls in the hole, discard it
		err := f.expandToBlockSize(&f.block)
		if err != nil {
			return err
		}
		f.loaded = false
	}
	if l > 0 {
		err := f.loadAt(offset)
		if err != nil {
			if err == io.EOF {
				err = nil
			}
			return err
		}
		if int64(len(f.block.data)) <= l {
			return nil
		}
		tail := f.block.data[l:]
		if int64(len(tail)) > size {
			tail = tail[:size]
		}
		for i := range tail {
			tail[i] = 0
		}
		f.block.dirty = true
		l = int64(len(tail))
		offset += l
		size -= l
	}

	if blocks := endZeroBlock - startZeroBlock; blocks > 0 {
		err := f.f.PunchHole(headerSize+startZeroBlock*(f.blockSize+1), blocks*(f.blockSize+1))
		if err != nil {
			return err
		}
		l = blocks * f.blockSize
		offset += l
		size -= l
	}
	if size > 0 {
		err := f.loadAt(offset)
		if err != nil {
			if err == io.EOF {
				err = nil
			}
			return err
		}
		l := int(size)
		if l > len(f.block.data) {
			l = len(f.block.data)
		}
		head := f.block.data[:l]
		for i := range head {
			head[i] = 0
		}
		f.block.dirty = true
	}

	return nil
}

func (f *SpgzFile) Size() (int64, error) {
	f.Lock()
	defer f.Unlock()
	var lastBlock *block
	// Try to get the last block either from the writeQueue or from the currently loaded block
	if len(f.writeQueue) > 0 {
		lastBlock = &f.writeQueue[len(f.writeQueue)-1]
	}
	if f.loaded && (lastBlock == nil || f.block.num >= lastBlock.num) {
		lastBlock = &f.block
	}
	if lastBlock != nil && int64(len(lastBlock.data)) == f.blockSize {
		lastBlock = nil
	}

	if lastBlock == nil {
		o := f.size
		if f.size < headerSize {
			o = headerSize
		}
		lastBlockNum := (o - headerSize) / (f.blockSize + 1)
		lastBlock = &f.tmpBlock

		err := f.loadBlock(lastBlockNum, lastBlock)
		if err != nil {
			if err == io.EOF {
				return lastBlockNum * f.blockSize, nil
			}
			return 0, err
		}
	} else {
		err := lastBlock.readTail()
		if err != nil {
			return 0, err
		}
	}

	return lastBlock.num*f.blockSize + int64(len(lastBlock.data)), nil
}

func (f *SpgzFile) Seek(offset int64, whence int) (int64, error) {
	newOffset := f.offset
	switch whence {
	case io.SeekStart:
		newOffset = offset
	case io.SeekCurrent:
		newOffset += offset
	case io.SeekEnd:
		size, err := f.Size()
		if err != nil {
			return newOffset, err
		}
		newOffset = size + offset
	default:
		return newOffset, os.ErrInvalid
	}
	if newOffset < 0 {
		return newOffset, os.ErrInvalid
	}
	f.offset = newOffset
	return newOffset, nil
}

// Expand the block to full size by padding it with zeros. This is done when the block used to be the last one,
// but there is another one written after it.
func (b *block) expandToFullSize() error {
	err := b.readTail()
	if err != nil {
		return err
	}
	tail := b.data[len(b.data):b.f.blockSize]
	if len(tail) > 0 {
		for i := range tail {
			tail[i] = 0
		}
		b.data = b.data[:b.f.blockSize]
		b.dirty = true
	}
	return nil
}

func (f *SpgzFile) Truncate(size int64) error {
	blockNum := size / f.blockSize
	newLen := int(size - blockNum*f.blockSize)
	var b *block

	f.Lock()
	defer f.Unlock()
	if f.loaded {
		if f.block.num == blockNum {
			b = &f.block
		} else if f.block.num < blockNum {
			err := f.block.expandToFullSize()
			if err != nil {
				return err
			}
		} else {
			f.loaded = false
		}
	}
	if len(f.writeQueue) > 0 {
		idx := blockNum - f.writeQueue[0].num
		if idx < 0 {
			f.writeQueue = f.writeQueue[:0]
		} else {
			if idx < int64(len(f.writeQueue)) {
				if newLen > 0 {
					f.writeQueue = f.writeQueue[:idx+1]
					if b == nil {
						b = &f.writeQueue[idx]
					}
				} else {
					f.writeQueue = f.writeQueue[:idx]
				}
			}
			idx--
			if idx >= 0 && idx < int64(len(f.writeQueue)) {
				err := f.writeQueue[idx].expandToFullSize()
				if err != nil {
					return err
				}
			}
		}
	}
	if newLen > 0 {
		if b == nil {
			err := f.loadNum(blockNum)
			if err != nil {
				if err != io.EOF {
					return err
				}
				return f.rawTruncate(headerSize + blockNum*(f.blockSize+1) + int64(newLen) + 1)
			}
			b = &f.block
		} else if len(b.data) < newLen {
			err := b.readTail()
			if err != nil {
				return err
			}
		}
		if newLen != len(b.data) {
			if newLen > len(b.data) {
				tail := b.data[len(b.data):newLen]
				for i := range tail {
					tail[i] = 0
				}
			}
			b.data = b.data[:newLen]
			b.dirty = true
		}
		if !b.dirty {
			return nil
		}
	}
	return f.rawTruncate(headerSize + blockNum*(f.blockSize+1))
}

func (f *SpgzFile) WriteTo(w io.Writer) (n int64, err error) {
	f.Lock()
	defer f.Unlock()

	for {
		err = f.loadAt(f.offset)
		if err != nil {
			if err == io.EOF {
				err = nil
			}
			return
		}
		buf := f.block.data[f.offset-f.block.num*f.blockSize:]
		if len(buf) == 0 {
			return
		}
		var written int
		written, err = w.Write(buf)
		f.offset += int64(written)
		n += int64(written)
		if err != nil {
			return
		}
	}
}

func (f *SpgzFile) ReadFrom(rd io.Reader) (n int64, err error) {
	if f.readOnly {
		return 0, os.ErrPermission
	}
	f.Lock()
	defer f.Unlock()

	for {
		err = f.loadAt(f.offset)
		if err != nil {
			if err != io.EOF {
				return
			}
		}
		o := int(f.offset - f.block.num*f.blockSize)
		buf := f.block.data[o:f.blockSize]
		var r int
		r, err = rd.Read(buf)
		nl := o + r
		l := len(f.block.data)
		if nl > l {
			f.block.data = f.block.data[:nl]
		}
		if l < o {
			a := f.block.data[l:o]
			for i := range a {
				a[i] = 0
			}
		}
		f.offset += int64(r)
		n += int64(r)
		f.block.dirty = true
		if err != nil {
			if err == io.EOF {
				err = nil
			}
			return
		}
	}
}

func (f *SpgzFile) flush() error {
	if f.loaded && f.block.dirty {
		err := f.storeBlock()
		if err != nil {
			return err
		}
	}
	return f.flushWriteQueue()
}

func (f *SpgzFile) Sync() error {
	f.Lock()
	defer f.Unlock()
	err := f.flush()
	if err != nil {
		return err
	}
	return f.f.Sync()
}

func (f *SpgzFile) Close() error {
	f.Lock()
	defer f.Unlock()

	err := f.flush()
	if err != nil {
		return err
	}

	return f.f.Close()
}

func (f *SpgzFile) checkPunchHole() error {
	// Check if punching holes is supported
	off, err := f.f.Seek(0, io.SeekEnd)
	if err != nil {
		return err
	}

	if err := f.f.PunchHole(off, 4096); err != nil {
		return err
	}

	_, err = f.f.Seek(0, io.SeekStart)
	return err
}

func (f *SpgzFile) init(flag int, blockSize int64) error {
	if flag&os.O_WRONLY != 0 {
		return ErrWriteOnlyNotSupported
	}
	f.readOnly = flag&os.O_RDWR == 0
	// Trying to read the header
	buf := make([]byte, len(headerMagic)+4)
	_, err := io.ReadFull(f.f, buf)
	if err != nil {
		if err == io.EOF {
			// Empty file
			if flag&os.O_RDWR != 0 && flag&os.O_CREATE != 0 {
				err = f.checkPunchHole()
				if err != nil {
					return err
				}
				if blockSize == 0 {
					blockSize = DefBlockSize
				} else {
					blockSize = ((blockSize + 1) &^ 0xFFF) - 1
					if blockSize < MinBlockSize {
						blockSize = MinBlockSize
					}
				}
				copy(buf, headerMagic)
				binary.LittleEndian.PutUint32(buf[len(headerMagic):], uint32((blockSize+1)/4096))
				_, err = f.f.Write(buf)
				if err != nil {
					return err
				}
			} else {
				return ErrInvalidFormat
			}
		}
		if err == io.ErrUnexpectedEOF {
			return ErrInvalidFormat
		}
		if err != nil {
			return err
		}
	} else {
		if string(buf[:len(headerMagic)]) != headerMagic {
			return ErrInvalidFormat
		}
		if !f.readOnly {
			err = f.checkPunchHole()
			if err != nil {
				return err
			}
		}
		bs := binary.LittleEndian.Uint32(buf[8:])
		blockSize = int64(bs*4096) - 1
	}
	f.size, err = f.f.Seek(0, io.SeekEnd)
	if err != nil {
		return err
	}
	f.blockSize = blockSize
	f.block.init(f)
	f.tmpBlock.init(f)
	f.writeQueue = make([]block, 0, writeQueueSize)
	f.gzReader = new(gzip.Reader)
	f.compressor = newGzipCompressor(runtime.NumCPU())
	return nil
}

// OpenFile opens a file as SpgzFile with block size of DefBlockSize. See OpenFileSize for more details.
func OpenFile(name string, flag int, perm os.FileMode) (f *SpgzFile, err error) {
	return OpenFileSize(name, flag, perm, 0)
}

// OpenFileSize opens a file as SpgzFile. See NewFromFileSize for more details.
func OpenFileSize(name string, flag int, perm os.FileMode, blockSize int64) (f *SpgzFile, err error) {
	var ff *os.File
	if flag&os.O_WRONLY != 0 {
		return nil, ErrWriteOnlyNotSupported
	}
	ff, err = os.OpenFile(name, flag, perm)
	if err != nil {
		return nil, err
	}

	f = &SpgzFile{
		f: NewSparseFile(ff),
	}

	err = f.init(flag, blockSize)
	if err != nil {
		_ = f.f.Close()
		return nil, err
	}

	return f, nil
}

// NewFromFile creates a new SpgzFile from the given *os.File with desired block size of DefBlockSize.
// See NewFromFileSize for more details.
func NewFromFile(file *os.File, flag int) (f *SpgzFile, err error) {
	return NewFromFileSize(file, flag, 0)
}

// NewFromFileSize creates a new SpgzFile from the given *os.File. File position must be 0.
//
// The blockSize parameter specifies the desired block size for newly created files. The actual block size will be
// DefBlockSize if the supplied value is 0, otherwise ((blockSize+1) &^ 0xFFF)-1 or MinBlockSize whichever is greater. For
// optimal I/O performance reads and writes should be sized in multiples of the actual block size and aligned at the
// block size boundaries. This can be achieved by using bufio.Reader and bufio.Writer.
// This parameter is ignored for already initialised files. The current block size can be retrieved using
// SpgzFile.BlockSize().
//
// The flag parameter is similar to that of os.OpenFile().
// If the file is empty it will be initialised if os.O_CREATE and os.O_RDWR are set, otherwise
// ErrInvalidFormat is returned. Write-only mode (os.O_WRONLY) is not supported.
//
// Returns ErrPunchHoleNotSupported if opening for writing and the underlying OS or filesystem does not support
// punching holes (as space-saving will not be possible in this case).
func NewFromFileSize(file *os.File, flag int, blockSize int64) (f *SpgzFile, err error) {
	info, err := file.Stat()
	if err != nil {
		return nil, err
	}
	if info.IsDir() {
		return nil, ErrFileIsDirectory
	}

	return NewFromSparseFileSize(NewSparseFile(file), flag, blockSize)
}

func NewFromSparseFile(file SparseFile, flag int) (f *SpgzFile, err error) {
	return NewFromSparseFileSize(file, flag, 0)
}

func NewFromSparseFileSize(file SparseFile, flag int, blockSize int64) (f *SpgzFile, err error) {
	f = &SpgzFile{
		f: file,
	}

	err = f.init(flag, blockSize)
	if err != nil {
		return nil, err
	}

	return f, nil
}


text:
// +build e2e

package e2e

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"os"
	"regexp"
	"strings"
	"testing"

	"github.com/ktr0731/evans/adapter/cli"
	"github.com/ktr0731/evans/adapter/cui"
	"github.com/ktr0731/evans/di"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func flatten(s string) string {
	s = strings.Replace(s, "\n", " ", -1)
	s = strings.TrimSpace(s)
	re := regexp.MustCompile(" +")
	return re.ReplaceAllString(s, " ")
}

const (
	normalIn           = `{ "name": "maho" }`
	normalOut          = `{ "message": "hello, maho" }`
	clientStreamingIn  = `{ "name": "ash" } { "name": "eiji" }`
	clientStreamingOut = `{ "message": "you sent requests 2 times (ash, eiji)." }`
	bidiStreamingIn    = clientStreamingIn
)

func TestCLI(t *testing.T) {
	cleanup := di.Reset

	defer func() {
		cli.DefaultReader = os.Stdin
	}()

	cases := []struct {
		// in specifies the stdin input. Ignored if --file is specified.
		in   string
		args string
		code int

		// Server config
		useReflection bool
		useWeb        bool
		useTLS        bool
		specifyCA     bool

		// Expected output. Ignored if it is empty.
		out string
		// assertOut is called if it isn't nil.
		assertOut func(t *testing.T, out string)
	}{
		{in: normalIn, args: "", code: 1},
		{in: normalIn, args: "testdata/api.proto", code: 1},
		{in: normalIn, args: "--package api testdata/api.proto", code: 1},
		{in: normalIn, args: "--package api --service Example testdata/api.proto", code: 1},
		{in: normalIn, args: "--package api --service Example --call Unary", code: 1},
		{in: normalIn, args: "--package api --service Example --call Unary testdata/api.proto", out: normalOut},
		{in: clientStreamingIn, args: "--package api --service Example --call ClientStreaming testdata/api.proto", out: clientStreamingOut},
		{
			in:   normalIn,
			args: "--package api --service Example --call ServerStreaming testdata/api.proto",
			assertOut: func(t *testing.T, out string) {
				// Transform to a JSON-formed text.
				in := fmt.Sprintf(`[ %s ]`, strings.Replace(out, "} ", "}, ", -1))
				s := []struct {
					Message string `json:"message"`
				}{}
				err := json.Unmarshal([]byte(in), &s)
				require.NoError(t, err, "json.Unmarshal must parse the response message")

				assert.NotZero(t, s, "the response message must have one or more JSON texts, but missing")
				for i, f := range s {
					assert.Equal(t, f.Message, fmt.Sprintf("hello maho, I greet %d times.", i+1), "each message must contain text such that 'hello maho, I greet {n} times.'")
				}
			},
		},
		{
			in:   bidiStreamingIn,
			args: "--package api --service Example --call BidiStreaming testdata/api.proto",
			assertOut: func(t *testing.T, out string) {
				// Transform to a JSON-formed text.
				in := fmt.Sprintf(`[ %s ]`, strings.Replace(out, "} ", "}, ", -1))
				s := []struct {
					Message string `json:"message"`
				}{}
				err := json.Unmarshal([]byte(in), &s)
				require.NoError(t, err, "json.Unmarshal must parse the response message")

				assert.NotZero(t, s, "the response message must have one or more JSON texts, but missing")
				// First, the server greets for "ash" at least one times.
				// After that, the server also greets for "eiji".
				name := "ash"
				var i int
				for _, f := range s {
					if name != "eiji" && strings.HasPrefix(f.Message, "hello eiji, ") {
						name = "eiji"
						i = 0
					}
					assert.Equal(t, f.Message, fmt.Sprintf("hello %s, I greet %d times.", name, i+1), "each message must contain text such that 'hello (ash|eiji), I greet {n} times.'")
					i++
				}
			},
		},

		{in: normalIn, args: "--reflection", code: 1, useReflection: true},
		{in: normalIn, args: "--reflection --package api --service Example", code: 1, useReflection: true},
		{in: normalIn, args: "--reflection --service Example", code: 1, useReflection: true},     // Package api is inferred.
		{in: normalIn, args: "--reflection --service api.Example", code: 1, useReflection: true}, // Specify package by --service flag.
		{in: normalIn, args: "--reflection --call Unary", useReflection: true, out: normalOut},   // Package api and service Example are inferred.
		{in: normalIn, args: "--reflection --service Example --call Unary", useReflection: true, out: normalOut},

		{in: normalIn, args: "--web --package api --service Example --call Unary testdata/api.proto", useWeb: true, out: normalOut},

		{in: normalIn, args: "--web --reflection", useReflection: true, useWeb: true, code: 1},
		{in: normalIn, args: "--web --reflection --service bar", useReflection: true, useWeb: true, code: 1},
		{in: normalIn, args: "--web --reflection --service Example", useReflection: true, useWeb: true, code: 1},
		{in: normalIn, args: "--web --reflection --service Example --call Unary", useReflection: true, useWeb: true, out: normalOut},
		{in: clientStreamingIn, args: "--web --reflection --service Example --call ClientStreaming testdata/api.proto", useReflection: true, useWeb: true, out: clientStreamingOut},
		{
			in:            normalIn,
			args:          "--web --reflection --service Example --call ServerStreaming testdata/api.proto",
			useReflection: true,
			useWeb:        true,
			assertOut: func(t *testing.T, out string) {
				s := toStruct(t, out)
				for i, f := range s {
					assert.Equal(t, f.Message, fmt.Sprintf("hello maho, I greet %d times.", i+1), "each message must contain text such that 'hello maho, I greet {n} times.'")
				}
			},
		},
		{
			in:            bidiStreamingIn,
			args:          "--web --reflection --service Example --call BidiStreaming testdata/api.proto",
			useReflection: true,
			useWeb:        true,
			assertOut: func(t *testing.T, out string) {
				s := toStruct(t, out)
				// First, the server greets for "ash" at least one times.
				// After that, the server also greets for "eiji".
				name := "ash"
				var i int
				for _, f := range s {
					if name != "eiji" && strings.HasPrefix(f.Message, "hello eiji, ") {
						name = "eiji"
						i = 0
					}
					assert.Equal(t, f.Message, fmt.Sprintf("hello %s, I greet %d times.", name, i+1), "each message must contain text such that 'hello (ash|eiji), I greet {n} times.'")
					i++
				}
			},
		},

		{in: normalIn, args: "--tls -r --host localhost --service Example --call Unary", useReflection: true, useTLS: true, specifyCA: true, out: normalOut},
		{in: normalIn, args: "--tls -r --servername localhost --service Example --call Unary", useReflection: true, useTLS: true, specifyCA: true, out: normalOut},
		{in: normalIn, args: "--tls --cert testdata/cert/localhost.pem --certkey testdata/cert/localhost-key.pem -r --host localhost --service Example --call Unary", useReflection: true, useTLS: true, specifyCA: true, out: normalOut},
		// If both of --tls and --insecure are provided, --insecure is ignored.
		{in: normalIn, args: "--tls --insecure -r --host localhost --service Example --call Unary", useReflection: true, useTLS: true, specifyCA: true, out: normalOut},
		{in: normalIn, args: "--tls -r --host localhost --service Example --call Unary", useReflection: true, useTLS: true, code: 1},

		{in: normalIn, args: "--tls --web -r --host localhost --service Example --call Unary", useReflection: true, useTLS: true, specifyCA: true, code: 1},

		{args: "--file testdata/in.json", code: 1},
		{args: "--file testdata/in.json testdata/api.proto", code: 1},
		{args: "--file testdata/in.json --package api testdata/api.proto", code: 1},
		{args: "--file testdata/in.json --package api --service Example testdata/api.proto", code: 1},
		{args: "--file testdata/in.json --package api --service Example --call Unary", code: 1},
		{args: "--file testdata/in.json --package api --service Example --call Unary testdata/api.proto", out: normalOut},

		{args: "--reflection --file testdata/in.json", code: 1, useReflection: true},
		{args: "--reflection --file testdata/in.json --service Example", code: 1, useReflection: true},
		{args: "--reflection --file testdata/in.json --service Example --call Unary", useReflection: true, out: normalOut},

		{args: "--web --file testdata/in.json --package api --service Example --call Unary testdata/api.proto", useWeb: true, out: normalOut},

		{args: "--file testdata/in.json --tls -r --host localhost --service Example --call Unary", useReflection: true, useTLS: true, specifyCA: true, out: normalOut},
		{args: "--file testdata/in.json --tls --cert testdata/cert/localhost.pem --certkey testdata/cert/localhost-key.pem  -r --host localhost --service Example --call Unary", useReflection: true, useTLS: true, specifyCA: true, out: normalOut},
		{args: "--file testdata/in.json --tls -r --host localhost --service Example --call Unary", useReflection: true, useTLS: true, code: 1},
	}

	for _, c := range cases {
		c := c
		t.Run(c.args, func(t *testing.T) {
			srv, port := newServer(t, c.useReflection, c.useTLS, c.useWeb)
			defer srv.Serve().Stop()
			defer cleanup()

			in := strings.NewReader(c.in)
			cli.DefaultReader = in

			out := new(bytes.Buffer)
			errOut := new(bytes.Buffer)
			ui := cui.New(
				cui.Reader(in),
				cui.Writer(out),
				cui.ErrWriter(errOut),
			)

			args := strings.Split(c.args, " ")
			args = append([]string{"--cli", "--port", port}, args...)
			if c.useTLS && c.specifyCA {
				args = append([]string{"--cacert", "testdata/cert/rootCA.pem"}, args...)
			}
			code := newCommand(ui).Run(args)
			require.Equal(t, c.code, code, errOut.String())

			if c.code == 0 {
				out := flatten(out.String())
				if len(c.out) != 0 {
					assert.Equal(t, c.out, out, errOut.String())
				}
				if c.assertOut != nil {
					c.assertOut(t, out)
				}
			}
		})
	}
}

// toStruct converts a response string to a structured one.
func toStruct(t *testing.T, out string) (res []struct {
	Message string `json:"message"`
}) {
	// Transform to a JSON-formed text.
	dec := json.NewDecoder(strings.NewReader(out))
	for {
		var s struct {
			Message string `json:"message"`
		}
		err := dec.Decode(&s)
		if err == io.EOF {
			break
		}
		require.NoError(t, err, "dec.Decode must parse the response message")
		res = append(res, s)
	}
	// s := []struct {
	// 	Message string `json:"message"`
	// }{}
	// err := json.Unmarshal([]byte(in), &s)
	assert.NotZero(t, res, "the response message must have one or more JSON texts, but missing")
	return
}

repository: Zenozhouzhao/evans

repo_name: Zenozhouzhao/evans


text:
#pragma once

#include "GameObject.h"

class Scene : public GameObject
{
public:
	Scene();
	~Scene();

	void Init();
	void Deinit();
	void Update(int deltaTime);
	void Render();

	// Input
public:
	virtual void KeyDown(int keyCode);
	virtual void KeyUp(int keyCode);
};

license: Zlib,FTL

repository: Kibmer/RhythmGame

detected_licenses: Zlib FTL

repo_name: Kibmer/RhythmGame

extension: h


text:
//快速排序

void QuickSort(int A[], int low, int high)
{
  if (low < high)
  {
    int p = Partition(A, low, high);
    QuickSort(A, low, p - 1);
    QuickSort(A, p + 1, high);
  }
}

//划分
int Partition(int A[], int low, int high)
{
  int pivot = A[low];

  while (low < high)
  {
    while (low < high && A[high] >= pivot)
      --high;
    A[low] = A[high];
    while (low < high && A[low] <= pivot)
      ++low;
    A[high] = A[low];
  }

  A[low] = pivot;
  return low;
}

repository: verfallen/wang-dao

repo_name: verfallen/wang-dao

branch_name: refs/heads/main

extension: cpp


text:
@book{2016Icac,
series = {Monograph (Cotsen Institute of Archaeology at UCLA) ; 82},
abstract = {"This festschrift honors UCLA professor emerita Susan Downey and her meticulous scholarship on religious architecture and imagery in the Roman/Hellenistic world. The iconography of gods and goddesses, the analysis of sacred imagery in the context of ancient cult practices, and the design and decoration of sacred spaces are the main themes of the book. Authors examine such subjects as painting from Dura-Europos, Hellenistic sculpture at Saqqara in Egypt, Roman cameo glass, Pompeian fresco, and aspects of Venus in portrait sculpture. The essays on Dura-Europos are especially valuable in light of the present turmoil in the region.Professor Downey's influence shines through in these discussions, which echo her mentorship of several generations of art history and archaeology students and recognize her scholarly achievements. The broad temporal and geographic parameters of the volume are expansive, and the juxtaposition of images and analyses leads to surprising new conclusions"--},
isbn = {9781938770067},
year = {2016},
title = {Icon, cult, and context : sacred spaces and objects in the classical world : an edited volume featuring papers written by former students and colleagues of Susan B. Downey on the occasion of her retirement / editors, Maura K. Heyn and Ann Irvine Steinsapir.},
language = {eng},
keywords = {Sacred space -- Rome; Religious articles -- Rome; Art and religion -- Rome; Cults -- Rome},
lccn = {2015039847},
}

repository: mqAncientHistory/cityOfRome

repo_name: mqAncientHistory/cityOfRome

gha_language: HTML

extension: bib