text
stringlengths
2
100k
meta
dict
EESchema-DOCLIB Version 2.0 # $CMP BEAD-0402 D Chip ferrite, EIA 0402, metric 1005 $ENDCMP # $CMP BEAD-0603 D Chip ferrite, EIA 0603, metric 1608 $ENDCMP # $CMP BEAD-0805 D Chip ferrite, EIA 0805, metric 2012 $ENDCMP # $CMP BEAD-1206 D Chip ferrite, EIA 1206, metric 3216 $ENDCMP # $CMP BEAD-1210 D Chip ferrite, EIA 1210, metric 3225 $ENDCMP # $CMP BEAD-1812 D Chip ferrite, EIA 1210, metric 3225 $ENDCMP # $CMP BEAD-EMC-MCZ1210 D Common-mode filter $ENDCMP # $CMP L-0402 D Chip inductor, EIA 0402, metric 1005 $ENDCMP # $CMP L-0603 D Chip inductor, EIA 0603, metric 1608 $ENDCMP # $CMP L-0805 D Chip inductor, EIA 0805, metric 2012 $ENDCMP # $CMP L-1210 D Chip inductor, EIA 1210, metric 3225 $ENDCMP # $CMP L-ABRACON-AISC-1008 D Chip inductor, proprietary 1008 $ENDCMP # $CMP L-AISC-1008-ABRACON D Chip inductor, proprietary 1008 $ENDCMP # $CMP L-BOURNS-SRR7045 D Inductor, ferrite core $ENDCMP # $CMP L-MURATA-1200LRS D Inductor, ferrite core $ENDCMP # $CMP L-MURATA-3200 D Inductor, ferrite core $ENDCMP # $CMP L-MURATA-LQH3NP_J0 D Inductor, ferrite core $ENDCMP # #End Doc Library
{ "pile_set_name": "Github" }
$MeshFormat 2 0 8 $EndMeshFormat $PhysicalNames 1 100 "My fancy surface label" $EndPhysicalNames $Nodes 544 1 -0.075 0 0 2 -0.075 0.05 0 3 -0.035 0.05 0 4 -0.035 0.06000000000000001 0 5 -0.025 0.06000000000000001 0 6 -0.025 0.15 0 7 0.025 0.15 0 8 0.025 0.06000000000000001 0 9 0.035 0.06000000000000001 0 10 0.035 0.05 0 11 0.075 0.05 0 12 0.075 0 0 13 0.03 0 0 14 0.0109652703637529 0.0491025641025641 0 15 0 0.045 0 16 -0.0109652703637529 0.0491025641025641 0 17 -0.03 0 0 18 -0.015 0.1 0 19 -0.015 0.12 0 20 0 0.12 0 21 0.015 0.12 0 22 0.015 0.1 0 23 0 0.1 0 24 0 0.135 0 25 0 0.08500000000000001 0 26 -0.05250000000005287 0 0 27 -0.06375000000001441 0 0 28 -0.04125000000002772 0 0 29 -0.01770145931431111 0.03172568741071413 0 30 -0.0238507296571603 0.01586284370534483 0 31 -0.01433336483902945 0.04041412575664571 0 32 -0.02692536482857812 0.007931421852677641 0 33 -0.02077609448574284 0.02379426555801106 0 34 -0.01601741207666922 0.03606990658368264 0 35 -0.01264931760139082 0.04475834492960584 0 36 0.006672216884784963 0.05462027589044283 0 37 8.253380617828654e-015 0.05670761232557028 0 38 -0.006672216884775059 0.0546202758904497 0 39 0.00924021238685158 0.05218934360089431 0 40 0.003495549010920339 0.05617359939670736 0 41 -0.003495549010913613 0.05617359939670947 0 42 -0.009240212386847236 0.05218934360089989 0 43 0.01021995279901369 0.05071145788321839 0 44 0.008048522179897787 0.05350232186438143 0 45 0.005142865865084105 0.05551756231546065 0 46 0.001768052084637706 0.05657333911158977 0 47 -0.001768052084628563 0.05657333911159117 0 48 -0.005142865865076517 0.05551756231546436 0 49 -0.008048522179890497 0.05350232186438834 0 50 -0.01021995279901518 0.05071145788321572 0 51 0.01770145931427883 0.03172568741079739 0 52 0.01433336483901848 0.04041412575667399 0 53 0.02385072965713609 0.01586284370540726 0 54 0.01264931760138531 0.04475834492962004 0 55 0.01601741207664878 0.03606990658373537 0 56 0.02077609448570066 0.02379426555811986 0 57 0.0269253648285654 0.007931421852710466 0 58 0.05249999999990161 0 0 59 0.04124999999996247 0 0 60 0.06374999999995584 0 0 61 0.075 0.02499999999992762 0 62 0.075 0.01249999999996782 0 63 0.075 0.0374999999999708 0 64 0.05500000000004884 0.05 0 65 0.06500000000001203 0.05 0 66 0.04500000000002256 0.05 0 67 0.02792893218813696 0.0529289321881321 0 68 0.0257612046748879 0.05617316567634725 0 69 0.03117316567634611 0.05076120467488838 0 70 0.02519214719596937 0.05804909677983032 0 71 0.02668530387697918 0.05444429766979705 0 72 0.02944429766980314 0.05168530387697511 0 73 0.03304909677983536 0.05019214719596837 0 74 0.025 0.07904663306114092 0 75 0.025 0.1074985232541371 0 76 0.025 0.06952331653057818 0 77 0.025 0.09327257815763521 0 78 0.025 0.1287492616270891 0 79 0.025 0.06476165826528642 0 80 0.025 0.07428497479585498 0 81 0.025 0.08615960560938711 0 82 0.025 0.1003855507058752 0 83 0.025 0.11812389244059 0 84 0.025 0.1393746308135556 0 85 7.579353811237866e-014 0.15 0 86 0.01250000000003335 0.15 0 87 -0.01249999999996772 0.15 0 88 -0.025 0.1074985232543666 0 89 -0.025 0.07904663306121904 0 90 -0.025 0.1287492616271876 0 91 -0.025 0.09327257815781656 0 92 -0.025 0.06952331653060877 0 93 -0.025 0.1393746308136008 0 94 -0.025 0.1181238924408018 0 95 -0.025 0.1003855507060989 0 96 -0.025 0.08615960560952131 0 97 -0.025 0.07428497479590981 0 98 -0.025 0.06476165826530619 0 99 -0.02792893218813696 0.0529289321881321 0 100 -0.03117316567634442 0.05076120467488907 0 101 -0.02576120467487961 0.05617316567636727 0 102 -0.03304909677984357 0.05019214719596674 0 103 -0.02944429766979595 0.05168530387697992 0 104 -0.02668530387697169 0.05444429766980826 0 105 -0.02519214719596512 0.05804909677985167 0 106 -0.05499999999995621 0.05 0 107 -0.04499999999998791 0.05 0 108 -0.06499999999998338 0.05 0 109 -0.075 0.0250000000000758 0 110 -0.075 0.03750000000002586 0 111 -0.075 0.01250000000003228 0 112 -0.015 0.1099999999999556 0 113 -0.015 0.1050000000000024 0 114 -0.015 0.1149999999999778 0 115 0.0106066017178374 0.130606601717759 0 116 0.01385819298767485 0.1257402514854629 0 117 0.005740251485482476 0.1338581929876668 0 118 0.01471177920604989 0.1229263548302347 0 119 0.0124720441845566 0.1283335534952665 0 120 0.0083335534953145 0.1324720441845245 0 121 0.002926354830246341 0.1347117792060476 0 122 -0.01060660171782613 0.1306066017177703 0 123 -0.005740251485481235 0.1338581929876673 0 124 -0.01385819298768352 0.125740251485442 0 125 -0.002926354830245659 0.1347117792060477 0 126 -0.008333553495284838 0.1324720441845443 0 127 -0.0124720441845654 0.1283335534952533 0 128 -0.0147117792060482 0.1229263548302432 0 129 -0.0106066017178374 0.08939339828224098 0 130 -0.01385819298768909 0.09425974851457143 0 131 -0.005740251485507854 0.08614180701234375 0 132 -0.01471177920605367 0.0970736451697843 0 133 -0.01247204418457036 0.09166644650475414 0 134 -0.008333553495334437 0.08752795581548882 0 135 -0.00292635483025981 0.08528822079395511 0 136 0.01060660171782613 0.08939339828222971 0 137 0.005740251485495249 0.08614180701233853 0 138 0.01385819298768048 0.09425974851455064 0 139 0.002926354830257037 0.08528822079395455 0 140 0.008333553495318743 0.08752795581547834 0 141 0.0124720441845537 0.0916664465047292 0 142 0.01471177920605083 0.09707364516976999 0 143 0.015 0.1099999999999942 0 144 0.015 0.1149999999999906 0 145 0.015 0.105000000000023 0 146 -0.001071428571427213 0.1215971271998183 0 147 0.000803571428570116 0.1021299357606694 0 148 -0.007566964285714274 0.1109317657401219 0 149 0.006964285714286394 0.1207985635999092 0 150 0.004767586573205093 0.1261018644587887 0 151 0.007901785714285058 0.1010649678803347 0 152 0.005705086573198123 0.09576166702144956 0 153 -0.007098214285714942 0.1010649678803347 0 154 -0.004901515144633642 0.09576166702145519 0 155 0.000401785714285058 0.09356496788033469 0 156 -0.005839015144626671 0.1261018644587943 0 157 -0.008035714285713607 0.1207985635999092 0 158 -0.0005357142857136066 0.1282985635999092 0 159 0.007901785714285058 0.1110649678803347 0 160 -0.0001339285714285485 0.1118635314802438 0 161 -0.01128348214285714 0.105465882870061 0 162 -0.01128348214285714 0.115465882870061 0 163 -0.004319196428570744 0.1162644464699701 0 164 -0.003381696428572079 0.1065308507503957 0 165 0.00294642857142959 0.1211978453998637 0 166 0.005865936143745743 0.1234502140293489 0 167 0.00184807900088894 0.1238494958293035 0 168 0.01041123935098062 0.1232694075426861 0 169 0.009312889780439973 0.1259210579721258 0 170 0.0109821428571432 0.1203992817999546 0 171 0.007687094145521246 0.1283542330882738 0 172 0.009781639780439302 0.09501070776800011 0 173 0.008155844145512127 0.09257753265183963 0 174 0.01087998935098277 0.09766235819744268 0 175 0.006803436143741591 0.09841331745089213 0 176 0.01145089285714253 0.1005324839401674 0 177 0.004352678571427587 0.1015974518205021 0 178 0.003254329000884119 0.09894580139105948 0 179 -0.003147321428572413 0.1015974518205021 0 180 -0.005999864715174292 0.09841331745089495 0 181 -0.002048971858031763 0.09894580139106229 0 182 -0.01047820363670202 0.09766235819745306 0 183 -0.009379854066161366 0.09501070776801332 0 184 -0.01104910714285747 0.1005324839401674 0 185 -0.007754058431235522 0.09257753265184809 0 186 0.000602678571427587 0.09784745182050204 0 187 0.003053436143741591 0.09466331745089213 0 188 0.003071018599890154 0.08985338744633661 0 189 0.005722669029346686 0.09095173701689405 0 190 0.000200892857142529 0.08928248394016736 0 191 -0.002669232885611398 0.08985338744633922 0 192 -0.002249864715174292 0.09466331745089494 0 193 -0.005320883315070748 0.09095173701689947 0 194 -0.003455221858026943 0.1238494958293063 0 195 -0.006937364715170139 0.1234502140293517 0 196 -0.004553571428570409 0.1211978453998637 0 197 -0.009848604066155094 0.1259210579721182 0 198 -0.01094695363669856 0.1232694075426756 0 199 -0.0082228084312264 0.1283542330882823 0 200 -0.0115178571428568 0.1203992817999546 0 201 -0.0002678571428568033 0.1316492817999546 0 202 0.002602268599884435 0.131078378293788 0 203 0.002115936143745743 0.1272002140293489 0 204 0.005253919029343785 0.1299800287232277 0 205 -0.00080357142857041 0.1249478453998637 0 206 -0.005789633315053953 0.1299800287232308 0 207 -0.003187364715170139 0.1272002140293517 0 208 -0.003137982885597421 0.1310783782937882 0 209 0.01145089285714253 0.1055324839401645 0 210 0.01145089285714253 0.1105324839401645 0 211 0.007901785714285058 0.1060649678803347 0 212 0.01145089285714253 0.1155324839401674 0 213 0.004352678571427587 0.1065974518205021 0 214 -0.0006026785714278809 0.1167303293400311 0 215 0.003415178571428923 0.1163310475400765 0 216 0.003883928571428255 0.1114642496802893 0 217 0.007433035714285725 0.1159317657401219 0 218 0.0003348214285707838 0.1069967336204566 0 219 -0.01314174107142857 0.1127329414350083 0 220 -0.01314174107142857 0.1177329414350305 0 221 -0.01314174107142857 0.1077329414350083 0 222 -0.01128348214285714 0.110465882870061 0 223 -0.01314174107142857 0.1027329414350305 0 224 -0.009425223214285705 0.1081988243050915 0 225 -0.009425223214285705 0.1131988243050914 0 226 -0.001757812500000314 0.1091971911153198 0 227 -0.001289062500000981 0.1043303932555325 0 228 -0.002226562499999646 0.114063988975107 0 229 -0.003850446428571411 0.1113976486101829 0 230 -0.002695312499998979 0.1189307868348942 0 231 -0.005943080357142509 0.113598106105046 0 232 -0.005474330357143177 0.1087313082452588 0 233 -0.007332589285714608 0.1059983668102283 0 234 -0.009190848214286038 0.1032654253751978 0 235 -0.00523995535714351 0.1037979093153652 0 236 -0.00780133928571394 0.1158651646700155 0 237 -0.006177455357142175 0.1185315050349396 0 238 -0.009659598214285373 0.1181322232349851 0 239 -0.008254712063171157 0.06944618595469854 0 240 0.008274907836946241 0.06927131267303062 0 241 0.04654029186285577 0.02634513748215948 0 242 -0.04654029186286222 0.02634513748214283 0 243 -0.01096532844525214 0.08072155432453965 0 244 0.01097037738869309 0.08067783600410031 0 245 -0.01944710127594493 0.0510157481453481 0 246 -0.02281519575122403 0.04232730979942311 0 247 -0.02635072965715556 0.04086284370535706 0 248 0.02635072965713942 0.04086284370539869 0 249 0.02281519575120789 0.04232730979946474 0 250 0.01944710127594493 0.0510157481453481 0 251 0.02 0.1037492616270686 0 252 0.02 0.08952331653057047 0 253 0.01780330085891307 0.08422001567168531 0 254 -0.0178033008589187 0.08422001567173001 0 255 -0.02 0.08952331653060952 0 256 -0.02 0.1037492616271833 0 257 -0.02 0.1137492616271833 0 258 0.02 0.1137492616270686 0 259 -0.02 0.135 0 260 0.02 0.135 0 261 0.0178033008589187 0.1403033008588795 0 262 -0.01780330085891307 0.1403033008588852 0 263 -0.0125 0.1425 0 264 0.0125 0.1425 0 265 0.01663745391847312 0.07415897286708577 0 266 0.01663745391847312 0.06463565633651532 0 267 0.03827014593142789 0.01317256874107974 0 268 0.06077014593142788 0.01317256874107974 0 269 0.06077014593142788 0.03817256874107974 0 270 0.04077014593142789 0.03817256874107974 0 271 -0.06077014593143111 0.03817256874107142 0 272 -0.04077014593143111 0.03817256874107142 0 273 -0.03827014593143111 0.01317256874107141 0 274 -0.06077014593143111 0.01317256874107141 0 275 0.0321208755885673 0.02903541244647843 0 276 -0.03212087558858667 0.02903541244642847 0 277 0.004137453918473121 0.07713565633651531 0 278 -0.004127356031585578 0.07722309297734928 0 279 1.009788688754315e-005 0.06935874931386457 0 280 -0.01662735603158558 0.06472309297734927 0 281 -0.01662735603158558 0.07424640950795879 0 282 -0.00548266422262607 0.08286077716226983 0 283 -0.01078596508154477 0.08505747630339031 0 284 -0.01798266422262607 0.07988409369287934 0 285 -0.009610020254211649 0.07508387013961909 0 286 0.005485188694346547 0.08283891800205015 0 287 0.01078848955325961 0.08503561714316502 0 288 0.01798518869434655 0.07986223453262062 0 289 0.009622642612819667 0.07497457433856547 0 290 -0.01798263518187645 0.05455128205128206 0 291 -0.01583610844238753 0.05731013794522485 0 292 0.01798263518187645 0.05455128205128206 0 293 0.01583610844239248 0.05731013794522142 0 294 -0.007463464473973108 0.06203323092257412 0 295 -0.004127356031581451 0.06307689914013441 0 296 0.007473562360865603 0.06194579428173673 0 297 0.004137453918477248 0.06298946249930046 0 298 -0.01857428029512674 0.04137071777803442 0 299 -0.02025832753276757 0.03702649860506862 0 300 -0.01689023305748719 0.0457149369509969 0 301 -0.02113114851358448 0.04667152897238561 0 302 -0.01520618581984892 0.0500591561239561 0 303 -0.02368801673204094 0.0519723401667401 0 304 -0.0253720639696805 0.04762812099377761 0 305 -0.02458296270418979 0.04159507675239009 0 306 -0.02202609448573333 0.0362942655580356 0 307 -0.02699418071378423 0.04654425723715609 0 308 -0.02876194766674999 0.04581202419012306 0 309 -0.03067536482857778 0.04543142185267853 0 310 0.02202609448570912 0.03629426555809804 0 311 0.02458296270417365 0.04159507675243172 0 312 0.02025832753274336 0.03702649860513106 0 313 0.02876194766674276 0.04581202419014353 0 314 0.026994180713777 0.04654425723717656 0 315 0.03067536482856971 0.04543142185269935 0 316 0.02537206396967243 0.04762812099379842 0 317 0.01857428029511319 0.04137071777806936 0 318 0.02113114851357641 0.04667152897240642 0 319 0.0168902330574817 0.04571493695101105 0 320 0.02368801673204094 0.0519723401667401 0 321 0.01520618581984892 0.0500591561239561 0 322 0.0225 0.09139794734410284 0 323 0.0225 0.0842849747958557 0 324 0.0225 0.09851091989235189 0 325 0.02 0.09663628907881952 0 326 0.0225 0.1056238924406029 0 327 0.0175 0.1018746308135343 0 328 0.0175 0.09476165826528524 0 329 0.01890165042945653 0.0868716661011279 0 330 0.02140165042945653 0.08163332436641312 0 331 0.01692909649384024 0.09189153252256055 0 332 0.01583074692329677 0.08923988209311798 0 333 0.0142049512883696 0.08680670697695751 0 334 -0.02140165042945935 0.08163332436647453 0 335 -0.01890165042945935 0.08687166610116977 0 336 -0.0225 0.08428497479591428 0 337 -0.0158307469233039 0.08923988209315073 0 338 -0.01692909649384455 0.09189153252259047 0 339 -0.01420495128837805 0.0868067069769855 0 340 -0.0175 0.09476165826530476 0 341 -0.0225 0.09139794734421304 0 342 -0.02 0.0966362890788964 0 343 -0.0225 0.09851091989249992 0 344 -0.0175 0.1018746308135917 0 345 -0.0225 0.1056238924407749 0 346 -0.0175 0.1068746308135695 0 347 -0.0175 0.1118746308135695 0 348 -0.02 0.1087492616271833 0 349 -0.0175 0.1168746308135917 0 350 -0.0225 0.110623892440775 0 351 0.0175 0.1068746308135314 0 352 0.02 0.1087492616270686 0 353 0.0175 0.1118746308135314 0 354 0.0225 0.1106238924406029 0 355 0.0175 0.1168746308135343 0 356 -0.0225 0.1212492616271855 0 357 -0.02 0.1243746308135917 0 358 -0.0225 0.1318746308135938 0 359 -0.0175 0.1275 0 360 -0.0225 0.1425 0 361 0.0225 0.1212492616270789 0 362 0.0225 0.1318746308135446 0 363 0.02 0.1243746308135343 0 364 0.0225 0.1425 0 365 0.0175 0.1275 0 366 0.01692909649383743 0.1303701257427315 0 367 0.01890165042945935 0.1376516504294398 0 368 0.01583074692329678 0.1330217761721713 0 369 0.02140165042945935 0.1451516504294398 0 370 0.01420495128837805 0.1354549512883193 0 371 -0.01692909649384176 0.130370125742721 0 372 -0.01583074692329829 0.1330217761721636 0 373 -0.01890165042945653 0.1376516504294426 0 374 -0.0142049512883696 0.1354549512883277 0 375 -0.02140165042945653 0.1451516504294426 0 376 -0.01177177617219715 0.1370807469232762 0 377 -0.009120125742740619 0.1381790964938336 0 378 -0.01515165042945653 0.1414016504294426 0 379 -0.00625 0.13875 0 380 -0.01875 0.14625 0 381 0.01177177617220059 0.1370807469232732 0 382 0.01515165042945935 0.1414016504294398 0 383 0.009120125742741238 0.1381790964938334 0 384 0.01875 0.14625 0 385 0.00625 0.13875 0 386 0 0.1425 0 387 0.006250000000037897 0.14625 0 388 -0.006249999999962104 0.14625 0 389 0.02081872695923656 0.06707948643354675 0 390 0.02081872695923656 0.06231782816825766 0 391 0.02081872695923656 0.07184114469883197 0 392 0.01663745391847312 0.06939731460180054 0 393 0.02081872695923656 0.07660280296411334 0 394 0.01245618087770968 0.07171514277005819 0 395 0.01245618087770968 0.06695348450477297 0 396 0.04240521889714183 0.01975885311161961 0 397 0.04952014593142788 0.01317256874107974 0 398 0.05365521889714182 0.01975885311161961 0 399 0.04538507296566475 0.006586284370539869 0 400 0.05663507296566475 0.006586284370539869 0 401 0.03413507296571394 0.006586284370539869 0 402 0.06788507296571394 0.006586284370539869 0 403 0.05365521889714182 0.03225885311161961 0 404 0.05077014593142788 0.03817256874107974 0 405 0.04365521889714183 0.03225885311161961 0 406 0.05788507296573836 0.04408628437053987 0 407 0.04788507296573837 0.04408628437053987 0 408 0.06788507296571394 0.04408628437053987 0 409 0.03788507296571395 0.04408628437053987 0 410 0.06788507296571394 0.01908628437050368 0 411 0.06788507296571394 0.03158628437050368 0 412 0.06077014593142788 0.02567256874107974 0 413 -0.04788507296569367 0.04408628437053571 0 414 -0.03788507296571556 0.04408628437053571 0 415 -0.05788507296569366 0.04408628437053571 0 416 -0.05077014593143112 0.03817256874107142 0 417 -0.06788507296571555 0.04408628437053571 0 418 -0.05365521889714667 0.03225885311160712 0 419 -0.04365521889714667 0.03225885311160712 0 420 -0.056635072965742 0.006586284370535707 0 421 -0.06788507296571555 0.006586284370535707 0 422 -0.04538507296574199 0.006586284370535707 0 423 -0.04952014593143111 0.01317256874107141 0 424 -0.03413507296571555 0.006586284370535707 0 425 -0.04240521889714667 0.01975885311160712 0 426 -0.05365521889714667 0.01975885311160712 0 427 -0.06077014593143111 0.02567256874107142 0 428 -0.06788507296571555 0.03158628437057361 0 429 -0.06788507296571555 0.01908628437057361 0 430 0.02798580262285169 0.02244912807594285 0 431 0.02491116745142306 0.03038054992863791 0 432 0.03106043779428199 0.0145177062232435 0 433 0.03519551075999759 0.02110399059377908 0 434 0.03933058372571154 0.02769027496431895 0 435 0.02923580262285336 0.03494912807593856 0 436 0.03644551075999759 0.03360399059377909 0 437 0.03356043779428365 0.03951770622323922 0 438 -0.03519551076000889 0.02110399059374994 0 439 -0.03933058372572444 0.02769027496428565 0 440 -0.0310604377942957 0.01451770622320812 0 441 -0.02798580262287348 0.02244912807588665 0 442 -0.02491116745144889 0.0303805499285713 0 443 -0.03356043779429334 0.03951770622321424 0 444 -0.03644551076000889 0.03360399059374995 0 445 -0.02923580262287111 0.03494912807589277 0 446 0.006206180877709681 0.07320348450477296 0 447 0.002073775902680332 0.07324720282518994 0 448 0.004142502861916892 0.0693150309934476 0 449 5.048943443770708e-006 0.0771793746569323 0 450 -0.002058629072349018 0.07329092114560692 0 451 0.00206872695923656 0.08106782816825767 0 452 -0.002063678015792789 0.08111154648867464 0 453 -0.006191034047378368 0.07333463946602391 0 454 -0.004122307088141807 0.06940246763428155 0 455 -0.02081367801579279 0.07188486301928378 0 456 -0.02081367801579279 0.0766465212845889 0 457 -0.02081367801579279 0.06712320475397901 0 458 -0.01662735603158558 0.06948475124265402 0 459 -0.02081367801579279 0.06236154648867463 0 460 -0.01244103404737837 0.0670846394660239 0 461 -0.01244103404737837 0.07184629773132867 0 462 -0.008223996333939106 0.08179116574340474 0 463 -0.008134314652085421 0.08395912673283007 0 464 -0.01087564676339846 0.08288951531396498 0 465 -0.005611457854066962 0.08450129208730679 0 466 -0.008263108283526312 0.08559964165786703 0 467 -0.002741332111313035 0.08393038858113491 0 468 -0.01069628339969109 0.08722543729281565 0 469 -0.01447399633393911 0.0803028240087095 0 470 -0.01379634223841886 0.07748398191624922 0 471 -0.0102876743497319 0.07790271223207937 0 472 -0.01730501012710583 0.07706525160041906 0 473 -0.01311868814289861 0.07466513982378895 0 474 -0.02149133211131304 0.07946536337704918 0 475 -0.008932366158691403 0.07226502804715881 0 476 -0.006868688142898614 0.07615348155848419 0 477 -0.004805010127105824 0.08004193506980956 0 478 -0.00754634223841886 0.07897232365094446 0 479 -0.01429463297023174 0.08463874598756016 0 480 -0.01789298254077239 0.08205205468230467 0 481 -0.01438431465208542 0.08247078499813482 0 482 0.00826437051937743 0.08558871207775178 0 483 0.01069754563554287 0.08721450771269737 0 484 0.005612720089920898 0.08449036250719434 0 485 0.008136839123803079 0.08393726757260758 0 486 0.002742594347173273 0.08391945900102507 0 487 0.00822778304151982 0.08175837700307523 0 488 0.01087943347097635 0.08285672657363266 0 489 0.01313004826564639 0.07456677360282563 0 490 0.008948775224882955 0.07212294350579804 0 491 0.01731132130640983 0.07701060369985319 0 492 0.01380391565358311 0.07741840443559304 0 493 0.02149259434717327 0.07945443379688078 0 494 0.01447778304151982 0.08027003526836046 0 495 0.01029651000075638 0.07782620517133289 0 496 0.007553915653583107 0.07890674617030781 0 497 0.004811321306409834 0.07998728716928273 0 498 0.006880048265646394 0.07605511533754039 0 499 0.01438683912380308 0.08244892583789282 0 500 0.01789424477662981 0.08204112510215297 0 501 0.01429589520608634 0.08462781640742517 0 502 -0.02149131759093823 0.05727564102564103 0 503 -0.01690937181213199 0.05593070999825345 0 504 -0.02041805422119377 0.05865506897261243 0 505 -0.01361142378436184 0.05337031282609097 0 506 -0.01253816041461738 0.05474974077306237 0 507 -0.01447395277281468 0.05182692307692308 0 508 -0.0112541626635813 0.05596520691783728 0 509 -0.02260415297541227 0.05359445691085768 0 510 -0.01871486822891069 0.05278351509831508 0 511 -0.02187191992837803 0.05536222386382466 0 512 0.01253816041462203 0.05474974077305786 0 513 0.01125416266358872 0.05596520691783213 0 514 0.01361142378436402 0.05337031282608818 0 515 0.01690937181213447 0.05593070999825174 0 516 0.01447395277281468 0.05182692307692308 0 517 0.02149131759093823 0.05727564102564103 0 518 0.02041805422119624 0.05865506897261071 0 519 0.02187191992838218 0.05536222386381465 0 520 0.01871486822891069 0.05278351509831508 0 521 0.02260415297541642 0.05359445691084767 0 522 -0.007859088268572132 0.06573970843863633 0 523 -0.005795410252777279 0.06255506503135427 0 524 -0.006191034047376304 0.06626154254741648 0 525 -0.005479506742443361 0.05910341515964179 0 526 -0.003811452521247532 0.05962524926842194 0 527 -0.007067840679374084 0.05832675340651192 0 528 -0.002063678015786599 0.05989225573285235 0 529 -0.01164978645818032 0.05967168443389949 0 530 -0.01204541025277934 0.0633781619499617 0 531 -0.01623173223698655 0.06101661546128706 0 532 0.003816501464698793 0.05958153094800391 0 533 0.00206872695924275 0.05984853741243537 0 534 0.005484555685892971 0.05905969683922205 0 535 0.005805508139671425 0.06246762839051859 0 536 0.007072889622825283 0.05828303508608979 0 537 0.007874235098905922 0.06560855347738367 0 538 0.006206180877711744 0.06613038758616555 0 539 0.0162367811804328 0.06097289714086837 0 540 0.01205550813966936 0.06329072530912602 0 541 0.01165483540162904 0.05962796611347908 0 542 5.048943447897615e-006 0.06303318081971743 0 543 0.002073775902682395 0.06617410590658251 0 544 -0.002058629072346954 0.06621782422699948 0 $EndNodes $Elements 1141 1 15 3 0 1 0 1 2 15 3 0 2 0 2 3 15 3 0 3 0 3 4 15 3 0 4 0 4 5 15 3 0 5 0 5 6 15 3 0 6 0 6 7 15 3 0 7 0 7 8 15 3 0 8 0 8 9 15 3 0 9 0 9 10 15 3 0 10 0 10 11 15 3 0 11 0 11 12 15 3 0 12 0 12 13 15 3 0 13 0 13 14 15 3 0 14 0 14 15 15 3 0 15 0 15 16 15 3 0 16 0 16 17 15 3 0 17 0 17 18 15 3 0 18 0 18 19 15 3 0 19 0 19 20 15 3 0 20 0 20 21 15 3 0 21 0 21 22 15 3 0 22 0 22 23 15 3 0 23 0 23 24 15 3 0 24 0 24 25 15 3 0 25 0 25 26 1 3 0 1 0 1 27 27 1 3 0 1 0 27 26 28 1 3 0 1 0 26 28 29 1 3 0 1 0 28 17 30 1 3 0 2 0 17 32 31 1 3 0 2 0 32 30 32 1 3 0 2 0 30 33 33 1 3 0 2 0 33 29 34 1 3 0 2 0 29 34 35 1 3 0 2 0 34 31 36 1 3 0 2 0 31 35 37 1 3 0 2 0 35 16 38 1 3 0 3 0 14 43 39 1 3 0 3 0 43 39 40 1 3 0 3 0 39 44 41 1 3 0 3 0 44 36 42 1 3 0 3 0 36 45 43 1 3 0 3 0 45 40 44 1 3 0 3 0 40 46 45 1 3 0 3 0 46 37 46 1 3 0 3 0 37 47 47 1 3 0 3 0 47 41 48 1 3 0 3 0 41 48 49 1 3 0 3 0 48 38 50 1 3 0 3 0 38 49 51 1 3 0 3 0 49 42 52 1 3 0 3 0 42 50 53 1 3 0 3 0 50 16 54 1 3 0 4 0 14 54 55 1 3 0 4 0 54 52 56 1 3 0 4 0 52 55 57 1 3 0 4 0 55 51 58 1 3 0 4 0 51 56 59 1 3 0 4 0 56 53 60 1 3 0 4 0 53 57 61 1 3 0 4 0 57 13 62 1 3 0 5 0 13 59 63 1 3 0 5 0 59 58 64 1 3 0 5 0 58 60 65 1 3 0 5 0 60 12 66 1 3 0 6 0 12 62 67 1 3 0 6 0 62 61 68 1 3 0 6 0 61 63 69 1 3 0 6 0 63 11 70 1 3 0 7 0 11 65 71 1 3 0 7 0 65 64 72 1 3 0 7 0 64 66 73 1 3 0 7 0 66 10 74 1 3 0 8 0 8 70 75 1 3 0 8 0 70 68 76 1 3 0 8 0 68 71 77 1 3 0 8 0 71 67 78 1 3 0 8 0 67 72 79 1 3 0 8 0 72 69 80 1 3 0 8 0 69 73 81 1 3 0 8 0 73 10 82 1 3 0 9 0 8 79 83 1 3 0 9 0 79 76 84 1 3 0 9 0 76 80 85 1 3 0 9 0 80 74 86 1 3 0 9 0 74 81 87 1 3 0 9 0 81 77 88 1 3 0 9 0 77 82 89 1 3 0 9 0 82 75 90 1 3 0 9 0 75 83 91 1 3 0 9 0 83 78 92 1 3 0 9 0 78 84 93 1 3 0 9 0 84 7 94 1 3 0 10 0 7 86 95 1 3 0 10 0 86 85 96 1 3 0 10 0 85 87 97 1 3 0 10 0 87 6 98 1 3 0 11 0 6 93 99 1 3 0 11 0 93 90 100 1 3 0 11 0 90 94 101 1 3 0 11 0 94 88 102 1 3 0 11 0 88 95 103 1 3 0 11 0 95 91 104 1 3 0 11 0 91 96 105 1 3 0 11 0 96 89 106 1 3 0 11 0 89 97 107 1 3 0 11 0 97 92 108 1 3 0 11 0 92 98 109 1 3 0 11 0 98 5 110 1 3 0 12 0 3 102 111 1 3 0 12 0 102 100 112 1 3 0 12 0 100 103 113 1 3 0 12 0 103 99 114 1 3 0 12 0 99 104 115 1 3 0 12 0 104 101 116 1 3 0 12 0 101 105 117 1 3 0 12 0 105 5 118 1 3 0 13 0 3 107 119 1 3 0 13 0 107 106 120 1 3 0 13 0 106 108 121 1 3 0 13 0 108 2 122 1 3 0 14 0 2 110 123 1 3 0 14 0 110 109 124 1 3 0 14 0 109 111 125 1 3 0 14 0 111 1 126 1 3 0 15 0 18 113 127 1 3 0 15 0 113 112 128 1 3 0 15 0 112 114 129 1 3 0 15 0 114 19 130 1 3 0 16 0 21 118 131 1 3 0 16 0 118 116 132 1 3 0 16 0 116 119 133 1 3 0 16 0 119 115 134 1 3 0 16 0 115 120 135 1 3 0 16 0 120 117 136 1 3 0 16 0 117 121 137 1 3 0 16 0 121 24 138 1 3 0 17 0 24 125 139 1 3 0 17 0 125 123 140 1 3 0 17 0 123 126 141 1 3 0 17 0 126 122 142 1 3 0 17 0 122 127 143 1 3 0 17 0 127 124 144 1 3 0 17 0 124 128 145 1 3 0 17 0 128 19 146 1 3 0 18 0 18 132 147 1 3 0 18 0 132 130 148 1 3 0 18 0 130 133 149 1 3 0 18 0 133 129 150 1 3 0 18 0 129 134 151 1 3 0 18 0 134 131 152 1 3 0 18 0 131 135 153 1 3 0 18 0 135 25 154 1 3 0 19 0 25 139 155 1 3 0 19 0 139 137 156 1 3 0 19 0 137 140 157 1 3 0 19 0 140 136 158 1 3 0 19 0 136 141 159 1 3 0 19 0 141 138 160 1 3 0 19 0 138 142 161 1 3 0 19 0 142 22 162 1 3 0 20 0 21 144 163 1 3 0 20 0 144 143 164 1 3 0 20 0 143 145 165 1 3 0 20 0 145 22 166 2 3 0 22 0 146 165 167 167 2 3 0 22 0 165 166 167 168 2 3 0 22 0 165 149 166 169 2 3 0 22 0 167 166 150 170 2 3 0 22 0 149 168 166 171 2 3 0 22 0 168 169 166 172 2 3 0 22 0 168 116 169 173 2 3 0 22 0 166 169 150 174 2 3 0 22 0 149 170 168 175 2 3 0 22 0 170 118 168 176 2 3 0 22 0 170 21 118 177 2 3 0 22 0 168 118 116 178 2 3 0 22 0 150 169 171 179 2 3 0 22 0 169 119 171 180 2 3 0 22 0 169 116 119 181 2 3 0 22 0 171 119 115 182 2 3 0 22 0 136 141 173 183 2 3 0 22 0 141 172 173 184 2 3 0 22 0 141 138 172 185 2 3 0 22 0 173 172 152 186 2 3 0 22 0 138 174 172 187 2 3 0 22 0 174 175 172 188 2 3 0 22 0 174 151 175 189 2 3 0 22 0 172 175 152 190 2 3 0 22 0 138 142 174 191 2 3 0 22 0 142 176 174 192 2 3 0 22 0 142 22 176 193 2 3 0 22 0 174 176 151 194 2 3 0 22 0 152 175 178 195 2 3 0 22 0 175 177 178 196 2 3 0 22 0 175 151 177 197 2 3 0 22 0 178 177 147 198 2 3 0 22 0 147 179 181 199 2 3 0 22 0 179 180 181 200 2 3 0 22 0 179 153 180 201 2 3 0 22 0 181 180 154 202 2 3 0 22 0 153 182 180 203 2 3 0 22 0 182 183 180 204 2 3 0 22 0 182 130 183 205 2 3 0 22 0 180 183 154 206 2 3 0 22 0 153 184 182 207 2 3 0 22 0 184 132 182 208 2 3 0 22 0 184 18 132 209 2 3 0 22 0 182 132 130 210 2 3 0 22 0 154 183 185 211 2 3 0 22 0 183 133 185 212 2 3 0 22 0 183 130 133 213 2 3 0 22 0 185 133 129 214 2 3 0 22 0 147 186 178 215 2 3 0 22 0 186 187 178 216 2 3 0 22 0 186 155 187 217 2 3 0 22 0 178 187 152 218 2 3 0 22 0 155 188 187 219 2 3 0 22 0 188 189 187 220 2 3 0 22 0 188 137 189 221 2 3 0 22 0 187 189 152 222 2 3 0 22 0 155 190 188 223 2 3 0 22 0 190 139 188 224 2 3 0 22 0 190 25 139 225 2 3 0 22 0 188 139 137 226 2 3 0 22 0 152 189 173 227 2 3 0 22 0 189 140 173 228 2 3 0 22 0 189 137 140 229 2 3 0 22 0 173 140 136 230 2 3 0 22 0 25 190 135 231 2 3 0 22 0 190 191 135 232 2 3 0 22 0 190 155 191 233 2 3 0 22 0 135 191 131 234 2 3 0 22 0 155 192 191 235 2 3 0 22 0 192 193 191 236 2 3 0 22 0 192 154 193 237 2 3 0 22 0 191 193 131 238 2 3 0 22 0 155 186 192 239 2 3 0 22 0 186 181 192 240 2 3 0 22 0 186 147 181 241 2 3 0 22 0 192 181 154 242 2 3 0 22 0 131 193 134 243 2 3 0 22 0 193 185 134 244 2 3 0 22 0 193 154 185 245 2 3 0 22 0 134 185 129 246 2 3 0 22 0 146 194 196 247 2 3 0 22 0 194 195 196 248 2 3 0 22 0 194 156 195 249 2 3 0 22 0 196 195 157 250 2 3 0 22 0 156 197 195 251 2 3 0 22 0 197 198 195 252 2 3 0 22 0 197 124 198 253 2 3 0 22 0 195 198 157 254 2 3 0 22 0 156 199 197 255 2 3 0 22 0 199 127 197 256 2 3 0 22 0 199 122 127 257 2 3 0 22 0 197 127 124 258 2 3 0 22 0 157 198 200 259 2 3 0 22 0 198 128 200 260 2 3 0 22 0 198 124 128 261 2 3 0 22 0 200 128 19 262 2 3 0 22 0 24 201 121 263 2 3 0 22 0 201 202 121 264 2 3 0 22 0 201 158 202 265 2 3 0 22 0 121 202 117 266 2 3 0 22 0 158 203 202 267 2 3 0 22 0 203 204 202 268 2 3 0 22 0 203 150 204 269 2 3 0 22 0 202 204 117 270 2 3 0 22 0 158 205 203 271 2 3 0 22 0 205 167 203 272 2 3 0 22 0 205 146 167 273 2 3 0 22 0 203 167 150 274 2 3 0 22 0 117 204 120 275 2 3 0 22 0 204 171 120 276 2 3 0 22 0 204 150 171 277 2 3 0 22 0 120 171 115 278 2 3 0 22 0 122 199 126 279 2 3 0 22 0 199 206 126 280 2 3 0 22 0 199 156 206 281 2 3 0 22 0 126 206 123 282 2 3 0 22 0 156 207 206 283 2 3 0 22 0 207 208 206 284 2 3 0 22 0 207 158 208 285 2 3 0 22 0 206 208 123 286 2 3 0 22 0 156 194 207 287 2 3 0 22 0 194 205 207 288 2 3 0 22 0 194 146 205 289 2 3 0 22 0 207 205 158 290 2 3 0 22 0 123 208 125 291 2 3 0 22 0 208 201 125 292 2 3 0 22 0 208 158 201 293 2 3 0 22 0 125 201 24 294 2 3 0 22 0 22 145 176 295 2 3 0 22 0 145 209 176 296 2 3 0 22 0 145 143 209 297 2 3 0 22 0 176 209 151 298 2 3 0 22 0 143 210 209 299 2 3 0 22 0 210 211 209 300 2 3 0 22 0 210 159 211 301 2 3 0 22 0 209 211 151 302 2 3 0 22 0 143 144 210 303 2 3 0 22 0 144 212 210 304 2 3 0 22 0 144 21 212 305 2 3 0 22 0 210 212 159 306 2 3 0 22 0 151 211 177 307 2 3 0 22 0 211 213 177 308 2 3 0 22 0 211 159 213 309 2 3 0 22 0 177 213 147 310 2 3 0 22 0 146 214 165 311 2 3 0 22 0 214 215 165 312 2 3 0 22 0 214 160 215 313 2 3 0 22 0 165 215 149 314 2 3 0 22 0 160 216 215 315 2 3 0 22 0 216 217 215 316 2 3 0 22 0 216 159 217 317 2 3 0 22 0 215 217 149 318 2 3 0 22 0 160 218 216 319 2 3 0 22 0 218 213 216 320 2 3 0 22 0 218 147 213 321 2 3 0 22 0 216 213 159 322 2 3 0 22 0 149 217 170 323 2 3 0 22 0 217 212 170 324 2 3 0 22 0 217 159 212 325 2 3 0 22 0 170 212 21 326 2 3 0 22 0 19 114 220 327 2 3 0 22 0 114 219 220 328 2 3 0 22 0 114 112 219 329 2 3 0 22 0 220 219 162 330 2 3 0 22 0 112 221 219 331 2 3 0 22 0 221 222 219 332 2 3 0 22 0 221 161 222 333 2 3 0 22 0 219 222 162 334 2 3 0 22 0 112 113 221 335 2 3 0 22 0 113 223 221 336 2 3 0 22 0 113 18 223 337 2 3 0 22 0 221 223 161 338 2 3 0 22 0 162 222 225 339 2 3 0 22 0 222 224 225 340 2 3 0 22 0 222 161 224 341 2 3 0 22 0 225 224 148 342 2 3 0 22 0 147 218 227 343 2 3 0 22 0 218 226 227 344 2 3 0 22 0 218 160 226 345 2 3 0 22 0 227 226 164 346 2 3 0 22 0 160 228 226 347 2 3 0 22 0 228 229 226 348 2 3 0 22 0 228 163 229 349 2 3 0 22 0 226 229 164 350 2 3 0 22 0 160 214 228 351 2 3 0 22 0 214 230 228 352 2 3 0 22 0 214 146 230 353 2 3 0 22 0 228 230 163 354 2 3 0 22 0 164 229 232 355 2 3 0 22 0 229 231 232 356 2 3 0 22 0 229 163 231 357 2 3 0 22 0 232 231 148 358 2 3 0 22 0 148 224 232 359 2 3 0 22 0 224 233 232 360 2 3 0 22 0 224 161 233 361 2 3 0 22 0 232 233 164 362 2 3 0 22 0 161 234 233 363 2 3 0 22 0 234 235 233 364 2 3 0 22 0 234 153 235 365 2 3 0 22 0 233 235 164 366 2 3 0 22 0 161 223 234 367 2 3 0 22 0 223 184 234 368 2 3 0 22 0 223 18 184 369 2 3 0 22 0 234 184 153 370 2 3 0 22 0 164 235 227 371 2 3 0 22 0 235 179 227 372 2 3 0 22 0 235 153 179 373 2 3 0 22 0 227 179 147 374 2 3 0 22 0 148 231 225 375 2 3 0 22 0 231 236 225 376 2 3 0 22 0 231 163 236 377 2 3 0 22 0 225 236 162 378 2 3 0 22 0 163 237 236 379 2 3 0 22 0 237 238 236 380 2 3 0 22 0 237 157 238 381 2 3 0 22 0 236 238 162 382 2 3 0 22 0 163 230 237 383 2 3 0 22 0 230 196 237 384 2 3 0 22 0 230 146 196 385 2 3 0 22 0 237 196 157 386 2 3 0 22 0 162 238 220 387 2 3 0 22 0 238 200 220 388 2 3 0 22 0 238 157 200 389 2 3 0 22 0 220 200 19 390 2 3 0 24 0 29 34 299 391 2 3 0 24 0 34 298 299 392 2 3 0 24 0 34 31 298 393 2 3 0 24 0 299 298 246 394 2 3 0 24 0 31 300 298 395 2 3 0 24 0 300 301 298 396 2 3 0 24 0 300 245 301 397 2 3 0 24 0 298 301 246 398 2 3 0 24 0 31 35 300 399 2 3 0 24 0 35 302 300 400 2 3 0 24 0 35 16 302 401 2 3 0 24 0 300 302 245 402 2 3 0 24 0 246 301 304 403 2 3 0 24 0 301 303 304 404 2 3 0 24 0 301 245 303 405 2 3 0 24 0 304 303 99 406 2 3 0 24 0 29 299 306 407 2 3 0 24 0 299 305 306 408 2 3 0 24 0 299 246 305 409 2 3 0 24 0 306 305 247 410 2 3 0 24 0 246 307 305 411 2 3 0 24 0 307 308 305 412 2 3 0 24 0 307 100 308 413 2 3 0 24 0 305 308 247 414 2 3 0 24 0 246 304 307 415 2 3 0 24 0 304 103 307 416 2 3 0 24 0 304 99 103 417 2 3 0 24 0 307 103 100 418 2 3 0 24 0 247 308 309 419 2 3 0 24 0 308 102 309 420 2 3 0 24 0 308 100 102 421 2 3 0 24 0 309 102 3 422 2 3 0 24 0 51 310 312 423 2 3 0 24 0 310 311 312 424 2 3 0 24 0 310 248 311 425 2 3 0 24 0 312 311 249 426 2 3 0 24 0 248 313 311 427 2 3 0 24 0 313 314 311 428 2 3 0 24 0 313 69 314 429 2 3 0 24 0 311 314 249 430 2 3 0 24 0 248 315 313 431 2 3 0 24 0 315 73 313 432 2 3 0 24 0 315 10 73 433 2 3 0 24 0 313 73 69 434 2 3 0 24 0 249 314 316 435 2 3 0 24 0 314 72 316 436 2 3 0 24 0 314 69 72 437 2 3 0 24 0 316 72 67 438 2 3 0 24 0 51 312 55 439 2 3 0 24 0 312 317 55 440 2 3 0 24 0 312 249 317 441 2 3 0 24 0 55 317 52 442 2 3 0 24 0 249 318 317 443 2 3 0 24 0 318 319 317 444 2 3 0 24 0 318 250 319 445 2 3 0 24 0 317 319 52 446 2 3 0 24 0 249 316 318 447 2 3 0 24 0 316 320 318 448 2 3 0 24 0 316 67 320 449 2 3 0 24 0 318 320 250 450 2 3 0 24 0 52 319 54 451 2 3 0 24 0 319 321 54 452 2 3 0 24 0 319 250 321 453 2 3 0 24 0 54 321 14 454 2 3 0 24 0 74 81 323 455 2 3 0 24 0 81 322 323 456 2 3 0 24 0 81 77 322 457 2 3 0 24 0 323 322 252 458 2 3 0 24 0 77 324 322 459 2 3 0 24 0 324 325 322 460 2 3 0 24 0 324 251 325 461 2 3 0 24 0 322 325 252 462 2 3 0 24 0 77 82 324 463 2 3 0 24 0 82 326 324 464 2 3 0 24 0 82 75 326 465 2 3 0 24 0 324 326 251 466 2 3 0 24 0 252 325 328 467 2 3 0 24 0 325 327 328 468 2 3 0 24 0 325 251 327 469 2 3 0 24 0 328 327 22 470 2 3 0 24 0 74 323 330 471 2 3 0 24 0 323 329 330 472 2 3 0 24 0 323 252 329 473 2 3 0 24 0 330 329 253 474 2 3 0 24 0 252 331 329 475 2 3 0 24 0 331 332 329 476 2 3 0 24 0 331 138 332 477 2 3 0 24 0 329 332 253 478 2 3 0 24 0 252 328 331 479 2 3 0 24 0 328 142 331 480 2 3 0 24 0 328 22 142 481 2 3 0 24 0 331 142 138 482 2 3 0 24 0 253 332 333 483 2 3 0 24 0 332 141 333 484 2 3 0 24 0 332 138 141 485 2 3 0 24 0 333 141 136 486 2 3 0 24 0 89 334 336 487 2 3 0 24 0 334 335 336 488 2 3 0 24 0 334 254 335 489 2 3 0 24 0 336 335 255 490 2 3 0 24 0 254 337 335 491 2 3 0 24 0 337 338 335 492 2 3 0 24 0 337 130 338 493 2 3 0 24 0 335 338 255 494 2 3 0 24 0 254 339 337 495 2 3 0 24 0 339 133 337 496 2 3 0 24 0 339 129 133 497 2 3 0 24 0 337 133 130 498 2 3 0 24 0 255 338 340 499 2 3 0 24 0 338 132 340 500 2 3 0 24 0 338 130 132 501 2 3 0 24 0 340 132 18 502 2 3 0 24 0 89 336 96 503 2 3 0 24 0 336 341 96 504 2 3 0 24 0 336 255 341 505 2 3 0 24 0 96 341 91 506 2 3 0 24 0 255 342 341 507 2 3 0 24 0 342 343 341 508 2 3 0 24 0 342 256 343 509 2 3 0 24 0 341 343 91 510 2 3 0 24 0 255 340 342 511 2 3 0 24 0 340 344 342 512 2 3 0 24 0 340 18 344 513 2 3 0 24 0 342 344 256 514 2 3 0 24 0 91 343 95 515 2 3 0 24 0 343 345 95 516 2 3 0 24 0 343 256 345 517 2 3 0 24 0 95 345 88 518 2 3 0 24 0 18 113 344 519 2 3 0 24 0 113 346 344 520 2 3 0 24 0 113 112 346 521 2 3 0 24 0 344 346 256 522 2 3 0 24 0 112 347 346 523 2 3 0 24 0 347 348 346 524 2 3 0 24 0 347 257 348 525 2 3 0 24 0 346 348 256 526 2 3 0 24 0 112 114 347 527 2 3 0 24 0 114 349 347 528 2 3 0 24 0 114 19 349 529 2 3 0 24 0 347 349 257 530 2 3 0 24 0 256 348 345 531 2 3 0 24 0 348 350 345 532 2 3 0 24 0 348 257 350 533 2 3 0 24 0 345 350 88 534 2 3 0 24 0 22 327 145 535 2 3 0 24 0 327 351 145 536 2 3 0 24 0 327 251 351 537 2 3 0 24 0 145 351 143 538 2 3 0 24 0 251 352 351 539 2 3 0 24 0 352 353 351 540 2 3 0 24 0 352 258 353 541 2 3 0 24 0 351 353 143 542 2 3 0 24 0 251 326 352 543 2 3 0 24 0 326 354 352 544 2 3 0 24 0 326 75 354 545 2 3 0 24 0 352 354 258 546 2 3 0 24 0 143 353 144 547 2 3 0 24 0 353 355 144 548 2 3 0 24 0 353 258 355 549 2 3 0 24 0 144 355 21 550 2 3 0 24 0 88 350 94 551 2 3 0 24 0 350 356 94 552 2 3 0 24 0 350 257 356 553 2 3 0 24 0 94 356 90 554 2 3 0 24 0 257 357 356 555 2 3 0 24 0 357 358 356 556 2 3 0 24 0 357 259 358 557 2 3 0 24 0 356 358 90 558 2 3 0 24 0 257 349 357 559 2 3 0 24 0 349 359 357 560 2 3 0 24 0 349 19 359 561 2 3 0 24 0 357 359 259 562 2 3 0 24 0 90 358 93 563 2 3 0 24 0 358 360 93 564 2 3 0 24 0 358 259 360 565 2 3 0 24 0 93 360 6 566 2 3 0 24 0 75 83 354 567 2 3 0 24 0 83 361 354 568 2 3 0 24 0 83 78 361 569 2 3 0 24 0 354 361 258 570 2 3 0 24 0 78 362 361 571 2 3 0 24 0 362 363 361 572 2 3 0 24 0 362 260 363 573 2 3 0 24 0 361 363 258 574 2 3 0 24 0 78 84 362 575 2 3 0 24 0 84 364 362 576 2 3 0 24 0 84 7 364 577 2 3 0 24 0 362 364 260 578 2 3 0 24 0 258 363 355 579 2 3 0 24 0 363 365 355 580 2 3 0 24 0 363 260 365 581 2 3 0 24 0 355 365 21 582 2 3 0 24 0 21 365 118 583 2 3 0 24 0 365 366 118 584 2 3 0 24 0 365 260 366 585 2 3 0 24 0 118 366 116 586 2 3 0 24 0 260 367 366 587 2 3 0 24 0 367 368 366 588 2 3 0 24 0 367 261 368 589 2 3 0 24 0 366 368 116 590 2 3 0 24 0 260 364 367 591 2 3 0 24 0 364 369 367 592 2 3 0 24 0 364 7 369 593 2 3 0 24 0 367 369 261 594 2 3 0 24 0 116 368 119 595 2 3 0 24 0 368 370 119 596 2 3 0 24 0 368 261 370 597 2 3 0 24 0 119 370 115 598 2 3 0 24 0 19 128 359 599 2 3 0 24 0 128 371 359 600 2 3 0 24 0 128 124 371 601 2 3 0 24 0 359 371 259 602 2 3 0 24 0 124 372 371 603 2 3 0 24 0 372 373 371 604 2 3 0 24 0 372 262 373 605 2 3 0 24 0 371 373 259 606 2 3 0 24 0 124 127 372 607 2 3 0 24 0 127 374 372 608 2 3 0 24 0 127 122 374 609 2 3 0 24 0 372 374 262 610 2 3 0 24 0 259 373 360 611 2 3 0 24 0 373 375 360 612 2 3 0 24 0 373 262 375 613 2 3 0 24 0 360 375 6 614 2 3 0 24 0 122 126 374 615 2 3 0 24 0 126 376 374 616 2 3 0 24 0 126 123 376 617 2 3 0 24 0 374 376 262 618 2 3 0 24 0 123 377 376 619 2 3 0 24 0 377 378 376 620 2 3 0 24 0 377 263 378 621 2 3 0 24 0 376 378 262 622 2 3 0 24 0 123 125 377 623 2 3 0 24 0 125 379 377 624 2 3 0 24 0 125 24 379 625 2 3 0 24 0 377 379 263 626 2 3 0 24 0 262 378 375 627 2 3 0 24 0 378 380 375 628 2 3 0 24 0 378 263 380 629 2 3 0 24 0 375 380 6 630 2 3 0 24 0 115 370 120 631 2 3 0 24 0 370 381 120 632 2 3 0 24 0 370 261 381 633 2 3 0 24 0 120 381 117 634 2 3 0 24 0 261 382 381 635 2 3 0 24 0 382 383 381 636 2 3 0 24 0 382 264 383 637 2 3 0 24 0 381 383 117 638 2 3 0 24 0 261 369 382 639 2 3 0 24 0 369 384 382 640 2 3 0 24 0 369 7 384 641 2 3 0 24 0 382 384 264 642 2 3 0 24 0 117 383 121 643 2 3 0 24 0 383 385 121 644 2 3 0 24 0 383 264 385 645 2 3 0 24 0 121 385 24 646 2 3 0 24 0 24 385 379 647 2 3 0 24 0 385 386 379 648 2 3 0 24 0 385 264 386 649 2 3 0 24 0 379 386 263 650 2 3 0 24 0 264 387 386 651 2 3 0 24 0 387 388 386 652 2 3 0 24 0 387 85 388 653 2 3 0 24 0 386 388 263 654 2 3 0 24 0 264 384 387 655 2 3 0 24 0 384 86 387 656 2 3 0 24 0 384 7 86 657 2 3 0 24 0 387 86 85 658 2 3 0 24 0 263 388 380 659 2 3 0 24 0 388 87 380 660 2 3 0 24 0 388 85 87 661 2 3 0 24 0 380 87 6 662 2 3 0 24 0 8 79 390 663 2 3 0 24 0 79 389 390 664 2 3 0 24 0 79 76 389 665 2 3 0 24 0 390 389 266 666 2 3 0 24 0 76 391 389 667 2 3 0 24 0 391 392 389 668 2 3 0 24 0 391 265 392 669 2 3 0 24 0 389 392 266 670 2 3 0 24 0 76 80 391 671 2 3 0 24 0 80 393 391 672 2 3 0 24 0 80 74 393 673 2 3 0 24 0 391 393 265 674 2 3 0 24 0 266 392 395 675 2 3 0 24 0 392 394 395 676 2 3 0 24 0 392 265 394 677 2 3 0 24 0 395 394 240 678 2 3 0 24 0 241 396 398 679 2 3 0 24 0 396 397 398 680 2 3 0 24 0 396 267 397 681 2 3 0 24 0 398 397 268 682 2 3 0 24 0 267 399 397 683 2 3 0 24 0 399 400 397 684 2 3 0 24 0 399 58 400 685 2 3 0 24 0 397 400 268 686 2 3 0 24 0 267 401 399 687 2 3 0 24 0 401 59 399 688 2 3 0 24 0 401 13 59 689 2 3 0 24 0 399 59 58 690 2 3 0 24 0 268 400 402 691 2 3 0 24 0 400 60 402 692 2 3 0 24 0 400 58 60 693 2 3 0 24 0 402 60 12 694 2 3 0 24 0 241 403 405 695 2 3 0 24 0 403 404 405 696 2 3 0 24 0 403 269 404 697 2 3 0 24 0 405 404 270 698 2 3 0 24 0 269 406 404 699 2 3 0 24 0 406 407 404 700 2 3 0 24 0 406 64 407 701 2 3 0 24 0 404 407 270 702 2 3 0 24 0 269 408 406 703 2 3 0 24 0 408 65 406 704 2 3 0 24 0 408 11 65 705 2 3 0 24 0 406 65 64 706 2 3 0 24 0 270 407 409 707 2 3 0 24 0 407 66 409 708 2 3 0 24 0 407 64 66 709 2 3 0 24 0 409 66 10 710 2 3 0 24 0 12 62 402 711 2 3 0 24 0 62 410 402 712 2 3 0 24 0 62 61 410 713 2 3 0 24 0 402 410 268 714 2 3 0 24 0 61 411 410 715 2 3 0 24 0 411 412 410 716 2 3 0 24 0 411 269 412 717 2 3 0 24 0 410 412 268 718 2 3 0 24 0 61 63 411 719 2 3 0 24 0 63 408 411 720 2 3 0 24 0 63 11 408 721 2 3 0 24 0 411 408 269 722 2 3 0 24 0 268 412 398 723 2 3 0 24 0 412 403 398 724 2 3 0 24 0 412 269 403 725 2 3 0 24 0 398 403 241 726 2 3 0 24 0 3 107 414 727 2 3 0 24 0 107 413 414 728 2 3 0 24 0 107 106 413 729 2 3 0 24 0 414 413 272 730 2 3 0 24 0 106 415 413 731 2 3 0 24 0 415 416 413 732 2 3 0 24 0 415 271 416 733 2 3 0 24 0 413 416 272 734 2 3 0 24 0 106 108 415 735 2 3 0 24 0 108 417 415 736 2 3 0 24 0 108 2 417 737 2 3 0 24 0 415 417 271 738 2 3 0 24 0 272 416 419 739 2 3 0 24 0 416 418 419 740 2 3 0 24 0 416 271 418 741 2 3 0 24 0 419 418 242 742 2 3 0 24 0 1 27 421 743 2 3 0 24 0 27 420 421 744 2 3 0 24 0 27 26 420 745 2 3 0 24 0 421 420 274 746 2 3 0 24 0 26 422 420 747 2 3 0 24 0 422 423 420 748 2 3 0 24 0 422 273 423 749 2 3 0 24 0 420 423 274 750 2 3 0 24 0 26 28 422 751 2 3 0 24 0 28 424 422 752 2 3 0 24 0 28 17 424 753 2 3 0 24 0 422 424 273 754 2 3 0 24 0 274 423 426 755 2 3 0 24 0 423 425 426 756 2 3 0 24 0 423 273 425 757 2 3 0 24 0 426 425 242 758 2 3 0 24 0 242 418 426 759 2 3 0 24 0 418 427 426 760 2 3 0 24 0 418 271 427 761 2 3 0 24 0 426 427 274 762 2 3 0 24 0 271 428 427 763 2 3 0 24 0 428 429 427 764 2 3 0 24 0 428 109 429 765 2 3 0 24 0 427 429 274 766 2 3 0 24 0 271 417 428 767 2 3 0 24 0 417 110 428 768 2 3 0 24 0 417 2 110 769 2 3 0 24 0 428 110 109 770 2 3 0 24 0 274 429 421 771 2 3 0 24 0 429 111 421 772 2 3 0 24 0 429 109 111 773 2 3 0 24 0 421 111 1 774 2 3 0 24 0 51 56 431 775 2 3 0 24 0 56 430 431 776 2 3 0 24 0 56 53 430 777 2 3 0 24 0 431 430 275 778 2 3 0 24 0 53 432 430 779 2 3 0 24 0 432 433 430 780 2 3 0 24 0 432 267 433 781 2 3 0 24 0 430 433 275 782 2 3 0 24 0 53 57 432 783 2 3 0 24 0 57 401 432 784 2 3 0 24 0 57 13 401 785 2 3 0 24 0 432 401 267 786 2 3 0 24 0 275 433 434 787 2 3 0 24 0 433 396 434 788 2 3 0 24 0 433 267 396 789 2 3 0 24 0 434 396 241 790 2 3 0 24 0 51 431 310 791 2 3 0 24 0 431 435 310 792 2 3 0 24 0 431 275 435 793 2 3 0 24 0 310 435 248 794 2 3 0 24 0 275 436 435 795 2 3 0 24 0 436 437 435 796 2 3 0 24 0 436 270 437 797 2 3 0 24 0 435 437 248 798 2 3 0 24 0 275 434 436 799 2 3 0 24 0 434 405 436 800 2 3 0 24 0 434 241 405 801 2 3 0 24 0 436 405 270 802 2 3 0 24 0 248 437 315 803 2 3 0 24 0 437 409 315 804 2 3 0 24 0 437 270 409 805 2 3 0 24 0 315 409 10 806 2 3 0 24 0 242 425 439 807 2 3 0 24 0 425 438 439 808 2 3 0 24 0 425 273 438 809 2 3 0 24 0 439 438 276 810 2 3 0 24 0 273 440 438 811 2 3 0 24 0 440 441 438 812 2 3 0 24 0 440 30 441 813 2 3 0 24 0 438 441 276 814 2 3 0 24 0 273 424 440 815 2 3 0 24 0 424 32 440 816 2 3 0 24 0 424 17 32 817 2 3 0 24 0 440 32 30 818 2 3 0 24 0 276 441 442 819 2 3 0 24 0 441 33 442 820 2 3 0 24 0 441 30 33 821 2 3 0 24 0 442 33 29 822 2 3 0 24 0 3 414 309 823 2 3 0 24 0 414 443 309 824 2 3 0 24 0 414 272 443 825 2 3 0 24 0 309 443 247 826 2 3 0 24 0 272 444 443 827 2 3 0 24 0 444 445 443 828 2 3 0 24 0 444 276 445 829 2 3 0 24 0 443 445 247 830 2 3 0 24 0 272 419 444 831 2 3 0 24 0 419 439 444 832 2 3 0 24 0 419 242 439 833 2 3 0 24 0 444 439 276 834 2 3 0 24 0 247 445 306 835 2 3 0 24 0 445 442 306 836 2 3 0 24 0 445 276 442 837 2 3 0 24 0 306 442 29 838 2 3 0 24 0 240 446 448 839 2 3 0 24 0 446 447 448 840 2 3 0 24 0 446 277 447 841 2 3 0 24 0 448 447 279 842 2 3 0 24 0 277 449 447 843 2 3 0 24 0 449 450 447 844 2 3 0 24 0 449 278 450 845 2 3 0 24 0 447 450 279 846 2 3 0 24 0 277 451 449 847 2 3 0 24 0 451 452 449 848 2 3 0 24 0 451 25 452 849 2 3 0 24 0 449 452 278 850 2 3 0 24 0 279 450 454 851 2 3 0 24 0 450 453 454 852 2 3 0 24 0 450 278 453 853 2 3 0 24 0 454 453 239 854 2 3 0 24 0 89 97 456 855 2 3 0 24 0 97 455 456 856 2 3 0 24 0 97 92 455 857 2 3 0 24 0 456 455 281 858 2 3 0 24 0 92 457 455 859 2 3 0 24 0 457 458 455 860 2 3 0 24 0 457 280 458 861 2 3 0 24 0 455 458 281 862 2 3 0 24 0 92 98 457 863 2 3 0 24 0 98 459 457 864 2 3 0 24 0 98 5 459 865 2 3 0 24 0 457 459 280 866 2 3 0 24 0 281 458 461 867 2 3 0 24 0 458 460 461 868 2 3 0 24 0 458 280 460 869 2 3 0 24 0 461 460 239 870 2 3 0 24 0 243 462 464 871 2 3 0 24 0 462 463 464 872 2 3 0 24 0 462 282 463 873 2 3 0 24 0 464 463 283 874 2 3 0 24 0 282 465 463 875 2 3 0 24 0 465 466 463 876 2 3 0 24 0 465 131 466 877 2 3 0 24 0 463 466 283 878 2 3 0 24 0 282 467 465 879 2 3 0 24 0 467 135 465 880 2 3 0 24 0 467 25 135 881 2 3 0 24 0 465 135 131 882 2 3 0 24 0 283 466 468 883 2 3 0 24 0 466 134 468 884 2 3 0 24 0 466 131 134 885 2 3 0 24 0 468 134 129 886 2 3 0 24 0 243 469 471 887 2 3 0 24 0 469 470 471 888 2 3 0 24 0 469 284 470 889 2 3 0 24 0 471 470 285 890 2 3 0 24 0 284 472 470 891 2 3 0 24 0 472 473 470 892 2 3 0 24 0 472 281 473 893 2 3 0 24 0 470 473 285 894 2 3 0 24 0 284 474 472 895 2 3 0 24 0 474 456 472 896 2 3 0 24 0 474 89 456 897 2 3 0 24 0 472 456 281 898 2 3 0 24 0 285 473 475 899 2 3 0 24 0 473 461 475 900 2 3 0 24 0 473 281 461 901 2 3 0 24 0 475 461 239 902 2 3 0 24 0 239 453 475 903 2 3 0 24 0 453 476 475 904 2 3 0 24 0 453 278 476 905 2 3 0 24 0 475 476 285 906 2 3 0 24 0 278 477 476 907 2 3 0 24 0 477 478 476 908 2 3 0 24 0 477 282 478 909 2 3 0 24 0 476 478 285 910 2 3 0 24 0 278 452 477 911 2 3 0 24 0 452 467 477 912 2 3 0 24 0 452 25 467 913 2 3 0 24 0 477 467 282 914 2 3 0 24 0 285 478 471 915 2 3 0 24 0 478 462 471 916 2 3 0 24 0 478 282 462 917 2 3 0 24 0 471 462 243 918 2 3 0 24 0 129 339 468 919 2 3 0 24 0 339 479 468 920 2 3 0 24 0 339 254 479 921 2 3 0 24 0 468 479 283 922 2 3 0 24 0 254 480 479 923 2 3 0 24 0 480 481 479 924 2 3 0 24 0 480 284 481 925 2 3 0 24 0 479 481 283 926 2 3 0 24 0 254 334 480 927 2 3 0 24 0 334 474 480 928 2 3 0 24 0 334 89 474 929 2 3 0 24 0 480 474 284 930 2 3 0 24 0 283 481 464 931 2 3 0 24 0 481 469 464 932 2 3 0 24 0 481 284 469 933 2 3 0 24 0 464 469 243 934 2 3 0 24 0 136 140 483 935 2 3 0 24 0 140 482 483 936 2 3 0 24 0 140 137 482 937 2 3 0 24 0 483 482 287 938 2 3 0 24 0 137 484 482 939 2 3 0 24 0 484 485 482 940 2 3 0 24 0 484 286 485 941 2 3 0 24 0 482 485 287 942 2 3 0 24 0 137 139 484 943 2 3 0 24 0 139 486 484 944 2 3 0 24 0 139 25 486 945 2 3 0 24 0 484 486 286 946 2 3 0 24 0 287 485 488 947 2 3 0 24 0 485 487 488 948 2 3 0 24 0 485 286 487 949 2 3 0 24 0 488 487 244 950 2 3 0 24 0 240 394 490 951 2 3 0 24 0 394 489 490 952 2 3 0 24 0 394 265 489 953 2 3 0 24 0 490 489 289 954 2 3 0 24 0 265 491 489 955 2 3 0 24 0 491 492 489 956 2 3 0 24 0 491 288 492 957 2 3 0 24 0 489 492 289 958 2 3 0 24 0 265 393 491 959 2 3 0 24 0 393 493 491 960 2 3 0 24 0 393 74 493 961 2 3 0 24 0 491 493 288 962 2 3 0 24 0 289 492 495 963 2 3 0 24 0 492 494 495 964 2 3 0 24 0 492 288 494 965 2 3 0 24 0 495 494 244 966 2 3 0 24 0 244 487 495 967 2 3 0 24 0 487 496 495 968 2 3 0 24 0 487 286 496 969 2 3 0 24 0 495 496 289 970 2 3 0 24 0 286 497 496 971 2 3 0 24 0 497 498 496 972 2 3 0 24 0 497 277 498 973 2 3 0 24 0 496 498 289 974 2 3 0 24 0 286 486 497 975 2 3 0 24 0 486 451 497 976 2 3 0 24 0 486 25 451 977 2 3 0 24 0 497 451 277 978 2 3 0 24 0 289 498 490 979 2 3 0 24 0 498 446 490 980 2 3 0 24 0 498 277 446 981 2 3 0 24 0 490 446 240 982 2 3 0 24 0 244 494 488 983 2 3 0 24 0 494 499 488 984 2 3 0 24 0 494 288 499 985 2 3 0 24 0 488 499 287 986 2 3 0 24 0 288 500 499 987 2 3 0 24 0 500 501 499 988 2 3 0 24 0 500 253 501 989 2 3 0 24 0 499 501 287 990 2 3 0 24 0 288 493 500 991 2 3 0 24 0 493 330 500 992 2 3 0 24 0 493 74 330 993 2 3 0 24 0 500 330 253 994 2 3 0 24 0 287 501 483 995 2 3 0 24 0 501 333 483 996 2 3 0 24 0 501 253 333 997 2 3 0 24 0 483 333 136 998 2 3 0 24 0 5 502 504 999 2 3 0 24 0 502 503 504 1000 2 3 0 24 0 502 290 503 1001 2 3 0 24 0 504 503 291 1002 2 3 0 24 0 290 505 503 1003 2 3 0 24 0 505 506 503 1004 2 3 0 24 0 505 42 506 1005 2 3 0 24 0 503 506 291 1006 2 3 0 24 0 290 507 505 1007 2 3 0 24 0 507 50 505 1008 2 3 0 24 0 507 16 50 1009 2 3 0 24 0 505 50 42 1010 2 3 0 24 0 291 506 508 1011 2 3 0 24 0 506 49 508 1012 2 3 0 24 0 506 42 49 1013 2 3 0 24 0 508 49 38 1014 2 3 0 24 0 99 303 104 1015 2 3 0 24 0 303 509 104 1016 2 3 0 24 0 303 245 509 1017 2 3 0 24 0 104 509 101 1018 2 3 0 24 0 245 510 509 1019 2 3 0 24 0 510 511 509 1020 2 3 0 24 0 510 290 511 1021 2 3 0 24 0 509 511 101 1022 2 3 0 24 0 245 302 510 1023 2 3 0 24 0 302 507 510 1024 2 3 0 24 0 302 16 507 1025 2 3 0 24 0 510 507 290 1026 2 3 0 24 0 101 511 105 1027 2 3 0 24 0 511 502 105 1028 2 3 0 24 0 511 290 502 1029 2 3 0 24 0 105 502 5 1030 2 3 0 24 0 36 44 513 1031 2 3 0 24 0 44 512 513 1032 2 3 0 24 0 44 39 512 1033 2 3 0 24 0 513 512 293 1034 2 3 0 24 0 39 514 512 1035 2 3 0 24 0 514 515 512 1036 2 3 0 24 0 514 292 515 1037 2 3 0 24 0 512 515 293 1038 2 3 0 24 0 39 43 514 1039 2 3 0 24 0 43 516 514 1040 2 3 0 24 0 43 14 516 1041 2 3 0 24 0 514 516 292 1042 2 3 0 24 0 293 515 518 1043 2 3 0 24 0 515 517 518 1044 2 3 0 24 0 515 292 517 1045 2 3 0 24 0 518 517 8 1046 2 3 0 24 0 8 517 70 1047 2 3 0 24 0 517 519 70 1048 2 3 0 24 0 517 292 519 1049 2 3 0 24 0 70 519 68 1050 2 3 0 24 0 292 520 519 1051 2 3 0 24 0 520 521 519 1052 2 3 0 24 0 520 250 521 1053 2 3 0 24 0 519 521 68 1054 2 3 0 24 0 292 516 520 1055 2 3 0 24 0 516 321 520 1056 2 3 0 24 0 516 14 321 1057 2 3 0 24 0 520 321 250 1058 2 3 0 24 0 68 521 71 1059 2 3 0 24 0 521 320 71 1060 2 3 0 24 0 521 250 320 1061 2 3 0 24 0 71 320 67 1062 2 3 0 24 0 239 522 524 1063 2 3 0 24 0 522 523 524 1064 2 3 0 24 0 522 294 523 1065 2 3 0 24 0 524 523 295 1066 2 3 0 24 0 294 525 523 1067 2 3 0 24 0 525 526 523 1068 2 3 0 24 0 525 41 526 1069 2 3 0 24 0 523 526 295 1070 2 3 0 24 0 294 527 525 1071 2 3 0 24 0 527 48 525 1072 2 3 0 24 0 527 38 48 1073 2 3 0 24 0 525 48 41 1074 2 3 0 24 0 295 526 528 1075 2 3 0 24 0 526 47 528 1076 2 3 0 24 0 526 41 47 1077 2 3 0 24 0 528 47 37 1078 2 3 0 24 0 38 527 508 1079 2 3 0 24 0 527 529 508 1080 2 3 0 24 0 527 294 529 1081 2 3 0 24 0 508 529 291 1082 2 3 0 24 0 294 530 529 1083 2 3 0 24 0 530 531 529 1084 2 3 0 24 0 530 280 531 1085 2 3 0 24 0 529 531 291 1086 2 3 0 24 0 294 522 530 1087 2 3 0 24 0 522 460 530 1088 2 3 0 24 0 522 239 460 1089 2 3 0 24 0 530 460 280 1090 2 3 0 24 0 291 531 504 1091 2 3 0 24 0 531 459 504 1092 2 3 0 24 0 531 280 459 1093 2 3 0 24 0 504 459 5 1094 2 3 0 24 0 37 46 533 1095 2 3 0 24 0 46 532 533 1096 2 3 0 24 0 46 40 532 1097 2 3 0 24 0 533 532 297 1098 2 3 0 24 0 40 534 532 1099 2 3 0 24 0 534 535 532 1100 2 3 0 24 0 534 296 535 1101 2 3 0 24 0 532 535 297 1102 2 3 0 24 0 40 45 534 1103 2 3 0 24 0 45 536 534 1104 2 3 0 24 0 45 36 536 1105 2 3 0 24 0 534 536 296 1106 2 3 0 24 0 297 535 538 1107 2 3 0 24 0 535 537 538 1108 2 3 0 24 0 535 296 537 1109 2 3 0 24 0 538 537 240 1110 2 3 0 24 0 8 390 518 1111 2 3 0 24 0 390 539 518 1112 2 3 0 24 0 390 266 539 1113 2 3 0 24 0 518 539 293 1114 2 3 0 24 0 266 540 539 1115 2 3 0 24 0 540 541 539 1116 2 3 0 24 0 540 296 541 1117 2 3 0 24 0 539 541 293 1118 2 3 0 24 0 266 395 540 1119 2 3 0 24 0 395 537 540 1120 2 3 0 24 0 395 240 537 1121 2 3 0 24 0 540 537 296 1122 2 3 0 24 0 293 541 513 1123 2 3 0 24 0 541 536 513 1124 2 3 0 24 0 541 296 536 1125 2 3 0 24 0 513 536 36 1126 2 3 0 24 0 37 533 528 1127 2 3 0 24 0 533 542 528 1128 2 3 0 24 0 533 297 542 1129 2 3 0 24 0 528 542 295 1130 2 3 0 24 0 297 543 542 1131 2 3 0 24 0 543 544 542 1132 2 3 0 24 0 543 279 544 1133 2 3 0 24 0 542 544 295 1134 2 3 0 24 0 297 538 543 1135 2 3 0 24 0 538 448 543 1136 2 3 0 24 0 538 240 448 1137 2 3 0 24 0 543 448 279 1138 2 3 0 24 0 295 544 524 1139 2 3 0 24 0 544 454 524 1140 2 3 0 24 0 544 279 454 1141 2 3 0 24 0 524 454 239 $EndElements
{ "pile_set_name": "Github" }
tidelift: pypi/setuptools
{ "pile_set_name": "Github" }
package main import ( "fmt" "github.com/sbinet/go-python" ) func init() { err := python.Initialize() if err != nil { panic(err.Error()) } } func main() { exc, val, tb := python.PyErr_Fetch() fmt.Printf("exc=%v\nval=%v\ntb=%v\n", exc, val, tb) }
{ "pile_set_name": "Github" }
(module TerminalBlock_WAGO-236_2Stift_RM5mm_2pol (layer F.Cu) (tedit 54F03FF3) (descr "WAGO-Series 236, 2Stift, 2pol, RM 5mm,") (tags "WAGO-Series 236, 2Stift, 2pol, RM 5mm, Anreibare Leiterplattenklemme") (fp_text reference TerminalBlock_WAGO-236_2Stift_RM5mm_2pol (at 0 -8.89) (layer F.SilkS) (effects (font (size 1 1) (thickness 0.15))) ) (fp_text value VAL** (at 0 8.89) (layer F.SilkS) (effects (font (size 1 1) (thickness 0.15))) ) (fp_line (start 2.032 -4.572) (end 3.048 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start 3.048 -4.572) (end 3.048 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start 3.048 -7.112) (end 2.032 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start 2.032 -7.112) (end 2.032 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start 4.064 -2.54) (end 5.588 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 -2.54) (end 1.016 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start 1.016 -1.524) (end 1.016 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start 1.016 -0.508) (end 4.572 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start 4.572 -0.508) (end 4.572 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start 4.572 -1.524) (end 4.064 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start 1.524 4.572) (end 1.524 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start 1.524 5.08) (end 3.556 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start 3.556 5.08) (end 3.556 4.064) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 5.588) (end 5.588 5.588) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 0.508) (end 5.588 0.508) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 6.604) (end 5.588 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start 5.588 6.604) (end 5.588 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start 5.588 -7.62) (end 0.508 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 -7.62) (end -2.54 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 6.604) (end -4.572 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 6.604) (end -4.572 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 -7.62) (end 0.508 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start -2.54 -7.62) (end 0.508 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 -7.62) (end -4.572 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 6.604) (end -6.096 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 6.604) (end -6.096 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 -2.54) (end -4.064 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start -1.016 -2.54) (end 0.508 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start -3.048 -4.572) (end -3.048 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start -2.032 -4.572) (end -3.048 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start -2.032 -7.112) (end -2.032 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start -3.048 -7.112) (end -2.032 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 0.508) (end 0.508 0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 5.588) (end 0.508 5.588) (layer F.SilkS) (width 0.15)) (fp_line (start -0.508 -1.524) (end -1.016 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start -0.508 -0.508) (end -0.508 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start -4.064 -0.508) (end -0.508 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -4.064 -1.524) (end -4.064 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -1.524 5.08) (end -1.524 4.064) (layer F.SilkS) (width 0.15)) (fp_line (start -3.556 5.08) (end -1.524 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start -3.556 4.572) (end -3.556 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start -3.556 4.572) (end -3.556 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start -3.556 5.08) (end -1.524 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start -1.524 5.08) (end -1.524 4.064) (layer F.SilkS) (width 0.15)) (fp_line (start -4.064 -1.524) (end -4.064 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -4.064 -0.508) (end -0.508 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -0.508 -0.508) (end -0.508 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start -0.508 -1.524) (end -1.016 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 5.588) (end 0.508 5.588) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 0.508) (end 0.508 0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -3.048 -7.112) (end -2.032 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start -2.032 -7.112) (end -2.032 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start -2.032 -4.572) (end -3.048 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start -3.048 -4.572) (end -3.048 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start -1.016 -2.54) (end 0.508 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 -2.54) (end -4.064 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 6.604) (end -6.096 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 6.604) (end -6.096 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 -7.62) (end -4.572 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -2.54 -7.62) (end 0.508 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 -7.62) (end 0.508 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 6.604) (end -4.572 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 6.604) (end -4.572 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 -7.62) (end -2.54 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 -7.62) (end -2.54 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 6.604) (end -4.572 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 6.604) (end -4.572 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 -7.62) (end 0.508 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start -2.54 -7.62) (end 0.508 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 -7.62) (end -4.572 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 6.604) (end -6.096 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 6.604) (end -6.096 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 -2.54) (end -4.064 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start -1.016 -2.54) (end 0.508 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start -3.048 -4.572) (end -3.048 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start -2.032 -4.572) (end -3.048 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start -2.032 -7.112) (end -2.032 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start -3.048 -7.112) (end -2.032 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 0.508) (end 0.508 0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 5.588) (end 0.508 5.588) (layer F.SilkS) (width 0.15)) (fp_line (start -0.508 -1.524) (end -1.016 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start -0.508 -0.508) (end -0.508 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start -4.064 -0.508) (end -0.508 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -4.064 -1.524) (end -4.064 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -1.524 5.08) (end -1.524 4.064) (layer F.SilkS) (width 0.15)) (fp_line (start -3.556 5.08) (end -1.524 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start -3.556 4.572) (end -3.556 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start -3.556 4.572) (end -3.556 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start -3.556 5.08) (end -1.524 5.08) (layer F.SilkS) (width 0.15)) (fp_line (start -1.524 5.08) (end -1.524 4.064) (layer F.SilkS) (width 0.15)) (fp_line (start -4.064 -1.524) (end -4.064 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -4.064 -0.508) (end -0.508 -0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -0.508 -0.508) (end -0.508 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start -0.508 -1.524) (end -1.016 -1.524) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 5.588) (end 0.508 5.588) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 0.508) (end 0.508 0.508) (layer F.SilkS) (width 0.15)) (fp_line (start -3.048 -7.112) (end -2.032 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start -2.032 -7.112) (end -2.032 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start -2.032 -4.572) (end -3.048 -4.572) (layer F.SilkS) (width 0.15)) (fp_line (start -3.048 -4.572) (end -3.048 -7.112) (layer F.SilkS) (width 0.15)) (fp_line (start -1.016 -2.54) (end 0.508 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 -2.54) (end -4.064 -2.54) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 6.604) (end -6.096 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 6.604) (end -6.096 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -6.096 -7.62) (end -4.572 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -2.54 -7.62) (end 0.508 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 -7.62) (end 0.508 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start 0.508 6.604) (end -4.572 6.604) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 6.604) (end -4.572 -7.62) (layer F.SilkS) (width 0.15)) (fp_line (start -4.572 -7.62) (end -2.54 -7.62) (layer F.SilkS) (width 0.15)) (pad 1 thru_hole oval (at -2.54 2.54 90) (size 2.99974 1.50114) (drill 1.00076) (layers *.Cu *.Mask F.SilkS)) (pad 1 thru_hole oval (at -2.54 -2.54 90) (size 2.99974 1.50114) (drill 1.00076) (layers *.Cu *.Mask F.SilkS)) (pad 2 thru_hole oval (at 2.413 2.54 90) (size 2.99974 1.50114) (drill 1.00076) (layers *.Cu *.Mask F.SilkS)) (pad 2 thru_hole oval (at 2.413 -2.54 90) (size 2.99974 1.50114) (drill 1.00076) (layers *.Cu *.Mask F.SilkS)) )
{ "pile_set_name": "Github" }
--TEST-- V8\ExceptionManager::createError() --SKIPIF-- <?php if (!extension_loaded("v8")) print "skip"; ?> --FILE-- <?php /** @var \Phpv8Testsuite $helper */ $helper = require '.testsuite.php'; require '.v8-helpers.php'; $v8_helper = new PhpV8Helpers($helper); $isolate = new \V8\Isolate(); $context = new \V8\Context($isolate); try { $error = V8\ExceptionManager::createError($context, new \V8\StringValue($isolate, 'test')); $helper->assert('Can create error when out of context', $error instanceof \V8\Value); } catch (\Exception $e) { $helper->exception_export($e); } $helper->line(); $func_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) { $value = count($info->arguments()) ? $info->arguments()[0] : new \V8\StringValue($info->getIsolate(), "exception"); $info->getIsolate()->throwException($info->getContext(), V8\ExceptionManager::createError($info->getContext(), $value)); }); $func_test_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) use ($helper, $v8_helper) { $message = new \V8\StringValue($info->getIsolate(), "test"); $value1 = V8\ExceptionManager::createError($info->getContext(), $message); $value2 = V8\ExceptionManager::createError($info->getContext(), $message); $context = $info->getContext(); $v8_helper->CHECK_NE($value1, $value2); $v8_helper->CHECK(!$value1->equals($context, $value2), '!$value1->equals($context, $value2)'); $v8_helper->CHECK(!$value2->equals($context, $value1), '!$value2->equals($context, $value1)'); $v8_helper->CHECK(!$value1->strictEquals($value2), '!$value1->strictEquals($value2)'); $v8_helper->CHECK(!$value2->strictEquals($value1), '!$value2->strictEquals($value1)'); $v8_helper->CHECK(!$value1->sameValue($value2), '!$value1->sameValue($value2)'); $v8_helper->CHECK(!$value2->sameValue($value1), '!$value2->sameValue($value1)'); $helper->line(); }); $global_tpl = new \V8\ObjectTemplate($isolate); $global_tpl->set(new \V8\StringValue($isolate, 'e'), $func_tpl); $global_tpl->set(new \V8\StringValue($isolate, 'test'), $func_test_tpl); $context = new \V8\Context($isolate, $global_tpl); $v8_helper->injectConsoleLog($context); $v8_helper->CompileTryRun($context, 'test()'); $v8_helper->CompileTryRun($context, 'e()'); $v8_helper->CompileTryRun($context, 'e("test")'); $source = ' var ex; try { e("foo"); } catch (exception) { console.log("exception: ", "\'", exception, "\'"); console.log("exception.stack: ", exception.stack); ex = exception; } ex '; $helper->line(); $res = $v8_helper->CompileRun($context, $source); $helper->line(); $v8_helper->run_checks($res); ?> --EXPECT-- Can create error when out of context: ok CHECK_NE: OK CHECK !$value1->equals($context, $value2): OK CHECK !$value2->equals($context, $value1): OK CHECK !$value1->strictEquals($value2): OK CHECK !$value2->strictEquals($value1): OK CHECK !$value1->sameValue($value2): OK CHECK !$value2->sameValue($value1): OK e(): V8\Exceptions\TryCatchException: Error: exception e("test"): V8\Exceptions\TryCatchException: Error: test exception: 'Error: foo' exception.stack: Error: foo at test.js:5:9 Checks on V8\ObjectValue: ------------------------- V8\ObjectValue(V8\Value)->typeOf(): V8\StringValue->value(): string(6) "object" V8\ObjectValue->isCallable(): bool(false) V8\ObjectValue->isConstructor(): bool(false) V8\ObjectValue(V8\Value)->isUndefined(): bool(false) V8\ObjectValue(V8\Value)->isNull(): bool(false) V8\ObjectValue(V8\Value)->isNullOrUndefined(): bool(false) V8\ObjectValue(V8\Value)->isTrue(): bool(false) V8\ObjectValue(V8\Value)->isFalse(): bool(false) V8\ObjectValue(V8\Value)->isName(): bool(false) V8\ObjectValue(V8\Value)->isString(): bool(false) V8\ObjectValue(V8\Value)->isSymbol(): bool(false) V8\ObjectValue(V8\Value)->isFunction(): bool(false) V8\ObjectValue(V8\Value)->isArray(): bool(false) V8\ObjectValue(V8\Value)->isObject(): bool(true) V8\ObjectValue(V8\Value)->isBoolean(): bool(false) V8\ObjectValue(V8\Value)->isNumber(): bool(false) V8\ObjectValue(V8\Value)->isInt32(): bool(false) V8\ObjectValue(V8\Value)->isUint32(): bool(false) V8\ObjectValue(V8\Value)->isDate(): bool(false) V8\ObjectValue(V8\Value)->isArgumentsObject(): bool(false) V8\ObjectValue(V8\Value)->isBooleanObject(): bool(false) V8\ObjectValue(V8\Value)->isNumberObject(): bool(false) V8\ObjectValue(V8\Value)->isStringObject(): bool(false) V8\ObjectValue(V8\Value)->isSymbolObject(): bool(false) V8\ObjectValue(V8\Value)->isNativeError(): bool(true) V8\ObjectValue(V8\Value)->isRegExp(): bool(false) V8\ObjectValue(V8\Value)->isAsyncFunction(): bool(false) V8\ObjectValue(V8\Value)->isGeneratorFunction(): bool(false) V8\ObjectValue(V8\Value)->isGeneratorObject(): bool(false) V8\ObjectValue(V8\Value)->isPromise(): bool(false) V8\ObjectValue(V8\Value)->isMap(): bool(false) V8\ObjectValue(V8\Value)->isSet(): bool(false) V8\ObjectValue(V8\Value)->isMapIterator(): bool(false) V8\ObjectValue(V8\Value)->isSetIterator(): bool(false) V8\ObjectValue(V8\Value)->isWeakMap(): bool(false) V8\ObjectValue(V8\Value)->isWeakSet(): bool(false) V8\ObjectValue(V8\Value)->isArrayBuffer(): bool(false) V8\ObjectValue(V8\Value)->isArrayBufferView(): bool(false) V8\ObjectValue(V8\Value)->isTypedArray(): bool(false) V8\ObjectValue(V8\Value)->isUint8Array(): bool(false) V8\ObjectValue(V8\Value)->isUint8ClampedArray(): bool(false) V8\ObjectValue(V8\Value)->isInt8Array(): bool(false) V8\ObjectValue(V8\Value)->isUint16Array(): bool(false) V8\ObjectValue(V8\Value)->isInt16Array(): bool(false) V8\ObjectValue(V8\Value)->isUint32Array(): bool(false) V8\ObjectValue(V8\Value)->isInt32Array(): bool(false) V8\ObjectValue(V8\Value)->isFloat32Array(): bool(false) V8\ObjectValue(V8\Value)->isFloat64Array(): bool(false) V8\ObjectValue(V8\Value)->isBigInt64Array(): bool(false) V8\ObjectValue(V8\Value)->isBigUint64Array(): bool(false) V8\ObjectValue(V8\Value)->isDataView(): bool(false) V8\ObjectValue(V8\Value)->isSharedArrayBuffer(): bool(false) V8\ObjectValue(V8\Value)->isProxy(): bool(false)
{ "pile_set_name": "Github" }
/** * Copyright 2017 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #import "AIEventRequest.h" #import "AIDataService.h" #import "AIDataService_Private.h" #import "AIConfiguration.h" #import "AIRequestEntity_Private.h" #import "AIQueryRequest+Private.h" #import "AIRequest_Private.h" #import "AiOriginalRequest_Private.h" #import "AIResponseConstants.h" @implementation AIEventRequest - (void)configureHTTPRequest { AIDataService *dataService = self.dataService; id <AIConfiguration> configuration = dataService.configuration; NSString *version = self.version; NSString *path = @"query"; if (version) { path = [path stringByAppendingFormat:@"?v=%@", version]; } NSString *timeZoneString = self.timeZone ? self.timeZone.name : [NSTimeZone localTimeZone].name; NSDictionary *eventDictionary = @{ @"name": _event.name ?: @"", @"data": _event.data ?: @{} }; NSMutableDictionary *parameters = [@{ @"event": eventDictionary, @"timezone": timeZoneString, @"lang": self.lang } mutableCopy]; parameters[@"originalRequest"] = [self.originalRequest serialized]; if (self.resetContexts) { parameters[@"resetContexts"] = @(YES); } if ([self.requestContexts count]) { parameters[@"contexts"] = [self contextsRequestPresentation]; } if ([self.entities count]) { NSMutableArray *entities = [NSMutableArray array]; [self.entities enumerateObjectsUsingBlock:^(AIRequestEntity *obj, NSUInteger idx, BOOL *stop) { [entities addObject:obj.dictionaryPresentation]; }]; parameters[@"entities"] = [entities copy]; } parameters[@"sessionId"] = self.sessionId; AIQueryRequestLocation *location = self.location; if (location) { parameters[@"location"] = @{ @"latitude": @(location.latitude), @"longitude": @(location.longitude) }; } NSURL *URL = [configuration.baseURL URLByAppendingPathComponent:path]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:URL]; [request setHTTPMethod:@"POST"]; NSError *serializeError = nil; NSData *requestData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&serializeError]; [request setHTTPBody:requestData]; [request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:[NSString stringWithFormat:@"Bearer %@", configuration.clientAccessToken] forHTTPHeaderField:@"Authorization"]; NSURLSession *session = dataService.URLSession; __weak typeof(self) selfWeak = self; NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData * __AI_NULLABLE data, NSURLResponse * __AI_NULLABLE response1, NSError * __AI_NULLABLE error) { if (!error) { NSHTTPURLResponse *response = (NSHTTPURLResponse *)response1; if ([dataService.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode]) { NSError *responseSerializeError = nil; id responseData = [NSJSONSerialization JSONObjectWithData:data options:0 error:&responseSerializeError]; if (!responseSerializeError) { [self handleResponse:responseData]; } else { [self handleError:responseSerializeError]; } } else { NSError *responseStatusCodeError = [NSError errorWithDomain:AIErrorDomain code:NSURLErrorBadServerResponse userInfo:@{ NSLocalizedDescriptionKey: [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode] }]; [selfWeak handleError:responseStatusCodeError]; } } else { [selfWeak handleError:error]; } }]; self.dataTask = dataTask; [dataTask resume]; } @end
{ "pile_set_name": "Github" }
<section ng-controller="RecentController"> <section ng-init="find()"> <div deckgrid class="deckgrid" source="items" cardTemplate="/views/directives/cards/file.html" item-identifier-fn="compileCompare"> </section> </section>
{ "pile_set_name": "Github" }
<code_set_name> HP-ROMAN8 <comment_char> % <escape_char> / % version: 1.0 % source: LaserJet IIP Printer User's Manual, % HP part no 33471-90901, Hewlet-Packard, June 1989. % alias ROMAN8 % alias R8 CHARMAP <U0000> /x00 NULL (NUL) <U0001> /x01 START OF HEADING (SOH) <U0002> /x02 START OF TEXT (STX) <U0003> /x03 END OF TEXT (ETX) <U0004> /x04 END OF TRANSMISSION (EOT) <U0005> /x05 ENQUIRY (ENQ) <U0006> /x06 ACKNOWLEDGE (ACK) <U0007> /x07 BELL (BEL) <U0008> /x08 BACKSPACE (BS) <U0009> /x09 CHARACTER TABULATION (HT) <U000A> /x0a LINE FEED (LF) <U000B> /x0b LINE TABULATION (VT) <U000C> /x0c FORM FEED (FF) <U000D> /x0d CARRIAGE RETURN (CR) <U000E> /x0e SHIFT OUT (SO) <U000F> /x0f SHIFT IN (SI) <U0010> /x10 DATALINK ESCAPE (DLE) <U0011> /x11 DEVICE CONTROL ONE (DC1) <U0012> /x12 DEVICE CONTROL TWO (DC2) <U0013> /x13 DEVICE CONTROL THREE (DC3) <U0014> /x14 DEVICE CONTROL FOUR (DC4) <U0015> /x15 NEGATIVE ACKNOWLEDGE (NAK) <U0016> /x16 SYNCHRONOUS IDLE (SYN) <U0017> /x17 END OF TRANSMISSION BLOCK (ETB) <U0018> /x18 CANCEL (CAN) <U0019> /x19 END OF MEDIUM (EM) <U001A> /x1a SUBSTITUTE (SUB) <U001B> /x1b ESCAPE (ESC) <U001C> /x1c FILE SEPARATOR (IS4) <U001D> /x1d GROUP SEPARATOR (IS3) <U001E> /x1e RECORD SEPARATOR (IS2) <U001F> /x1f UNIT SEPARATOR (IS1) <U0020> /x20 SPACE <U0021> /x21 EXCLAMATION MARK <U0022> /x22 QUOTATION MARK <U0023> /x23 NUMBER SIGN <U0024> /x24 DOLLAR SIGN <U0025> /x25 PERCENT SIGN <U0026> /x26 AMPERSAND <U0027> /x27 APOSTROPHE <U0028> /x28 LEFT PARENTHESIS <U0029> /x29 RIGHT PARENTHESIS <U002A> /x2a ASTERISK <U002B> /x2b PLUS SIGN <U002C> /x2c COMMA <U002D> /x2d HYPHEN-MINUS <U002E> /x2e FULL STOP <U002F> /x2f SOLIDUS <U0030> /x30 DIGIT ZERO <U0031> /x31 DIGIT ONE <U0032> /x32 DIGIT TWO <U0033> /x33 DIGIT THREE <U0034> /x34 DIGIT FOUR <U0035> /x35 DIGIT FIVE <U0036> /x36 DIGIT SIX <U0037> /x37 DIGIT SEVEN <U0038> /x38 DIGIT EIGHT <U0039> /x39 DIGIT NINE <U003A> /x3a COLON <U003B> /x3b SEMICOLON <U003C> /x3c LESS-THAN SIGN <U003D> /x3d EQUALS SIGN <U003E> /x3e GREATER-THAN SIGN <U003F> /x3f QUESTION MARK <U0040> /x40 COMMERCIAL AT <U0041> /x41 LATIN CAPITAL LETTER A <U0042> /x42 LATIN CAPITAL LETTER B <U0043> /x43 LATIN CAPITAL LETTER C <U0044> /x44 LATIN CAPITAL LETTER D <U0045> /x45 LATIN CAPITAL LETTER E <U0046> /x46 LATIN CAPITAL LETTER F <U0047> /x47 LATIN CAPITAL LETTER G <U0048> /x48 LATIN CAPITAL LETTER H <U0049> /x49 LATIN CAPITAL LETTER I <U004A> /x4a LATIN CAPITAL LETTER J <U004B> /x4b LATIN CAPITAL LETTER K <U004C> /x4c LATIN CAPITAL LETTER L <U004D> /x4d LATIN CAPITAL LETTER M <U004E> /x4e LATIN CAPITAL LETTER N <U004F> /x4f LATIN CAPITAL LETTER O <U0050> /x50 LATIN CAPITAL LETTER P <U0051> /x51 LATIN CAPITAL LETTER Q <U0052> /x52 LATIN CAPITAL LETTER R <U0053> /x53 LATIN CAPITAL LETTER S <U0054> /x54 LATIN CAPITAL LETTER T <U0055> /x55 LATIN CAPITAL LETTER U <U0056> /x56 LATIN CAPITAL LETTER V <U0057> /x57 LATIN CAPITAL LETTER W <U0058> /x58 LATIN CAPITAL LETTER X <U0059> /x59 LATIN CAPITAL LETTER Y <U005A> /x5a LATIN CAPITAL LETTER Z <U005B> /x5b LEFT SQUARE BRACKET <U005C> /x5c REVERSE SOLIDUS <U005D> /x5d RIGHT SQUARE BRACKET <U005E> /x5e CIRCUMFLEX ACCENT <U005F> /x5f LOW LINE <U0060> /x60 GRAVE ACCENT <U0061> /x61 LATIN SMALL LETTER A <U0062> /x62 LATIN SMALL LETTER B <U0063> /x63 LATIN SMALL LETTER C <U0064> /x64 LATIN SMALL LETTER D <U0065> /x65 LATIN SMALL LETTER E <U0066> /x66 LATIN SMALL LETTER F <U0067> /x67 LATIN SMALL LETTER G <U0068> /x68 LATIN SMALL LETTER H <U0069> /x69 LATIN SMALL LETTER I <U006A> /x6a LATIN SMALL LETTER J <U006B> /x6b LATIN SMALL LETTER K <U006C> /x6c LATIN SMALL LETTER L <U006D> /x6d LATIN SMALL LETTER M <U006E> /x6e LATIN SMALL LETTER N <U006F> /x6f LATIN SMALL LETTER O <U0070> /x70 LATIN SMALL LETTER P <U0071> /x71 LATIN SMALL LETTER Q <U0072> /x72 LATIN SMALL LETTER R <U0073> /x73 LATIN SMALL LETTER S <U0074> /x74 LATIN SMALL LETTER T <U0075> /x75 LATIN SMALL LETTER U <U0076> /x76 LATIN SMALL LETTER V <U0077> /x77 LATIN SMALL LETTER W <U0078> /x78 LATIN SMALL LETTER X <U0079> /x79 LATIN SMALL LETTER Y <U007A> /x7a LATIN SMALL LETTER Z <U007B> /x7b LEFT CURLY BRACKET <U007C> /x7c VERTICAL LINE <U007D> /x7d RIGHT CURLY BRACKET <U007E> /x7e TILDE <U007F> /x7f DELETE (DEL) <U0080> /x80 PADDING CHARACTER (PAD) <U0081> /x81 HIGH OCTET PRESET (HOP) <U0082> /x82 BREAK PERMITTED HERE (BPH) <U0083> /x83 NO BREAK HERE (NBH) <U0084> /x84 INDEX (IND) <U0085> /x85 NEXT LINE (NEL) <U0086> /x86 START OF SELECTED AREA (SSA) <U0087> /x87 END OF SELECTED AREA (ESA) <U0088> /x88 CHARACTER TABULATION SET (HTS) <U0089> /x89 CHARACTER TABULATION WITH JUSTIFICATION (HTJ) <U008A> /x8a LINE TABULATION SET (VTS) <U008B> /x8b PARTIAL LINE FORWARD (PLD) <U008C> /x8c PARTIAL LINE BACKWARD (PLU) <U008D> /x8d REVERSE LINE FEED (RI) <U008E> /x8e SINGLE-SHIFT TWO (SS2) <U008F> /x8f SINGLE-SHIFT THREE (SS3) <U0090> /x90 DEVICE CONTROL STRING (DCS) <U0091> /x91 PRIVATE USE ONE (PU1) <U0092> /x92 PRIVATE USE TWO (PU2) <U0093> /x93 SET TRANSMIT STATE (STS) <U0094> /x94 CANCEL CHARACTER (CCH) <U0095> /x95 MESSAGE WAITING (MW) <U0096> /x96 START OF GUARDED AREA (SPA) <U0097> /x97 END OF GUARDED AREA (EPA) <U0098> /x98 START OF STRING (SOS) <U0099> /x99 SINGLE GRAPHIC CHARACTER INTRODUCER (SGCI) <U009A> /x9a SINGLE CHARACTER INTRODUCER (SCI) <U009B> /x9b CONTROL SEQUENCE INTRODUCER (CSI) <U009C> /x9c STRING TERMINATOR (ST) <U009D> /x9d OPERATING SYSTEM COMMAND (OSC) <U009E> /x9e PRIVACY MESSAGE (PM) <U009F> /x9f APPLICATION PROGRAM COMMAND (APC) <U00A0> /xa0 NO-BREAK SPACE <U00C0> /xa1 LATIN CAPITAL LETTER A WITH GRAVE <U00C2> /xa2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX <U00C8> /xa3 LATIN CAPITAL LETTER E WITH GRAVE <U00CA> /xa4 LATIN CAPITAL LETTER E WITH CIRCUMFLEX <U00CB> /xa5 LATIN CAPITAL LETTER E WITH DIAERESIS <U00CE> /xa6 LATIN CAPITAL LETTER I WITH CIRCUMFLEX <U00CF> /xa7 LATIN CAPITAL LETTER I WITH DIAERESIS <U00B4> /xa8 ACUTE ACCENT <U02CB> /xa9 MODIFIER LETTER GRAVE ACCENT (Mandarin Chinese fourth tone) <U02C6> /xaa MODIFIER LETTER CIRCUMFLEX ACCENT <U00A8> /xab DIAERESIS <U02DC> /xac SMALL TILDE <U00D9> /xad LATIN CAPITAL LETTER U WITH GRAVE <U00DB> /xae LATIN CAPITAL LETTER U WITH CIRCUMFLEX <U20A4> /xaf LIRA SIGN <U00AF> /xb0 MACRON <U00DD> /xb1 LATIN CAPITAL LETTER Y WITH ACUTE <U00FD> /xb2 LATIN SMALL LETTER Y WITH ACUTE <U00B0> /xb3 DEGREE SIGN <U00C7> /xb4 LATIN CAPITAL LETTER C WITH CEDILLA <U00E7> /xb5 LATIN SMALL LETTER C WITH CEDILLA <U00D1> /xb6 LATIN CAPITAL LETTER N WITH TILDE <U00F1> /xb7 LATIN SMALL LETTER N WITH TILDE <U00A1> /xb8 INVERTED EXCLAMATION MARK <U00BF> /xb9 INVERTED QUESTION MARK <U00A4> /xba CURRENCY SIGN <U00A3> /xbb POUND SIGN <U00A5> /xbc YEN SIGN <U00A7> /xbd SECTION SIGN <U0192> /xbe LATIN SMALL LETTER F WITH HOOK <U00A2> /xbf CENT SIGN <U00E2> /xc0 LATIN SMALL LETTER A WITH CIRCUMFLEX <U00EA> /xc1 LATIN SMALL LETTER E WITH CIRCUMFLEX <U00F4> /xc2 LATIN SMALL LETTER O WITH CIRCUMFLEX <U00FB> /xc3 LATIN SMALL LETTER U WITH CIRCUMFLEX <U00E1> /xc4 LATIN SMALL LETTER A WITH ACUTE <U00E9> /xc5 LATIN SMALL LETTER E WITH ACUTE <U00F3> /xc6 LATIN SMALL LETTER O WITH ACUTE <U00FA> /xc7 LATIN SMALL LETTER U WITH ACUTE <U00E0> /xc8 LATIN SMALL LETTER A WITH GRAVE <U00E8> /xc9 LATIN SMALL LETTER E WITH GRAVE <U00F2> /xca LATIN SMALL LETTER O WITH GRAVE <U00F9> /xcb LATIN SMALL LETTER U WITH GRAVE <U00E4> /xcc LATIN SMALL LETTER A WITH DIAERESIS <U00EB> /xcd LATIN SMALL LETTER E WITH DIAERESIS <U00F6> /xce LATIN SMALL LETTER O WITH DIAERESIS <U00FC> /xcf LATIN SMALL LETTER U WITH DIAERESIS <U00C5> /xd0 LATIN CAPITAL LETTER A WITH RING ABOVE <U00EE> /xd1 LATIN SMALL LETTER I WITH CIRCUMFLEX <U00D8> /xd2 LATIN CAPITAL LETTER O WITH STROKE <U00C6> /xd3 LATIN CAPITAL LETTER AE <U00E5> /xd4 LATIN SMALL LETTER A WITH RING ABOVE <U00ED> /xd5 LATIN SMALL LETTER I WITH ACUTE <U00F8> /xd6 LATIN SMALL LETTER O WITH STROKE <U00E6> /xd7 LATIN SMALL LETTER AE <U00C4> /xd8 LATIN CAPITAL LETTER A WITH DIAERESIS <U00EC> /xd9 LATIN SMALL LETTER I WITH GRAVE <U00D6> /xda LATIN CAPITAL LETTER O WITH DIAERESIS <U00DC> /xdb LATIN CAPITAL LETTER U WITH DIAERESIS <U00C9> /xdc LATIN CAPITAL LETTER E WITH ACUTE <U00EF> /xdd LATIN SMALL LETTER I WITH DIAERESIS <U00DF> /xde LATIN SMALL LETTER SHARP S (German) <U00D4> /xdf LATIN CAPITAL LETTER O WITH CIRCUMFLEX <U00C1> /xe0 LATIN CAPITAL LETTER A WITH ACUTE <U00C3> /xe1 LATIN CAPITAL LETTER A WITH TILDE <U00E3> /xe2 LATIN SMALL LETTER A WITH TILDE <U00D0> /xe3 LATIN CAPITAL LETTER ETH (Icelandic) <U00F0> /xe4 LATIN SMALL LETTER ETH (Icelandic) <U00CD> /xe5 LATIN CAPITAL LETTER I WITH ACUTE <U00CC> /xe6 LATIN CAPITAL LETTER I WITH GRAVE <U00D3> /xe7 LATIN CAPITAL LETTER O WITH ACUTE <U00D2> /xe8 LATIN CAPITAL LETTER O WITH GRAVE <U00D5> /xe9 LATIN CAPITAL LETTER O WITH TILDE <U00F5> /xea LATIN SMALL LETTER O WITH TILDE <U0160> /xeb LATIN CAPITAL LETTER S WITH CARON <U0161> /xec LATIN SMALL LETTER S WITH CARON <U00DA> /xed LATIN CAPITAL LETTER U WITH ACUTE <U0178> /xee LATIN CAPITAL LETTER Y WITH DIAERESIS <U00FF> /xef LATIN SMALL LETTER Y WITH DIAERESIS <U00DE> /xf0 LATIN CAPITAL LETTER THORN (Icelandic) <U00FE> /xf1 LATIN SMALL LETTER THORN (Icelandic) <U00B7> /xf2 MIDDLE DOT <U00B5> /xf3 MICRO SIGN <U00B6> /xf4 PILCROW SIGN <U00BE> /xf5 VULGAR FRACTION THREE QUARTERS <U2014> /xf6 EM DASH <U00BC> /xf7 VULGAR FRACTION ONE QUARTER <U00BD> /xf8 VULGAR FRACTION ONE HALF <U00AA> /xf9 FEMININE ORDINAL INDICATOR <U00BA> /xfa MASCULINE ORDINAL INDICATOR <U00AB> /xfb LEFT-POINTING DOUBLE ANGLE QUOTATION MARK <U25A0> /xfc BLACK SQUARE <U00BB> /xfd RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK <U00B1> /xfe PLUS-MINUS SIGN END CHARMAP
{ "pile_set_name": "Github" }
--- --- @import "main";
{ "pile_set_name": "Github" }
[![Releases](https://img.shields.io/github/release/Oxalide/vsphere-influxdb-go.svg?style=flat-square)](https://github.com/Oxalide/vsphere-influxdb-go/releases/latest) [![Build Status](https://travis-ci.org/Oxalide/vsphere-influxdb-go.svg?branch=master)](https://travis-ci.org/Oxalide/vsphere-influxdb-go) [![Go Report Card](https://goreportcard.com/badge/Oxalide/vsphere-influxdb-go)](https://goreportcard.com/report/github.com/Oxalide/vsphere-influxdb-go) # Collect VMware vCenter and ESXi performance metrics and send them to InfluxDB # Screenshots of Grafana dashboards ![screenshot](https://grafana.com/api/dashboards/3556/images/2224/image) ![screenshot](https://grafana.com/api/dashboards/3556/images/2227/image) ![screenshot](https://grafana.com/api/dashboards/3556/images/2230/image) ![screenshot](https://grafana.com/api/dashboards/3571/images/2245/image) ![screenshot](https://grafana.com/api/dashboards/3571/images/2251/image) ![screenshot](https://grafana.com/api/dashboards/3571/images/2254/image) # Description and Features This is a tool written in Go that helps you do your own custom tailored monitoring, capacity planning and performance debugging of VMware based infrastructures. It collects all possible metrics from vCenters and ESXi hypervisors about hosts, clusters, resource pools, datastores and virtual machines and sends them to an [InfluxDB database](https://github.com/influxdata/influxdb) (a popular open source time series database project written in Go), which you can then visualise in Grafana (links to sample dashboards [below](#example-dashboards)) or Chronograf, and use Grafana, Kapacitor or custom scripts to do alerting based on your needs, KPIs, capacity plannings/expectations. # Install Grab the [latest release](https://github.com/Oxalide/vsphere-influxdb-go/releases/latest) for your OS (deb, rpm packages, exes, archives for Linux, Darwin, Windows, FreeBSD on amd64, arm6, arm7, arm64 are available) and install it. For Debian/Ubuntu on adm64: ``` curl -L -O $(curl -s https://api.github.com/repos/Oxalide/vsphere-influxdb-go/releases | grep browser_download_url | grep '64[.]deb' | head -n 1 | cut -d '"' -f 4) dpkg -i vsphere-influxdb-go*.deb ``` CentOS/Red Hat on amd64: ``` curl -L -O $(curl -s https://api.github.com/repos/Oxalide/vsphere-influxdb-go/releases | grep browser_download_url | grep '64[.]rpm' | head -n 1 | cut -d '"' -f 4) rpm -i vsphere-influxdb-go*.rpm ``` This will install vsphere-influxdb-go in /usr/local/bin/vsphere-influxdb-go and an example configuration file in /etc/vsphere-influxdb-go.json that needs to be edited. # Configure The JSON configuration file in /etc/vsphere-influxdb-go.json contains all your vCenters/ESXi to connect to, the InfluxDB connection details(url, username/password, database to use), and the metrics to collect(full list [here](http://www.virten.net/2015/05/vsphere-6-0-performance-counter-description/) ). **Note: Not all metrics are available directly, you might need to change your metric collection level.** A table with the level needed for each metric is availble [here](http://www.virten.net/2015/05/which-performance-counters-are-available-in-each-statistic-level/), and you can find a python script to change the collect level in the [tools folder of the project](./tools/). Additionally you can provide a vCenter/ESXi server and InfluxDB connection details via environment variables, wich is extremly helpful when running inside a container: For InfluxDB: * INFLUX\_HOSTNAME * INFLUX\_USERNAME * INFLUX\_PASSWORD * INFLUX\_DATABASE For vSphere: * VSPHERE\_HOSTNAME * VSPHERE\_USERNAME * VSPHERE\_PASSWORD Keep in mind, that currently only one vCenter/ESXi can be added via environment variable. If you set a domain, it will be automaticaly removed from the names of the found objects. Metrics collected are defined by associating ObjectType groups with Metric groups. There have been reports of the script not working correctly when the time is incorrect on the vsphere or vcenter. Make sure that the time is valid or activate the NTP service on the machine. # Run as a service Create a crontab to run it every X minutes(one minute is fine - in our case, ~30 vCenters, ~100 ESXi and ~1400 VMs take approximately 25s to collect all metrics - rather impressive, i might add). ``` * * * * * /usr/local/bin/vsphere-influxdb-go ``` # Example dashboards * https://grafana.com/dashboards/1299 (thanks to @exbane ) * https://grafana.com/dashboards/3556 (VMware cloud overview, mostly provisioning/global cloud usage stats) * https://grafana.com/dashboards/3571 (VMware performance, mostly VM oriented performance stats) Contributions welcome! # Compile from source ``` go get github.com/oxalide/vsphere-influxdb-go ``` This will install the project in your $GOBIN($GOPATH/bin). If you have appended $GOBIN to your $PATH, you will be able to call it directly. Otherwise, you'll have to call it with its full path. Example: ``` vsphere-influxdb-go ``` or : ``` $GOBIN/vsphere-influxdb-go ``` # TODO before v1.0 * Add service discovery(or probably something like [Viper](https://github.com/spf13/viper) for easier and more flexible configuration with multiple backends) * Daemonize * Provide a ready to use Dockerfile # Contributing You are welcome to contribute! # License The original project, upon which this one is based, is written by cblomart, sends the data to Graphite, and is available [here](https://github.com/cblomart/vsphere-graphite). This one is licensed under GPLv3. You can find a copy of the license in [LICENSE.txt](./LICENSE.txt)
{ "pile_set_name": "Github" }
class PartyAnimal: x = 0 name = '' def __init__(self, nam): self.name = nam print(self.name,'constructed') def party(self) : self.x = self.x + 1 print(self.name,'party count',self.x) s = PartyAnimal('Sally') j = PartyAnimal('Jim') s.party() j.party() s.party()
{ "pile_set_name": "Github" }
namespace Windows.UI.Xaml { public delegate void RoutedEventHandler (object sender, RoutedEventArgs e); public delegate void RoutedEventHandler<in TArgs>(object sender, TArgs e) where TArgs : RoutedEventArgs; #if __WASM__ public delegate bool RoutedEventHandlerWithHandled (object sender, RoutedEventArgs e); #endif }
{ "pile_set_name": "Github" }
/** * Tag Manager useExistingTag custom hook. * * Site Kit by Google, Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * WordPress dependencies */ import { useEffect } from '@wordpress/element'; /** * Internal dependencies */ import Data from 'googlesitekit-data'; import { STORE_NAME } from '../datastore/constants'; const { useSelect, useDispatch } = Data; export default function useExistingTagEffect() { const hasExistingTag = useSelect( ( select ) => select( STORE_NAME ).hasExistingTag() ); const existingTag = useSelect( ( select ) => select( STORE_NAME ).getExistingTag() ); const existingTagPermission = useSelect( ( select ) => select( STORE_NAME ).getTagPermission( existingTag ) ); const hasExistingTagPermission = useSelect( ( select ) => select( STORE_NAME ).hasExistingTagPermission() ); // Set the accountID and containerID if there is an existing tag. const { selectAccount, selectContainerByID } = useDispatch( STORE_NAME ); useEffect( () => { ( async () => { if ( hasExistingTag && hasExistingTagPermission ) { await selectAccount( existingTagPermission.accountID ); await selectContainerByID( existingTag ); } } )(); }, [ hasExistingTag, existingTag, hasExistingTagPermission, existingTagPermission ] ); }
{ "pile_set_name": "Github" }
body { padding: 50px; font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; } a { color: #00B7FF; }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.1" language="eu" sourcelanguage="en"> <context> <name>CmdMeshPartCrossSections</name> <message> <location filename="../../Command.cpp" line="276"/> <source>MeshPart</source> <translation>Amaraun-pieza</translation> </message> <message> <location filename="../../Command.cpp" line="277"/> <source>Cross-sections...</source> <translation>Zeharkako sekzioak...</translation> </message> <message> <location filename="../../Command.cpp" line="278"/> <source>Cross-sections</source> <translation>Zeharkako sekzioak</translation> </message> </context> <context> <name>CmdMeshPartCurveOnMesh</name> <message> <location filename="../../Command.cpp" line="312"/> <source>Mesh</source> <translation>Amarauna</translation> </message> <message> <location filename="../../Command.cpp" line="313"/> <source>Curve on mesh...</source> <translation>Kurba amaraunean...</translation> </message> <message> <location filename="../../Command.cpp" line="314"/> <source>Curve on mesh</source> <translation>Kurba amaraunean</translation> </message> </context> <context> <name>CmdMeshPartMesher</name> <message> <location filename="../../Command.cpp" line="59"/> <source>Mesh</source> <translation>Amarauna</translation> </message> <message> <location filename="../../Command.cpp" line="60"/> <source>Create mesh from shape...</source> <translation>Sortu amarauna formatik...</translation> </message> <message> <location filename="../../Command.cpp" line="61"/> <source>Tessellate shape</source> <translation>Teselatu forma</translation> </message> </context> <context> <name>CmdMeshPartSection</name> <message> <location filename="../../Command.cpp" line="192"/> <source>Mesh</source> <translation>Amarauna</translation> </message> <message> <location filename="../../Command.cpp" line="193"/> <source>Create section from mesh and plane</source> <translation>Sortu sekzioa amaraunetik eta planotik</translation> </message> <message> <location filename="../../Command.cpp" line="194"/> <source>Section</source> <translation>Sekzioa</translation> </message> </context> <context> <name>CmdMeshPartTrimByPlane</name> <message> <location filename="../../Command.cpp" line="84"/> <source>Mesh</source> <translation>Amarauna</translation> </message> <message> <location filename="../../Command.cpp" line="85"/> <source>Trim mesh with a plane</source> <translation>Muxarratu amarauna plano batekin</translation> </message> <message> <location filename="../../Command.cpp" line="86"/> <location filename="../../Command.cpp" line="87"/> <source>Trims a mesh with a plane</source> <translation>Amaraun bat muxarratzen du plano batekin</translation> </message> </context> <context> <name>MeshPartGui::CrossSections</name> <message> <location filename="../../CrossSections.ui" line="14"/> <source>Cross sections</source> <translation>Zeharkako sekzioak</translation> </message> <message> <location filename="../../CrossSections.ui" line="20"/> <source>Guiding plane</source> <translation>Gida-planoa</translation> </message> <message> <location filename="../../CrossSections.ui" line="26"/> <source>XY</source> <translation>XY</translation> </message> <message> <location filename="../../CrossSections.ui" line="36"/> <source>XZ</source> <translation>XZ</translation> </message> <message> <location filename="../../CrossSections.ui" line="43"/> <source>YZ</source> <translation>YZ</translation> </message> <message> <location filename="../../CrossSections.ui" line="52"/> <source>Position:</source> <translation>Posizioa:</translation> </message> <message> <location filename="../../CrossSections.ui" line="71"/> <source>Sections</source> <translation>Sekzioak</translation> </message> <message> <location filename="../../CrossSections.ui" line="83"/> <source>On both sides</source> <translation>Bi aldeetan</translation> </message> <message> <location filename="../../CrossSections.ui" line="92"/> <source>Count</source> <translation>Zenbaketa</translation> </message> <message> <location filename="../../CrossSections.ui" line="109"/> <source>Distance:</source> <translation>Distantzia:</translation> </message> <message> <location filename="../../CrossSections.ui" line="128"/> <source>Options</source> <translation>Aukerak</translation> </message> <message> <location filename="../../CrossSections.ui" line="134"/> <source>Connect edges if distance less than</source> <translation>Konektatu ertzak distantzia hau baino txikiagoa bada:</translation> </message> <message> <location filename="../../CrossSections.cpp" line="345"/> <source>Failure</source> <translation>Hutsegitea</translation> </message> </context> <context> <name>MeshPartGui::CurveOnMeshHandler</name> <message> <location filename="../../CurveOnMesh.cpp" line="364"/> <source>Create</source> <translation>Sortu</translation> </message> <message> <location filename="../../CurveOnMesh.cpp" line="366"/> <source>Close wire</source> <translation>Itxi lerroa</translation> </message> <message> <location filename="../../CurveOnMesh.cpp" line="368"/> <source>Clear</source> <translation>Garbitu</translation> </message> <message> <location filename="../../CurveOnMesh.cpp" line="369"/> <source>Cancel</source> <translation>Utzi</translation> </message> <message> <location filename="../../CurveOnMesh.cpp" line="615"/> <source>Wrong mesh picked</source> <translation>Amaraun okerra aukeratu da</translation> </message> <message> <location filename="../../CurveOnMesh.cpp" line="655"/> <source>No point was picked</source> <translation>Ez da punturik aukeratu</translation> </message> </context> <context> <name>MeshPartGui::TaskCurveOnMesh</name> <message> <location filename="../../TaskCurveOnMesh.ui" line="14"/> <source>Curve on mesh</source> <translation>Kurba amaraunean</translation> </message> <message> <location filename="../../TaskCurveOnMesh.ui" line="20"/> <source>Wire</source> <translation>Alanbrea</translation> </message> <message> <location filename="../../TaskCurveOnMesh.ui" line="26"/> <source>Snap tolerance to vertexes</source> <translation>Erpinekiko atxikitze-tolerantzia</translation> </message> <message> <location filename="../../TaskCurveOnMesh.ui" line="33"/> <source> px</source> <translation> px</translation> </message> <message> <location filename="../../TaskCurveOnMesh.ui" line="43"/> <source>Split threshold</source> <translation>Zatiketa-atalasea</translation> </message> <message> <location filename="../../TaskCurveOnMesh.ui" line="69"/> <source>Spline Approximation</source> <translation>Spline hurbilketa</translation> </message> <message> <location filename="../../TaskCurveOnMesh.ui" line="78"/> <source>Tolerance to mesh</source> <translation>Amaraunarekiko tolerantzia</translation> </message> <message> <location filename="../../TaskCurveOnMesh.ui" line="104"/> <source>Continuity</source> <translation>Jarraitutasuna</translation> </message> <message> <location filename="../../TaskCurveOnMesh.ui" line="111"/> <source>Maximum curve degree</source> <translation>Kurba-gradu maximoa</translation> </message> <message> <location filename="../../TaskCurveOnMesh.ui" line="135"/> <source>Start</source> <translation>Hasi</translation> </message> </context> <context> <name>MeshPartGui::Tessellation</name> <message> <location filename="../../Tessellation.ui" line="14"/> <source>Tessellation</source> <translation>Teselazioa</translation> </message> <message> <location filename="../../Tessellation.ui" line="20"/> <source>Meshing options</source> <translation>Amaraun-aukerak</translation> </message> <message> <location filename="../../Tessellation.ui" line="30"/> <source>Standard</source> <translation>Estandarra</translation> </message> <message> <location filename="../../Tessellation.ui" line="145"/> <source>Mefisto</source> <translation>Mefisto</translation> </message> <message> <location filename="../../Tessellation.ui" line="206"/> <source>Netgen</source> <translation>Netgen</translation> </message> <message> <location filename="../../Tessellation.ui" line="41"/> <source>Surface deviation:</source> <translation>Gainazalaren desbideratzea:</translation> </message> <message> <location filename="../../Tessellation.ui" line="33"/> <source>Use the standard mesher</source> <translation>Erabili amaraun-sortzaile estandarra</translation> </message> <message> <location filename="../../Tessellation.ui" line="48"/> <source>Maximal linear deflection of a mesh section from the surface of the object</source> <translation>Amaraun-sekzio baten makurdura lineal maimoa objektuaren gainazaletik</translation> </message> <message> <location filename="../../Tessellation.ui" line="67"/> <source>Angular deviation:</source> <translation>Desbideratze angeluarra:</translation> </message> <message> <location filename="../../Tessellation.ui" line="74"/> <source>Maximal angular deflection of a mesh section to the next section</source> <translation>Amaraun-sekzio baten makurdura angeluar maximoa hurrengo sekziotik</translation> </message> <message> <location filename="../../Tessellation.ui" line="98"/> <source>The maximal linear deviation of a mesh segment will be the specified Surface deviation multiplied by the length of the current mesh segment (edge)</source> <translation>Amaraun-segmentu baten desbideratze lineal maximoa izango da zehaztutako gainazal-desbideratzea bidez uneko amaraun-segmentuaren (ertzaren) luzera. </translation> </message> <message> <location filename="../../Tessellation.ui" line="102"/> <source>Relative surface deviation</source> <translation>Gainazalaren desbideratze erlatiboa</translation> </message> <message> <location filename="../../Tessellation.ui" line="109"/> <source>Mesh will get face colors of the object</source> <translation>Amaraunak objektuaren aurpegi-koloreak hartuko ditu</translation> </message> <message> <location filename="../../Tessellation.ui" line="112"/> <source>Apply face colors to mesh</source> <translation>Aplikatu aurpegi-koloreak amaraunari</translation> </message> <message> <location filename="../../Tessellation.ui" line="119"/> <source>Mesh segments will be grouped according to the color of the object faces. These groups will be exported for mesh output formats supporting this feature (e.g. the format OBJ).</source> <translation>Amaraun-segmentuak objektu-aurpegien kolorearen arabera taldekatuko dira. Talde horiek eginbide hau onartzen duten irteera-formatuetara esportatuko dira (adibidez, OBJ formatua).</translation> </message> <message> <location filename="../../Tessellation.ui" line="124"/> <source>Define segments by face colors</source> <translation>Definitu segmentuak aurpegi-kolorearen arabera</translation> </message> <message> <location filename="../../Tessellation.ui" line="148"/> <source>Use the Mefisto mesher</source> <translation>Erabili Mefisto amaraun-sortzailea</translation> </message> <message> <location filename="../../Tessellation.ui" line="156"/> <source>Maximum edge length:</source> <translation>Ertz-luzera maximoa:</translation> </message> <message> <location filename="../../Tessellation.ui" line="162"/> <source>If this number is smaller the mesh becomes finer. The smallest value is 0.</source> <translation>Zenbaki hau txikiagoa bada, amarauna meheagoa bihurtzen da. Baliorik txikiena 0 da.</translation> </message> <message> <location filename="../../Tessellation.ui" line="183"/> <source>Estimate</source> <translation>Zenbatetsi</translation> </message> <message> <location filename="../../Tessellation.ui" line="209"/> <source>Use the Netgen mesher</source> <translation>Erabili Netgen amaraun-sortzailea</translation> </message> <message> <location filename="../../Tessellation.ui" line="217"/> <source>Fineness:</source> <translation>Fintasuna:</translation> </message> <message> <location filename="../../Tessellation.ui" line="234"/> <source>Very coarse</source> <translation>Oso latza</translation> </message> <message> <location filename="../../Tessellation.ui" line="239"/> <source>Coarse</source> <translation>Latza</translation> </message> <message> <location filename="../../Tessellation.ui" line="244"/> <source>Moderate</source> <translation>Ertaina</translation> </message> <message> <location filename="../../Tessellation.ui" line="249"/> <source>Fine</source> <translation>Fina</translation> </message> <message> <location filename="../../Tessellation.ui" line="254"/> <source>Very fine</source> <translation>Oso xehea</translation> </message> <message> <location filename="../../Tessellation.ui" line="259"/> <source>User defined</source> <translation>Erabiltzaileak definitutakoa</translation> </message> <message> <location filename="../../Tessellation.ui" line="269"/> <source>Mesh size grading:</source> <translation>Amaraun-tamainaren graduazioa:</translation> </message> <message> <location filename="../../Tessellation.ui" line="279"/> <source>If this parameter is smaller, the mesh becomes finer. A value in the range of 0.1-1.</source> <translation>Parametro hau txikiagoa bada, amarauna meheagoa bihurtzen da. 0.1-1 barrutiko balio bat.</translation> </message> <message> <location filename="../../Tessellation.ui" line="302"/> <source>Elements per edge:</source> <translation>Elementuak ertz bakoitzeko:</translation> </message> <message> <location filename="../../Tessellation.ui" line="312"/> <location filename="../../Tessellation.ui" line="345"/> <source>If this parameter is larger, the mesh becomes finer. A value in the range of 0.2-10.</source> <translation>Parametro hau handiagoa bada, amarauna meheagoa bihurtzen da. 0.2-10 barrutiko balio bat.</translation> </message> <message> <location filename="../../Tessellation.ui" line="335"/> <source>Elements per curvature radius:</source> <translation>Elementu kopurua kurbadura-erradioko:</translation> </message> <message> <location filename="../../Tessellation.ui" line="370"/> <source>Whether optimization of surface shape will be done</source> <translation>Gainazal-formaren optimizazioa egingo den ala ez</translation> </message> <message> <location filename="../../Tessellation.ui" line="373"/> <source>Optimize surface</source> <translation>Optimizatu gainazala</translation> </message> <message> <location filename="../../Tessellation.ui" line="383"/> <source>Whether second order elements will be generated</source> <translation>Bigarren mailako elementuak sortuko diren ala ez</translation> </message> <message> <location filename="../../Tessellation.ui" line="386"/> <source>Second order elements</source> <translation>Bigarren ordenako elementuak</translation> </message> <message> <location filename="../../Tessellation.ui" line="393"/> <source>Whether meshes will be arranged preferably using quadrilateral faces</source> <translation>Amaraunak ahal bada lau aldeko aurpegiak erabilita antolatuko diren ala ez</translation> </message> <message> <location filename="../../Tessellation.ui" line="396"/> <source>Quad dominated</source> <translation>Karratuen mendekoa</translation> </message> <message> <location filename="../../Tessellation.ui" line="422"/> <source>Leave panel open</source> <translation>Utzi panela irekita</translation> </message> <message> <location filename="../../Tessellation.cpp" line="62"/> <source>gmsh</source> <translation>gmsh</translation> </message> <message> <location filename="../../Tessellation.cpp" line="226"/> <location filename="../../Tessellation.cpp" line="232"/> <source>No active document</source> <translation>Ez dago dokumentu aktiborik</translation> </message> <message> <location filename="../../Tessellation.cpp" line="247"/> <source>Select a shape for meshing, first.</source> <translation>Hasteko, hautatu forma bat amarauna sortzeko.</translation> </message> </context> <context> <name>MeshPart_Section</name> <message> <location filename="../../Command.cpp" line="205"/> <source>Select plane</source> <translation>Hautatu planoa</translation> </message> <message> <location filename="../../Command.cpp" line="206"/> <source>Please select a plane at which you section the mesh.</source> <translation>Hautatu amarauna ebakitzeko erabiliko den planoa.</translation> </message> </context> <context> <name>MeshPart_TrimByPlane</name> <message> <location filename="../../Command.cpp" line="96"/> <source>Select plane</source> <translation>Hautatu planoa</translation> </message> <message> <location filename="../../Command.cpp" line="97"/> <source>Please select a plane at which you trim the mesh.</source> <translation>Hautatu amarauna muxarratzeko erabiliko den planoa.</translation> </message> <message> <location filename="../../Command.cpp" line="103"/> <source>Trim by plane</source> <translation>Ebaki planoaren bidez</translation> </message> <message> <location filename="../../Command.cpp" line="104"/> <source>Select the side you want to keep.</source> <translation>Hautatu mantendu nahi duzun aldea.</translation> </message> <message> <location filename="../../Command.cpp" line="105"/> <source>Below</source> <translation>Azpian</translation> </message> <message> <location filename="../../Command.cpp" line="106"/> <source>Above</source> <translation>Gainean</translation> </message> <message> <location filename="../../Command.cpp" line="107"/> <source>Split</source> <translation>Zatitu</translation> </message> </context> <context> <name>Workbench</name> <message> <location filename="../../Workbench.cpp" line="36"/> <source>MeshPart</source> <translation>Amaraun-pieza</translation> </message> </context> </TS>
{ "pile_set_name": "Github" }
package aws import ( "fmt" "log" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" ) func dataSourceAwsEc2LocalGatewayRouteTables() *schema.Resource { return &schema.Resource{ Read: dataSourceAwsEc2LocalGatewayRouteTablesRead, Schema: map[string]*schema.Schema{ "filter": ec2CustomFiltersSchema(), "tags": tagsSchemaComputed(), "ids": { Type: schema.TypeSet, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, }, } } func dataSourceAwsEc2LocalGatewayRouteTablesRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn req := &ec2.DescribeLocalGatewayRouteTablesInput{} req.Filters = append(req.Filters, buildEC2TagFilterList( keyvaluetags.New(d.Get("tags").(map[string]interface{})).Ec2Tags(), )...) req.Filters = append(req.Filters, buildEC2CustomFilterList( d.Get("filter").(*schema.Set), )...) if len(req.Filters) == 0 { // Don't send an empty filters list; the EC2 API won't accept it. req.Filters = nil } log.Printf("[DEBUG] DescribeLocalGatewayRouteTables %s\n", req) resp, err := conn.DescribeLocalGatewayRouteTables(req) if err != nil { return fmt.Errorf("error describing EC2 Local Gateway Route Tables: %w", err) } if resp == nil || len(resp.LocalGatewayRouteTables) == 0 { return fmt.Errorf("no matching Local Gateway Route Table found") } localgatewayroutetables := make([]string, 0) for _, localgatewayroutetable := range resp.LocalGatewayRouteTables { localgatewayroutetables = append(localgatewayroutetables, aws.StringValue(localgatewayroutetable.LocalGatewayRouteTableId)) } d.SetId(time.Now().UTC().String()) if err := d.Set("ids", localgatewayroutetables); err != nil { return fmt.Errorf("Error setting local gateway route table ids: %s", err) } return nil }
{ "pile_set_name": "Github" }
/***************************************************************************** * * * OpenNI 1.x Alpha * * Copyright (C) 2012 PrimeSense Ltd. * * * * This file is part of OpenNI. * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * * * *****************************************************************************/ //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #ifndef ANDROID // This define enables Large File Support (64bit version of I/O functions and data types). // for more information - 'man 7 feature_test_macros' // Moreover, it MUST be defined before ANY other include from this file. #define _FILE_OFFSET_BITS 64 #define OFF_T off_t #define LSEEK lseek #else #define OFF_T off64_t #define LSEEK lseek64 #endif #include <XnOS.h> #include <libgen.h> #include <errno.h> #include <limits.h> #include <XnLog.h> //--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- #ifndef XN_PLATFORM_LINUX_NO_GLOB #include <glob.h> XN_C_API XnStatus xnOSGetFileList(const XnChar* cpSearchPattern, const XnChar* cpPrefixPath, XnChar cpFileList[][XN_FILE_MAX_PATH], const XnUInt32 nMaxFiles, XnUInt32* pnFoundFiles) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpSearchPattern); XN_VALIDATE_OUTPUT_PTR(cpFileList); XN_VALIDATE_OUTPUT_PTR(pnFoundFiles); // Reset the number of found files counter *pnFoundFiles = 0; // now call the OS glob function glob_t tGlob; glob(cpSearchPattern, 0, NULL, &tGlob); XnUInt32 nFoundFiles = XN_MIN(tGlob.gl_pathc, nMaxFiles); for (XnUInt32 i = 0; i < nFoundFiles; ++i) { // Copy the file string into its place in the file list xnOSStrCopy(cpFileList[i], tGlob.gl_pathv[i], XN_FILE_MAX_PATH); if (cpPrefixPath != NULL) { xnOSStrPrefix(cpPrefixPath, cpFileList[i], XN_FILE_MAX_PATH); } } // free memory allocated by OS globfree(&tGlob); // Return a file not found error if no files were found... if (nFoundFiles == 0) { return (XN_STATUS_OS_FILE_NOT_FOUND); } // Write the temporary number of found files counter into the output *pnFoundFiles = nFoundFiles; // All is good... return (XN_STATUS_OK); } #else XN_C_API XnStatus xnOSGetFileList(const XnChar* cpSearchPattern, const XnChar* cpPrefixPath, XnChar cpFileList[][XN_FILE_MAX_PATH], const XnUInt32 nMaxFiles, XnUInt32* pnFoundFiles) { XN_ASSERT(FALSE); return XN_STATUS_OS_FILE_NOT_FOUND; } #endif XN_C_API XnStatus xnOSOpenFile(const XnChar* cpFileName, const XnUInt32 nFlags, XN_FILE_HANDLE* pFile) { // Local function variables XnUInt32 nOSOpenFlags = 0; XnStatus nRetVal = XN_STATUS_OK; // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpFileName); XN_VALIDATE_OUTPUT_PTR(pFile); // Update the OS Open flags according the user request if ((nFlags & XN_OS_FILE_READ) && (nFlags & XN_OS_FILE_WRITE)) { nOSOpenFlags |= O_RDWR | O_CREAT; } else if (nFlags & XN_OS_FILE_READ) { nOSOpenFlags |= O_RDONLY; } else if (nFlags & XN_OS_FILE_WRITE) { nOSOpenFlags |= O_WRONLY | O_CREAT; } if (nFlags & XN_OS_FILE_CREATE_NEW_ONLY) { // It's OK to create a new file, but fail if the file already exist nOSOpenFlags |= O_EXCL; } if (nFlags & XN_OS_FILE_TRUNCATE) { // If the file exists, we need to truncate it to zero nOSOpenFlags |= O_TRUNC; } if ((nFlags & XN_OS_FILE_WRITE) && (nFlags & XN_OS_FILE_AUTO_FLUSH)) { nOSOpenFlags |= O_SYNC; } if (nFlags & XN_OS_FILE_APPEND) { nOSOpenFlags |= O_APPEND; } // Open the file via the OS (give read permissions to ALL) *pFile = open(cpFileName, nOSOpenFlags, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // handle failure... if (*pFile == XN_INVALID_FILE_HANDLE) { switch (errno) { case EEXIST: return XN_STATUS_OS_FILE_ALREDY_EXISTS; case ENOENT: return XN_STATUS_OS_FILE_NOT_FOUND; default: return XN_STATUS_OS_FILE_OPEN_FAILED; } } // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSCloseFile(XN_FILE_HANDLE* pFile) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(pFile); // make sure this is a valid file descriptor if (*pFile == XN_INVALID_FILE_HANDLE) { return XN_STATUS_OS_INVALID_FILE; } if (0 != close(*pFile)) { // Something went wrong while trying to close the file... return (XN_STATUS_OS_FILE_CLOSE_FAILED); } // make the user file descriptor invalid *pFile = XN_INVALID_FILE_HANDLE; return XN_STATUS_OK; } XN_C_API XnStatus xnOSReadFile(const XN_FILE_HANDLE File, void* pBuffer, XnUInt32* pnBufferSize) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(pBuffer); XN_VALIDATE_INPUT_PTR(pnBufferSize); // Make sure the actual file handle isn't invalid if (File == XN_INVALID_FILE_HANDLE) { return XN_STATUS_OS_INVALID_FILE; } // Read a buffer from a file handle via the OS ssize_t nBytesRead = read(File, pBuffer, *pnBufferSize); if (nBytesRead == -1) { return XN_STATUS_OS_FILE_READ_FAILED; } // update the number of bytes read *pnBufferSize = nBytesRead; // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSWriteFile(const XN_FILE_HANDLE File, const void* pBuffer, const XnUInt32 nBufferSize) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(pBuffer); // Make sure the actual file handle isn't invalid if (File == XN_INVALID_FILE_HANDLE) { return XN_STATUS_OS_INVALID_FILE; } // Write a buffer to a file handle via the OS ssize_t nBytesWritten = write(File, pBuffer, nBufferSize); // Make sure it succeeded (return value is not -1) and that the correct number of bytes were written if ((nBytesWritten == -1) || (nBufferSize != nBytesWritten)) { return XN_STATUS_OS_FILE_WRITE_FAILED; } // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSSeekFile(const XN_FILE_HANDLE File, const XnOSSeekType SeekType, const XnInt32 nOffset) { // Local function variables int nRealSeekType = 0; OFF_T nRetOffset = 0; // Make sure the actual file handle isn't invalid if (File == XN_INVALID_FILE_HANDLE) { return XN_STATUS_OS_INVALID_FILE; } // Convert the Xiron seek type into OS seek type switch (SeekType) { case XN_OS_SEEK_SET: // Absolute seek from the file beginning nRealSeekType = SEEK_SET; break; case XN_OS_SEEK_CUR: // Relative seek from the current location nRealSeekType = SEEK_CUR; break; case XN_OS_SEEK_END: // Absolute seek from the file ending nRealSeekType = SEEK_END; break; default: return (XN_STATUS_OS_INVALID_SEEK_TYPE); } // Seek a file handle via the OS nRetOffset = LSEEK(File, (OFF_T)nOffset, nRealSeekType); // Make sure it succeeded (return value is valid) and that we reached the expected file offset if (nRetOffset == (OFF_T)-1) { return (XN_STATUS_OS_FILE_SEEK_FAILED); } // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSSeekFile64(const XN_FILE_HANDLE File, const XnOSSeekType SeekType, const XnInt64 nOffset) { // Local function variables int nRealSeekType = 0; OFF_T nRetOffset = 0; // Make sure the actual file handle isn't invalid if (File == XN_INVALID_FILE_HANDLE) { return XN_STATUS_OS_INVALID_FILE; } // Convert the Xiron seek type into OS seek type switch (SeekType) { case XN_OS_SEEK_SET: // Absolute seek from the file beginning nRealSeekType = SEEK_SET; break; case XN_OS_SEEK_CUR: // Relative seek from the current location nRealSeekType = SEEK_CUR; break; case XN_OS_SEEK_END: // Absolute seek from the file ending nRealSeekType = SEEK_END; break; default: return (XN_STATUS_OS_INVALID_SEEK_TYPE); } // Seek a file handle via the OS nRetOffset = LSEEK(File, nOffset, nRealSeekType); // Make sure it succeeded (return value is valid) and that we reached the expected file offset if (nRetOffset == (OFF_T)-1) { return (XN_STATUS_OS_FILE_SEEK_FAILED); } // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSTellFile(const XN_FILE_HANDLE File, XnUInt32* pnFilePos) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_OUTPUT_PTR(pnFilePos); // Make sure the actual file handle isn't invalid if (File == XN_INVALID_FILE_HANDLE) { return XN_STATUS_OS_INVALID_FILE; } // Seek a file handle by 0 bytes in order to read the file position OFF_T nFilePos = LSEEK(File, 0, SEEK_CUR); // Make sure it succeeded (return value is valid) if (nFilePos == (OFF_T)-1) { return (XN_STATUS_OS_FILE_TELL_FAILED); } // Enforce uint32 limitation if ((nFilePos >> 32) != 0) { return XN_STATUS_INTERNAL_BUFFER_TOO_SMALL; } *pnFilePos = (XnUInt32)nFilePos; // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSTellFile64(const XN_FILE_HANDLE File, XnUInt64* pnFilePos) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_OUTPUT_PTR(pnFilePos); // Make sure the actual file handle isn't invalid if (File == XN_INVALID_FILE_HANDLE) { return XN_STATUS_OS_INVALID_FILE; } // Seek a file handle by 0 bytes in order to read the file position OFF_T nFilePos = LSEEK(File, 0, SEEK_CUR); // Make sure it succeeded (return value is valid) if (nFilePos == (OFF_T)-1) { return (XN_STATUS_OS_FILE_TELL_FAILED); } *pnFilePos = nFilePos; // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSFlushFile(const XN_FILE_HANDLE File) { // Make sure the actual file handle isn't invalid if (File == XN_INVALID_FILE_HANDLE) { return XN_STATUS_OS_INVALID_FILE; } // flush via the OS if (-1 == fsync(File)) { return XN_STATUS_OS_FILE_FLUSH_FAILED; } return XN_STATUS_OK; } XN_C_API XnStatus xnOSFileExists(const XnChar* cpFileName, XnBool* bResult) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpFileName); XN_VALIDATE_OUTPUT_PTR(bResult); // Reset the output result *bResult = FALSE; // Check if the file exists and update the result accordingly if ((access(cpFileName, F_OK)) != -1) { *bResult = TRUE; } // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSGetFileSize(const XnChar* cpFileName, XnUInt32* pnFileSize) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpFileName); XN_VALIDATE_OUTPUT_PTR(pnFileSize); struct stat fileStat; if (-1 == stat(cpFileName, &fileStat)) { return (XN_STATUS_OS_FILE_GET_SIZE_FAILED); } // Enforce uint32 limitation if (fileStat.st_size >> 32) { return XN_STATUS_INTERNAL_BUFFER_TOO_SMALL; } *pnFileSize = (XnUInt32)fileStat.st_size; return (XN_STATUS_OK); } XN_C_API XnStatus xnOSGetFileSize64(const XnChar* cpFileName, XnUInt64* pnFileSize) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpFileName); XN_VALIDATE_OUTPUT_PTR(pnFileSize); struct stat fileStat; if (-1 == stat(cpFileName, &fileStat)) { return (XN_STATUS_OS_FILE_GET_SIZE_FAILED); } *pnFileSize = fileStat.st_size; return (XN_STATUS_OK); } XN_C_API XnStatus xnOSCreateDirectory(const XnChar* cpDirName) { // Local function variables XnInt32 nRetVal = 0; // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpDirName); nRetVal = mkdir(cpDirName, S_IRWXU | S_IRWXG | S_IRWXO); if (nRetVal != 0) { return (XN_STATUS_OS_FAILED_TO_CREATE_DIR); } // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSGetDirName(const XnChar* cpFilePath, XnChar* cpDirName, const XnUInt32 nBufferSize) { XnStatus nRetVal = XN_STATUS_OK; // first copy the string (OS may change the argument) XnChar cpInput[XN_FILE_MAX_PATH]; nRetVal = xnOSStrCopy(cpInput, cpFilePath, XN_FILE_MAX_PATH); XN_IS_STATUS_OK(nRetVal); // now call the OS XnChar* cpResult = dirname(cpInput); // copy result to user buffer nRetVal = xnOSStrCopy(cpDirName, cpResult, nBufferSize); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } XN_C_API XnStatus xnOSGetFileName(const XnChar* cpFilePath, XnChar* cpDirName, const XnUInt32 nBufferSize) { XnStatus nRetVal = XN_STATUS_OK; // first copy the string (OS may change the argument) XnChar cpInput[XN_FILE_MAX_PATH]; nRetVal = xnOSStrCopy(cpInput, cpFilePath, XN_FILE_MAX_PATH); XN_IS_STATUS_OK(nRetVal); // now call the OS XnChar* cpResult = basename(cpInput); // copy result to user buffer nRetVal = xnOSStrCopy(cpDirName, cpResult, nBufferSize); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); } XN_C_API XnStatus xnOSGetFullPathName(const XnChar* strFilePath, XnChar* strFullPath, XnUInt32 nBufferSize) { XnStatus nRetVal = XN_STATUS_OK; // pass a temp string (with max size) XnChar strResult[PATH_MAX]; if (NULL == realpath(strFilePath, strResult)) { xnLogWarning(XN_MASK_OS, "Failed getting full path name: errno is %d", errno); return XN_STATUS_ERROR; } // now check if we can copy if (strlen(strResult) >= nBufferSize) { return XN_STATUS_OUTPUT_BUFFER_OVERFLOW; } // and copy strcpy(strFullPath, strResult); return (XN_STATUS_OK); } XN_C_API XnStatus xnOSGetCurrentDir(XnChar* cpDirName, const XnUInt32 nBufferSize) { XnStatus nRetVal = XN_STATUS_OK; if (NULL == getcwd(cpDirName, nBufferSize)) { if (errno == ERANGE) return (XN_STATUS_OUTPUT_BUFFER_OVERFLOW); else return (XN_STATUS_ERROR); } return (XN_STATUS_OK); } XN_C_API XnStatus xnOSSetCurrentDir(const XnChar* cpDirName) { if (0 != chdir(cpDirName)) { return (XN_STATUS_ERROR); } return (XN_STATUS_OK); } XN_C_API XnStatus xnOSDeleteFile(const XnChar* cpFileName) { // Local function variables XnStatus nRetVal = XN_STATUS_OK; // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpFileName); if (0 != unlink(cpFileName)) { return (XN_STATUS_OS_FAILED_TO_DELETE_FILE); } return (XN_STATUS_OK); } XN_C_API XnStatus xnOSDoesFileExist(const XnChar* cpFileName, XnBool* pbResult) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpFileName); XN_VALIDATE_OUTPUT_PTR(pbResult); // Reset the output result *pbResult = FALSE; // Check if the file exists and update the result accordingly if ((access(cpFileName, F_OK)) != -1) { *pbResult = TRUE; } // All is good... return (XN_STATUS_OK); } XN_C_API XnStatus xnOSDoesDirecotyExist(const XnChar* cpDirName, XnBool* pbResult) { // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpDirName); XN_VALIDATE_OUTPUT_PTR(pbResult); // Reset the output result *pbResult = FALSE; // Check if the file exists and update the result accordingly struct stat nodeStat; if (stat(cpDirName, &nodeStat) == 0 && S_ISDIR(nodeStat.st_mode)) { *pbResult = TRUE; } // All is good... return (XN_STATUS_OK); }
{ "pile_set_name": "Github" }
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. #include "kudu/security/test/test_certs.h" #include <string> #include "kudu/util/env.h" #include "kudu/util/path_util.h" #include "kudu/util/status.h" using std::string; namespace kudu { namespace security { // // The easiest way to create RSA private key and CA self-signed certificate pair // is using the couple of commands below: // // openssl genrsa -out ca.pkey.pem 2048 // openssl req -new -x509 -batch -days 3650 -key ca.pkey.pem -out ca.cert.pem // // NOTE: // The latter command uses configuration properties from default configuration // file of the OpenSSL library. Also, it runs in batch mode due to the // '-batch' flag. To specify custom certificate subject properties, omit // the '-batch' flag and run the command in interactive mode. If more // customization is needed, see the other methods below. // //////////////////////////////////////////////////////////////////////////// // // The other way to create RSA private key and CA self-signed certificate pair // is using OpenSSL's CA.sh script in $OPENSSL_SRC_ROOT/apps: // // cp $OPENSSL_SRC_ROOT/CA.sh . // chmod +x CA.sh // ./CA.sh -newca // // Find the newly generated files at the following locations: // * demoCA/cacert.pem: self-signed CA certificate // * demoCA/private/cakey.pem: encrypted CA private key // // To decrypt the generated private key, run the following command and provide // the pass phrase (assuming that was an RSA key): // // openssl rsa -in ./demoCA/private/cakey.pem // //////////////////////////////////////////////////////////////////////////// // // Besides, the following sequence of commands can used to create // a private key and CA certficate with custom properties. // // * Create a separate directory, e.g.: // // mkdir /tmp/cert && cd /tmp/cert // // * Create custom my.cnf configuration file for the OpenSSL library, copying // the default one and modifying the result, if necessary. // // cp $OPENSSL_CFG_ROOT/etc/openssl.cnf my.cnf // vim my.cnf // // * Create the CA directory structure which matches the directory structure // of the 'default_ca' section from the configuration file, e.g.: // // mkdir -p demoCA/certs demoCA/crl demoCA/newcerts demoCA/private // touch demoCA/index.txt // // * Create private key and certificate signing request (CSR): // // openssl req -new -keyout ca.pkey.pem -out ca.req.pem \ // -subj "/C=US/ST=CA/O=MyCompany/CN=MyName/[email protected]" \ // -passin pass:mega_pass -passout pass:mega_pass -batch // // * Create a self-signed certificate using the newly generated CSR as input: // // openssl ca -config my.cnf -create_serial -days 3650 \ // -keyfile ca.pkey.pem -selfsign -extensions v3_ca \ // -outdir ./ -out ca.cert.pem -passin pass:mega_pass -batch \ // -infiles ca.req.pem // // The encryped private key is in ca.pkey.pem, the certificate is in // ca.cert.pem. To decrypt the generated private key, execute the following // (assuming that was an RSA key): // // openssl rsa -passin pass:mega_pass -in ./ca.pkey.pem // const char kCaCert[] = R"***( -----BEGIN CERTIFICATE----- MIIDizCCAnOgAwIBAgIJAIsQXjBhvdPoMA0GCSqGSIb3DQEBCwUAMFwxCzAJBgNV BAYTAlVTMQswCQYDVQQIDAJDQTESMBAGA1UECgwJTXlDb21wYW55MQ8wDQYDVQQD DAZNeU5hbWUxGzAZBgkqhkiG9w0BCQEWDG15QGVtYWlsLmNvbTAeFw0xNjEwMjUw NjAxNThaFw0yNjEwMjMwNjAxNThaMFwxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJD QTESMBAGA1UECgwJTXlDb21wYW55MQ8wDQYDVQQDDAZNeU5hbWUxGzAZBgkqhkiG 9w0BCQEWDG15QGVtYWlsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC ggEBAKexXVOe0SfNexxl1nqMBRy8MCYWTl1kbRt5VQ698aXYcPNBC7gnEBW+8Yaa 2f3Hl1Ye51zUGnOl4FU6HFDiIq59/lKCNG2X3amlYjzkImXn4M56r+5rEWs+HoHW kuqmMaxnrJatM86Of0K3j5QrOUft/qT5R6vSPnFH/pz+6ccBkAGV0UFVdshYSGkx KziVTdJ2Ri8oZgyeuReGxLkXOqKHzcOUFinvQ8fe8yaQr1kRAaPRo1eFqORXAMAU 4KyvfiVjZMEGj0p47IekJHVPVVMopEmMMjhzRfbrxrKrMcIG6e4acF1KAd4wGI9A pCR3e1vcfbghDO7GhTMswLCnMYUCAwEAAaNQME4wHQYDVR0OBBYEFDc1+ybIwvG2 IvEuAusZ9GGMlga/MB8GA1UdIwQYMBaAFDc1+ybIwvG2IvEuAusZ9GGMlga/MAwG A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAJT9fL/vtayfAHpdzFvdWBe+ R6y5HsVQQTBNF9x1eM6M0vGAlsXGgip3+RH7OMwurxNetL2mc03+PECas5LxB5Pr u1+kwtmv5YyfQzou0VwztjcbK2OEpWKj16XX6NO403iKoRF4fLn0DjZQcB0oXw4s vBxhNfz+SAsjsAMNgLHHXonJfg7wcdmNSp2N3TslGL/DH0bXMhsKx2CuMA3rd9WZ mJjItRIk8qNjazlmG0KYxQclP3lGagIMHxU6tY+iBXs1JR1/AUnPl/GaPeayCJSR 3PB7R+MMrI0hfWFWkBt0D+UAKVa9to/N06wp4JqxEgOooU08PguXLIVDlW0xBcw= -----END CERTIFICATE----- )***"; // See the comment for kCaCert_ const char kCaPrivateKey[] = R"***( -----BEGIN RSA PRIVATE KEY----- MIIEogIBAAKCAQEAp7FdU57RJ817HGXWeowFHLwwJhZOXWRtG3lVDr3xpdhw80EL uCcQFb7xhprZ/ceXVh7nXNQac6XgVTocUOIirn3+UoI0bZfdqaViPOQiZefgznqv 7msRaz4egdaS6qYxrGeslq0zzo5/QrePlCs5R+3+pPlHq9I+cUf+nP7pxwGQAZXR QVV2yFhIaTErOJVN0nZGLyhmDJ65F4bEuRc6oofNw5QWKe9Dx97zJpCvWREBo9Gj V4Wo5FcAwBTgrK9+JWNkwQaPSnjsh6QkdU9VUyikSYwyOHNF9uvGsqsxwgbp7hpw XUoB3jAYj0CkJHd7W9x9uCEM7saFMyzAsKcxhQIDAQABAoIBABuZQ0TZ5I5qcRKR aCUvGkBKcJo0HZ2dQ5+77lXIyRaEcsJ2OBmMxEbv8Aw5PBtaV/vihi1u8xOJf0xH jhV5wj95mPu3Vi2bSu36vBpNaaPf783Lv1y73lgKFzdDO1bHF3HKdksuIlKifStb zpOSMZE3CCvaowMSTRiTwsHP6mXIBdQ/TwAZHqGVTWDVGxc8JvoJ/3GjSgUIPKzy I2aS/5DQ+zmLktuP61GFMJg9tCSrwZPDi/XAatpoAOC9eA7AqF/l1TiaXsQN95mr mz2DkCoWRzAuDbya2Sh6nTJvpOMPAeXJ/MMZh9TWswJc4OAO2kZZsFfd0H6M1TKy 1eAYKVkCgYEA1JhkKQ2h4cVzqQ9A5+4C0q5+j/RFDUOVnNlIjQiM73RchNu713mK zzhsom9S/6ZU8OH3TxzD54i2hHtX+QIJqVG0412QgAqAqnAKXGGkkAXiXGfGZhEW UB3OuTMbhfVqrkpj0wAPiEJAAuek7zES2B+gURUC24aAfOWU8xMkSjMCgYEAye4U e0NQ4HhhWRgWbgFYeAzsC/ezvlx30JjXiLPCNXGoLLJUCMjqWCPGYUvDonIJbxbj +MYFkvYSDFGwTobKsB7FyT8DxPNus40zOh47y8QUK7jTL4nAmnBa3W9Oj00ceKpo wKe/adc2xPrS7mnVpz3ZkJ4I9z/MbEinyV5UTWcCgYAy8gXmlJ67dM6/r6kVK0M/ 65Lmulml0RFUUfmB2o+zfkYBjIqaG0U5XUMjNdxE6T4nr27NZY5IuMlMPCabxHI+ Qhc/+Rb8qAenUEwbUUbXQKG7FR9FLEkVj98PIIEy+9nBxI/ha31NYNroF0y+CRuD 8ShA5fEWXEgEJhwol+i1YwKBgEnGeiUuyvW4BZkPe+JlC3WRAwy8SydZkUzdCqIf Su1LwS3TWXB8N2JMb8ZMcAWBtICp1FCnyJGQ5bcqgUevZ45BL/H+29mxNtjS1cx+ D0q7MMNom3/azEugkRImAIXKnoRXfj4lC4IX5yLAoSAJ+s1Hg52an5v16zIEuYiQ tiwxAoGAOP8/yjMzit1hzk27k9IfQSLD+1SqKCsRdGbAIhFRFlz4RUQOly1dEX8M qVmStlQ7N5gQWJSyDTe6rTe8pG9r030kNDJ+etr2KWpATGNaVWSmLWSYBXrPtejK gmbcYCewtt7dFP9tvx6k7aUQ6CKzg0GxaIHQecNzjxYrw8sb4Js= -----END RSA PRIVATE KEY----- )***"; // Corresponding public key for the kCaPrivateKey const char kCaPublicKey[] = R"***( -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp7FdU57RJ817HGXWeowF HLwwJhZOXWRtG3lVDr3xpdhw80ELuCcQFb7xhprZ/ceXVh7nXNQac6XgVTocUOIi rn3+UoI0bZfdqaViPOQiZefgznqv7msRaz4egdaS6qYxrGeslq0zzo5/QrePlCs5 R+3+pPlHq9I+cUf+nP7pxwGQAZXRQVV2yFhIaTErOJVN0nZGLyhmDJ65F4bEuRc6 oofNw5QWKe9Dx97zJpCvWREBo9GjV4Wo5FcAwBTgrK9+JWNkwQaPSnjsh6QkdU9V UyikSYwyOHNF9uvGsqsxwgbp7hpwXUoB3jAYj0CkJHd7W9x9uCEM7saFMyzAsKcx hQIDAQAB -----END PUBLIC KEY----- )***"; // See the comment for kCaCert_ // (but use '-1' as number of days for the certificate expiration). const char kCaExpiredCert[] = R"***( -----BEGIN CERTIFICATE----- MIIDjTCCAnWgAwIBAgIJALNJes+nGWH9MA0GCSqGSIb3DQEBCwUAMF0xCzAJBgNV BAYTAlVTMQswCQYDVQQIDAJDQTETMBEGA1UECgwKRXhwQ29tcGFueTEQMA4GA1UE AwwHRXhwTmFtZTEaMBgGCSqGSIb3DQEJARYLZXhwQGV4cC5jb20wHhcNMTYxMDI1 MTkzOTM4WhcNMTYxMDI0MTkzOTM4WjBdMQswCQYDVQQGEwJVUzELMAkGA1UECAwC Q0ExEzARBgNVBAoMCkV4cENvbXBhbnkxEDAOBgNVBAMMB0V4cE5hbWUxGjAYBgkq hkiG9w0BCQEWC2V4cEBleHAuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB CgKCAQEAzqPj5nRm57mr9YtZDvHREuVFHTwPcKzDeff9fnrKKwOJPSF0Bou/BjS1 S7yQYAtmT/EMi7qxEWjgrR1qW+muR8QN+zAwNdkdLrFK3SJigQ4a/OeSH86aHXUD ekV8mgBgzP90osbHf7AiqrGzkYWq+ApTO/IgnXgaWbbdt5znGTW5lKQ4O2CYhpcM MC1sBBjW7Qqx+Gi8iXub0zlJ2mVI8o+zb9qvSDb8fa0JYxasRDn/nB0wKZC3f/Gf Rs+lJZUTEy5+eMhVdj1RjVBE+mgW7L27On24ViPU7B3DjM0SYnD6ZOUWMH0mtwO8 W3OoK8MJhPvFP7Lr5QfSjiBH+ryLOwIDAQABo1AwTjAdBgNVHQ4EFgQUsp8OZLl1 2Z/2aXBQRH0Z+nWxqXcwHwYDVR0jBBgwFoAUsp8OZLl12Z/2aXBQRH0Z+nWxqXcw DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEArWvFi13iqmvnY0xkgt3R acurTvWcQzcUOgVPF8u1atj9d+0zrMk7Don1KQp6uYLdeNLL8NbL4oLxtidW/Yap ZEbHVDQTeZAsT7Hr+0uD3vMUndsjG7C85tOhZMiGukFPhuaHE5KmQEy6nUCaJiAv opZlNj1mEOGyshSXHsBATl9o33WLTLfPqrO3/12jExApHiADcON4RsPUV6M6k5A2 /KghYEPYAuFfXTsqj+W7HRL1UuiHJxW96ySQqYzQ86aRN2ZZlTdbDnIU5Jrb6YJB hUALcxIUhtodui61zsJFIkVauxTxk7jNCwRvj4I1dSSFWA63t9eh7sKilLRCayNl yQ== -----END CERTIFICATE----- )***"; // See the comment for kCaExpiredCert_ const char kCaExpiredPrivateKey[] = R"***( -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEAzqPj5nRm57mr9YtZDvHREuVFHTwPcKzDeff9fnrKKwOJPSF0 Bou/BjS1S7yQYAtmT/EMi7qxEWjgrR1qW+muR8QN+zAwNdkdLrFK3SJigQ4a/OeS H86aHXUDekV8mgBgzP90osbHf7AiqrGzkYWq+ApTO/IgnXgaWbbdt5znGTW5lKQ4 O2CYhpcMMC1sBBjW7Qqx+Gi8iXub0zlJ2mVI8o+zb9qvSDb8fa0JYxasRDn/nB0w KZC3f/GfRs+lJZUTEy5+eMhVdj1RjVBE+mgW7L27On24ViPU7B3DjM0SYnD6ZOUW MH0mtwO8W3OoK8MJhPvFP7Lr5QfSjiBH+ryLOwIDAQABAoIBABszgcWNXxpz24oI HOIVvPLi0VVG2bV4WIcOuQTUPxaocYFljPNro+q6N39PxCWQephdX8xo9/QVvTWs oJqWyUVTLo/5SO9dtDS4S+WOKC9a3vyZsyeSt8DW7W1EBmHzWMrDeeQPjKVnVzjn CX9HfDkIiupiNh7kd3uF0evgsJ8lsZ65HtBq9MWu+mIR1H0EpRLxywdoRJLJ+JdW g1fLFRuhnWo0GcEyBK45kLCoVJsRbCkFGf6uPDOOC0g5mIyxGclWeF6ps1OFnFyu FWsYeMLSt5tYZfB0/QR46X9HQOhfLunjA04VBkScSRjlohGO4d20ZW7HlPY20CbR 1PHhEvkCgYEA98FYoovNezx8OgkcAtNOOTK7GpUaUfh3Xl5yPGgCqxoG8G+BTmKF MGlIf6URKQA0BUtNdjIvfIcaIctj56qFwjHL6CbzR5MkXUZLlyl0XzYFXm/lavr4 Z5DHWdFo+GyFaiXIiVof93jAnOFgjSxdhHaEhQqj7pmaBoHVZqtwHFcCgYEA1YRH xTzcWErp06KJTt+/P4YtWRh9GDBhhlO3oaGOANkEab8cGjRO9LJP24wyo7exXqGb UjtEifEHtzhj6a/UwSAMsFcNhlQRvy525HD1gJmQ2m4wZ3GxztK4IZ4rVDjsB5/D SMMBsDfs1r1iRwdSMHAOhrVH2l/DMFQLnx1x+b0CgYEAlQm6SA3RjlDUahUQxKJY bBAYfeUz8BuHsz0dezkWYddGVVy+bGjXtkefVSn3KLL2mDi0YGXQKxkanzm636G0 1R0fjIfh0Syys2mWD1jgqGXW1Ph7Cd/vjl2Jjn5qpwahOzl/aSDOGhCJzdXGPyZx Gz4wedfsxZuhDEkOFrUKvAECgYEAxHYYy8V6Qct8Z30wtmBuSvcdFtPPlsg9lCnH 13MdhG4q/1oXc40Z8VF45VyU48uL6rTsg7eBEyOyo8XBOS7Opnzk8ATJrwX/5lfM kdnWK2QhwrqM00HsB5AgWN5+o9pUY5d/Sp4UGZ77z4MmwJBd8a/Jze1Tlf1zTi6n GtsvGkkCgYAfILUAPf+ujgB9zdsJa+4l9XCEq0j39/Usfj0VrInNAk7RN8W0qNw7 ZLs3Qt2fgPO0CeMeVUVKcvdjlXq3EbrWKrsJLxy3Gb8ruBjIlJqncJn6mKslXS+l H/sbP2R+P6RvQceLEEtk6ZZLiuScVmLtVOpUoUZb3Rx6a7GKbec7oQ== -----END RSA PRIVATE KEY----- )***"; // Corresponding public part of the kCaExpiredPrivateKey const char kCaExpiredPublicKey[] = R"***( -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzqPj5nRm57mr9YtZDvHR EuVFHTwPcKzDeff9fnrKKwOJPSF0Bou/BjS1S7yQYAtmT/EMi7qxEWjgrR1qW+mu R8QN+zAwNdkdLrFK3SJigQ4a/OeSH86aHXUDekV8mgBgzP90osbHf7AiqrGzkYWq +ApTO/IgnXgaWbbdt5znGTW5lKQ4O2CYhpcMMC1sBBjW7Qqx+Gi8iXub0zlJ2mVI 8o+zb9qvSDb8fa0JYxasRDn/nB0wKZC3f/GfRs+lJZUTEy5+eMhVdj1RjVBE+mgW 7L27On24ViPU7B3DjM0SYnD6ZOUWMH0mtwO8W3OoK8MJhPvFP7Lr5QfSjiBH+ryL OwIDAQAB -----END PUBLIC KEY----- )***"; const char kCertDnsHostnamesInSan[] = R"***( -----BEGIN CERTIFICATE----- MIIEPzCCAyegAwIBAgIJAJoczuNKGspGMA0GCSqGSIb3DQEBCwUAMFwxCzAJBgNV BAYTAlVTMQswCQYDVQQIDAJDQTESMBAGA1UECgwJTXlDb21wYW55MQ8wDQYDVQQD DAZNeU5hbWUxGzAZBgkqhkiG9w0BCQEWDG15QGVtYWlsLmNvbTAeFw0xNzA0Mjgx OTUwNTVaFw0yNzA0MjYxOTUwNTVaMAAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEA rpJhLdS/Euf2cu0hPXkvkocLO0XbNtFwXNjkOOjuJZd65FHqLb6TmmxxDpL7fB94 Mq1fD20fqdAgSVzljOyvuwIDAQABo4ICJjCCAiIwDgYDVR0PAQH/BAQDAgWgMCAG A1UdJQEB/wQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMIIB 3gYDVR0RBIIB1TCCAdGCDG1lZ2EuZ2lnYS5pb4ILZm9vLmJhci5jb22CggGydG9v b29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29v b29vb29vb29vb29vb29vb29vLmxvb29vb29vb29vb29vb29vb29vb29vb29vb29v b29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29v b29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29v b29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29v b29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29v b29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29v b29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29v b29vb29vb29vb29vb29vb29vb29vb29vb29vb29vb29vbmcuaG9zdG5hbWUuaW8w DQYJKoZIhvcNAQELBQADggEBAIKVVABj3nTyqDEnDKDfvS6QNEQSa1mw7WdFTpzH 6cbMfiixVyyLqfAV4NZ+PnIa4mpsWP5LrsrWFVK/HtiTX7Y8oW0qdA04WtYd9VUT BgWKHyLygbA+PSZ6GdXFjZd8wDthK0qlT2MfZJUwD36eYnBxuonU8a4lmxaUG2zC L8FplhNJUEt6XfJ0zZGx1VHe12LLjgMz3ShDAmD9DlHHFjJ1aQ/17OGmmjWmbWnm an4ys5seqeHuK2WzP3NAx7LOwe/R1kHpEAX/Al6xyLIY3h7BBzurpgfrO6hTTECF 561gUMp+cAvogw074thF5j4b+uEK5Bl8nzN2h8BwwxwGzUo= -----END CERTIFICATE----- )***"; // // The reference signatures were obtained by using the following sequence: // 0. The reference private key was saved into /tmp/ca.pkey.pem file. // 1. Put the input data into /tmp/in.txt file. // 2. To sign the input data, run // openssl dgst -sign /tmp/ca.pkey.pem -sha512 -out /tmp/out /tmp/in.txt // 3. To capture the signature in text format, run // base64 -b 60 /tmp/out // const char kDataTiny[] = "Tiny"; const char kSignatureTinySHA512[] = "omtvSpfj9tKo0RdI4zJwasWSQnXl++aKVjhH19ABJCd0haKT8RXNuhnxcbZU" "Y1ILE5F9YjVj+tN/7ah5WQZR5qlJ6GMFfCFBhOzvi/vf5PSbUrFfwFvFD6sq" "Bu0PWdwKM3t8/YFE2HcZWSzGCcasKlG/aw2eQCN3Kdv8QVMlC28CFA/EqQBt" "8Sfye1DLba33SzDpJqR2DduTFrEW2UffumpYIbkEcMwUSBFzfdp5hgWPowFb" "LrnKvyWKpEPMFGQmf5siyXSkbBIfL774tynhWN/lAUWykwXSUfGgi2G0NQvj" "xmuHhbxWpbW/31uMGssw92OfVQ/+aQ4pNmY9GbibcA=="; const char kDataShort[] = "ShortRefInputData"; const char kSignatureShortSHA512[] = "BHaDipr8ibn40BMD6+DlatKsjbmsGZsJIDlheppBjqv66eBDLKOVjpmpMLl9" "9lXCGUlVS+cNcVP4RPDzXNoXkpzUOJD3UQSnxCAm6tV1eGjD3SHi3fk6PCNc" "MhM/+09fA0WHdIdZm93cpHt6c9MFzB/dUjHJByhQ7Csmz2zdITyMIl3/D+bi" "ocW0aIibk0wNGn/FmXfgFDP+3pBS2bpS0AdFnckX8AqXHFMJnvqKYODpYCW8" "NWFSD1TgZOumu/gzxm+HySPezQ2j9tdR6nb9swfShvN+o0oBVGq5vgtgZMTM" "7Ws+BrasLfvQFkvtGMWB9VeH/rDlGOym8RwUrCIJJQ=="; const char kDataLong[] = R"***(Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. )***"; const char kSignatureLongSHA512[] = "kc62qPHApVFbueR1xSCQJR5NomqDRzVA+4Xi9egVyfkKgpVhDAYGxbMl8OTY/YCb" "eQuwY+B7RGxF9sj3gvsq/dvrbIjLT3QDhs0bv+lXTtBQ5r9zrals3de0tEFrPoLr" "CkKPhVZaG+zwmUVltfsdlsqvepy6rNW7BocehvgpPTbzxgsZg4nUANsjSy8HBoDb" "xWyfbkMgBY4aWIH1g+wksq1DHzdTNdZCYstupRwVw/ESC+zrFQiZPFeRE/wCSeG/" "bd0L8TcotQHJchZ8THW0rEbuCg79I7Crd1KQYljBpOOhMYZEDEdM9L19JlaMlw+Z" "leyLfL8Bw3wCg9cMfNmQfQ=="; Status CreateTestSSLCertWithPlainKey(const string& dir, string* cert_file, string* key_file) { const char* kCert = R"( -----BEGIN CERTIFICATE----- MIIEejCCA2KgAwIBAgIJAKMdvDR5PL82MA0GCSqGSIb3DQEBBQUAMIGEMQswCQYD VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5j aXNjbzERMA8GA1UEChMIQ2xvdWRlcmExEjAQBgNVBAMTCWxvY2FsaG9zdDEhMB8G CSqGSIb3DQEJARYSaGVucnlAY2xvdWRlcmEuY29tMB4XDTEzMDkyMjAwMjUxOFoX DTQxMDIwNzAwMjUxOFowgYQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9y bmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMREwDwYDVQQKEwhDbG91ZGVyYTES MBAGA1UEAxMJbG9jYWxob3N0MSEwHwYJKoZIhvcNAQkBFhJoZW5yeUBjbG91ZGVy YS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCoUj3pMQ2ELkrz zq+koixljVFBAEEqwUWSjA+GEKwfFb/UPRjeO/wrKndp2r83jc6KRt66rvAIl8cr b54yTOsJ/ZcARrjTwG3IG8Tely/54ZQyH0ImdJyEbCSoI04zX3ovjlppz3g5xanj WmpAh6pzPgBOTfisCLMPD70xQ8F//QWZdNatoly54STkTWoJv/Oll/UpXcBY8JOR +ytX82eGgG4F8YoQqmbjrrN5JAmqLRiBAkr3WUena6ekqJBalJRzex/Wh8a9XEV7 9HFVVngBhezsOJgf81hzBzzhULKfxuXl8uaUj3Z9cZg39CDsyz+ULYbsPm8VoMUI VCf7MUVTAgMBAAGjgewwgekwHQYDVR0OBBYEFK94kea7jIKQawAIb+0DqsA1rf6n MIG5BgNVHSMEgbEwga6AFK94kea7jIKQawAIb+0DqsA1rf6noYGKpIGHMIGEMQsw CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy YW5jaXNjbzERMA8GA1UEChMIQ2xvdWRlcmExEjAQBgNVBAMTCWxvY2FsaG9zdDEh MB8GCSqGSIb3DQEJARYSaGVucnlAY2xvdWRlcmEuY29tggkAox28NHk8vzYwDAYD VR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAEtkPPncCnN2IFVJvz04K+VsX b6w3qwPynQKc67+++JkNb3TYKrh/0UVM1NrEOu3TGplqOrKgAlITuaWNqNOSBu1R WJtrz85YkonED5awjjuALVEY82+c7pOXkuv5G5421RINfRn2hNzgw8VFb5CEvxHH jER80Vx6UGKr/S649qTQ8AzVzTwWS86VsGI2azAD7D67G/IDGf+0P7FsXonKY+vl vKzkfaO1+qEOLtDHV9mwlsxl3Re/MNym4ExWHi9txynCNiRZHqWoZUS+KyYqIR2q seCrQwgi1Fer9Ekd5XNjWjigC3VC3SjMqWaxeKbZ2/AuABJMz5xSiRkgwphXEQ== -----END CERTIFICATE----- )"; const char* kKey = R"( -----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEAqFI96TENhC5K886vpKIsZY1RQQBBKsFFkowPhhCsHxW/1D0Y 3jv8Kyp3adq/N43Oikbeuq7wCJfHK2+eMkzrCf2XAEa408BtyBvE3pcv+eGUMh9C JnSchGwkqCNOM196L45aac94OcWp41pqQIeqcz4ATk34rAizDw+9MUPBf/0FmXTW raJcueEk5E1qCb/zpZf1KV3AWPCTkfsrV/NnhoBuBfGKEKpm466zeSQJqi0YgQJK 91lHp2unpKiQWpSUc3sf1ofGvVxFe/RxVVZ4AYXs7DiYH/NYcwc84VCyn8bl5fLm lI92fXGYN/Qg7Ms/lC2G7D5vFaDFCFQn+zFFUwIDAQABAoIBABNTpiIxbLDhs998 uvQ3XsumR08kXVcwa/GgvWOSZIEJOUaAYWubDaBTNvTjlhMl6DI+YvKihZMnAkp9 fXefF1nFUWJJvI0ryi8w6RD54RtbCG4c4raRqysVU7wumZsSenAdc0o09UQE6zXc uth/+1VSKCzVjRkLwquXDg0rD3vHfQHWQvQlzwUh3OACA3LfLezVqzrEB02YVRxm xwg5veeMg6Aod8vsvsajry9eE0hKeFGonRANerL9lwZxzD2ZjU2fSEJYY3xxKVgi o+QVTKaAt9pivOs10YVZDcIDH0xmDpxAkaLb5ZAbnjwhf7WGYgEm8VruAHkJxyXX yPf3rpkCgYEA0dp/Xv5KBIkD6JJao8hnhtP5x9U7o/pTzRxaO3WUflvTI6DtC0nk cTOwFVs4WljT76T937q2x4stuX0woHzvIaZ6wwZ2vv81ikDY6pE8eLWsH/xFAmkx HBfkSijFgJV6EpTqUnFD7QKU89tzWrh/kxaMO1WgFaBhxPPs3K1LDTUCgYEAzVW5 3yjfVHNgjWTeAbnbToGvUihOidvIvS5cVo5q0Dhfabz0tiXFxAoQUGErUGPC8Nu2 n/HxTI3b0PbCCwjBsDNqX2kzxTSe5aTGIrBUWbped1bxme8jggXuWYbg8vvLpsYf wAJPxnGIxW/v/aftHUhbTIuVfZX2+UnilrwiwWcCgYEAg8paz4eXaH277KVtMwq6 qZwac/tgNz0Qv/GcYVcYaLq2QNvhwoMnakhxvxfIrkS25PuTTJxwCaVIlAMhNMkB TPrGghBfJtgUAb1z/Ow1NAG0FWpS1I7HfsMqZcBxOK2nOmA3QItNg11pujQJn+Ha jL9OVj0SCkLs48nk6ToTtjkCgYEAh8YCtNwq6IWuN3CWGCAUMpIwIqxCWof48Zch OZ7MZEiSVrG6QmMxpRJefTfzUyHUOj2eQZ7SxqMa0c8IuhEdOeyVjudaczD7TLAq z68252oDovfbo8Tr/sL7OzmjryfuHqXtQqKEq5xRKvR8hYavlGhO7otx2uv5thcz /CYE+UsCgYAsgewfzbcBqJwsAUs98DK99EU8VqKuaYlU5wNvAVb27O6sVeysSokM G1TGIXJPphA3dSAe4Pf/j4ff/eGaS20FAFhs4BPpw0fAeCHpmD0BjIba0lxBS/gY dc+JVPKL8Fe4a8fmsI6ndcZQ9qpOdZM5WOD0ldKRc+SsrYKkTmOOJQ== -----END RSA PRIVATE KEY----- )"; *cert_file = JoinPathSegments(dir, "test.cert"); *key_file = JoinPathSegments(dir, "test.key"); RETURN_NOT_OK(WriteStringToFile(Env::Default(), kCert, *cert_file)); RETURN_NOT_OK(WriteStringToFile(Env::Default(), kKey, *key_file)); return Status::OK(); } Status CreateTestSSLCertWithEncryptedKey(const string& dir, string* cert_file, string* key_file, string* key_password) { const char* kCert = R"( -----BEGIN CERTIFICATE----- MIIFuTCCA6GgAwIBAgIJAMboiIQH/LDlMA0GCSqGSIb3DQEBCwUAMHMxCzAJBgNV BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMMBk15TmFtZTEbMBkGCSqGSIb3DQEJARYM bXlAZW1haWwuY29tMB4XDTE3MDQxNDE3MzEzOVoXDTI3MDQxMjE3MzEzOVowczEL MAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVy bmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1UEAwwGTXlOYW1lMRswGQYJKoZIhvcN AQkBFgxteUBlbWFpbC5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC AQC+Av808cmgkgtLpH+ERAaJLgpSQ+l2UfUHTB4XeFXcWcxlsRyXqqNTh5NwkjMI c6Ei8p12PBol9I2j//l9sCmLXWDXq2EFFkZ+tcszPjQiTmqzPeruAnamYzuQFioZ mnNbPypD9qdk/IWY4XWMWOL/qIhnkNQvswSCqu7JA37xaiOqdLBYt/nSN9h5cOwi iHQODY15OmrgAB4JO9brHdBp/fzoN3DkHpQ0V5rlEZ+5Ud9qDs3UEQMgo+ZV8wYL KVb9/sUyWu+i1NJIAIhNt5oC8AXJJt+C5Bqme3+7mkWnnBo9DwsvnqDOjOY6AvpO NHDeRgEBBelj8rGOGQAFgfTlv+w3kDas25oxmoeVXSPF94eU75bu/EE6GGNpe1EB ZtfGUSfRLZwBMAeTZ7f1b9xgNygNpBGmwt9bg+qOZ6PYWkGIrP5+Umhjyss26j5r PzJSummB93+69QoESLnF68WcFrR7fxN+oVra63kic/wvC3RH+P3lAIaYw9dKGtec D3/F2xBp9+Q3nMJQ5MGDdv4wbWQ9lA63uwcWSGIP3R3KKrs4ULtvHIVQz3tgKbwu Lw5LM7x3KnV1iMwfJC09I+lv8MxJBS7cxGU7UEyIasIirsZblPTBshjoKPax2RWR I/VI9HwdA4cCk+zbvklK3hHgemCagVLIGwT5+tU7tY4UOQIDAQABo1AwTjAdBgNV HQ4EFgQU+4nVu5ZsCzs3wxbyS8LNmkL849AwHwYDVR0jBBgwFoAU+4nVu5ZsCzs3 wxbyS8LNmkL849AwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAWHLA OCjmeqf6AWpmoOOx3fUaGzaR0SG1Cn85nDMypdTrZtNUn9mkDDDXH40xP31vUyjx i2Z68dvHsJCdqYL1KAwvvWIEt8xzIWI9ALCANl7JD1L224lUdXI/SgOVaba5bxf4 nVhqeGH5G7WB6g4ZoOkiICluCnjc5FWaZlENJ4oQLLS9mQE7sREouCy+lDnlUW0x Mf1A5hiERTmvuy26b/lkjXfdGw0z/lNXNAS2k59cKHZ11FqzSLwzK2betmpJYzcq N4kPMbfUDrN5x/pjAl//GATQgCiXCUjwGvKnhhXedLjnLUC7bxrAoDwKj986iKnO v9wzukBC6t/Ao1COodDISzTLORTMIWLOjyg9bPVKSjdFxmKhpCUQQ3Jt6k9JOZtR hvKVmDZBCB10eCJALsHlDWAy0DgjRrD1dnnXrOIUgq6ZLqtzAKGkQF5Y5sYEXyTm fCFgiXHtU2haGzp5x+i/vz/E6bBsxJhUVzaWlP149WhQs4RO1YL3Iqsdcy0AcMA9 FUNW6C+37fVk6w1OJGcI4uTfgMpSJL7iTCSzuspR4lEPUHLIvB3kZKyjr7/eAiMg NU9t8oyYtGfrXWXHEZ+d8vK7KCnvMZ2ezNtMC88tC8NtnJ8yBPxBLS7k1f/IrYVL OHUKIgiZvAfTg3GSj/iiNespDd665okkzRb0QNQ= -----END CERTIFICATE----- )"; const char* kKey = R"( -----BEGIN ENCRYPTED PRIVATE KEY----- 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 TOQYXv+dMtOkYg== -----END ENCRYPTED PRIVATE KEY----- )"; const char* kKeyPassword = "test"; *cert_file = JoinPathSegments(dir, "test.cert"); *key_file = JoinPathSegments(dir, "test.key"); *key_password = kKeyPassword; RETURN_NOT_OK(WriteStringToFile(Env::Default(), kCert, *cert_file)); RETURN_NOT_OK(WriteStringToFile(Env::Default(), kKey, *key_file)); return Status::OK(); } // // These certificates were generated by following the steps outlined in this tutorial // for creating the Root CA, Intermediate CA and end-user cert: // https://raymii.org/s/tutorials/ \ // OpenSSL_command_line_Root_and_Intermediate_CA_including_OCSP_CRL%20and_revocation.html // // The parts relating to the OSCP and CRL were omitted. // // | serverCert TRUSTS intermediateCA TRUSTS rootCA | // // The 'cert_file' here contains the serverCert and intermediateCA. // The 'ca_cert_file' contains the rootCA and the same intermediateCA. // This was added to test KUDU-2091 and KUDU-2220. Status CreateTestSSLCertSignedByChain(const string& dir, string* cert_file, string* key_file, string* ca_cert_file) { const char* kCert = R"( -----BEGIN CERTIFICATE----- MIIFizCCA3OgAwIBAgICEAAwDQYJKoZIhvcNAQEFBQAwUTEXMBUGA1UEAwwOSW50 ZXJtZWRpYXRlQ0ExCzAJBgNVBAgMAkNBMQswCQYDVQQGEwJVUzENMAsGA1UECgwE QWNtZTENMAsGA1UECwwES3VkdTAeFw0xNzA4MTEyMTM4MDZaFw00NDEyMjYyMTM4 MDZaMEwxEjAQBgNVBAMMCWxvY2FsaG9zdDELMAkGA1UECAwCQ0ExCzAJBgNVBAYT AlVTMQ0wCwYDVQQKDARBY21lMQ0wCwYDVQQLDARLdWR1MIICIjANBgkqhkiG9w0B AQEFAAOCAg8AMIICCgKCAgEAqevNYH73n4kARZtMsHRucdKmqVd/xxztMlK5VOor ERUBhKVVOw3kpDrN9z80ldIkpOrtrfE7Ame/nA9v4k6P3minPEm1qCA/kvaAodtT 4HjAkrPc+fto6VO6+aUV6l+ckAV/79lOuc7AutNlvvPtBQQcgOKvlNUSRKwM7ndy dO4ZAa+uP9Wtsd0gl8b5F3P8vwevD3a0+iDvwSd3pi2s/BeVgRwvOxJzud8ipZ/A ZmZN8Df9nHw5lsqLdNnqHXjTVCNXLnYXQC4gKU56fzyZL595liuefyQxiGY+dCCn CpqlSsHboJVC/F3OaQi3xVRTB5l2Nwb149EIadwCF0OulZCuYljJ5y9H2bECXEjP e5aOdz9d8W3/T7p9vBKWctToeCpqKXUd+8RPudh0D0sUHuwQ4u4S1K6X+eK+gGhT HOnPwt+P8ytG0M463z5Gh9feW9ZDIYoiFckheFBAHxsgDWhjYpFmYireLLXMbyaM s5v/AxPNRAsx3vAAd0M0vGOpdgEJ9V1MsKmxkPO/tDC3zmnv6uJhtJfrOAKxwiGC fDe4IoSC6H5fTxeAgw6BG5onS1UPLADL8NA/M1y8qiSCZS/5S0cHoJp5AxDfZSSR O49ispjqcONRwckcRJ5Pbl0IA+wGyg2DuI9LaqS5kKWp5AE8VCLPz7yepDkRnnjO 3m8CAwEAAaNyMHAwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUZBZLZZaUfyIK/8B7 GIIWDqeEvDgwHwYDVR0jBBgwFoAU8KctfaqAq0887CHqDsIC0Rkg7oQwCwYDVR0P BAQDAgWgMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA0GCSqGSIb3DQEBBQUAA4ICAQA3 XJXk9CbzdZUQugPI43LY88g+WjbTJfc/KtPSkHN3GjBBh8C0He7A2tp6Xj/LELmx crq62FzcFBnq8/iSdFITaYWRo0V/mXlpv2cpPebtwqbARCXUHGvF4/dGk/kw7uK/ ohZJbeNySuQmQ5SQyfTdVA30Z0OSZ4jp24jC8uME7L8XOcFDgCRw01QNOISpi/5J BqeuFihmu/odYMHiEJdCXqe+4qIFfTh0mbgQ57l/geZm0K8uCEiOdTzSMoO8YdO2 tm6EGNnc4yrVywjIHIvSy6YtNzd4ZM1a1CkEfPvGwe/wI1DI/zl3aJ721kcMPken rgEA4xXTPh6gZNMELIGZfu/mOTCFObe8rrh4QSaW4L+xa/VrLEnQRxuXAYGnmDWF e79aA+uXdS4+3OysNgEf4qDBt/ZquS/31DBdfJ59VfXWxp2yxMcGhcfiOdnx2Jy5 KO8wdpXJA/7uwTJzsjLrIgfZnserOiBwE4luaHhDmKDGNVQvhkMq5tdtMdzuwn3/ n6P1UwbFPiRGIzEAo0SSC1PRT8phv+5y0B1+gcj/peFymZVE+gRcrv9irVQqUpAY Lo9xrClAJ2xx4Ouz1GprKPoHdVyqtgcLXN4Oyi8Tehu96Zf6GytSEfTXsbQp+GgR TGRhKnDySjPhLp/uObfVwioyuAyA5mVCwjsZ/cvUUA== -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- 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 Wd40Cr+wAdHKN6t/oransoxu0EZ3HcSOI1umFg== -----END CERTIFICATE----- )"; const char* kKey = R"( -----BEGIN RSA PRIVATE KEY----- MIIJKAIBAAKCAgEAqevNYH73n4kARZtMsHRucdKmqVd/xxztMlK5VOorERUBhKVV Ow3kpDrN9z80ldIkpOrtrfE7Ame/nA9v4k6P3minPEm1qCA/kvaAodtT4HjAkrPc +fto6VO6+aUV6l+ckAV/79lOuc7AutNlvvPtBQQcgOKvlNUSRKwM7ndydO4ZAa+u P9Wtsd0gl8b5F3P8vwevD3a0+iDvwSd3pi2s/BeVgRwvOxJzud8ipZ/AZmZN8Df9 nHw5lsqLdNnqHXjTVCNXLnYXQC4gKU56fzyZL595liuefyQxiGY+dCCnCpqlSsHb oJVC/F3OaQi3xVRTB5l2Nwb149EIadwCF0OulZCuYljJ5y9H2bECXEjPe5aOdz9d 8W3/T7p9vBKWctToeCpqKXUd+8RPudh0D0sUHuwQ4u4S1K6X+eK+gGhTHOnPwt+P 8ytG0M463z5Gh9feW9ZDIYoiFckheFBAHxsgDWhjYpFmYireLLXMbyaMs5v/AxPN RAsx3vAAd0M0vGOpdgEJ9V1MsKmxkPO/tDC3zmnv6uJhtJfrOAKxwiGCfDe4IoSC 6H5fTxeAgw6BG5onS1UPLADL8NA/M1y8qiSCZS/5S0cHoJp5AxDfZSSRO49ispjq cONRwckcRJ5Pbl0IA+wGyg2DuI9LaqS5kKWp5AE8VCLPz7yepDkRnnjO3m8CAwEA AQKCAgAE3oL2Hu1Nnwlo9ThPXibEEDtCYwWAWS3a4U/6RPOS+70dZfd5R76jjiPU z/TbzjfKmgjRkTYVrY9qE28rVwD8aJdSPPJ9rN7lgTbSbIyMxCkQiyLr7u5ksUeM W9Sy8KZ14hJ2dw2weWJAeEpUHH1QRXvjnZtWcnyhhySfuMCI5UHGMJiXr7HYhPOo JcWBjItTlg7ILKim+kakjFL7aheo6awZFQutb6vtSZ2ejWNgC9Jz7cbQsyabUZaJ dK0mxw2XPaQD6tJjvm6hgGQ2PTBOkw1S5lEWZ50bwYJMpZrjzOarq751bZGL1cxS ajOJ7g6rCxS+Iu7s5lKNZgaRUBkymATYccoigfZDR//fHKAmdgjgPstqy1NJL+uX bIuNE0bR+mBM2JQzNjPIcE67PG+0aQdO4dj0TnTzkTP1JSsa6Tz4ckOUgt7IBK8j ilCQpHgOB900hXC6xVRnAaU/uuSYEtfi2eFBKHT02OqH51yNZ2jsgOQJCvxNrrdI OmA0AaZ2tVXTTXe6qebaNjjp2cziiO5ma+5mdI1vmLQAA9v0micO+eKp/pi5e0r6 j+9uyR2Oo4qnHg04TIfDyglW3uKz1eI0RPfBN/dx3WLpydxKeywXPH6EzfBFk8pz ST2sy+1ZN4vn0bDSTjSLsLBW+xBKYINqKkBD2Kg6B7aeNINjEQKCAQEA4BQByyZV 9va91T+rQiNPifuI4PKgmLTl0wxM1Jg/H4YCyLtuEkmuvwfeAjaUaUuk2MDs3xfQ 4pu8vtAnDapq5vJ/lMg0m3+NIwoks+xee9F//M4du9j67USvX5Qw/6Cnx1zAvrWR TyZncKUocQowcXM9VU0xcv4qVCMaH5F5Q/1VvG7uAtGCnB8TOHzV7GUaj9xxSqDc f3+p9BzsecpPZsdpVi01dQbCKi9neZwFv1Vr3MvieNDOGqSGn8X5EjSHY5PzCaXL S+/HoFWOSzWcuNdzKJRjVkC8U+eHoEabaRnD47dfJntN3qOQ6Mwf6P2jMN9GqlQu DQlvpMxBwQT1/QKCAQEAwiC4hr6EZKaLmeZBLggsS+oifHReXQy6tf2n7kCAwAgL +65K8UW+YUtQyHL6UFfD27vvW5yp6LZxMRUD3ghguHPMQcejgoQTfGmth1bCb9tx zqfxuWUoNauqZiP4/kgxoh815Kt+kC8BRCXNIWjH38zxY+ncv0b4oKP7lYna/7Xk URLmMFr92QVAydRxY9kQTHQTCd+ZQrFT97xEoosgzkKhmynSfWNx7ymYmCrHzscA TutpD26u4CA4Wh4ZdVPEF10lGR531SAFEqXCkaUvIfwPphPmOtum2LZdEYho9C76 71kLzzoJOJUNo2L9ORd5I4tOrMT0tmN+MpS1cPXb2wKCAQAu3aBeZ9807vhXQKDG DXKWTmibe8OBDNzAnmL3V/xj0HiGmUT1SDnnNHMHjXjO6QZKW1dvdaC3tJDua8Sv RARl1zQ93v25xBy1xmpUw0wjo3acXlOztTcOJv5zBCCXZneQ5+JcQMdqgYLC+ZgS xGnLYKnkTGfaQDSEMm9FSPzO7o5fAeh/6Gfj1VAE0X9AmQjMK/P6Atj7Ra07JE2F T3355h0u6/exST+U6SNAORSupuQPYwkz8aAZzG1nv1VPrHLgrdH4I5f4gucCrsI7 ErR7qHwqcZaxNIrvFY61Q+8/NSdWWkTpXIK13Qny1raZ2WqnTxuNhlu3WFDka+AY ybvVAoIBACOaxL1R7A5ZzXjolkPPE/DIfJK+9R+z2frPDyHPis2trCT5Dp254PUP Tz20eNyLfEys53WyAifAbnpGFHOArdymwGvAJekmODy1VTJhY0AIy5LPkrIiL4HI fnRFXMGmlBPcDZJnMctYE69gD4N1KFOPzyY4Gliqt6ce7GG86wHDZqDICpgL2EsZ f4yE/lcF1Mtw7pz8+asVwwTI7v2w7s9lwSYoQYbl2lu3EVm3XvY54YCYBKjj8AcD YdKFer3eIzT1zHwS7n+UY9nLtSfpV/+vr18Sf0OETdGpgOBaWIWQqE2F03iqeE58 aAfze+YgvAMc5c0iQo/BJ8A3LiANt8kCggEBAK8cFEBm+Z1g5s1IaWxqTIylR5XF 5RFty9HyUXtkAd2d1qVzBaBG3SXg4cRsW0EhcUV2XP3iTFIPXEEABRRu5U6DEal6 wQclrhfP4hiRQHp2Ny6jDj70NCSeUmyEu2lmwEJJYsDSOCnVmtt+qlgmk4yI1Dua nXhLcPLqopuhEZs2V/l2Q6E5i4vrs71Y7of+vsAvvt42Vx5wsGdPQihc5E1MI7GB hxmQys1MwG3Jyd7Zk88MVNveASeEIc7UAmr/TGL+RIv4bxNi/1HrgekBf1jnFUU3 4fsdqKy0W+rOgOlGN8TX7NYCz3B41UEiyf+/gZ/TcLKAyGnoAO727Ngayqo= -----END RSA PRIVATE KEY----- )"; const char* kCaChainCert = R"( -----BEGIN CERTIFICATE----- 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 -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- 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 Wd40Cr+wAdHKN6t/oransoxu0EZ3HcSOI1umFg== -----END CERTIFICATE----- )"; *cert_file = JoinPathSegments(dir, "test.cert"); *key_file = JoinPathSegments(dir, "test.key"); *ca_cert_file = JoinPathSegments(dir, "testchainca.cert"); RETURN_NOT_OK(WriteStringToFile(Env::Default(), kCert, *cert_file)); RETURN_NOT_OK(WriteStringToFile(Env::Default(), kKey, *key_file)); RETURN_NOT_OK(WriteStringToFile(Env::Default(), kCaChainCert, *ca_cert_file)); return Status::OK(); } // // These certificates were generated by following the steps outlined in this tutorial // for creating the Root CA, Intermediate CA and end-user cert: // https://raymii.org/s/tutorials/ \ // OpenSSL_command_line_Root_and_Intermediate_CA_including_OCSP_CRL%20and_revocation.html // // The parts relating to the OSCP and CRL were omitted. // // | serverCert TRUSTS intermediateCA TRUSTS rootCA | // // The 'cert_file' here contains the serverCert and intermediateCA. // The 'ca_cert_file' contains only the rootCA. // This was added to test KUDU-2041. Status CreateTestSSLCertWithChainSignedByRoot(const string& dir, string* cert_file, string* key_file, string* ca_cert_file) { const char* kCert = R"( -----BEGIN CERTIFICATE----- MIIFizCCA3OgAwIBAgICEAAwDQYJKoZIhvcNAQEFBQAwUTEXMBUGA1UEAwwOSW50 ZXJtZWRpYXRlQ0ExCzAJBgNVBAgMAkNBMQswCQYDVQQGEwJVUzENMAsGA1UECgwE QWNtZTENMAsGA1UECwwES3VkdTAeFw0xNzA4MTEyMTM4MDZaFw00NDEyMjYyMTM4 MDZaMEwxEjAQBgNVBAMMCWxvY2FsaG9zdDELMAkGA1UECAwCQ0ExCzAJBgNVBAYT AlVTMQ0wCwYDVQQKDARBY21lMQ0wCwYDVQQLDARLdWR1MIICIjANBgkqhkiG9w0B AQEFAAOCAg8AMIICCgKCAgEAqevNYH73n4kARZtMsHRucdKmqVd/xxztMlK5VOor ERUBhKVVOw3kpDrN9z80ldIkpOrtrfE7Ame/nA9v4k6P3minPEm1qCA/kvaAodtT 4HjAkrPc+fto6VO6+aUV6l+ckAV/79lOuc7AutNlvvPtBQQcgOKvlNUSRKwM7ndy dO4ZAa+uP9Wtsd0gl8b5F3P8vwevD3a0+iDvwSd3pi2s/BeVgRwvOxJzud8ipZ/A ZmZN8Df9nHw5lsqLdNnqHXjTVCNXLnYXQC4gKU56fzyZL595liuefyQxiGY+dCCn CpqlSsHboJVC/F3OaQi3xVRTB5l2Nwb149EIadwCF0OulZCuYljJ5y9H2bECXEjP e5aOdz9d8W3/T7p9vBKWctToeCpqKXUd+8RPudh0D0sUHuwQ4u4S1K6X+eK+gGhT HOnPwt+P8ytG0M463z5Gh9feW9ZDIYoiFckheFBAHxsgDWhjYpFmYireLLXMbyaM s5v/AxPNRAsx3vAAd0M0vGOpdgEJ9V1MsKmxkPO/tDC3zmnv6uJhtJfrOAKxwiGC fDe4IoSC6H5fTxeAgw6BG5onS1UPLADL8NA/M1y8qiSCZS/5S0cHoJp5AxDfZSSR O49ispjqcONRwckcRJ5Pbl0IA+wGyg2DuI9LaqS5kKWp5AE8VCLPz7yepDkRnnjO 3m8CAwEAAaNyMHAwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUZBZLZZaUfyIK/8B7 GIIWDqeEvDgwHwYDVR0jBBgwFoAU8KctfaqAq0887CHqDsIC0Rkg7oQwCwYDVR0P BAQDAgWgMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA0GCSqGSIb3DQEBBQUAA4ICAQA3 XJXk9CbzdZUQugPI43LY88g+WjbTJfc/KtPSkHN3GjBBh8C0He7A2tp6Xj/LELmx crq62FzcFBnq8/iSdFITaYWRo0V/mXlpv2cpPebtwqbARCXUHGvF4/dGk/kw7uK/ ohZJbeNySuQmQ5SQyfTdVA30Z0OSZ4jp24jC8uME7L8XOcFDgCRw01QNOISpi/5J BqeuFihmu/odYMHiEJdCXqe+4qIFfTh0mbgQ57l/geZm0K8uCEiOdTzSMoO8YdO2 tm6EGNnc4yrVywjIHIvSy6YtNzd4ZM1a1CkEfPvGwe/wI1DI/zl3aJ721kcMPken rgEA4xXTPh6gZNMELIGZfu/mOTCFObe8rrh4QSaW4L+xa/VrLEnQRxuXAYGnmDWF e79aA+uXdS4+3OysNgEf4qDBt/ZquS/31DBdfJ59VfXWxp2yxMcGhcfiOdnx2Jy5 KO8wdpXJA/7uwTJzsjLrIgfZnserOiBwE4luaHhDmKDGNVQvhkMq5tdtMdzuwn3/ n6P1UwbFPiRGIzEAo0SSC1PRT8phv+5y0B1+gcj/peFymZVE+gRcrv9irVQqUpAY Lo9xrClAJ2xx4Ouz1GprKPoHdVyqtgcLXN4Oyi8Tehu96Zf6GytSEfTXsbQp+GgR TGRhKnDySjPhLp/uObfVwioyuAyA5mVCwjsZ/cvUUA== -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- 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 Wd40Cr+wAdHKN6t/oransoxu0EZ3HcSOI1umFg== -----END CERTIFICATE----- )"; const char* kKey = R"( -----BEGIN RSA PRIVATE KEY----- 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 -----END RSA PRIVATE KEY----- )"; const char* kRootCaCert = R"( -----BEGIN CERTIFICATE----- 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 -----END CERTIFICATE----- )"; *cert_file = JoinPathSegments(dir, "test.cert"); *key_file = JoinPathSegments(dir, "test.key"); *ca_cert_file = JoinPathSegments(dir, "testchainca.cert"); RETURN_NOT_OK(WriteStringToFile(Env::Default(), kCert, *cert_file)); RETURN_NOT_OK(WriteStringToFile(Env::Default(), kKey, *key_file)); RETURN_NOT_OK(WriteStringToFile(Env::Default(), kRootCaCert, *ca_cert_file)); return Status::OK(); } } // namespace security } // namespace kudu
{ "pile_set_name": "Github" }
From d57aecba0cd291e0c28e2c82c3d4bce06c5b5b94 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh <[email protected]> Date: Mon, 2 Dec 2019 17:36:24 -0800 Subject: [PATCH] udmabuf: use cache_sgt_mapping option Commit bc7a71da43b48333f84c6534ab43d240e34cf9eb uptream. The GEM prime helpers do it, so should we. It's also possible to make it optional later. Signed-off-by: Gurchetan Singh <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Gerd Hoffmann <[email protected]> --- drivers/dma-buf/udmabuf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -94,10 +94,11 @@ static void release_udmabuf(struct dma_b } static const struct dma_buf_ops udmabuf_ops = { - .map_dma_buf = map_udmabuf, - .unmap_dma_buf = unmap_udmabuf, - .release = release_udmabuf, - .mmap = mmap_udmabuf, + .cache_sgt_mapping = true, + .map_dma_buf = map_udmabuf, + .unmap_dma_buf = unmap_udmabuf, + .release = release_udmabuf, + .mmap = mmap_udmabuf, }; #define SEALS_WANTED (F_SEAL_SHRINK)
{ "pile_set_name": "Github" }
package com.u9porn.ui.porn9video.favorite; import android.app.Activity; import android.os.Bundle; import android.app.Fragment; import android.support.annotation.NonNull; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.u9porn.R; import com.u9porn.ui.MvpFragment; import javax.inject.Inject; /** * A simple {@link Fragment} subclass. * @author megoc */ public class FavoriteFragment extends MvpFragment<FavoriteView,FavoritePresenter>{ @Inject protected FavoritePresenter favoritePresenter; public FavoriteFragment() { // Required empty public constructor } @Override public void onAttach(Activity activity) { super.onAttach(activity); } @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.fragment_favorite, container, false); } @NonNull @Override public FavoritePresenter createPresenter() { return favoritePresenter; } }
{ "pile_set_name": "Github" }
/** * Populate DB with sample data on server start * to disable, edit config/environment/index.js, and set `seedDB: false` */ 'use strict'; import User from '../api/user/user.model'; import config from './environment/'; import logger from '../components/logger/logger'; export default function seedDatabaseIfNeeded() { logger.info('seedDB = %s', config.seedDB); // If asked to seed DB - create Admin and Test user // Else create admin user at the minimum if(config.seedDB == "true") { logger.info('Removing and re-creating local users'); User.find({}).remove() .then(() => { User.create({ provider: 'local', name: 'Test User', email: process.env.EMAIL_USER_TEST || '[email protected]', password: process.env.PASSWORD_TEST || 'test' }, { provider: 'local', role: 'admin', name: 'Admin', email: process.env.EMAIL_USER_ADMIN || '[email protected]', password: process.env.PASSWORD_ADMIN || 'admin' }) .then(() => logger.info('finished populating users')) .catch(err => logger.error('error populating users - %s', err)); }); }else{ logger.info('Finding local admin user'); User.find({name: 'Admin'}).then((user) => { if(!user.length){ logger.info('Admin user not found, creating local admin user'); User.create({ provider: 'local', role: 'admin', name: 'Admin', email: process.env.EMAIL_USER_ADMIN || '[email protected]', password: process.env.PASSWORD_ADMIN || 'admin' }) .then(() => logger.info('finished populating users')) .catch(err => logger.error('error populating users - %s', err)); }else{ logger.info('Admin user already exists.'); } }); } }
{ "pile_set_name": "Github" }
/* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } body { line-height: 1; } ol, ul { list-style: none; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content:''; content: none; } table { border-collapse: collapse; border-spacing: 0; } /* LAYOUT STYLES */ body { font-size: 15px; line-height: 1.5; background: #fafafa url(../assets/body-bg.jpg) 0 0 repeat; font-family:'Helvetica Neue', Helvetica, Arial, serif; font-weight: 400; color: #666; } a { color: #2879d0; } a:hover { color: #2268b2; } header { padding-top: 40px; padding-bottom: 40px; font-family:'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; background: #2e7bcf url(../assets/header-bg.jpg) 0 0 repeat-x; border-bottom: solid 1px #275da1; height: auto; margin-bottom: 10px; } header h1 { letter-spacing: -1px; font-size: 72px; color: #fff; line-height: 1; margin-bottom: 0.2em; width: auto; } header h2 { font-size: 26px; color: #9ddcff; font-weight: normal; line-height: 1.3; width: 540px; letter-spacing: 0; } .inner { position: relative; width: 1170px; margin: 0 auto; padding-left: 30px; padding-right: 30px; } #content-wrapper { border-top: solid 1px #fff; padding-top: 30px; } #main-content { width: 690px; float: left; } #main-content img { max-width: 100%; } aside#sidebar { width: 200px; padding-left: 20px; min-height: 504px; float: right; background: transparent url(../assets/sidebar-bg.jpg) 0 0 no-repeat; font-size: 12px; line-height: 1.3; } aside#sidebar p.repo-owner, aside#sidebar p.repo-owner a { font-weight: bold; } #downloads { margin-bottom: 40px; } a.gh-button { width: 134px; height: 58px; line-height: 1.2; font-size: 23px; color: #fff; padding-left: 68px; padding-top: 22px; font-family:'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; } a.gh-button small { display: block; font-size: 11px; } header a.gh-button { position: absolute; right: 0; top: 0; background: transparent url(../assets/github-button.png) 0 0 no-repeat; } aside a.gh-button { width: 138px; padding-left: 64px; display: block; background: transparent url(../assets/download-button.png) 0 0 no-repeat; margin-bottom: 20px; font-size: 21px; } code, pre { font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; color: #222; margin-bottom: 30px; font-size: 13px; } code { background-color: #f2f8fc; border: solid 1px #dbe7f3; padding: 0 3px; } pre { padding: 20px; background: #fff; text-shadow: none; overflow: auto; border: solid 1px #f2f2f2; } pre code { color: #2879d0; background-color: #fff; border: none; padding: 0; } ul, ol, dl { margin-bottom: 20px; } /* COMMON STYLES */ hr { height: 1px; line-height: 1px; margin-top: 1em; padding-bottom: 1em; border: none; } table { width: 100%; border: 1px solid #ebebeb; } th { font-weight: 500; } td { border: 1px solid #ebebeb; text-align: center; font-weight: 300; } form { background: #f2f2f2; padding: 20px; } /* GENERAL ELEMENT TYPE STYLES */ #main-content h1 { font-family:'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 2.8em; letter-spacing: -1px; color: #474747; } #main-content h1:before { content:"/"; color: #9ddcff; padding-right: 0.3em; margin-left: -0.9em; } #main-content h2 { font-family:'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 22px; font-weight: bold; margin-bottom: 8px; color: #474747; } #main-content h2:before { content:"//"; color: #9ddcff; padding-right: 0.3em; margin-left: -1.5em; } #main-content h3 { font-family:'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 18px; font-weight: bold; margin-top: 24px; margin-bottom: 8px; color: #474747; } #main-content h3:before { content:"///"; color: #9ddcff; padding-right: 0.3em; margin-left: -2em; } #main-content h4 { font-family:'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 15px; font-weight: bold; color: #474747; } h4:before { content:"////"; color: #9ddcff; padding-right: 0.3em; } #main-content h5 { font-family:'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: 14px; color: #474747; } h5:before { content:"/////"; color: #9ddcff; padding-right: 0.3em; margin-left: -3.2em; } #main-content h6 { font-family:'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif; font-size: .8em; color: #474747; } h6:before { content:"//////"; color: #9ddcff; padding-right: 0.3em; margin-left: -3.7em; } p { margin-bottom: 20px; } a { text-decoration: none; } p a { font-weight: 400; } blockquote { font-size: 1.6em; border-left: 10px solid #e9e9e9; margin-bottom: 20px; padding: 0 0 0 30px; } ul { list-style: disc inside; padding-left: 20px; } ol { list-style: decimal inside; padding-left: 3px; } dl dd { font-style: italic; font-weight: 100; } footer { margin-top: 40px; padding-top: 20px; padding-bottom: 10px; font-size: 13px; color: #aaa; } footer a { color: #666; } footer a:hover { color: #444; } /* MISC */ .clearfix:after { clear: both; content:'.'; display: block; visibility: hidden; height: 0; } .clearfix { display: inline-block; } * html .clearfix { height: 1%; } .clearfix { display: block; } /* #Media Queries ================================================== */ /* Smaller than standard 960 (devices and browsers) */ @media only screen and (max-width: 959px) { } /* Tablet Portrait size to standard 960 (devices and browsers) */ @media only screen and (min-width: 768px) and (max-width: 959px) { .inner { width: 740px; } header h1, header h2 { width: 740px; } header h1 { font-size: 60px; } header h2 { font-size: 30px; } #main-content { width: 490px; } #main-content h1:before, #main-content h2:before, #main-content h3:before, #main-content h4:before, #main-content h5:before, #main-content h6:before { content: none; padding-right: 0; margin-left: 0; } } /* All Mobile Sizes (devices and browser) */ @media only screen and (max-width: 767px) { .inner { width: 93%; } header { padding: 20px 0; } header .inner { position: relative; } header h1, header h2 { width: 100%; } header h1 { font-size: 48px; } header h2 { font-size: 24px; } header a.gh-button { background-image: none; width: auto; height: auto; display: inline-block; margin-top: 15px; padding: 5px 10px; position: relative; text-align: center; font-size: 13px; line-height: 1; background-color: #9ddcff; color: #2879d0; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } header a.gh-button small { font-size: 13px; display: inline; } #main-content, aside#sidebar { float: none; width: 100% ! important; } aside#sidebar { background-image: none; margin-top: 20px; border-top: solid 1px #ddd; padding: 20px 0; min-height: 0; } aside#sidebar a.gh-button { display: none; } #main-content h1:before, #main-content h2:before, #main-content h3:before, #main-content h4:before, #main-content h5:before, #main-content h6:before { content: none; padding-right: 0; margin-left: 0; } a.option[disabled] { opacity: 0.5; } } .custom-trigger { padding: 0.75em; margin-top: 1.5em; border: 1px solid #ccc; cursor: pointer; } /* Mobile Landscape Size to Tablet Portrait (devices and browsers) */ @media only screen and (min-width: 480px) and (max-width: 767px) { } /* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */ @media only screen and (max-width: 479px) { }
{ "pile_set_name": "Github" }
import zipfile from urllib import urlopen from StringIO import StringIO import pandas as pd import numpy as np import matplotlib.pyplot as plt def get_data_pwt(path=None, version=71, date='11302012', extract=True, panel=True): """Loads the Penn World Tables (PWT) data. If you have a local copy of the PWT data that you wish to work with, then you can directly specify the path arugment to load your local copy directly. Alternatively, you can download a copy of the PWT data by specify a version number and date corresponding to the specific (default settings will grab the most recent update of the most recent version of PWT). The required date format is 'MMDDYYYY'. By default, any downloaded data is extracted into your current working directory. If you don't want a local copy of the PWT data, then set extract to false. Returns a pandas Panel object where the major axis is country (technically country iso codes) and the minor axis is year. Setting panel to false will return a DataFrame object with the pandas default index. """ # first check for a local copy of PWT if path != None and panel == False: pwt = pd.read_csv(path) elif path != None and panel == True: pwt = pd.read_csv(path, index_col=['year', 'isocode']) pwt = pwt.to_panel() # otherwise, download the appropriate zip file elif path == None: url = 'http://pwt.econ.upenn.edu/Downloads/pwt' + str(version) + \ '/pwt' + str(version) +'_' + date + 'version.zip' archive = zipfile.ZipFile(StringIO(urlopen(url).read()), 'r') # to extract or not to extract... tmp_file = 'pwt' + str(version) + '_wo_country_names_wo_g_vars.csv' if extract == True: archive.extractall() pwt = pd.read_csv(tmp_file) else: pwt = archive.read(tmp_file) pwt = pd.read_csv(StringIO(pwt)) # Do you want a Panel or Dataframe? if panel == True: # inelegant! Should use MultiIndex instead... pwt = pd.read_csv(tmp_file, index_col=['year', 'isocode']) pwt = pwt.to_panel() else: pass return pwt ##### Example usage ##### # download data, extract to working directory, load into Pandas Panel pwt = get_data_pwt() # plot some data plt.figure(figsize=(8,8)) for yr in xrange(1951, 2011): pwt['rgdpch'].pct_change().xs(yr).hist(color='blue', normed=False, alpha=0.025) plt.xlabel('Annual percentage change in real GDP per capita') plt.ylabel('Frequency') plt.title('Growth rates of real GDP per capita 1950-2010\n2005 I$/person, Source: Penn World Tables', weight='bold') plt.savefig('Histogram-historical-growth-rates-RGDPPC.png') # TODO: Work out how to generate the panel groupings #def intervals(x, n=5): # """Maps years to n year groups, eg., 1960-n -> 1960""" # return 1960 + 5 * int(np.floor((x - 1960.)/5)) # #def panel_average(x): # panel_grp = x.groupby(lambda x : x[1]) # return panel_grp.aggregate('mean') # ignores NaNs # #yr_group = pwt.groupby(intervals, level=0) #pwt_new = yr_group['rgdpl'].apply(panel_average) #pwt_new = pwt_new.T.stack(dropna=False) #pwt_new.name = 'rgdpl'
{ "pile_set_name": "Github" }
/* * Copyright 2001-2004 Brandon Long * All Rights Reserved. * * ClearSilver Templating System * * This code is made available under the terms of the ClearSilver License. * http://www.clearsilver.net/license.hdf * */ #ifndef incl_HPHP_NEO_FILES_H_ #define incl_HPHP_NEO_FILES_H_ 1 __BEGIN_DECLS #include <stdarg.h> #include <sys/types.h> NEOERR *ne_load_file (const char *path, char **str); NEOERR *ne_load_file_len (const char *path, char **str, int *len); __END_DECLS #endif /* incl_HPHP_NEO_FILES_H_ */
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp"> <Identity Name="3b208cda-c6f8-484c-b6d4-8e3703fa7177" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="1.0.0.0" /> <mp:PhoneIdentity PhoneProductId="3b208cda-c6f8-484c-b6d4-8e3703fa7177" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> <Properties> <DisplayName>VideoTextureUWP</DisplayName> <PublisherDisplayName>Xbox Advanced Technology Group</PublisherDisplayName> <Logo>Assets\StoreLogo.png</Logo> </Properties> <Dependencies> <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" /> </Dependencies> <Resources> <Resource Language="x-generate"/> </Resources> <Applications> <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="VideoTextureUWP.App"> <uap:VisualElements DisplayName="VideoTextureUWP" Square150x150Logo="Assets\Logo.png" Square44x44Logo="Assets\SmallLogo.png" Description="VideoTextureUWP" BackgroundColor="transparent"> <uap:DefaultTile Wide310x150Logo="Assets\WideLogo.png"/> <uap:SplashScreen Image="Assets\SplashScreen.png" /> </uap:VisualElements> </Application> </Applications> <Capabilities> <Capability Name="internetClient" /> </Capabilities> </Package>
{ "pile_set_name": "Github" }
const fs = require("fs") const path = require("path") const run = require("test262-parser-runner") const parse = require("..").parse const unsupportedFeatures = [ "BigInt", "class-fields", "class-fields-private", "class-fields-public", "numeric-separator-literal" ]; run( (content, {sourceType}) => parse(content, {sourceType, ecmaVersion: 10}), { testsDirectory: path.dirname(require.resolve("test262/package.json")), skip: test => (test.attrs.features && unsupportedFeatures.some(f => test.attrs.features.includes(f))), whitelist: fs.readFileSync("./bin/test262.whitelist", "utf8").split("\n").filter(v => v) } )
{ "pile_set_name": "Github" }
module FogExtensions module Libvirt module Server extend ActiveSupport::Concern include ActionView::Helpers::NumberHelper attr_accessor :image_id def to_s name end def cpu_mode attributes[:cpu][:mode] end def cpu_mode=(cpumode) attributes[:cpu][:mode] = (cpumode == 'default') ? nil : cpumode end def nics_attributes=(attrs) end def volumes_attributes=(attrs) end # Libvirt expect units in KB, while we use bytes def memory attributes[:memory_size].to_i.kilobytes end def memory=(mem) attributes[:memory_size] = mem.to_i / 1.kilobyte if mem end def reset poweroff start end def vm_description _("%{cpus} CPUs and %{memory} memory") % {:cpus => cpus, :memory => number_to_human_size(memory.to_i)} end # Other Fog CRs use .interfaces as the accessor, but libvirt does not def interfaces nics end def select_nic(fog_nics, nic) nic_attrs = nic.compute_attributes match = fog_nics.detect { |fn| fn.network == nic_attrs['network'] } # grab any nic on the same network match ||= fog_nics.detect { |fn| fn.bridge == nic_attrs['bridge'] } # no network? try a bridge... match end end end end
{ "pile_set_name": "Github" }
require 'test_helper' require 'scout_apm/transaction_time_consumed' module ScoutApm class TransactionTimeConsumedTest < Minitest::Test def setup @ttc = ScoutApm::TransactionTimeConsumed.new end def test_insert_new_times @ttc.add("Controller/Foo", 1.5) @ttc.add("Controller/Foo", 2.75) assert_equal 4.25, @ttc.total_time_for("Controller/Foo") end def test_insert_tracks_endpoints_separately @ttc.add("Controller/Foo", 1.5) @ttc.add("Controller/Foo", 2.75) @ttc.add("Controller/Bar", 5) @ttc.add("Controller/Bar", 5) assert_equal 4.25, @ttc.total_time_for("Controller/Foo") assert_equal 10.0, @ttc.total_time_for("Controller/Bar") end def test_calculates_percent_of_total @ttc.add("Controller/Foo", 1) @ttc.add("Controller/Bar", 4) assert_equal 0.2, @ttc.percent_of_total("Controller/Foo") assert_equal 0.8, @ttc.percent_of_total("Controller/Bar") end def test_counts_total_call_count @ttc.add("Controller/Foo", 1) @ttc.add("Controller/Foo", 1) @ttc.add("Controller/Foo", 1) @ttc.add("Controller/Bar", 4) assert_equal 3, @ttc.call_count_for("Controller/Foo") assert_equal 1, @ttc.call_count_for("Controller/Bar") end def test_percent_of_total_is_0_with_no_data assert_equal 0.0, @ttc.percent_of_total("Controller/Foo") end end end
{ "pile_set_name": "Github" }
## Recommended/Popular Community Packages Beyond the packages in the Clinical Meteor track, there are many other packages that have caught our eye over the years. Here are a few which we keep a watch on, and have been contemplating how they might fit into the Clinical Meteor project. | Package | UI | Contributor | Scaffold | | ------------- | :----------------: | :----------------: | :----------------: | | [jrudio:electron](https://atmospherejs.com/jrudio/electron) | --- | --- | --- | | [jamielob:transitions](https://github.com/jamielob/transitions) | --- | --- | --- | | [jamielob:native-transitions](https://github.com/jamielob/native-transitions) | --- | --- | --- | | [datariot/meteor-ganalytics](https://github.com/datariot/meteor-ganalytics) | none | datariot | yes | | [meson:electron](https://github.com/electron-webapps/meteor-electron) | --- | --- | --- | | [nicolaslopezj/meteor-router-layer](https://github.com/nicolaslopezj/meteor-router-layer) | --- | --- | --- | | [Event Hooks](https://atmosphere.meteor.com/package/event-hooks) | none | ? | No | | [Payments - Stripe](https://atmosphere.meteor.com/package/stripe) | none | ? | Yes | | [Date/Time - Moment](https://github.com/possibilities/meteor-moment) | none | possibilities | No | | [msavin:mongol](https://github.com/msavin/mongol) | --- | --- | --- | | [msavin:jetsetter](https://github.com/msavin/jetsetter) | --- | --- | --- | | [jboulhous/dev](https://atmospherejs.com/jboulhous/dev)| none | jboulhous | no | | [aldeed/meteor-template-extension](https://github.com/aldeed/meteor-template-extension) | ? | aldeed | No | | [Clustering - Meteor-Cluster](https://github.com/arunoda/meteor-cluster) | none | ? | No | | [Browser Detection](https://atmosphere.meteor.com/package/browser-detection ) | none | ? | No | | [Collection2](https://atmosphere.meteor.com/package/collection2) | none | ? | No | | [cron](https://atmosphere.meteor.com/package/cron) | none | ? | No | | [Mesosphere](https://atmosphere.meteor.com/package/Mesosphere) | none | ? | No | | [Login Page](https://atmosphere.meteor.com/package/accounts-entry) | bootstrap3 | ? | Yes | | [LeapJ](https://github.com/kevohagan/meteor-leapmotion) | none | ? | No | | [rzymek:fullcalendar](https://atmospherejs.com/rzymek/fullcalendar) | custom | rzymek | no | | [gwendall:meteor-ui-hooks](https://github.com/gwendall/meteor-ui-hooks) | --- | --- | --- | | [peerlibrary/meteor-blaze-components](https://github.com/peerlibrary/meteor-blaze-components) | no | --- | no | | [numtel/meteor-webcomponent](https://github.com/numtel/meteor-webcomponent) | no | --- | no | | [grigio:babel](https://atmospherejs.com/grigio/babel) | --- | --- | --- | | [grove:less](https://atmospherejs.com/grove/less) | ---| --- | --- | | [rahul:animate-everything](https://atmospherejs.com/rahul/animate-everything) | --- | --- | --- | | [yogiben:pretty-emails](https://atmospherejs.com/yogiben/pretty-emails) | --- | --- | --- | | [gfk:notifications](https://atmospherejs.com/gfk/notifications) | --- | --- | --- | | [CodeAdventure:meteor-space](https://atmospherejs.com/CodeAdventure/meteor-space) | --- | --- | --- | | [meteorhacks:sikka](https://github.com/meteorhacks/sikka) | --- | --- | --- | | [elidoran:cosmos-browserify](https://github.com/elidoran/cosmos-browserify) | --- | --- | --- | | [handtrix:chrome-extension-utils](https://www.npmjs.com/package/meteor-chrome-extension-utils) | --- | --- | --- | | [helfer:minimongo-index](https://github.com/helfer/minimongo-index) | --- | --- | --- | | [useraccounts:core](http://useraccounts.meteor.com/) | --- | --- | --- | | [nathantreid:blaze-modules](https://github.com/nathantreid/blaze-modules) | --- | --- | --- | https://github.com/Telerik-Verified-Plugins/NativePageTransitions
{ "pile_set_name": "Github" }
/*------------------------------------------------------------------------- * * ginutil.c * Utility routines for the Postgres inverted index access method. * * * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION * src/backend/access/gin/ginutil.c *------------------------------------------------------------------------- */ #include "postgres.h" #include "access/gin_private.h" #include "access/ginxlog.h" #include "access/reloptions.h" #include "access/xloginsert.h" #include "catalog/pg_collation.h" #include "catalog/pg_type.h" #include "miscadmin.h" #include "storage/indexfsm.h" #include "storage/lmgr.h" #include "storage/predicate.h" #include "utils/builtins.h" #include "utils/index_selfuncs.h" #include "utils/typcache.h" /* * GIN handler function: return IndexAmRoutine with access method parameters * and callbacks. */ Datum ginhandler(PG_FUNCTION_ARGS) { IndexAmRoutine *amroutine = makeNode(IndexAmRoutine); amroutine->amstrategies = 0; amroutine->amsupport = GINNProcs; amroutine->amcanorder = false; amroutine->amcanorderbyop = false; amroutine->amcanbackward = false; amroutine->amcanunique = false; amroutine->amcanmulticol = true; amroutine->amoptionalkey = true; amroutine->amsearcharray = false; amroutine->amsearchnulls = false; amroutine->amstorage = true; amroutine->amclusterable = false; amroutine->ampredlocks = true; amroutine->amcanparallel = false; amroutine->amcaninclude = false; amroutine->amkeytype = InvalidOid; amroutine->ambuild = ginbuild; amroutine->ambuildempty = ginbuildempty; amroutine->aminsert = gininsert; amroutine->ambulkdelete = ginbulkdelete; amroutine->amvacuumcleanup = ginvacuumcleanup; amroutine->amcanreturn = NULL; amroutine->amcostestimate = gincostestimate; amroutine->amoptions = ginoptions; amroutine->amproperty = NULL; amroutine->ambuildphasename = NULL; amroutine->amvalidate = ginvalidate; amroutine->ambeginscan = ginbeginscan; amroutine->amrescan = ginrescan; amroutine->amgettuple = NULL; amroutine->amgetbitmap = gingetbitmap; amroutine->amendscan = ginendscan; amroutine->ammarkpos = NULL; amroutine->amrestrpos = NULL; amroutine->amestimateparallelscan = NULL; amroutine->aminitparallelscan = NULL; amroutine->amparallelrescan = NULL; PG_RETURN_POINTER(amroutine); } /* * initGinState: fill in an empty GinState struct to describe the index * * Note: assorted subsidiary data is allocated in the CurrentMemoryContext. */ void initGinState(GinState *state, Relation index) { TupleDesc origTupdesc = RelationGetDescr(index); int i; MemSet(state, 0, sizeof(GinState)); state->index = index; state->oneCol = (origTupdesc->natts == 1) ? true : false; state->origTupdesc = origTupdesc; for (i = 0; i < origTupdesc->natts; i++) { Form_pg_attribute attr = TupleDescAttr(origTupdesc, i); if (state->oneCol) state->tupdesc[i] = state->origTupdesc; else { state->tupdesc[i] = CreateTemplateTupleDesc(2); TupleDescInitEntry(state->tupdesc[i], (AttrNumber) 1, NULL, INT2OID, -1, 0); TupleDescInitEntry(state->tupdesc[i], (AttrNumber) 2, NULL, attr->atttypid, attr->atttypmod, attr->attndims); TupleDescInitEntryCollation(state->tupdesc[i], (AttrNumber) 2, attr->attcollation); } /* * If the compare proc isn't specified in the opclass definition, look * up the index key type's default btree comparator. */ if (index_getprocid(index, i + 1, GIN_COMPARE_PROC) != InvalidOid) { fmgr_info_copy(&(state->compareFn[i]), index_getprocinfo(index, i + 1, GIN_COMPARE_PROC), CurrentMemoryContext); } else { TypeCacheEntry *typentry; typentry = lookup_type_cache(attr->atttypid, TYPECACHE_CMP_PROC_FINFO); if (!OidIsValid(typentry->cmp_proc_finfo.fn_oid)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("could not identify a comparison function for type %s", format_type_be(attr->atttypid)))); fmgr_info_copy(&(state->compareFn[i]), &(typentry->cmp_proc_finfo), CurrentMemoryContext); } /* Opclass must always provide extract procs */ fmgr_info_copy(&(state->extractValueFn[i]), index_getprocinfo(index, i + 1, GIN_EXTRACTVALUE_PROC), CurrentMemoryContext); fmgr_info_copy(&(state->extractQueryFn[i]), index_getprocinfo(index, i + 1, GIN_EXTRACTQUERY_PROC), CurrentMemoryContext); /* * Check opclass capability to do tri-state or binary logic consistent * check. */ if (index_getprocid(index, i + 1, GIN_TRICONSISTENT_PROC) != InvalidOid) { fmgr_info_copy(&(state->triConsistentFn[i]), index_getprocinfo(index, i + 1, GIN_TRICONSISTENT_PROC), CurrentMemoryContext); } if (index_getprocid(index, i + 1, GIN_CONSISTENT_PROC) != InvalidOid) { fmgr_info_copy(&(state->consistentFn[i]), index_getprocinfo(index, i + 1, GIN_CONSISTENT_PROC), CurrentMemoryContext); } if (state->consistentFn[i].fn_oid == InvalidOid && state->triConsistentFn[i].fn_oid == InvalidOid) { elog(ERROR, "missing GIN support function (%d or %d) for attribute %d of index \"%s\"", GIN_CONSISTENT_PROC, GIN_TRICONSISTENT_PROC, i + 1, RelationGetRelationName(index)); } /* * Check opclass capability to do partial match. */ if (index_getprocid(index, i + 1, GIN_COMPARE_PARTIAL_PROC) != InvalidOid) { fmgr_info_copy(&(state->comparePartialFn[i]), index_getprocinfo(index, i + 1, GIN_COMPARE_PARTIAL_PROC), CurrentMemoryContext); state->canPartialMatch[i] = true; } else { state->canPartialMatch[i] = false; } /* * If the index column has a specified collation, we should honor that * while doing comparisons. However, we may have a collatable storage * type for a noncollatable indexed data type (for instance, hstore * uses text index entries). If there's no index collation then * specify default collation in case the support functions need * collation. This is harmless if the support functions don't care * about collation, so we just do it unconditionally. (We could * alternatively call get_typcollation, but that seems like expensive * overkill --- there aren't going to be any cases where a GIN storage * type has a nondefault collation.) */ if (OidIsValid(index->rd_indcollation[i])) state->supportCollation[i] = index->rd_indcollation[i]; else state->supportCollation[i] = DEFAULT_COLLATION_OID; } } /* * Extract attribute (column) number of stored entry from GIN tuple */ OffsetNumber gintuple_get_attrnum(GinState *ginstate, IndexTuple tuple) { OffsetNumber colN; if (ginstate->oneCol) { /* column number is not stored explicitly */ colN = FirstOffsetNumber; } else { Datum res; bool isnull; /* * First attribute is always int16, so we can safely use any tuple * descriptor to obtain first attribute of tuple */ res = index_getattr(tuple, FirstOffsetNumber, ginstate->tupdesc[0], &isnull); Assert(!isnull); colN = DatumGetUInt16(res); Assert(colN >= FirstOffsetNumber && colN <= ginstate->origTupdesc->natts); } return colN; } /* * Extract stored datum (and possible null category) from GIN tuple */ Datum gintuple_get_key(GinState *ginstate, IndexTuple tuple, GinNullCategory *category) { Datum res; bool isnull; if (ginstate->oneCol) { /* * Single column index doesn't store attribute numbers in tuples */ res = index_getattr(tuple, FirstOffsetNumber, ginstate->origTupdesc, &isnull); } else { /* * Since the datum type depends on which index column it's from, we * must be careful to use the right tuple descriptor here. */ OffsetNumber colN = gintuple_get_attrnum(ginstate, tuple); res = index_getattr(tuple, OffsetNumberNext(FirstOffsetNumber), ginstate->tupdesc[colN - 1], &isnull); } if (isnull) *category = GinGetNullCategory(tuple, ginstate); else *category = GIN_CAT_NORM_KEY; return res; } /* * Allocate a new page (either by recycling, or by extending the index file) * The returned buffer is already pinned and exclusive-locked * Caller is responsible for initializing the page by calling GinInitBuffer */ Buffer GinNewBuffer(Relation index) { Buffer buffer; bool needLock; /* First, try to get a page from FSM */ for (;;) { BlockNumber blkno = GetFreeIndexPage(index); if (blkno == InvalidBlockNumber) break; buffer = ReadBuffer(index, blkno); /* * We have to guard against the possibility that someone else already * recycled this page; the buffer may be locked if so. */ if (ConditionalLockBuffer(buffer)) { if (GinPageIsRecyclable(BufferGetPage(buffer))) return buffer; /* OK to use */ LockBuffer(buffer, GIN_UNLOCK); } /* Can't use it, so release buffer and try again */ ReleaseBuffer(buffer); } /* Must extend the file */ needLock = !RELATION_IS_LOCAL(index); if (needLock) LockRelationForExtension(index, ExclusiveLock); buffer = ReadBuffer(index, P_NEW); LockBuffer(buffer, GIN_EXCLUSIVE); if (needLock) UnlockRelationForExtension(index, ExclusiveLock); return buffer; } void GinInitPage(Page page, uint32 f, Size pageSize) { GinPageOpaque opaque; PageInit(page, pageSize, sizeof(GinPageOpaqueData)); opaque = GinPageGetOpaque(page); memset(opaque, 0, sizeof(GinPageOpaqueData)); opaque->flags = f; opaque->rightlink = InvalidBlockNumber; } void GinInitBuffer(Buffer b, uint32 f) { GinInitPage(BufferGetPage(b), f, BufferGetPageSize(b)); } void GinInitMetabuffer(Buffer b) { GinMetaPageData *metadata; Page page = BufferGetPage(b); GinInitPage(page, GIN_META, BufferGetPageSize(b)); metadata = GinPageGetMeta(page); metadata->head = metadata->tail = InvalidBlockNumber; metadata->tailFreeSize = 0; metadata->nPendingPages = 0; metadata->nPendingHeapTuples = 0; metadata->nTotalPages = 0; metadata->nEntryPages = 0; metadata->nDataPages = 0; metadata->nEntries = 0; metadata->ginVersion = GIN_CURRENT_VERSION; /* * Set pd_lower just past the end of the metadata. This is essential, * because without doing so, metadata will be lost if xlog.c compresses * the page. */ ((PageHeader) page)->pd_lower = ((char *) metadata + sizeof(GinMetaPageData)) - (char *) page; } /* * Compare two keys of the same index column */ int ginCompareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, GinNullCategory categorya, Datum b, GinNullCategory categoryb) { /* if not of same null category, sort by that first */ if (categorya != categoryb) return (categorya < categoryb) ? -1 : 1; /* all null items in same category are equal */ if (categorya != GIN_CAT_NORM_KEY) return 0; /* both not null, so safe to call the compareFn */ return DatumGetInt32(FunctionCall2Coll(&ginstate->compareFn[attnum - 1], ginstate->supportCollation[attnum - 1], a, b)); } /* * Compare two keys of possibly different index columns */ int ginCompareAttEntries(GinState *ginstate, OffsetNumber attnuma, Datum a, GinNullCategory categorya, OffsetNumber attnumb, Datum b, GinNullCategory categoryb) { /* attribute number is the first sort key */ if (attnuma != attnumb) return (attnuma < attnumb) ? -1 : 1; return ginCompareEntries(ginstate, attnuma, a, categorya, b, categoryb); } /* * Support for sorting key datums in ginExtractEntries * * Note: we only have to worry about null and not-null keys here; * ginExtractEntries never generates more than one placeholder null, * so it doesn't have to sort those. */ typedef struct { Datum datum; bool isnull; } keyEntryData; typedef struct { FmgrInfo *cmpDatumFunc; Oid collation; bool haveDups; } cmpEntriesArg; static int cmpEntries(const void *a, const void *b, void *arg) { const keyEntryData *aa = (const keyEntryData *) a; const keyEntryData *bb = (const keyEntryData *) b; cmpEntriesArg *data = (cmpEntriesArg *) arg; int res; if (aa->isnull) { if (bb->isnull) res = 0; /* NULL "=" NULL */ else res = 1; /* NULL ">" not-NULL */ } else if (bb->isnull) res = -1; /* not-NULL "<" NULL */ else res = DatumGetInt32(FunctionCall2Coll(data->cmpDatumFunc, data->collation, aa->datum, bb->datum)); /* * Detect if we have any duplicates. If there are equal keys, qsort must * compare them at some point, else it wouldn't know whether one should go * before or after the other. */ if (res == 0) data->haveDups = true; return res; } /* * Extract the index key values from an indexable item * * The resulting key values are sorted, and any duplicates are removed. * This avoids generating redundant index entries. */ Datum * ginExtractEntries(GinState *ginstate, OffsetNumber attnum, Datum value, bool isNull, int32 *nentries, GinNullCategory **categories) { Datum *entries; bool *nullFlags; int32 i; /* * We don't call the extractValueFn on a null item. Instead generate a * placeholder. */ if (isNull) { *nentries = 1; entries = (Datum *) palloc(sizeof(Datum)); entries[0] = (Datum) 0; *categories = (GinNullCategory *) palloc(sizeof(GinNullCategory)); (*categories)[0] = GIN_CAT_NULL_ITEM; return entries; } /* OK, call the opclass's extractValueFn */ nullFlags = NULL; /* in case extractValue doesn't set it */ entries = (Datum *) DatumGetPointer(FunctionCall3Coll(&ginstate->extractValueFn[attnum - 1], ginstate->supportCollation[attnum - 1], value, PointerGetDatum(nentries), PointerGetDatum(&nullFlags))); /* * Generate a placeholder if the item contained no keys. */ if (entries == NULL || *nentries <= 0) { *nentries = 1; entries = (Datum *) palloc(sizeof(Datum)); entries[0] = (Datum) 0; *categories = (GinNullCategory *) palloc(sizeof(GinNullCategory)); (*categories)[0] = GIN_CAT_EMPTY_ITEM; return entries; } /* * If the extractValueFn didn't create a nullFlags array, create one, * assuming that everything's non-null. */ if (nullFlags == NULL) nullFlags = (bool *) palloc0(*nentries * sizeof(bool)); /* * If there's more than one key, sort and unique-ify. * * XXX Using qsort here is notationally painful, and the overhead is * pretty bad too. For small numbers of keys it'd likely be better to use * a simple insertion sort. */ if (*nentries > 1) { keyEntryData *keydata; cmpEntriesArg arg; keydata = (keyEntryData *) palloc(*nentries * sizeof(keyEntryData)); for (i = 0; i < *nentries; i++) { keydata[i].datum = entries[i]; keydata[i].isnull = nullFlags[i]; } arg.cmpDatumFunc = &ginstate->compareFn[attnum - 1]; arg.collation = ginstate->supportCollation[attnum - 1]; arg.haveDups = false; qsort_arg(keydata, *nentries, sizeof(keyEntryData), cmpEntries, (void *) &arg); if (arg.haveDups) { /* there are duplicates, must get rid of 'em */ int32 j; entries[0] = keydata[0].datum; nullFlags[0] = keydata[0].isnull; j = 1; for (i = 1; i < *nentries; i++) { if (cmpEntries(&keydata[i - 1], &keydata[i], &arg) != 0) { entries[j] = keydata[i].datum; nullFlags[j] = keydata[i].isnull; j++; } } *nentries = j; } else { /* easy, no duplicates */ for (i = 0; i < *nentries; i++) { entries[i] = keydata[i].datum; nullFlags[i] = keydata[i].isnull; } } pfree(keydata); } /* * Create GinNullCategory representation from nullFlags. */ *categories = (GinNullCategory *) palloc0(*nentries * sizeof(GinNullCategory)); for (i = 0; i < *nentries; i++) (*categories)[i] = (nullFlags[i] ? GIN_CAT_NULL_KEY : GIN_CAT_NORM_KEY); return entries; } bytea * ginoptions(Datum reloptions, bool validate) { relopt_value *options; GinOptions *rdopts; int numoptions; static const relopt_parse_elt tab[] = { {"fastupdate", RELOPT_TYPE_BOOL, offsetof(GinOptions, useFastUpdate)}, {"gin_pending_list_limit", RELOPT_TYPE_INT, offsetof(GinOptions, pendingListCleanupSize)} }; options = parseRelOptions(reloptions, validate, RELOPT_KIND_GIN, &numoptions); /* if none set, we're done */ if (numoptions == 0) return NULL; rdopts = allocateReloptStruct(sizeof(GinOptions), options, numoptions); fillRelOptions((void *) rdopts, sizeof(GinOptions), options, numoptions, validate, tab, lengthof(tab)); pfree(options); return (bytea *) rdopts; } /* * Fetch index's statistical data into *stats * * Note: in the result, nPendingPages can be trusted to be up-to-date, * as can ginVersion; but the other fields are as of the last VACUUM. */ void ginGetStats(Relation index, GinStatsData *stats) { Buffer metabuffer; Page metapage; GinMetaPageData *metadata; metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); LockBuffer(metabuffer, GIN_SHARE); metapage = BufferGetPage(metabuffer); metadata = GinPageGetMeta(metapage); stats->nPendingPages = metadata->nPendingPages; stats->nTotalPages = metadata->nTotalPages; stats->nEntryPages = metadata->nEntryPages; stats->nDataPages = metadata->nDataPages; stats->nEntries = metadata->nEntries; stats->ginVersion = metadata->ginVersion; UnlockReleaseBuffer(metabuffer); } /* * Write the given statistics to the index's metapage * * Note: nPendingPages and ginVersion are *not* copied over */ void ginUpdateStats(Relation index, const GinStatsData *stats, bool is_build) { Buffer metabuffer; Page metapage; GinMetaPageData *metadata; metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); LockBuffer(metabuffer, GIN_EXCLUSIVE); metapage = BufferGetPage(metabuffer); metadata = GinPageGetMeta(metapage); START_CRIT_SECTION(); metadata->nTotalPages = stats->nTotalPages; metadata->nEntryPages = stats->nEntryPages; metadata->nDataPages = stats->nDataPages; metadata->nEntries = stats->nEntries; /* * Set pd_lower just past the end of the metadata. This is essential, * because without doing so, metadata will be lost if xlog.c compresses * the page. (We must do this here because pre-v11 versions of PG did not * set the metapage's pd_lower correctly, so a pg_upgraded index might * contain the wrong value.) */ ((PageHeader) metapage)->pd_lower = ((char *) metadata + sizeof(GinMetaPageData)) - (char *) metapage; MarkBufferDirty(metabuffer); if (RelationNeedsWAL(index) && !is_build) { XLogRecPtr recptr; ginxlogUpdateMeta data; data.node = index->rd_node; data.ntuples = 0; data.newRightlink = data.prevTail = InvalidBlockNumber; memcpy(&data.metadata, metadata, sizeof(GinMetaPageData)); XLogBeginInsert(); XLogRegisterData((char *) &data, sizeof(ginxlogUpdateMeta)); XLogRegisterBuffer(0, metabuffer, REGBUF_WILL_INIT | REGBUF_STANDARD); recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_UPDATE_META_PAGE); PageSetLSN(metapage, recptr); } UnlockReleaseBuffer(metabuffer); END_CRIT_SECTION(); }
{ "pile_set_name": "Github" }
<% content_for :breadcrumb do %> <li class="breadcrumb-item"><%= link_to "Home", root_path %></li> <li class="breadcrumb-item"><%= link_to "Examples", examples_path %></li> <li class="breadcrumb-item active">Inline Form</li> <% end %> <div class="app-example container"> <div class="row"> <%= render partial: "bootstrap", layout: "card_bootstrap", locals: { title: "Inline Form" } %> <%= render partial: "form", layout: "card_simple_form", locals: { title: "Inline Form" } %> </div> <%= render partial: "shared/tipps" %> <%# move modals to bottom %> <%= render partial: "shared/modal", locals: { id: "modal-bootstrap", title: "Bootstrap", content: render_source(File.read(File.join(Rails.root, 'app/views/examples/inlines/_bootstrap.html.erb'))) } %> <%= render partial: "shared/modal", locals: { id: "modal-simpleform", title: "Simple Form", content: render_source(File.read(File.join(Rails.root, 'app/views/examples/inlines/_form.html.erb'))) } %> </div>
{ "pile_set_name": "Github" }
name: Project check on: push: pull_request: jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [10.x, 12.x] os: [ubuntu-latest, windows-latest, macOS-latest] steps: - uses: actions/checkout@v1 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - name: npm install, build, test:coverage and lint run: | npm i npm run release env: CI: true
{ "pile_set_name": "Github" }
/** * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: // config.language = 'fr'; // config.uiColor = '#AADC6E'; };
{ "pile_set_name": "Github" }
// Boost string_algo library string_funct.hpp header file ---------------------------// // Copyright Pavol Droba 2002-2003. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/ for updates, documentation, and revision history. #ifndef BOOST_STRING_CASE_CONV_DETAIL_HPP #define BOOST_STRING_CASE_CONV_DETAIL_HPP #include <boost/algorithm/string/config.hpp> #include <locale> #include <functional> #include <boost/type_traits/make_unsigned.hpp> namespace boost { namespace algorithm { namespace detail { // case conversion functors -----------------------------------------------// #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) #pragma warning(push) #pragma warning(disable:4512) //assignment operator could not be generated #endif // a tolower functor template<typename CharT> struct to_lowerF : public std::unary_function<CharT, CharT> { // Constructor to_lowerF( const std::locale& Loc ) : m_Loc( &Loc ) {} // Operation CharT operator ()( CharT Ch ) const { #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) return std::tolower( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch )); #else return std::tolower<CharT>( Ch, *m_Loc ); #endif } private: const std::locale* m_Loc; }; // a toupper functor template<typename CharT> struct to_upperF : public std::unary_function<CharT, CharT> { // Constructor to_upperF( const std::locale& Loc ) : m_Loc( &Loc ) {} // Operation CharT operator ()( CharT Ch ) const { #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) return std::toupper( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch )); #else return std::toupper<CharT>( Ch, *m_Loc ); #endif } private: const std::locale* m_Loc; }; #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) #pragma warning(pop) #endif // algorithm implementation ------------------------------------------------------------------------- // Transform a range template<typename OutputIteratorT, typename RangeT, typename FunctorT> OutputIteratorT transform_range_copy( OutputIteratorT Output, const RangeT& Input, FunctorT Functor) { return std::transform( ::boost::begin(Input), ::boost::end(Input), Output, Functor); } // Transform a range (in-place) template<typename RangeT, typename FunctorT> void transform_range( const RangeT& Input, FunctorT Functor) { std::transform( ::boost::begin(Input), ::boost::end(Input), ::boost::begin(Input), Functor); } template<typename SequenceT, typename RangeT, typename FunctorT> inline SequenceT transform_range_copy( const RangeT& Input, FunctorT Functor) { return SequenceT( ::boost::make_transform_iterator( ::boost::begin(Input), Functor), ::boost::make_transform_iterator( ::boost::end(Input), Functor)); } } // namespace detail } // namespace algorithm } // namespace boost #endif // BOOST_STRING_CASE_CONV_DETAIL_HPP
{ "pile_set_name": "Github" }
0 18 7 9 8 14 9 12 17 2 19 2 22 11 24 1 26 1 27 1 40 3 41 6 42 6 51 3 52 9 53 9 54 14 55 10 56 10 57 10 58 14 59 14 60 13 61 10 62 14 64 2 65 2 66 1 67 1 68 1 69 1 71 11 72 11 73 11 75 11 76 11 77 3 78 11 79 11 80 11 81 6 82 15 83 9 84 12 85 12 86 12 87 12 88 5 89 4 90 4 91 4 92 3 93 13 94 13 95 13 96 13 97 13 100 13 101 7 109 7 110 10 112 13 113 13 114 14 115 13 119 2 122 7 123 3 124 3 125 4 126 9 127 10 128 10 133 13 134 13 136 1 138 13 139 3 141 6 143 2 145 10 147 11 149 13 151 3 152 10 155 4 156 13 157 5
{ "pile_set_name": "Github" }
// Karma Unit Test Runner Configuration module.exports = function(config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "", browserNoActivityTimeout: 0, // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ["jasmine"], // list of files / patterns to load in the browser files: [ // Application Source Files // This list should match the order defined in index.html "www/js/build-vars.js", "www/lib/ionic/js/ionic.bundle.min.js", "www/lib/angular-mocks/angular-mocks.js", "www/lib/lodash/lodash.min.js", "www/lib/moment/moment.min.js", "www/lib/nprogress/nprogress.js", "www/lib/uri/uri.min.js", "www/js/templates.js", "www/js/bundle.js", "www/js/boot1.js", // Tests "tests/bundle.tests.js", // Allow the source maps and source for the TypeScript test files to be served // so they can be used for debugging tests, but do not include them as script // references in the browser instance. { pattern: "tests/**/*.js.map", included: false, watched: false, served: true }, { pattern: "tests/**/*.ts", included: false, watched: false, served: true } ], // list of files to exclude exclude: [ ], // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { }, // test results reporter to use // possible values: "dots", "progress" // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ["progress"], // web server port port: 9876, // enable / disable colors in the output (reporters and logs) colors: true, // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes autoWatch: true, // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ["PhantomJS"], // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: false }) }
{ "pile_set_name": "Github" }
/* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.flowable.dmn.rest.service.api.repository; import static org.flowable.common.rest.api.PaginateListUtil.paginateList; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.flowable.common.engine.api.query.QueryProperty; import org.flowable.common.rest.api.DataResponse; import org.flowable.dmn.api.DmnDecisionQuery; import org.flowable.dmn.api.DmnRepositoryService; import org.flowable.dmn.engine.impl.DecisionQueryProperty; import org.flowable.dmn.rest.service.api.DmnRestApiInterceptor; import org.flowable.dmn.rest.service.api.DmnRestResponseFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import io.swagger.annotations.Authorization; /** * @author Yvo Swillens */ @RestController @Api(tags = { "Decisions" }, description = "Manage Decisions", authorizations = { @Authorization(value = "basicAuth") }) public class DecisionCollectionResource { private static final Map<String, QueryProperty> properties = new HashMap<>(); static { properties.put("id", DecisionQueryProperty.DECISION_ID); properties.put("key", DecisionQueryProperty.DECISION_KEY); properties.put("category", DecisionQueryProperty.DECISION_CATEGORY); properties.put("name", DecisionQueryProperty.DECISION_NAME); properties.put("version", DecisionQueryProperty.DECISION_VERSION); properties.put("deploymentId", DecisionQueryProperty.DECISION_DEPLOYMENT_ID); properties.put("tenantId", DecisionQueryProperty.DECISION_TENANT_ID); properties.put("decisionType", DecisionQueryProperty.DECISION_TYPE); } @Autowired protected DmnRestResponseFactory dmnRestResponseFactory; @Autowired protected DmnRepositoryService dmnRepositoryService; @Autowired(required=false) protected DmnRestApiInterceptor restApiInterceptor; @ApiOperation(value = "List of decision", tags = { "Decisions" }, nickname = "listDecisions") @ApiImplicitParams({ @ApiImplicitParam(name = "category", dataType = "string", value = "Only return decision with the given category.", paramType = "query"), @ApiImplicitParam(name = "categoryLike", dataType = "string", value = "Only return decision with a category like the given name.", paramType = "query"), @ApiImplicitParam(name = "categoryNotEquals", dataType = "string", value = "Only return decision which do not have the given category.", paramType = "query"), @ApiImplicitParam(name = "key", dataType = "string", value = "Only return decision with the given key.", paramType = "query"), @ApiImplicitParam(name = "keyLike", dataType = "string", value = "Only return decision with a name like the given key.", paramType = "query"), @ApiImplicitParam(name = "name", dataType = "string", value = "Only return decision with the given name.", paramType = "query"), @ApiImplicitParam(name = "nameLike", dataType = "string", value = "Only return decision with a name like the given name.", paramType = "query"), @ApiImplicitParam(name = "resourceName", dataType = "string", value = "Only return decision with the given resource name.", paramType = "query"), @ApiImplicitParam(name = "resourceNameLike", dataType = "string", value = "Only return decision with a name like the given resource name.", paramType = "query"), @ApiImplicitParam(name = "version", dataType = "integer", value = "Only return decision with the given version.", paramType = "query"), @ApiImplicitParam(name = "latest", dataType = "boolean", value = "Only return the latest decision versions. Can only be used together with key and keyLike parameters, using any other parameter will result in a 400-response.", paramType = "query"), @ApiImplicitParam(name = "deploymentId", dataType = "string", value = "Only return decision with the given category.", paramType = "query"), @ApiImplicitParam(name = "tenantId", dataType = "string", value = "Only return decision with the given tenant ID.", paramType = "query"), @ApiImplicitParam(name = "decisionType", dataType = "string", value = "Only return decision with the given type.", paramType = "query"), @ApiImplicitParam(name = "decisionTypeLike", dataType = "string", value = "Only return decision like the given type.", paramType = "query"), @ApiImplicitParam(name = "sort", dataType = "string", value = "Property to sort on, to be used together with the order.", allowableValues = "name,id,key,category,deploymentId,version,decisionType", paramType = "query"), }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates request was successful and the process-definitions are returned"), @ApiResponse(code = 400, message = "Indicates a parameter was passed in the wrong format or that latest is used with other parameters other than key and keyLike. The status-message contains additional information.") }) @GetMapping(value = "/dmn-repository/decisions", produces = "application/json") public DataResponse<DecisionResponse> getDecisions(@ApiParam(hidden = true) @RequestParam Map<String, String> allRequestParams, HttpServletRequest request) { DmnDecisionQuery definitionQuery = dmnRepositoryService.createDecisionQuery(); // Populate filter-parameters if (allRequestParams.containsKey("category")) { definitionQuery.decisionCategory(allRequestParams.get("category")); } if (allRequestParams.containsKey("categoryLike")) { definitionQuery.decisionCategoryLike(allRequestParams.get("categoryLike")); } if (allRequestParams.containsKey("categoryNotEquals")) { definitionQuery.decisionCategoryNotEquals(allRequestParams.get("categoryNotEquals")); } if (allRequestParams.containsKey("key")) { definitionQuery.decisionKey(allRequestParams.get("key")); } if (allRequestParams.containsKey("keyLike")) { definitionQuery.decisionKeyLike(allRequestParams.get("keyLike")); } if (allRequestParams.containsKey("name")) { definitionQuery.decisionName(allRequestParams.get("name")); } if (allRequestParams.containsKey("nameLike")) { definitionQuery.decisionNameLike(allRequestParams.get("nameLike")); } if (allRequestParams.containsKey("resourceName")) { definitionQuery.decisionResourceName(allRequestParams.get("resourceName")); } if (allRequestParams.containsKey("resourceNameLike")) { definitionQuery.decisionResourceNameLike(allRequestParams.get("resourceNameLike")); } if (allRequestParams.containsKey("version")) { definitionQuery.decisionVersion(Integer.valueOf(allRequestParams.get("version"))); } if (allRequestParams.containsKey("latest")) { Boolean latest = Boolean.valueOf(allRequestParams.get("latest")); if (latest != null && latest) { definitionQuery.latestVersion(); } } if (allRequestParams.containsKey("deploymentId")) { definitionQuery.deploymentId(allRequestParams.get("deploymentId")); } if (allRequestParams.containsKey("tenantId")) { definitionQuery.decisionTenantId(allRequestParams.get("tenantId")); } if (allRequestParams.containsKey("tenantIdLike")) { definitionQuery.decisionTenantIdLike(allRequestParams.get("tenantIdLike")); } if (allRequestParams.containsKey("decisionType")) { definitionQuery.decisionType(allRequestParams.get("decisionType")); } if (allRequestParams.containsKey("decisionTypeLike")) { definitionQuery.decisionTypeLike(allRequestParams.get("decisionType")); } if (restApiInterceptor != null) { restApiInterceptor.accessDecisionTableInfoWithQuery(definitionQuery); } return paginateList(allRequestParams, definitionQuery, "name", properties, dmnRestResponseFactory::createDecisionResponseList); } }
{ "pile_set_name": "Github" }
// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See License.txt in the repository root. package com.microsoft.tfs.core.checkinpolicies.events; import java.util.EventListener; import com.microsoft.tfs.core.checkinpolicies.PolicyEvaluator; /** * <p> * Defines an interface for listeners of the * {@link PolicyEvaluatorStateChangedEvent}. * </p> * * @since TEE-SDK-10.1 * @threadsafety thread-compatible */ public interface PolicyEvaluatorStateChangedListener extends EventListener { /** * Invoked when the state of a ({@link PolicyEvaluator}) has changed. * * @param e * the event that describes the changes. */ public void onPolicyEvaluatorStateChanged(PolicyEvaluatorStateChangedEvent e); }
{ "pile_set_name": "Github" }
import os, glob, random import pretty_midi import numpy as np from keras.models import model_from_json from multiprocessing import Pool as ThreadPool def log(message, verbose): if verbose: print('[*] {}'.format(message)) def parse_midi(path): midi = None try: midi = pretty_midi.PrettyMIDI(path) midi.remove_invalid_notes() except Exception as e: raise Exception(("%s\nerror readying midi file %s" % (e, path))) return midi def get_percent_monophonic(pm_instrument_roll): mask = pm_instrument_roll.T > 0 notes = np.sum(mask, axis=1) n = np.count_nonzero(notes) single = np.count_nonzero(notes == 1) if single > 0: return float(single) / float(n) elif single == 0 and n > 0: return 0.0 else: # no notes of any kind return 0.0 def filter_monophonic(pm_instruments, percent_monophonic=0.99): return [i for i in pm_instruments if \ get_percent_monophonic(i.get_piano_roll()) >= percent_monophonic] # if the experiment dir doesn't exist create it and its subfolders def create_experiment_dir(experiment_dir, verbose=False): # if the experiment directory was specified and already exists if experiment_dir != 'experiments/default' and \ os.path.exists(experiment_dir): # raise an error raise Exception('Error: Invalid --experiemnt_dir, {} already exists' \ .format(experiment_dir)) # if the experiment directory was not specified, create a new numeric folder if experiment_dir == 'experiments/default': experiments = os.listdir('experiments') experiments = [dir_ for dir_ in experiments \ if os.path.isdir(os.path.join('experiments', dir_))] most_recent_exp = 0 for dir_ in experiments: try: most_recent_exp = max(int(dir_), most_recent_exp) except ValueError as e: # ignrore non-numeric folders in experiments/ pass experiment_dir = os.path.join('experiments', str(most_recent_exp + 1).rjust(2, '0')) os.mkdir(experiment_dir) log('Created experiment directory {}'.format(experiment_dir), verbose) os.mkdir(os.path.join(experiment_dir, 'checkpoints')) log('Created checkpoint directory {}'.format(os.path.join(experiment_dir, 'checkpoints')), verbose) os.mkdir(os.path.join(experiment_dir, 'tensorboard-logs')) log('Created log directory {}'.format(os.path.join(experiment_dir, 'tensorboard-logs')), verbose) return experiment_dir # load data with a lazzy loader def get_data_generator(midi_paths, window_size=20, batch_size=32, num_threads=8, max_files_in_ram=170): if num_threads > 1: # load midi data pool = ThreadPool(num_threads) load_index = 0 while True: load_files = midi_paths[load_index:load_index + max_files_in_ram] # print('length of load files: {}'.format(len(load_files))) load_index = (load_index + max_files_in_ram) % len(midi_paths) # print('loading large batch: {}'.format(max_files_in_ram)) # print('Parsing midi files...') # start_time = time.time() if num_threads > 1: parsed = pool.map(parse_midi, load_files) else: parsed = map(parse_midi, load_files) # print('Finished in {:.2f} seconds'.format(time.time() - start_time)) # print('parsed, now extracting data') data = _windows_from_monophonic_instruments(parsed, window_size) batch_index = 0 while batch_index + batch_size < len(data[0]): # print('getting data...') # print('yielding small batch: {}'.format(batch_size)) res = (data[0][batch_index: batch_index + batch_size], data[1][batch_index: batch_index + batch_size]) yield res batch_index = batch_index + batch_size # probably unneeded but why not del parsed # free the mem del data # free the mem def save_model(model, model_dir): with open(os.path.join(model_dir, 'model.json'), 'w') as f: f.write(model.to_json()) def load_model_from_checkpoint(model_dir): '''Loads the best performing model from checkpoint_dir''' with open(os.path.join(model_dir, 'model.json'), 'r') as f: model = model_from_json(f.read()) epoch = 0 newest_checkpoint = max(glob.iglob(model_dir + '/checkpoints/*.hdf5'), key=os.path.getctime) if newest_checkpoint: epoch = int(newest_checkpoint[-22:-19]) model.load_weights(newest_checkpoint) return model, epoch def generate(model, seeds, window_size, length, num_to_gen, instrument_name): # generate a pretty midi file from a model using a seed def _gen(model, seed, window_size, length): generated = [] # ring buffer buf = np.copy(seed).tolist() while len(generated) < length: arr = np.expand_dims(np.asarray(buf), 0) pred = model.predict(arr) # argmax sampling (NOT RECOMMENDED), or... # index = np.argmax(pred) # prob distrobuition sampling index = np.random.choice(range(0, seed.shape[1]), p=pred[0]) pred = np.zeros(seed.shape[1]) pred[index] = 1 generated.append(pred) buf.pop(0) buf.append(pred) return generated midis = [] for i in range(0, num_to_gen): seed = seeds[random.randint(0, len(seeds) - 1)] gen = _gen(model, seed, window_size, length) midis.append(_network_output_to_midi(gen, instrument_name)) return midis # create a pretty midi file with a single instrument using the one-hot encoding # output of keras model.predict. def _network_output_to_midi(windows, instrument_name='Acoustic Grand Piano', allow_represses=False): # Create a PrettyMIDI object midi = pretty_midi.PrettyMIDI() # Create an Instrument instance for a cello instrument instrument_program = pretty_midi.instrument_name_to_program(instrument_name) instrument = pretty_midi.Instrument(program=instrument_program) cur_note = None # an invalid note to start with cur_note_start = None clock = 0 # Iterate over note names, which will be converted to note number later for step in windows: note_num = np.argmax(step) - 1 # a note has changed if allow_represses or note_num != cur_note: # if a note has been played before and it wasn't a rest if cur_note is not None and cur_note >= 0: # add the last note, now that we have its end time note = pretty_midi.Note(velocity=127, pitch=int(cur_note), start=cur_note_start, end=clock) instrument.notes.append(note) # update the current note cur_note = note_num cur_note_start = clock # update the clock clock = clock + 1.0 / 4 # Add the cello instrument to the PrettyMIDI object midi.instruments.append(instrument) return midi # returns X, y data windows from all monophonic instrument # tracks in a pretty midi file def _windows_from_monophonic_instruments(midi, window_size): X, y = [], [] for m in midi: if m is not None: melody_instruments = filter_monophonic(m.instruments, 1.0) for instrument in melody_instruments: if len(instrument.notes) > window_size: windows = _encode_sliding_windows(instrument, window_size) for w in windows: X.append(w[0]) y.append(w[1]) return (np.asarray(X), np.asarray(y)) # one-hot encode a sliding window of notes from a pretty midi instrument. # This approach uses the piano roll method, where each step in the sliding # window represents a constant unit of time (fs=4, or 1 sec / 4 = 250ms). # This allows us to encode rests. # expects pm_instrument to be monophonic. def _encode_sliding_windows(pm_instrument, window_size): roll = np.copy(pm_instrument.get_piano_roll(fs=4).T) # trim beginning silence summed = np.sum(roll, axis=1) mask = (summed > 0).astype(float) roll = roll[np.argmax(mask):] # transform note velocities into 1s roll = (roll > 0).astype(float) # calculate the percentage of the events that are rests # s = np.sum(roll, axis=1) # num_silence = len(np.where(s == 0)[0]) # print('{}/{} {:.2f} events are rests'.format(num_silence, len(roll), float(num_silence)/float(len(roll)))) # append a feature: 1 to rests and 0 to notes rests = np.sum(roll, axis=1) rests = (rests != 1).astype(float) roll = np.insert(roll, 0, rests, axis=1) windows = [] for i in range(0, roll.shape[0] - window_size - 1): windows.append((roll[i:i + window_size], roll[i + window_size + 1])) return windows
{ "pile_set_name": "Github" }
fileFormatVersion: 2 guid: 341194f768f6bdf4e98ec1c4a531c825 NativeFormatImporter: externalObjects: {} mainObjectFileID: 100100000 userData: assetBundleName: assetBundleVariant:
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <lint> </lint>
{ "pile_set_name": "Github" }
var baseIsArrayBuffer = require('./_baseIsArrayBuffer'), baseUnary = require('./_baseUnary'), nodeUtil = require('./_nodeUtil'); /* Node.js helper references. */ var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer; /** * Checks if `value` is classified as an `ArrayBuffer` object. * * @static * @memberOf _ * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. * @example * * _.isArrayBuffer(new ArrayBuffer(2)); * // => true * * _.isArrayBuffer(new Array(2)); * // => false */ var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; module.exports = isArrayBuffer;
{ "pile_set_name": "Github" }
"""The roomba constants.""" DOMAIN = "roomba" COMPONENTS = ["sensor", "binary_sensor", "vacuum"] CONF_CERT = "certificate" CONF_CONTINUOUS = "continuous" CONF_DELAY = "delay" CONF_NAME = "name" CONF_BLID = "blid" DEFAULT_CERT = "/etc/ssl/certs/ca-certificates.crt" DEFAULT_CONTINUOUS = True DEFAULT_DELAY = 1 ROOMBA_SESSION = "roomba_session" BLID = "blid_key"
{ "pile_set_name": "Github" }
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/test/web_contents_observer_sanity_checker.h" #include "base/memory/ptr_util.h" #include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "build/build_config.h" #include "content/browser/frame_host/render_frame_host_impl.h" #include "content/common/content_navigation_policy.h" #include "content/common/frame_messages.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" #include "net/base/net_errors.h" namespace content { namespace { const char kWebContentsObserverSanityCheckerKey[] = "WebContentsObserverSanityChecker"; GlobalRoutingID GetRoutingPair(RenderFrameHost* host) { if (!host) return GlobalRoutingID(0, 0); return GlobalRoutingID(host->GetProcess()->GetID(), host->GetRoutingID()); } } // namespace // static void WebContentsObserverSanityChecker::Enable(WebContents* web_contents) { if (web_contents->GetUserData(&kWebContentsObserverSanityCheckerKey)) return; web_contents->SetUserData( &kWebContentsObserverSanityCheckerKey, base::WrapUnique(new WebContentsObserverSanityChecker(web_contents))); } void WebContentsObserverSanityChecker::RenderFrameCreated( RenderFrameHost* render_frame_host) { CHECK(!web_contents_destroyed_); GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); bool frame_exists = !live_routes_.insert(routing_pair).second; deleted_routes_.erase(routing_pair); if (frame_exists) { CHECK(false) << "RenderFrameCreated called more than once for routing pair:" << Format(render_frame_host); } CHECK(render_frame_host->IsRenderFrameCreated()) << "RenderFrameCreated was called for a RenderFrameHost that has not been" "marked created."; CHECK(render_frame_host->GetProcess()->IsInitializedAndNotDead()) << "RenderFrameCreated was called for a RenderFrameHost whose render " "process is not currently live, so there's no way for the RenderFrame " "to have been created."; CHECK(render_frame_host->IsRenderFrameLive()) << "RenderFrameCreated called on for a RenderFrameHost that thinks it is " "not alive."; EnsureStableParentValue(render_frame_host); CHECK(!HasAnyChildren(render_frame_host)); if (render_frame_host->GetParent()) { // It should also be a current host. GlobalRoutingID parent_routing_pair = GetRoutingPair(render_frame_host->GetParent()); CHECK(current_hosts_.count(parent_routing_pair)) << "RenderFrameCreated called for a RenderFrameHost whose parent was " << "not a current RenderFrameHost. Only the current frame should be " << "spawning children."; } } void WebContentsObserverSanityChecker::RenderFrameDeleted( RenderFrameHost* render_frame_host) { CHECK(!web_contents_destroyed_); CHECK(!render_frame_host->IsRenderFrameCreated()) << "RenderFrameDeleted was called for a RenderFrameHost that is" "(still) marked as created."; CHECK(!render_frame_host->IsRenderFrameLive()) << "RenderFrameDeleted was called for a RenderFrameHost that is" "still live."; GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); bool was_live = !!live_routes_.erase(routing_pair); bool was_dead_already = !deleted_routes_.insert(routing_pair).second; if (was_dead_already) { CHECK(false) << "RenderFrameDeleted called more than once for routing pair " << Format(render_frame_host); } else if (!was_live) { CHECK(false) << "RenderFrameDeleted called for routing pair " << Format(render_frame_host) << " for which RenderFrameCreated was never called"; } EnsureStableParentValue(render_frame_host); CHECK(!HasAnyChildren(render_frame_host)); if (render_frame_host->GetParent()) AssertRenderFrameExists(render_frame_host->GetParent()); // All players should have been paused by this point. for (const auto& id : active_media_players_) CHECK_NE(id.render_frame_host, render_frame_host); } void WebContentsObserverSanityChecker::RenderFrameForInterstitialPageCreated( RenderFrameHost* render_frame_host) { // TODO(nick): Record this. } void WebContentsObserverSanityChecker::RenderFrameHostChanged( RenderFrameHost* old_host, RenderFrameHost* new_host) { CHECK(new_host); CHECK_NE(new_host, old_host); CHECK(GetRoutingPair(old_host) != GetRoutingPair(new_host)); if (old_host) { EnsureStableParentValue(old_host); CHECK_EQ(old_host->GetParent(), new_host->GetParent()); GlobalRoutingID routing_pair = GetRoutingPair(old_host); // If the navigation requires a new RFH, IsCurrent on old host should be // false. CHECK(!old_host->IsCurrent()); bool old_did_exist = !!current_hosts_.erase(routing_pair); if (!old_did_exist) { CHECK(false) << "RenderFrameHostChanged called with old host that did not exist:" << Format(old_host); } } CHECK(new_host->IsCurrent()); EnsureStableParentValue(new_host); if (new_host->GetParent()) { AssertRenderFrameExists(new_host->GetParent()); CHECK(current_hosts_.count(GetRoutingPair(new_host->GetParent()))) << "Parent of frame being committed must be current."; } GlobalRoutingID routing_pair = GetRoutingPair(new_host); bool host_exists = !current_hosts_.insert(routing_pair).second; if (host_exists) { CHECK(false) << "RenderFrameHostChanged called more than once for routing pair:" << Format(new_host); } // If |new_host| is restored from the BackForwardCache, it can contain // iframes, otherwise it has just been created and can't contain iframes for // the moment. if (!IsBackForwardCacheEnabled()) { CHECK(!HasAnyChildren(new_host)) << "A frame should not have children before it is committed."; } } void WebContentsObserverSanityChecker::FrameDeleted( RenderFrameHost* render_frame_host) { // A frame can be deleted before RenderFrame in the renderer process is // created, so there is not much that can be enforced here. CHECK(!web_contents_destroyed_); EnsureStableParentValue(render_frame_host); CHECK(!HasAnyChildren(render_frame_host)) << "All children should be deleted before a frame is detached."; GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); CHECK(current_hosts_.erase(routing_pair)) << "FrameDeleted called with a non-current RenderFrameHost."; if (render_frame_host->GetParent()) AssertRenderFrameExists(render_frame_host->GetParent()); } void WebContentsObserverSanityChecker::DidStartNavigation( NavigationHandle* navigation_handle) { CHECK(!NavigationIsOngoing(navigation_handle)); CHECK(!navigation_handle->HasCommitted()); CHECK(!navigation_handle->IsErrorPage()); CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); ongoing_navigations_.insert(navigation_handle); } void WebContentsObserverSanityChecker::DidRedirectNavigation( NavigationHandle* navigation_handle) { CHECK(NavigationIsOngoing(navigation_handle)); CHECK(navigation_handle->GetNetErrorCode() == net::OK); CHECK(!navigation_handle->HasCommitted()); CHECK(!navigation_handle->IsErrorPage()); CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); } void WebContentsObserverSanityChecker::ReadyToCommitNavigation( NavigationHandle* navigation_handle) { CHECK(NavigationIsOngoing(navigation_handle)); CHECK(!navigation_handle->HasCommitted()); CHECK(navigation_handle->GetRenderFrameHost()); CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); CHECK(navigation_handle->GetRenderFrameHost() != nullptr); ready_to_commit_hosts_.insert( std::make_pair(navigation_handle->GetNavigationId(), navigation_handle->GetRenderFrameHost())); } void WebContentsObserverSanityChecker::DidFinishNavigation( NavigationHandle* navigation_handle) { CHECK(NavigationIsOngoing(navigation_handle)); CHECK(!(navigation_handle->HasCommitted() && !navigation_handle->IsErrorPage()) || navigation_handle->GetNetErrorCode() == net::OK); CHECK_EQ(navigation_handle->GetWebContents(), web_contents()); CHECK(!navigation_handle->HasCommitted() || navigation_handle->GetRenderFrameHost() != nullptr); CHECK(!navigation_handle->HasCommitted() || navigation_handle->GetRenderFrameHost()->IsCurrent()); // If ReadyToCommitNavigation was dispatched, verify that the // |navigation_handle| has the same RenderFrameHost at this time as the one // returned at ReadyToCommitNavigation. if (base::Contains(ready_to_commit_hosts_, navigation_handle->GetNavigationId())) { CHECK_EQ(ready_to_commit_hosts_[navigation_handle->GetNavigationId()], navigation_handle->GetRenderFrameHost()); ready_to_commit_hosts_.erase(navigation_handle->GetNavigationId()); } ongoing_navigations_.erase(navigation_handle); } void WebContentsObserverSanityChecker::DocumentAvailableInMainFrame() { AssertMainFrameExists(); } void WebContentsObserverSanityChecker::DocumentOnLoadCompletedInMainFrame() { CHECK(web_contents()->IsDocumentOnLoadCompletedInMainFrame()); AssertMainFrameExists(); } void WebContentsObserverSanityChecker::DOMContentLoaded( RenderFrameHost* render_frame_host) { AssertRenderFrameExists(render_frame_host); } void WebContentsObserverSanityChecker::DidFinishLoad( RenderFrameHost* render_frame_host, const GURL& validated_url) { AssertRenderFrameExists(render_frame_host); } void WebContentsObserverSanityChecker::DidFailLoad( RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code) { AssertRenderFrameExists(render_frame_host); } void WebContentsObserverSanityChecker::DidOpenRequestedURL( WebContents* new_contents, RenderFrameHost* source_render_frame_host, const GURL& url, const Referrer& referrer, WindowOpenDisposition disposition, ui::PageTransition transition, bool started_from_context_menu, bool renderer_initiated) { AssertRenderFrameExists(source_render_frame_host); } void WebContentsObserverSanityChecker::MediaStartedPlaying( const MediaPlayerInfo& media_info, const MediaPlayerId& id) { CHECK(!web_contents_destroyed_); CHECK(!base::Contains(active_media_players_, id)); active_media_players_.push_back(id); } void WebContentsObserverSanityChecker::MediaStoppedPlaying( const MediaPlayerInfo& media_info, const MediaPlayerId& id, WebContentsObserver::MediaStoppedReason reason) { CHECK(!web_contents_destroyed_); CHECK(base::Contains(active_media_players_, id)); base::Erase(active_media_players_, id); } bool WebContentsObserverSanityChecker::OnMessageReceived( const IPC::Message& message, RenderFrameHost* render_frame_host) { CHECK(render_frame_host->IsRenderFrameLive()); AssertRenderFrameExists(render_frame_host); return false; } void WebContentsObserverSanityChecker::WebContentsDestroyed() { CHECK(!web_contents_destroyed_); web_contents_destroyed_ = true; CHECK(ongoing_navigations_.empty()); CHECK(active_media_players_.empty()); CHECK(live_routes_.empty()); } void WebContentsObserverSanityChecker::DidStartLoading() { // TODO(clamy): add checks for the loading state in the rest of observer // methods. CHECK(!is_loading_); CHECK(web_contents()->IsLoading()); is_loading_ = true; } void WebContentsObserverSanityChecker::DidStopLoading() { // TODO(crbug.com/466089): Add back CHECK(is_loading_). The CHECK was removed // because of flaky failures during browser_test shutdown. CHECK(!web_contents()->IsLoading()); is_loading_ = false; } WebContentsObserverSanityChecker::WebContentsObserverSanityChecker( WebContents* web_contents) : WebContentsObserver(web_contents), is_loading_(false), web_contents_destroyed_(false) {} WebContentsObserverSanityChecker::~WebContentsObserverSanityChecker() { CHECK(web_contents_destroyed_); CHECK(ready_to_commit_hosts_.empty()); } void WebContentsObserverSanityChecker::AssertRenderFrameExists( RenderFrameHost* render_frame_host) { CHECK(!web_contents_destroyed_); GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); bool render_frame_created_happened = live_routes_.count(routing_pair) != 0; bool render_frame_deleted_happened = deleted_routes_.count(routing_pair) != 0; CHECK(render_frame_created_happened) << "A RenderFrameHost pointer was passed to a WebContentsObserver " << "method, but WebContentsObserver::RenderFrameCreated was never called " << "for that RenderFrameHost: " << Format(render_frame_host); CHECK(!render_frame_deleted_happened) << "A RenderFrameHost pointer was passed to a WebContentsObserver " << "method, but WebContentsObserver::RenderFrameDeleted had already been " << "called on that frame:" << Format(render_frame_host); } void WebContentsObserverSanityChecker::AssertMainFrameExists() { AssertRenderFrameExists(web_contents()->GetMainFrame()); } std::string WebContentsObserverSanityChecker::Format( RenderFrameHost* render_frame_host) { return base::StringPrintf( "(%d, %d -> %s)", render_frame_host->GetProcess()->GetID(), render_frame_host->GetRoutingID(), render_frame_host->GetSiteInstance()->GetSiteURL().spec().c_str()); } bool WebContentsObserverSanityChecker::NavigationIsOngoing( NavigationHandle* navigation_handle) { auto it = ongoing_navigations_.find(navigation_handle); return it != ongoing_navigations_.end(); } void WebContentsObserverSanityChecker::EnsureStableParentValue( RenderFrameHost* render_frame_host) { GlobalRoutingID routing_pair = GetRoutingPair(render_frame_host); GlobalRoutingID parent_routing_pair = GetRoutingPair(render_frame_host->GetParent()); auto it = parent_ids_.find(routing_pair); if (it == parent_ids_.end()) { parent_ids_.insert(std::make_pair(routing_pair, parent_routing_pair)); } else { GlobalRoutingID former_parent_routing_pair = it->second; CHECK(former_parent_routing_pair == parent_routing_pair) << "RFH's parent value changed over time! That is really not good!"; } } bool WebContentsObserverSanityChecker::HasAnyChildren(RenderFrameHost* parent) { GlobalRoutingID parent_routing_pair = GetRoutingPair(parent); for (auto& entry : parent_ids_) { if (entry.second == parent_routing_pair) { if (live_routes_.count(entry.first)) return true; if (current_hosts_.count(entry.first)) return true; } } return false; } } // namespace content
{ "pile_set_name": "Github" }
<?php // $Id: Italic.php,v 1.1 2005/01/31 15:46:52 pmjones Exp $ /** * * This class implements a Text_Wiki_Parse to find source text marked for * emphasis (italics) as defined by text surrounded by two single-quotes. * On parsing, the text itself is left in place, but the starting and ending * instances of two single-quotes are replaced with tokens. * * @author Paul M. Jones <[email protected]> * * @package Text_Wiki * */ class Text_Wiki_Parse_Italic extends Text_Wiki_Parse { /** * * The regular expression used to parse the source text and find * matches conforming to this rule. Used by the parse() method. * * @access public * * @var string * * @see parse() * */ var $regex = "/''(()|[^'].*)''/U"; /** * * Generates a replacement for the matched text. Token options are: * * 'type' => ['start'|'end'] The starting or ending point of the * emphasized text. The text itself is left in the source. * * @access public * * @param array &$matches The array of matches from parse(). * * @return string A pair of delimited tokens to be used as a * placeholder in the source text surrounding the text to be * emphasized. * */ function process(&$matches) { $start = $this->wiki->addToken( $this->rule, array('type' => 'start') ); $end = $this->wiki->addToken( $this->rule, array('type' => 'end') ); return $start . $matches[1] . $end; } } ?>
{ "pile_set_name": "Github" }
from flask import Blueprint, render_template, redirect from user_management import check_logged_in from device_info import * import subprocess import re import os mynode_caravan = Blueprint('mynode_caravan',__name__) ### Page functions @mynode_caravan.route("/caravan") def caravan_page(): check_logged_in() # Load page templateData = { "title": "myNode Caravan", "local_ip": get_local_ip(), "ui_settings": read_ui_settings() } return render_template('caravan.html', **templateData)
{ "pile_set_name": "Github" }
// +build !notfastpath // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved. // Use of this source code is governed by a MIT license found in the LICENSE file. // ************************************************************ // DO NOT EDIT. // THIS FILE IS AUTO-GENERATED from fast-path.go.tmpl // ************************************************************ package codec // Fast path functions try to create a fast path encode or decode implementation // for common maps and slices. // // We define the functions and register then in this single file // so as not to pollute the encode.go and decode.go, and create a dependency in there. // This file can be omitted without causing a build failure. // // The advantage of fast paths is: // - Many calls bypass reflection altogether // // Currently support // - slice of all builtin types, // - map of all builtin types to string or interface value // - symetrical maps of all builtin types (e.g. str-str, uint8-uint8) // This should provide adequate "typical" implementations. // // Note that fast track decode functions must handle values for which an address cannot be obtained. // For example: // m2 := map[string]int{} // p2 := []interface{}{m2} // // decoding into p2 will bomb if fast track functions do not treat like unaddressable. // import ( "reflect" "sort" ) const fastpathCheckNilFalse = false // for reflect const fastpathCheckNilTrue = true // for type switch type fastpathT struct {} var fastpathTV fastpathT type fastpathE struct { rtid uintptr rt reflect.Type encfn func(*encFnInfo, reflect.Value) decfn func(*decFnInfo, reflect.Value) } type fastpathA [{{ .FastpathLen }}]fastpathE func (x *fastpathA) index(rtid uintptr) int { // use binary search to grab the index (adapted from sort/search.go) h, i, j := 0, 0, {{ .FastpathLen }} // len(x) for i < j { h = i + (j-i)/2 if x[h].rtid < rtid { i = h + 1 } else { j = h } } if i < {{ .FastpathLen }} && x[i].rtid == rtid { return i } return -1 } type fastpathAslice []fastpathE func (x fastpathAslice) Len() int { return len(x) } func (x fastpathAslice) Less(i, j int) bool { return x[i].rtid < x[j].rtid } func (x fastpathAslice) Swap(i, j int) { x[i], x[j] = x[j], x[i] } var fastpathAV fastpathA // due to possible initialization loop error, make fastpath in an init() func init() { if !fastpathEnabled { return } i := 0 fn := func(v interface{}, fe func(*encFnInfo, reflect.Value), fd func(*decFnInfo, reflect.Value)) (f fastpathE) { xrt := reflect.TypeOf(v) xptr := reflect.ValueOf(xrt).Pointer() fastpathAV[i] = fastpathE{xptr, xrt, fe, fd} i++ return } {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} fn([]{{ .Elem }}(nil), (*encFnInfo).{{ .MethodNamePfx "fastpathEnc" false }}R, (*decFnInfo).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}} {{range .Values}}{{if not .Primitive}}{{if .MapKey }} fn(map[{{ .MapKey }}]{{ .Elem }}(nil), (*encFnInfo).{{ .MethodNamePfx "fastpathEnc" false }}R, (*decFnInfo).{{ .MethodNamePfx "fastpathDec" false }}R){{end}}{{end}}{{end}} sort.Sort(fastpathAslice(fastpathAV[:])) } // -- encode // -- -- fast path type switch func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { if !fastpathEnabled { return false } switch v := iv.(type) { {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} case []{{ .Elem }}:{{else}} case map[{{ .MapKey }}]{{ .Elem }}:{{end}} fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e){{if not .MapKey }} case *[]{{ .Elem }}:{{else}} case *map[{{ .MapKey }}]{{ .Elem }}:{{end}} fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) {{end}}{{end}} default: _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true } func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { if !fastpathEnabled { return false } switch v := iv.(type) { {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} case []{{ .Elem }}: fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e) case *[]{{ .Elem }}: fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) {{end}}{{end}}{{end}} default: _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true } func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { if !fastpathEnabled { return false } switch v := iv.(type) { {{range .Values}}{{if not .Primitive}}{{if .MapKey }} case map[{{ .MapKey }}]{{ .Elem }}: fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, fastpathCheckNilTrue, e) case *map[{{ .MapKey }}]{{ .Elem }}: fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, fastpathCheckNilTrue, e) {{end}}{{end}}{{end}} default: _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true } // -- -- fast path functions {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} func (f *encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) { if f.ti.mbs { fastpathTV.{{ .MethodNamePfx "EncAsMap" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e) } else { fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e) } } func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) { ee := e.e cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeArrayStart(len(v)) for _, v2 := range v { if cr != nil { cr.sendContainerState(containerArrayElem) } {{ encmd .Elem "v2"}} } if cr != nil { cr.sendContainerState(containerArrayEnd) }{{/* ee.EncodeEnd() */}} } func (_ fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) { ee := e.e cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } if len(v)%2 == 1 { e.errorf("mapBySlice requires even slice length, but got %v", len(v)) return } ee.EncodeMapStart(len(v) / 2) for j, v2 := range v { if cr != nil { if j%2 == 0 { cr.sendContainerState(containerMapKey) } else { cr.sendContainerState(containerMapValue) } } {{ encmd .Elem "v2"}} } if cr != nil { cr.sendContainerState(containerMapEnd) } } {{end}}{{end}}{{end}} {{range .Values}}{{if not .Primitive}}{{if .MapKey }} func (f *encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) { fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv.Interface().(map[{{ .MapKey }}]{{ .Elem }}), fastpathCheckNilFalse, f.e) } func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, e *Encoder) { ee := e.e cr := e.cr if checkNil && v == nil { ee.EncodeNil() return } ee.EncodeMapStart(len(v)) {{if eq .MapKey "string"}}asSymbols := e.h.AsSymbols&AsSymbolMapStringKeysFlag != 0 {{end}}if e.h.Canonical { {{if eq .MapKey "interface{}"}}{{/* out of band */}}var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding e2 := NewEncoderBytes(&mksv, e.hh) v2 := make([]bytesI, len(v)) var i, l int var vp *bytesI {{/* put loop variables outside. seems currently needed for better perf */}} for k2, _ := range v { l = len(mksv) e2.MustEncode(k2) vp = &v2[i] vp.v = mksv[l:] vp.i = k2 i++ } sort.Sort(bytesISlice(v2)) for j := range v2 { if cr != nil { cr.sendContainerState(containerMapKey) } e.asis(v2[j].v) if cr != nil { cr.sendContainerState(containerMapValue) } e.encode(v[v2[j].i]) } {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v)) var i int for k, _ := range v { v2[i] = {{ $x }}(k) i++ } sort.Sort({{ sorttype .MapKey false}}(v2)) for _, k2 := range v2 { if cr != nil { cr.sendContainerState(containerMapKey) } {{if eq .MapKey "string"}}if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) }{{else}}{{ $y := printf "%s(k2)" .MapKey }}{{ encmd .MapKey $y }}{{end}} if cr != nil { cr.sendContainerState(containerMapValue) } {{ $y := printf "v[%s(k2)]" .MapKey }}{{ encmd .Elem $y }} } {{end}} } else { for k2, v2 := range v { if cr != nil { cr.sendContainerState(containerMapKey) } {{if eq .MapKey "string"}}if asSymbols { ee.EncodeSymbol(k2) } else { ee.EncodeString(c_UTF8, k2) }{{else}}{{ encmd .MapKey "k2"}}{{end}} if cr != nil { cr.sendContainerState(containerMapValue) } {{ encmd .Elem "v2"}} } } if cr != nil { cr.sendContainerState(containerMapEnd) }{{/* ee.EncodeEnd() */}} } {{end}}{{end}}{{end}} // -- decode // -- -- fast path type switch func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { if !fastpathEnabled { return false } switch v := iv.(type) { {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} case []{{ .Elem }}:{{else}} case map[{{ .MapKey }}]{{ .Elem }}:{{end}} fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, d){{if not .MapKey }} case *[]{{ .Elem }}:{{else}} case *map[{{ .MapKey }}]{{ .Elem }}:{{end}} v2, changed2 := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*v, fastpathCheckNilFalse, true, d) if changed2 { *v = v2 } {{end}}{{end}} default: _ = v // TODO: workaround https://github.com/golang/go/issues/12927 (remove after go 1.6 release) return false } return true } // -- -- fast path functions {{range .Values}}{{if not .Primitive}}{{if not .MapKey }} {{/* Slices can change if they - did not come from an array - are addressable (from a ptr) - are settable (e.g. contained in an interface{}) */}} func (f *decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) { array := f.seq == seqTypeArray if !array && rv.CanAddr() { {{/* // CanSet => CanAddr + Exported */}} vp := rv.Addr().Interface().(*[]{{ .Elem }}) v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, fastpathCheckNilFalse, !array, f.d) if changed { *vp = v } } else { v := rv.Interface().([]{{ .Elem }}) fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, f.d) } } func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *[]{{ .Elem }}, checkNil bool, d *Decoder) { v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, checkNil, true, d) if changed { *vp = v } } func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v []{{ .Elem }}, checkNil bool, canChange bool, d *Decoder) (_ []{{ .Elem }}, changed bool) { dd := d.d {{/* // if dd.isContainerType(valueTypeNil) { dd.TryDecodeAsNil() */}} if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true } return nil, changed } slh, containerLenS := d.decSliceHelperStart() if containerLenS == 0 { if canChange { if v == nil { v = []{{ .Elem }}{} } else if len(v) != 0 { v = v[:0] } changed = true } slh.End() return v, changed } if containerLenS > 0 { x2read := containerLenS var xtrunc bool if containerLenS > cap(v) { if canChange { {{/* // fast-path is for "basic" immutable types, so no need to copy them over // s := make([]{{ .Elem }}, decInferLen(containerLenS, d.h.MaxInitLen)) // copy(s, v[:cap(v)]) // v = s */}} var xlen int xlen, xtrunc = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) if xtrunc { if xlen <= cap(v) { v = v[:xlen] } else { v = make([]{{ .Elem }}, xlen) } } else { v = make([]{{ .Elem }}, xlen) } changed = true } else { d.arrayCannotExpand(len(v), containerLenS) } x2read = len(v) } else if containerLenS != len(v) { if canChange { v = v[:containerLenS] changed = true } } {{/* // all checks done. cannot go past len. */}} j := 0 for ; j < x2read; j++ { slh.ElemContainerState(j) {{ if eq .Elem "interface{}" }}d.decode(&v[j]){{ else }}v[j] = {{ decmd .Elem }}{{ end }} } if xtrunc { {{/* // means canChange=true, changed=true already. */}} for ; j < containerLenS; j++ { v = append(v, {{ zerocmd .Elem }}) slh.ElemContainerState(j) {{ if eq .Elem "interface{}" }}d.decode(&v[j]){{ else }}v[j] = {{ decmd .Elem }}{{ end }} } } else if !canChange { for ; j < containerLenS; j++ { slh.ElemContainerState(j) d.swallow() } } } else { breakFound := dd.CheckBreak() {{/* check break first, so we can initialize v with a capacity of 4 if necessary */}} if breakFound { if canChange { if v == nil { v = []{{ .Elem }}{} } else if len(v) != 0 { v = v[:0] } changed = true } slh.End() return v, changed } if cap(v) == 0 { v = make([]{{ .Elem }}, 1, 4) changed = true } j := 0 for ; !breakFound; j++ { if j >= len(v) { if canChange { v = append(v, {{ zerocmd .Elem }}) changed = true } else { d.arrayCannotExpand(len(v), j+1) } } slh.ElemContainerState(j) if j < len(v) { {{/* // all checks done. cannot go past len. */}} {{ if eq .Elem "interface{}" }}d.decode(&v[j]) {{ else }}v[j] = {{ decmd .Elem }}{{ end }} } else { d.swallow() } breakFound = dd.CheckBreak() } if canChange && j < len(v) { v = v[:j] changed = true } } slh.End() return v, changed } {{end}}{{end}}{{end}} {{range .Values}}{{if not .Primitive}}{{if .MapKey }} {{/* Maps can change if they are - addressable (from a ptr) - settable (e.g. contained in an interface{}) */}} func (f *decFnInfo) {{ .MethodNamePfx "fastpathDec" false }}R(rv reflect.Value) { if rv.CanAddr() { vp := rv.Addr().Interface().(*map[{{ .MapKey }}]{{ .Elem }}) v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}V(*vp, fastpathCheckNilFalse, true, f.d) if changed { *vp = v } } else { v := rv.Interface().(map[{{ .MapKey }}]{{ .Elem }}) fastpathTV.{{ .MethodNamePfx "Dec" false }}V(v, fastpathCheckNilFalse, false, f.d) } } func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, d *Decoder) { v, changed := f.{{ .MethodNamePfx "Dec" false }}V(*vp, checkNil, true, d) if changed { *vp = v } } func (_ fastpathT) {{ .MethodNamePfx "Dec" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, checkNil bool, canChange bool, d *Decoder) (_ map[{{ .MapKey }}]{{ .Elem }}, changed bool) { dd := d.d cr := d.cr {{/* // if dd.isContainerType(valueTypeNil) {dd.TryDecodeAsNil() */}} if checkNil && dd.TryDecodeAsNil() { if v != nil { changed = true } return nil, changed } containerLen := dd.ReadMapStart() if canChange && v == nil { xlen, _ := decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }}) v = make(map[{{ .MapKey }}]{{ .Elem }}, xlen) changed = true } {{ if eq .Elem "interface{}" }}mapGet := !d.h.MapValueReset && !d.h.InterfaceReset{{end}} var mk {{ .MapKey }} var mv {{ .Elem }} if containerLen > 0 { for j := 0; j < containerLen; j++ { if cr != nil { cr.sendContainerState(containerMapKey) } {{ if eq .MapKey "interface{}" }}mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}} }{{ else }}mk = {{ decmd .MapKey }}{{ end }} if cr != nil { cr.sendContainerState(containerMapValue) } {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil } d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }} if v != nil { v[mk] = mv } } } else if containerLen < 0 { for j := 0; !dd.CheckBreak(); j++ { if cr != nil { cr.sendContainerState(containerMapKey) } {{ if eq .MapKey "interface{}" }}mk = nil d.decode(&mk) if bv, bok := mk.([]byte); bok { mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}} }{{ else }}mk = {{ decmd .MapKey }}{{ end }} if cr != nil { cr.sendContainerState(containerMapValue) } {{ if eq .Elem "interface{}" }}if mapGet { mv = v[mk] } else { mv = nil } d.decode(&mv){{ else }}mv = {{ decmd .Elem }}{{ end }} if v != nil { v[mk] = mv } } } if cr != nil { cr.sendContainerState(containerMapEnd) } return v, changed } {{end}}{{end}}{{end}}
{ "pile_set_name": "Github" }
"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var React = _interopRequireWildcard(require("react")); var _RedEnvelopeTwoTone = _interopRequireDefault(require("@ant-design/icons-svg/lib/asn/RedEnvelopeTwoTone")); var _AntdIcon = _interopRequireDefault(require("../components/AntdIcon")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } // GENERATE BY ./scripts/generate.ts // DON NOT EDIT IT MANUALLY var RedEnvelopeTwoTone = function RedEnvelopeTwoTone(props, ref) { return React.createElement(_AntdIcon.default, Object.assign({}, props, { ref: ref, icon: _RedEnvelopeTwoTone.default })); }; RedEnvelopeTwoTone.displayName = 'RedEnvelopeTwoTone'; var _default = React.forwardRef(RedEnvelopeTwoTone); exports.default = _default;
{ "pile_set_name": "Github" }
--- layout: default title: Training an audio keyword spotter with PyTorch permalink: /tutorials/Training-audio-keyword-spotter-with-pytorch/ --- # Training an audio keyword spotter with PyTorch *by Chris Lovett* This tutorial will show you how to train a keyword spotter using PyTorch. A keyword spotter listens to an audio stream from a microphone and recognizes certain spoken keywords. Since it is always listening there is good reason to find a keyword spotter that can run on a very small low-power co-processor so the main computer can sleep until a word is recognized. The ELL compiler makes that possible. In this tutorial you will train a keyword spotter using the the [speech commands dataset](http://download.tensorflow.org/data/speech_commands_v0.01.tar.gz) which contains 65,000 recordings of 30 different keywords (_bed, bird, cat, dog, down, eight, five, four, go, happy, house, left, marvin, nine, no, off, on, one, right, seven, sheila, six, stop, three, tree, two, up, wow, yes, zero_) each about one second long. This is the dataset used to train the models in the [speech commands model gallery](/ELL/gallery/speech_commands_v0.01/). The [Getting started with keyword spotting on the Raspberry Pi](/ELL/tutorials/Getting-started-with-audio-keyword-spotting-on-the-Raspberry-Pi/) tutorial uses these models. Once you learn how to train a model you can then train your own custom model that responds to different keywords, or even random sounds, or perhaps you want just a subset of the 30 keywords for your application. This tutorial shows you how to do that. ## Before you begin Complete the following steps before starting the tutorial. * Install ELL on your computer ([Windows](https://github.com/Microsoft/ELL/blob/master/INSTALL-Windows.md), [Ubuntu Linux](https://github.com/Microsoft/ELL/blob/master/INSTALL-Ubuntu.md), [macOS](https://github.com/Microsoft/ELL/blob/master/INSTALL-Mac.md)). ## What you will need * Laptop or desktop computer with at least 16 GB of RAM. * Optional NVidia Graphics Card that supports CUDA. You will get great results with a [GTX 1080](https://www.nvidia.com/en-us/geforce/products/10series/geforce-gtx-1080/) which is commonly used for training neural networks. * The NVidia CUDA 10.0 SDK from [https://developer.nvidia.com/cuda-downloads](https://developer.nvidia.com/cuda-downloads). ## Overview The picture below illustrates the process you will follow in this tutorial. First you will convert the wav files into a big training dataset using a featurizer. This dataset is the input to the training process which outputs a trained keyword spotter. The keyword spotter can then be verified by testing. ![process](process.jpg) Training a Neural Network is a computationally intensive task that takes millions or even billions of floating point operations. That is why you probably want to use CUDA accelerated training. Fortunately, audio models train pretty quickly. On an NVidia 1080 graphic card the 30 keyword speech_commands dataset trains in about 3 minutes using PyTorch. Without CUDA the same training takes over 2.5 hours on an Intel Core i7 CPU. ## ELL Root After you have installed and built the ELL compiler, you also need to set an environment variable named ELL_ROOT that points to the location of your ELL git repo, for example: ``` [Linux] export ELL_ROOT="~/git/ell" [Windows] set ELL_ROOT=d:\git\ell ``` Subsequent scripts depend on this path being set correctly. Now make a new working folder: ```shell mkdir tutorial cd tutorial ``` ## Installing PyTorch Installing PyTorch with CUDA is easy to do using your Conda environment. If you don't have a Conda environment, see the ELL setup instructions ([Windows](https://github.com/Microsoft/ELL/blob/master/INSTALL-Windows.md), [Ubuntu Linux](https://github.com/Microsoft/ELL/blob/master/INSTALL-Ubuntu.md), [macOS](https://github.com/Microsoft/ELL/blob/master/INSTALL-Mac.md)). You may want to create a new Conda environment for PyTorch training, or you can add PyTorch to your existing one. You can create a new environment easily with this command: ```shell conda create -n torch python=3.6 ``` Activate it ```shell [Linux] source activate torch [Windows] activate torch ``` Then follow the PyTorch setup instructions for Anaconda and your version of CUDA as described on this page: [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/). ## Installing pyaudio This tutorial uses `pyaudio` which can be installed using: ``` [Linux] sudo apt-get install python-pyaudio python3-pyaudio && pip install pyaudio [Windows] pip install pyaudio [macOS] brew install portaudio && pip install pyaudio ``` ## Helper Python Code This tutorial uses python scripts located in your ELL git repo under `tools/utilities/pythonlibs/audio` and `tools/utilities/pythonlibs/audio/training`. When you see a python script referenced below like `make_training_list.py`, just prefix that with the full path to that script your ELL git repo. ## Downloading the Training Data Next, you will need to download the training data set: * [Speech Commands Dataset](http://download.tensorflow.org/data/speech_commands_v0.01.tar.gz) (1.4 gigabytes) Google crowd sourced the creation of these recordings so you get a nice variety of voices. Google released it under the [Creative Commons BY 4.0 license](https://creativecommons.org/licenses/by/4.0/). Go ahead and download that file and move it into a folder named `audio` then unpack it using this Linux command: ```shell tar xvf speech_commands_v0.01.tar.gz ``` On Windows you can use the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to do the same. Alternatively, you can install [7-zip](https://www.7-zip.org/download.html). 7-zip will install a new menu item so you can right click the `speech_commands_v0.01.tar.gz` and select "Extract here". The total disk space required for the uncompressed files is about 2 GB. When complete your `audio` folder should contain 30 folders plus one named _background\_noise_. You should also see the following additional files: * validation_list.txt - the list of files that make up the validation set * testing_list.txt - the list of files in the testing set Lastly, you will need to create the **training_list.txt** file containing all the wav files (minus the validation and test sets) which you can do with this command: ```shell python make_training_list.py --wav_files audio --max_files_per_directory 1600 copy audio\categories.txt . ``` Where `audio` is the path to your unpacked speech command wav files. This will also create a **categories.txt** file in the same folder. This file lists the names of the keywords (directories) found in the audio folder. Copy that file to your working tutorial folder. Note that the command line above includes the option `--max_files_per_directory 1600`. This options limits the training list to a maximum of 1600 files per subdirectory and will result in a training dataset of around 1.2 GB (using the make_dataset command line options shown below). Feel free to try other numbers here or remove the limit entirely to use every available file for training. You will notice there are not exactly the same number of training files in each subdirectory, but that is ok. Without any limits the full speech_commands training dataset file will be about 1.6 GB and the **make_training_list.py** script may use up to 6 gb RAM to get the job done. As you can see you can try different sized training datasets. When you are ready to experiment, figure out which gives the best results, all the training files, or a subset. ## Create a Featurizer Model As shown in the [earlier tutorial](/ELL/tutorials/Getting-started-with-audio-keyword-classification-on-the-Raspberry-Pi/) the featurizer model is a [mel-frequency cepstrum](https://en.wikipedia.org/wiki/Mel-frequency_cepstrum) (mfcc) audio transformer which preprocesses audio input, preparing it for use by the training process. This featurizer is created as an ELL model using the `make_featurizer` command: ``` python make_featurizer.py --sample_rate 16000 --window_size 512 --input_buffer_size 512 --hamming_window --filterbank_type mel --filterbank_size 80 --filterbank_nfft 512 --nfft 512 --log --auto_scale ``` The reason for the `--sample_rate 16000` argument is that small low powered target devices might not be able to record and process audio at very high rates. So while your host PC can probably do 96kHz audio and higher just fine, this tutorial shows you how to down sample the audio to something that will run on a tiny target device. The main point being that you will get the best results if you train the model on audio that is sampled at the same rate that your target device will be recording. The `--auto_scale` option converts raw integer audio values to floating point numbers in the range [-1, 1]. You should see a message saying "Saving **featurizer.ell**" and if you print this using the following command line: ```shell [Linux] $ELL_ROOT/build/bin/print -imap featurizer.ell [Windows] %ELL_ROOT%\build\bin\release\print -imap featurizer.ell -fmt dgml -of graph.dgml ``` then you will see the following nodes: ![featurizer](featurizer.png) You can now compile this model using the ELL model compiler to run on your PC using the familiar `wrap` command: ``` [Windows] python %ELL_ROOT%\tools\wrap\wrap.py --model_file featurizer.ell --outdir compiled_featurizer --module_name mfcc [Linux] python $ELL_ROOT/tools/wrap/wrap.py --model_file featurizer.ell --outdir compiled_featurizer --module_name mfcc ``` Then you can build the **compiled_featurizer** folder using cmake as done in prior tutorials. You will do this a lot so it might be handy to create a little batch or shell script called `makeit` that contains the following: **Windows**: ```batch mkdir build cd build cmake -G "Visual Studio 16 2019" -A x64 .. cmake --build . --config Release cd .. ``` **Linux**: ```shell #!/bin/bash mkdir build cd build cmake .. make cd .. ``` So compiling a wrapped ELL model is now this simple: ```shell pushd compiled_featurizer makeit popd ``` ## Create the Dataset using the Featurizer Now you have a compiled featurizer, so you can preprocess all the audio files using this featurizer and create a compressed numpy dataset with the result. This large dataset will contain one row per audio file, where each row contains all the featurizer output for that file. The featurizer output is smaller than the raw audio, but it will still end up being a pretty big file, (about 1.2 GB). Of course it depends how many files you include in the set. Remember for best training results the more files the better, so you will use the **training_list.txt** you created earlier which selected 1600 files per keyword. You need three datasets created from each of the list files in your audio folder using `make_dataset` as follows: ```shell python make_dataset.py --list_file audio/training_list.txt --featurizer compiled_featurizer/mfcc --window_size 40 --shift 40 python make_dataset.py --list_file audio/validation_list.txt --featurizer compiled_featurizer/mfcc --window_size 40 --shift 40 python make_dataset.py --list_file audio/testing_list.txt --featurizer compiled_featurizer/mfcc --window_size 40 --shift 40 ``` Where the **audio** folder contains your unpacked .wav files. If your audio files are in a different location then simply provide the full path to it in the above commands. Creating the datasets will take a while, about 10 minutes or more, so now is a great time to grab a cup of tea. It will produce three files in your working folder named **training.npz**, **validation.npz** and **testing.npz** which you will use below. Note that make_training_list.py skipped the _background_noise folder. But make_dataset.py has options to use that background noise to randomly mix in with each training word. By default make_dataset.py does not do that. But you can experiment with this and see if it helps or not. ## Train the Keyword Spotter You can now finally train the keyword spotter using the `train_classifier` script: ```shell python train_classifier.py --architecture GRU --num_layers 2 --dataset . --use_gpu --outdir . ``` This script will use PyTorch to train a GRU based model using the datasets you created earlier then it will export an onnx model from that. The file will be named **KeywordSpotter.onnx** and if all goes well you should see console output like this: ``` Loading .\testing_list.npz... Loaded dataset testing_list.npz and found sample rate 16000, audio_size 512, input_size 80, window_size 40 and shift 40 Loading .\training_list.npz... Loaded dataset training_list.npz and found sample rate 16000, audio_size 512, input_size 80, window_size 40 and shift 40 Loading .\validation_list.npz... Loaded dataset validation_list.npz and found sample rate 16000, audio_size 512, input_size 80, window_size 40 and shift 40 Training model GRU128KeywordSpotter.pt Training 2 layer GRU 128 using 46256 rows of featurized training input... RMSprop ( Parameter Group 0 alpha: 0 centered: False eps: 1e-08 lr: 0.001 momentum: 0 weight_decay: 1e-05 ) Epoch 0, Loss 1.624, Validation Accuracy 48.340, Learning Rate 0.001 Epoch 1, Loss 0.669, Validation Accuracy 78.581, Learning Rate 0.001 Epoch 2, Loss 0.538, Validation Accuracy 88.623, Learning Rate 0.001 Epoch 3, Loss 0.334, Validation Accuracy 91.423, Learning Rate 0.001 Epoch 4, Loss 0.274, Validation Accuracy 92.041, Learning Rate 0.001 Epoch 5, Loss 0.196, Validation Accuracy 93.945, Learning Rate 0.001 Epoch 6, Loss 0.322, Validation Accuracy 93.652, Learning Rate 0.001 Epoch 7, Loss 0.111, Validation Accuracy 94.548, Learning Rate 0.001 Epoch 8, Loss 0.146, Validation Accuracy 95.296, Learning Rate 0.001 Epoch 9, Loss 0.109, Validation Accuracy 95.052, Learning Rate 0.001 Epoch 10, Loss 0.115, Validation Accuracy 95.492, Learning Rate 0.001 Epoch 11, Loss 0.116, Validation Accuracy 95.931, Learning Rate 0.001 Epoch 12, Loss 0.064, Validation Accuracy 95.866, Learning Rate 0.001 Epoch 13, Loss 0.159, Validation Accuracy 95.736, Learning Rate 0.001 Epoch 14, Loss 0.083, Validation Accuracy 95.898, Learning Rate 0.001 Epoch 15, Loss 0.094, Validation Accuracy 96.484, Learning Rate 0.001 Epoch 16, Loss 0.056, Validation Accuracy 95.801, Learning Rate 0.001 Epoch 17, Loss 0.096, Validation Accuracy 95.964, Learning Rate 0.001 Epoch 18, Loss 0.019, Validation Accuracy 96.305, Learning Rate 0.001 Epoch 19, Loss 0.140, Validation Accuracy 96.501, Learning Rate 0.001 Epoch 20, Loss 0.057, Validation Accuracy 96.094, Learning Rate 0.001 Epoch 21, Loss 0.025, Validation Accuracy 96.289, Learning Rate 0.001 Epoch 22, Loss 0.037, Validation Accuracy 95.947, Learning Rate 0.001 Epoch 23, Loss 0.008, Validation Accuracy 96.191, Learning Rate 0.001 Epoch 24, Loss 0.050, Validation Accuracy 96.419, Learning Rate 0.001 Epoch 25, Loss 0.010, Validation Accuracy 96.257, Learning Rate 0.001 Epoch 26, Loss 0.014, Validation Accuracy 96.712, Learning Rate 0.001 Epoch 27, Loss 0.044, Validation Accuracy 96.159, Learning Rate 0.001 Epoch 28, Loss 0.011, Validation Accuracy 96.289, Learning Rate 0.001 Epoch 29, Loss 0.029, Validation Accuracy 96.143, Learning Rate 0.001 Trained in 299.81 seconds Training accuracy = 99.307 % Evaluating GRU keyword spotter using 6573 rows of featurized test audio... Saving evaluation results in '.\results.txt' Testing accuracy = 93.673 % saving onnx file: GRU128KeywordSpotter.onnx ``` So here you see the model has trained well and is getting an evaluation score of 93.673% using the **testing_list.npz** dataset. The testing_list contains files that the training_list never saw before so it is expected that the test score will always be lower than the final training accuracy (99.307%). The real trick is increasing that test score. This problem has many data scientists employed around the world! ## Importing the ONNX Model In order to try your new model using ELL, you first need to import it from ONNX into the ELL format as follows: ``` [Linux] python $ELL_ROOT/tools/importers/onnx/onnx_import.py GRU128KeywordSpotter.onnx [Windows] python %ELL_ROOT%\tools\importers\onnx\onnx_import.py GRU128KeywordSpotter.onnx ``` This will generate an ELL model named **GRU128KeywordSpotter.ell** which you can now compile using similar technique you used on the featurizer: ``` [Linux] python $ELL_ROOT%/tools/wrap/wrap.py --model_file GRU128KeywordSpotter.ell --outdir KeywordSpotter --module_name model [Windows] python %ELL_ROOT%\tools\wrap\wrap.py --model_file GRU128KeywordSpotter.ell --outdir KeywordSpotter --module_name model ``` then compile the resulting KeywordSpotter project using your new `makeit` command: ```shell pushd KeywordSpotter makeit popd ``` ## Testing the Model So you can now take the new compiled keyword spotter for a spin and see how it works. You can measure the accuracy of the ELL model using the testing list. The `test_ell_model.py` script will do that: ```shell python test_ell_model.py --classifier KeywordSpotter/model --featurizer compiled_featurizer/mfcc --sample_rate 16000 --list_file audio/testing_list.txt --categories categories.txt --reset --auto_scale ``` This is going back to the raw .wav file input and refeaturizing each .wav file using the compiled featurizer, processing each file in random order. This is similar to what you will do on your target device while processing microphone input. As a result this test pass will take a little longer (about 2 minutes). You will see every file scroll by telling you which one passed or failed with a running pass rate. The last page of output should look something like this: ``` ... Saving 'results.json' Test completed in 157.65 seconds 6090 passed, 483 failed, pass rate of 92.65 % Best prediction time was 0.0 seconds ``` The final pass rate printed here is 92.65% which is close to the pytorch test accuracy of 93.673%. But how will this model perform on a continuous stream of audio from a microphone? You can try this out using the following tool: ``` [Linux] python $ELL_ROOT/tools/utilities/pythonlibs/audio/view_audio.py --classifier KeywordSpotter\model --featurizer compiled_featurizer/mfcc --categories categories.txt --sample_rate 16000 --threshold 0.8 --auto_scale [Windows] python %ELL_ROOT%\tools\utilities\pythonlibs\audio\view_audio.py --classifier KeywordSpotter\model --featurizer compiled_featurizer/mfcc --categories categories.txt --sample_rate 16000 --threshold 0.8 --auto_scale ``` Speak some words from `categories.txt` slowly and clearly. You will find that the accuracy is not as good, it recoginizes the first word you speak, but nothing else. If you run the `test_ell_model.py` script without "--reset" argument then the test is run as one continuous steam of audio with no model reset between each .wav file. In this case you will see the test score drop to about 70%. So why is this? Well, remember the trainer has one row per wav recording and this helps the trainer know when to reset the GRU node hidden state. See the **init_hidden** method. But in live audio how do you know when one word stops and another starts? Sometimes spoken words blur together. How does ELL then know when to reset the GRU nodes hidden state? By default ELL does not reset the hidden state so the GRU state blurs together over time and gets confused especially if there is no clear silence between consecutive words. So how can you fix this? Well, this is where Voice Activity Detection (VAD) can come in handy. ELL actually has a node called VoiceActivityDetectorNode that you can add to the model. The input is the same featurizer input that the classifier uses, and the output is an integer value 0 if there is no activity detected and 1 if there is activity. This output signal can then be piped into the GRU nodes as a "reset_trigger". The GRU nodes will then reset themselves when they see that trigger change from 1 to 0 (the end of a word). To enable this you will need to edit the ELL **GRU128KeywordSpotter.ell** file using the `add_vad.py` script: ``` python add_vad.py GRU128KeywordSpotter.ell --sample_rate 16000 --window_size 512 --tau_up 1.5 --tau_down 0.09 --large_input 4 --gain_att 0.01 --threshold_up 3.5 --threshold_down 0.9 --level_threshold 0.02 ``` This will edit the ELL model, remove the dummy reset triggers on the two GRU nodes and replace them with a VoiceActivityDetectorNode. Your new GRU128KeywordSpotter.ell should now look like this: ![graph](GRUKeywordSpotter.png) **Note:** you can use the following tool to generate these graphs: ``` [Linux] $ELL_ROOT/build/bin/release/print -imap GRU128KeywordSpotter.ell -fmt dot -of graph.dot [Windows] %ELL_ROOT%\build\bin\release\print -imap GRU128KeywordSpotter.ell -fmt dgml -of graph.dgml ``` And you can view graph.dgml using Visual Studio. On Linux you can use the `dot` format which can be viewed using GraphViz. You can now compile this new GRU128KeywordSpotter.ell model using `wrap.py` as before and try it out. You should see the `test_ell_model` accuracy increase back up from 70% to about 85%. The VoiceActivityDetector is not perfect on all the audio test samples, especially those with high background noise. The VoiceActivityDetector has many parameters that you can see in `add_vad.py`. These parameters can be tuned for your particular device to get the best result. You can use the `<ELL_ROOT>/tools/utilities/pythonlibs/audio/vad_test.py` tool to help with that. You can also use the `view_audio.py` script again and see how it behaves when you speak the 30 different keywords listed in categories.txt. You should notice that it works better now because of the VoiceActivityDetection whereas previously you had to click "stop" and "record" to reset the model. Now it resets automatically and is able to recognize the next keyword after a small silence. You still cannot speak the keywords too quickly, so this solution is not perfect. Understanding full conversation speech is a different kind of problem that requires bigger models and audio datasets that include whole phrases. ## VAD Tuning The add_vad.py script takes many parameters that you may need to tune for your particular microphone. To do this use the following tool: ``` tools/utilities/pythonlibs/audio/vad_test.py ``` This tool takes the featurizer.ell and generates vad.ell models matching the given parameters you provide in the dialog, and it will test that on a given wav file. So record wav files off the STM32F469-disco of you speaking a few words (in a quiet place) and run them, then calibrate the vad.ell model parameters until the vad output detects words and silence correctly. You are done when the graph looks like this. You may also need to configure the microphone gain on your device. Specifically you should see the Orange VAD signal nicely frame each word spoken. ![vad](vad.png) Use `--help` on the `add_vad.py` command line to see what each parameter means. ## Experimenting The `train_classifier.py` script has a number of other options you can play with including number of epochs, batch_size, learning_rate, and the number of hidden_units to use in the GRU layers. Note that training also has an element of randomness to it, so you will never see the exact same numbers even when you retrain with the exact same parameters. This is due to the Stochastic Gradient Descent algorithm that is used by the trainer. The neural network you just trained is described by the KeywordSpotter class in the `train_classifier.py` script. You can see the **\_\_init\_\_** method of the GRU128KeywordSpotter class creating two GRU nodes and a Linear layer which are used by the **forward** method as follows: ```python def forward(self, input): # input has shape: [seq,batch,feature] gru_out, self.hidden1 = self.gru1(input, self.hidden1) gru_out, self.hidden2 = self.gru2(gru_out, self.hidden2) keyword_space = self.hidden2keyword(gru_out) result = F.log_softmax(keyword_space, dim=2) # return the mean across the sequence length to produce the # best prediction of which word it found in that sequence. # we can do that because we know each window_size sequence in # the training dataset contains at most one word and a single # word is not spread across multiple training rows result = result.mean(dim=0) return result ``` You can now experiment with different model architectures. For example, what happens if you add a third GRU layer? To do that you can make the following changes to the KeywordSpotter class: 1. Add the construction of the 3rd GRU layer in the **\_\_init\_\_** method: ```python self.gru3 = nn.GRU(hidden_dim, num_keywords) ``` 2. Change the Linear layer to take a different number of inputs since the output of gru3 will now be size **num_keywords** instead of **hidden_dim**: ```python self.hidden2keyword = nn.Linear(num_keywords, num_keywords) ``` 3. Add a third hidden state member in the **init_hidden** method: ```python self.hidden3 = None ``` 4. Use this new GRU layer in the **forward** method right after the gru2. ```python gru_out, self.hidden3 = self.gru3(gru_out, self.hidden3) ``` 5. That's it! Pretty simple. Now re-run `train_classifier` as before. Your new model should get an evaluation accuracy that is similar, so the 3rd GRU layer didn't really help much. But accuracy is not the only measure, you might also want to compare the performance of these two models to see which one is faster. It is often a speed versus accuracy trade off with neural networks which is why you see a speed versus accuracy graph on the [ELL Model Gallery](https://microsoft.github.io/ELL/gallery/). There are many other things you could try. So long as the trainer still shows a decreasing loss across epochs then it should train ok. You know you have a broken model if the loss never decreases. As you can see, PyTorch makes it pretty easy to experiment. To learn more about PyTorch see their [excellent tutorials](https://pytorch.org/tutorials/). ## Hyper-parameter Tuning So far your training has used all the defaults provided by `train_classifier`, but an important step in training neural networks is tuning all the training parameters. These include `learning_rate`, `batch_size`, `weight_decay`, `lr_schedulers` and their associated `lr_min` and `lr_peaks`, and of course the number of `epochs`. It is good practice to do a set of training runs that test a range of different values independently testing all these hyper-parameters. You can probably get a full 1% increase in training accuracy by finding the optimal parameters. ## Cleaning the Data The speech commands dataset contains many bad training files, either total silence, or bad noise, clipped words and some completely mislabelled words. Obviously this will impact your training accuracy. So included in this tutorial is a `bad_list.txt` file. If you copy that to your speech commands folder (next to your `testing_list.txt` file) then re-run `make_training_list.py` with the additional argument `--bad_list bad_list.txt` then it will create a cleaner test, validation and training list. Re-run the featurization steps with `make_dataset.py` and retrain your model and you should now see the test accuracy jump to about 94%. So this is a good illustration of the fact that higher quality labelled data can make a big difference in model performance. ## Next steps That's it, you just trained your first keyword spotter using PyTorch and you compiled and tested it using ELL, congratulations! You can now use your new featurizer and classifier in your embedded application, perhaps on a Raspberry Pi, or even on an [Azure IOT Dev Kit](https://microsoft.github.io/azure-iot-developer-kit/), as shown in the [DevKitKeywordSpotter](https://github.com/IoTDevEnvExamples/DevKitKeywordSpotter/) example. There are also lots of things you can experiment with as listed above. You can also build your own training sets, or customize the speech commands set by simply modifying the the **training_list.txt** file, then recreate the **training_list.npz** dataset using `make_dataset.py`, retrain the model and see how it does. Another dimension you can play with is mixing noise with your clean .wav files. This can give you a much bigger dataset and a model that performs better in noisy locations. Of course, this depends on what kind of noise you care about. Crowds of people? Industrial machinery? Just the hum of computers and HVAC systems in an Office environment? It depends on your application. You can experiment using the noise files included in the speech_commands dataset. There are some more advanced options on the `make_dataset.py` script to help with mixing noise in with the audio recordings. The [github speech commands gallery](https://github.com/Microsoft/ELL-models/tree/master/models/speech_commands_v0.01) contains some other types of models, some based on LSTM nodes, for example. The GRU architecture does well on smaller sized models, but LSTM hits the highest score when it maximizes the hidden state size. ## Troubleshooting For any PyTorch issues, see [https://pytorch.org/](https://pytorch.org/). `Exception: Please set your ELL_ROOT environment, as you will be using python scripts from there` If you see this error then you need to following ELL setup instructions above and clone the ELL repo, build it, and set an environment variable that points to the location of that repo. This tutorial uses scripts in that repo, and those scripts use the binaries that are built there.
{ "pile_set_name": "Github" }
{ "parameters": { "subscriptionId": "12345678-1234-1234-12345678abc", "resourceGroupName": "exampleResourceGroup", "factoryName": "exampleFactoryName", "api-version": "2017-09-01-preview" }, "responses": { "200": { "headers": { "Date": "Wed, 13 Sep 2017 17:55:54 GMT", "x-ms-request-id": "b78883ab-f299-495e-ad30-804003deb775", "X-Content-Type-Options": "nosniff", "x-ms-ratelimit-remaining-subscription-reads": "14913", "x-ms-correlation-request-id": "4864247b-bf7c-4bc6-8d34-4a2bcebdb473" }, "body": { "value": [ { "id": "/subscriptions/12345678-1234-1234-12345678abc/resourceGroups/exampleResourceGroup/providers/Microsoft.DataFactory/factories/exampleFactoryName/linkedservices/exampleLinkedService", "name": "exampleLinkedService", "properties": { "type": "AzureStorage", "typeProperties": { "connectionString": { "value": "**********", "type": "SecureString" } }, "description": "Example description" }, "etag": "28031da7-0000-0000-0000-59b971290000" } ] } } } }
{ "pile_set_name": "Github" }
/* .tribe-events { */ /* ----------------------------------------------------------------------------- * Nav * ----------------------------------------------------------------------------- */ /* } */
{ "pile_set_name": "Github" }
#N canvas 0 0 808 621 10; #X obj 30 519 GEMglBlendFunc; #X msg 233 356 GL_ONE_MINUS_SRC_ALPHA; #X msg 232 238 GL_ONE; #X msg 231 220 GL_ZERO; #X msg 234 297 GL_ONE_MINUS_DST_COLOR; #X msg 234 316 GL_ONE_MINUS_SRC_COLOR; #X msg 234 276 GL_DST_COLOR; #X text 272 201 Jitter Mode Equiv; #X text 305 222 0; #X text 305 237 1; #X text 330 258 2; #X text 331 278 3; #X text 396 300 4; #X text 398 318 5; #X msg 234 337 GL_SRC_ALPHA; #X text 330 340 6; #X text 398 357 7; #X msg 235 378 GL_DST_ALPHA; #X msg 235 399 GL_ONE_MINUS_DST_ALPHA; #X text 332 380 8; #X text 396 402 9; #X msg 234 421 GL_SRC_ALPHA_SATURATE; #X text 391 423 10; #X msg 471 358 GL_ONE_MINUS_SRC_ALPHA; #X msg 470 240 GL_ONE; #X msg 471 258 GL_DST_COLOR; #X msg 469 222 GL_ZERO; #X msg 472 299 GL_ONE_MINUS_DST_COLOR; #X msg 472 318 GL_ONE_MINUS_SRC_COLOR; #X msg 472 278 GL_DST_COLOR; #X msg 472 339 GL_SRC_ALPHA; #X msg 473 380 GL_DST_ALPHA; #X msg 473 401 GL_ONE_MINUS_DST_ALPHA; #X msg 472 423 GL_SRC_ALPHA_SATURATE; #X msg 233 256 GL_SRC_COLOR; #X obj 30 561 outlet; #X obj 8 36 inlet; #X obj 71 139 sel 0 1 2 3 4 5 6 7 8 9 10; #X obj 318 125 sel 0 1 2 3 4 5 6 7 8 9 10; #X obj 99 31 inlet; #X obj 135 56 loadbang; #X obj 136 83 init.df \$1 6; #X obj 355 17 inlet; #X obj 317 56 loadbang; #X obj 318 85 init.df \$2 7; #X obj 34 297 alpha; #X obj 247 564 outlet; #X obj 469 572 outlet; #X obj 152 489 GLdefine; #X obj 158 461 t a a; #X obj 238 530 symbol; #X obj 374 510 GLdefine; #X obj 396 463 t a a; #X obj 496 536 symbol; #X obj 42 81 clip 0 10; #X obj 42 105 int; #X obj 430 80 clip 0 10; #X obj 429 99 int; #X connect 0 0 35 0; #X connect 1 0 49 0; #X connect 2 0 49 0; #X connect 3 0 49 0; #X connect 4 0 49 0; #X connect 5 0 49 0; #X connect 6 0 49 0; #X connect 14 0 49 0; #X connect 17 0 49 0; #X connect 18 0 49 0; #X connect 21 0 49 0; #X connect 23 0 52 0; #X connect 24 0 52 0; #X connect 25 0 52 0; #X connect 26 0 52 0; #X connect 27 0 52 0; #X connect 28 0 52 0; #X connect 29 0 52 0; #X connect 30 0 52 0; #X connect 31 0 52 0; #X connect 32 0 52 0; #X connect 33 0 52 0; #X connect 34 0 49 0; #X connect 36 0 45 0; #X connect 37 0 3 0; #X connect 37 1 2 0; #X connect 37 2 34 0; #X connect 37 3 6 0; #X connect 37 4 4 0; #X connect 37 5 5 0; #X connect 37 6 14 0; #X connect 37 7 1 0; #X connect 37 8 17 0; #X connect 37 9 18 0; #X connect 37 10 21 0; #X connect 38 0 26 0; #X connect 38 1 24 0; #X connect 38 2 25 0; #X connect 38 3 29 0; #X connect 38 4 27 0; #X connect 38 5 28 0; #X connect 38 6 30 0; #X connect 38 7 23 0; #X connect 38 8 31 0; #X connect 38 9 32 0; #X connect 38 10 33 0; #X connect 39 0 54 0; #X connect 40 0 41 0; #X connect 41 0 54 0; #X connect 42 0 56 0; #X connect 43 0 44 0; #X connect 44 0 56 0; #X connect 45 0 0 0; #X connect 48 0 0 1; #X connect 49 0 50 0; #X connect 49 1 48 0; #X connect 50 0 46 0; #X connect 51 0 0 2; #X connect 52 0 53 0; #X connect 52 1 51 0; #X connect 53 0 47 0; #X connect 54 0 55 0; #X connect 55 0 37 0; #X connect 56 0 57 0; #X connect 57 0 38 0;
{ "pile_set_name": "Github" }
cmd /K list-target.bat
{ "pile_set_name": "Github" }
/*** Copyright 2014 Cisco Systems Inc. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package netutils import ( "fmt" "github.com/jainvipin/bitset" "testing" ) type testSubnetInfo struct { subnetIP string subnetLen uint hostID uint hostIP string ipv6Subnet string ipv6SubnetLen uint ipv6HostID string ipv6HostIP string } var testSubnets = []testSubnetInfo{ {subnetIP: "11.2.1.0", subnetLen: 24, hostID: 5, hostIP: "11.2.1.5"}, {subnetIP: "10.123.16.0", subnetLen: 22, hostID: 513, hostIP: "10.123.18.1"}, {subnetIP: "172.12.0.0", subnetLen: 16, hostID: 261, hostIP: "172.12.1.5"}, } func TestGetSubnetIP(t *testing.T) { for _, te := range testSubnets { hostIP, err := GetSubnetIP(te.subnetIP, te.subnetLen, 32, te.hostID) if err != nil { t.Fatalf("error getting host ip from subnet %s/%d for hostid %d - err '%s'", te.subnetIP, te.subnetLen, te.hostID, err) } if hostIP != te.hostIP { t.Fatalf("obtained ip %s doesn't match expected ip %s for subnet %s/%d\n", hostIP, te.hostIP, te.subnetIP, te.subnetLen) } } } var testInvalidSubnets = []testSubnetInfo{ {subnetIP: "11.2.1.0", subnetLen: 32, hostID: 5, hostIP: "11.2.1.5"}, {subnetIP: "10.123.16.0", subnetLen: 22, hostID: 1025, hostIP: "10.123.18.1"}, {subnetIP: "172.12.0.0", subnetLen: 4, hostID: 261, hostIP: "172.12.1.5"}, } func TestInvalidGetSubnetIP(t *testing.T) { for _, te := range testInvalidSubnets { _, err := GetSubnetIP(te.subnetIP, te.subnetLen, 32, te.hostID) if err == nil { t.Fatalf("Expecting error on invalid config subnet %s/%d for hostid %d", te.subnetIP, te.subnetLen, te.hostID) } } } func TestGetIPNumber(t *testing.T) { for _, te := range testSubnets { hostID, err := GetIPNumber(te.subnetIP, te.subnetLen, 32, te.hostIP) if err != nil { t.Fatalf("error getting host ip from subnet %s/%d for hostid %d ", te.subnetIP, te.subnetLen, te.hostID) } if hostID != te.hostID { t.Fatalf("obtained ip %d doesn't match with expected ip %d \n", hostID, te.hostID) } } } var testValidNetParams = []testSubnetInfo{ {subnetIP: "11.2.1.10-11.2.1.100", subnetLen: 24}, {subnetIP: "10.123.16.0", subnetLen: 26}, {subnetIP: "10.123.16.66", subnetLen: 26}, {subnetIP: "10.123.16.10-10.123.16.100", subnetLen: 22}, } func TestValidNetworkRangeParams(t *testing.T) { for _, tvnp := range testValidNetParams { err := ValidateNetworkRangeParams(tvnp.subnetIP, tvnp.subnetLen) if err != nil { t.Fatalf("Error validating network params for subnet: %s/%d", tvnp.subnetIP, tvnp.subnetLen) } } } var testInvalidNetParams = []testSubnetInfo{ {subnetIP: "10.123.16.10-10.123.16.100", subnetLen: 26}, {subnetIP: "10.123.16.60-10.123.16.100", subnetLen: 26}, {subnetIP: "10.1.1.0", subnetLen: 1}, {subnetIP: "10.1.1.0", subnetLen: 33}, } func TestInvalidNetworkRangeParams(t *testing.T) { for _, tinp := range testInvalidNetParams { err := ValidateNetworkRangeParams(tinp.subnetIP, tinp.subnetLen) if err == nil { t.Fatalf("Expected error for invalid network params for subnet: %s/%d", tinp.subnetIP, tinp.subnetLen) } } } type testSubnetAddrInfo struct { ipRange string subnetLen uint expectedSubnet string } var testSubnetAddr = []testSubnetAddrInfo{ {ipRange: "10.1.1.10", subnetLen: 16, expectedSubnet: "10.1.0.0"}, {ipRange: "10.1.1.10-20", subnetLen: 24, expectedSubnet: "10.1.1.0"}, {ipRange: "10.1.1.100", subnetLen: 26, expectedSubnet: "10.1.1.64"}, {ipRange: "10.1.1.70-100", subnetLen: 26, expectedSubnet: "10.1.1.64"}, } func TestGetSubnetAddr(t *testing.T) { for _, addr := range testSubnetAddr { subnetAddr := GetSubnetAddr(addr.ipRange, addr.subnetLen) if subnetAddr != addr.expectedSubnet { t.Fatalf("Invalid subnet address %s obtained for IPRange: %s/%d. Expected: %s", subnetAddr, addr.ipRange, addr.subnetLen, addr.expectedSubnet) } } } var testv6Subnets = []testSubnetInfo{ {ipv6Subnet: "2016:430::", ipv6SubnetLen: 64, ipv6HostID: "::254", ipv6HostIP: "2016:430::254"}, {ipv6Subnet: "babe:face::80", ipv6SubnetLen: 121, ipv6HostID: "::45", ipv6HostIP: "babe:face::c5"}, {ipv6Subnet: "2001::", ipv6SubnetLen: 100, ipv6HostID: "::2", ipv6HostIP: "2001::2"}, } func TestGetSubnetIPv6(t *testing.T) { for _, te := range testv6Subnets { ipv6HostIP, err := GetSubnetIPv6(te.ipv6Subnet, te.ipv6SubnetLen, te.ipv6HostID) if err != nil { t.Fatalf("error getting host ip from ipv6Subnet %s/%d for hostid %s - err '%s'", te.ipv6Subnet, te.ipv6SubnetLen, te.ipv6HostID, err) } if ipv6HostIP != te.ipv6HostIP { t.Fatalf("obtained ip %s doesn't match expected ip %s for ipv6Subnet %s/%d\n", ipv6HostIP, te.ipv6HostIP, te.ipv6Subnet, te.ipv6SubnetLen) } } } var testInvalidv6Subnets = []testSubnetInfo{ {ipv6Subnet: "2016:430::", ipv6SubnetLen: 128, ipv6HostID: "::254"}, {ipv6Subnet: "babe:face::80", ipv6SubnetLen: 121, ipv6HostID: "::c5"}, {ipv6Subnet: "babe:face::80", ipv6SubnetLen: 121, ipv6HostID: "::105"}, {ipv6Subnet: "2001::", ipv6SubnetLen: 130, ipv6HostID: "::2", ipv6HostIP: "2001::2"}, } func TestInvalidGetSubnetIPv6(t *testing.T) { for _, te := range testInvalidSubnets { _, err := GetSubnetIPv6(te.ipv6Subnet, te.ipv6SubnetLen, te.ipv6HostID) if err == nil { t.Fatalf("Expecting error on invalid config subnet %s/%d for hostid %s", te.ipv6Subnet, te.ipv6SubnetLen, te.ipv6HostID) } } } type testHostID struct { hostID string nextHostID string subnetAddr string subnetLen uint } var testHostIDs = []testHostID{ // verify initial case {hostID: "", nextHostID: "::1", subnetAddr: "1234::", subnetLen: 100}, // lasthost set to 0 and ::1 allocated above {hostID: "::", nextHostID: "::2", subnetAddr: "1234::", subnetLen: 100}, // find next of 4 {hostID: "::4:FFFF:FFFF", nextHostID: "::5:0:0", subnetAddr: "1234::", subnetLen: 100}, // this time next of 4 should skip 5, as it was alloc'd above {hostID: "::4:ffff:ffff", nextHostID: "::5:0:1", subnetAddr: "1234::", subnetLen: 100}, // verify the corner case {hostID: "::FFFE", nextHostID: "::ffff", subnetAddr: "1234::", subnetLen: 100}, // verify the wrap around case, with subnetLen 124 {hostID: "::F", nextHostID: "::3", subnetAddr: "1234::", subnetLen: 124}, } func TestGetNextIPv6HostID(t *testing.T) { var allocMap map[string]bool for _, te := range testHostIDs { nextHostID, err := GetNextIPv6HostID(te.hostID, te.subnetAddr, te.subnetLen, allocMap) if nextHostID != te.nextHostID || err != nil { t.Fatalf("obtained nextHostID %s doesn't match expected ID %s for %s\n", nextHostID, te.nextHostID, te.hostID) } ReserveIPv6HostID(nextHostID, &allocMap) } } func TestValidRange(t *testing.T) { rangeStr := "5-100, 101-200" _, err := ParseTagRanges(rangeStr, "vlan") if err != nil { t.Fatalf("error '%s' parsing valid vlan range '%s'\n", err, rangeStr) } } func TestInvalidVlanRange(t *testing.T) { rangeStr := "5--100, 101-200" _, err := ParseTagRanges(rangeStr, "vlan") if err == nil { t.Fatalf("successfully parsed invalid vlan range '%s'\n", rangeStr) } } func TestInvalidVlanValue(t *testing.T) { rangeStr := "5-100, 101-5000" _, err := ParseTagRanges(rangeStr, "vlan") if err == nil { t.Fatalf("successfully parsed invalid vlan id '%s'\n", rangeStr) } } func TestInvalidMinMaxVlan(t *testing.T) { rangeStr := "5-100, 200-101" _, err := ParseTagRanges(rangeStr, "vlan") if err == nil { t.Fatalf("successfully parsed invalid min-max vlan values '%s'\n", rangeStr) } } func TestInvalidRangeExtraSeperators(t *testing.T) { rangeStr := "5-100,,101-200" _, err := ParseTagRanges(rangeStr, "vlan") if err == nil { t.Fatalf("successfully parsed vlan range with extra seperators '%s'\n", rangeStr) } } func TestValidVxlanRange(t *testing.T) { rangeStr := "10000-16000" _, err := ParseTagRanges(rangeStr, "vxlan") if err != nil { t.Fatalf("error '%s' parsing valid vxlan range '%s'\n", err, rangeStr) } } func TestInvalidVxlanMultipleRanges(t *testing.T) { rangeStr := "101-400, 10000-15000" _, err := ParseTagRanges(rangeStr, "vxlan") if err == nil { t.Fatalf("successfully parsed invalid vxlan value '%s'\n", rangeStr) } } func TestInvalidVxlanValue(t *testing.T) { rangeStr := "101-75535" _, err := ParseTagRanges(rangeStr, "vxlan") if err == nil { t.Fatalf("successfully parsed invalid vxlan value '%s'\n", rangeStr) } } func TestInvalidMinMaxVxlan(t *testing.T) { rangeStr := "8000-7999" _, err := ParseTagRanges(rangeStr, "vxlan") if err == nil { t.Fatalf("successfully parsed invalid min-max vxlan values '%s'\n", rangeStr) } } type testSubnetAllocInfo struct { subnetIP string subnetLen uint subnetAllocLen uint hostID uint hostIP string } var testSubnetAllocs = []testSubnetAllocInfo{ {subnetIP: "11.1.0.0", subnetLen: 16, subnetAllocLen: 24, hostID: 5, hostIP: "11.1.5.0"}, {subnetIP: "10.0.0.0", subnetLen: 8, subnetAllocLen: 24, hostID: 5, hostIP: "10.0.5.0"}, } func TestGetSubnetAlloc(t *testing.T) { for _, te := range testSubnetAllocs { hostIP, err := GetSubnetIP(te.subnetIP, te.subnetLen, te.subnetAllocLen, te.hostID) if err != nil { t.Fatalf("error getting subnet ip from subnet-range %s/%d alloc-size %d "+ "for id %d - err '%s'", te.subnetIP, te.subnetLen, te.subnetAllocLen, te.hostID, err) } if hostIP != te.hostIP { t.Fatalf("obtained ip %s doesn't match expected ip %s for subnet %s/%d "+ "for AllocLen %d \n", hostIP, te.hostIP, te.subnetIP, te.subnetLen, te.subnetAllocLen) } } } func TestGetSubnetNumber(t *testing.T) { for _, te := range testSubnetAllocs { hostID, err := GetIPNumber(te.subnetIP, te.subnetLen, te.subnetAllocLen, te.hostIP) if err != nil { t.Fatalf("error getting subnet ip from subnet %s/%d for hostid %d "+ "for subnet alloc size %d \n", te.subnetIP, te.subnetLen, te.hostID, te.subnetAllocLen) } if hostID != te.hostID { t.Fatalf("obtained subnet ip %d doesn't match with expected ip %d "+ "for subnet %s/%d alloc size %d \n", hostID, te.hostID, te.subnetIP, te.subnetLen, te.subnetAllocLen) } } } func TestGetAddrList(t *testing.T) { addrList, err := GetNetlinkAddrList() if err != nil { t.Fatalf("Error getting address list. Err: %v", err) } fmt.Printf("Got netlink address list: %v\n", addrList) addrList, err = GetLocalAddrList() if err != nil { t.Fatalf("Error getting address list. Err: %v", err) } fmt.Printf("Got local address list: %v\n", addrList) } func TestGetIPRange(t *testing.T) { testData := []struct { subnetIP string subnetLen uint startIdx uint endIdx uint result string }{ {subnetIP: "10.36.1.0", subnetLen: 24, startIdx: 1, endIdx: 2, result: "10.36.1.1-10.36.1.2"}, {subnetIP: "11.2.1.0", subnetLen: 24, startIdx: 5, endIdx: 11, result: "11.2.1.5-11.2.1.11"}, {subnetIP: "10.123.16.0", subnetLen: 22, startIdx: 1020, endIdx: 1022, result: "10.123.19.252-10.123.19.254"}, {subnetIP: "172.12.0.0", subnetLen: 8, startIdx: 261, endIdx: 266, result: "172.12.1.5-172.12.1.10"}, {subnetIP: "10.36.2.0", subnetLen: 24, startIdx: 5, endIdx: 6, result: "10.36.2.5-10.36.2.6"}, } for _, i := range testData { r := getIPRange(i.subnetIP, i.subnetLen, i.startIdx, i.endIdx) if r != i.result { t.Fatalf("test failed: got %s instead of %s for %+v", r, i.result, i) } } } func assertOnTrue(t *testing.T, val bool, msg string) { if val == true { t.Fatalf("Error %s", msg) } // else continue } func TestSetIPAddrRange(t *testing.T) { var amap bitset.BitSet var err error testAddrRange := []struct { addrRange []string subnetIP string subnetLen uint status bool allocAddr string freeAddr string }{ {addrRange: []string{"10.36.1.1-10.36.1.10"}, subnetIP: "10.36.1.0", subnetLen: 24, status: true, allocAddr: "10.36.1.1-10.36.1.10", freeAddr: "10.36.1.11-10.36.1.254"}, {addrRange: []string{"10.36.1.1-10.36.1.10", "10.36.1.11-10.36.1.254"}, subnetIP: "10.36.1.0", subnetLen: 24, status: true, allocAddr: "10.36.1.1-10.36.1.254", freeAddr: ""}, {addrRange: []string{"10.36.1.1-10.36.1.10", "10.36.1.31-10.36.1.54"}, subnetIP: "10.36.1.0", subnetLen: 24, status: true, allocAddr: "10.36.1.1-10.36.1.10, 10.36.1.31-10.36.1.54", freeAddr: "10.36.1.11-10.36.1.30, 10.36.1.55-10.36.1.254"}, {addrRange: []string{"10.36.2.1-10.36.2.10", "10.36.0.1-10.36.0.10"}, subnetIP: "10.36.0.0", subnetLen: 16, status: true, allocAddr: "10.36.0.1-10.36.0.10, 10.36.2.1-10.36.2.10", freeAddr: "10.36.0.11-10.36.2.0, 10.36.2.11-10.36.255.254"}, {addrRange: []string{"10.36.1.1-10.36.1.10", "10.36.1.1-10.36.1.10"}, subnetIP: "10.36.2.0", subnetLen: 24, status: false}, } for _, i := range testAddrRange { amap.ClearAll() InitSubnetBitset(&amap, i.subnetLen) for _, pool := range i.addrRange { err = SetIPAddrRange(&amap, pool, i.subnetIP, i.subnetLen) assertOnTrue(t, (err != nil) == (i.status == true), fmt.Sprintf("set failed %s %+v", err, i)) } if i.status == true { assertOnTrue(t, err != nil, fmt.Sprintf("err: %s, failed for data %+v", err, i)) f := ListAvailableIPs(amap, i.subnetIP, i.subnetLen) assertOnTrue(t, f != i.freeAddr, fmt.Sprintf("got avail addr: [%s], expected [%s] failed for data %+v", f, i.freeAddr, i)) a := ListAllocatedIPs(amap, i.subnetIP, i.subnetIP, i.subnetLen) assertOnTrue(t, a != i.allocAddr, fmt.Sprintf("got allocated addr: [%s], expected [%s] failed for data %+v", a, i.allocAddr, i)) } else { assertOnTrue(t, err == nil, fmt.Sprintf("err: %s, failed for data %+v", err, i)) } } } func TestVerifyIPAddrRange(t *testing.T) { var amap bitset.BitSet var err error testAddrRange := []struct { addrRange []string testRange string subnetIP string subnetLen uint status bool }{ {addrRange: []string{"10.36.1.1-10.36.1.10"}, testRange: "10.36.1.15-10.36.1.17", subnetIP: "10.36.1.0", subnetLen: 24, status: true}, {addrRange: []string{"10.36.1.1-10.36.1.10", "10.36.1.11-10.36.1.204"}, testRange: "10.36.1.205-10.36.1.254", subnetIP: "10.36.1.0", subnetLen: 24, status: true}, {addrRange: []string{"10.36.1.1-10.36.1.10", "10.36.1.11-10.36.1.54"}, testRange: "10.36.1.55-10.36.1.55", subnetIP: "10.36.1.0", subnetLen: 24, status: true}, {addrRange: []string{"10.36.2.1-10.36.2.10", "10.36.0.1-10.36.0.10"}, subnetIP: "10.36.0.0", subnetLen: 16, status: false, testRange: "10.36.2.1-10.36.2.2"}, {addrRange: []string{"10.36.1.1-10.36.1.10", "10.36.1.1-10.36.1.10"}, subnetIP: "10.36.1.0", testRange: "10.36.2.1-10.36.2.11", subnetLen: 24, status: false}, } for _, i := range testAddrRange { amap.ClearAll() InitSubnetBitset(&amap, i.subnetLen) for _, pool := range i.addrRange { err = SetIPAddrRange(&amap, pool, i.subnetIP, i.subnetLen) assertOnTrue(t, err != nil, fmt.Sprintf("set failed %s %+v", err, i)) } err = TestIPAddrRange(&amap, i.testRange, i.subnetIP, i.subnetLen) assertOnTrue(t, (err != nil) == (i.status == true), fmt.Sprintf("clear failed %s %+v", err, i)) } } func TestClearIPAddrRange(t *testing.T) { var amap bitset.BitSet var err error testAddrRange := []struct { addrRange []string clearRange string subnetIP string subnetLen uint status bool allocAddr string freeAddr string }{ {addrRange: []string{"10.36.1.1-10.36.1.10"}, clearRange: "10.36.1.5-10.36.1.7", subnetIP: "10.36.1.0", subnetLen: 24, status: true, allocAddr: "10.36.1.1-10.36.1.4, 10.36.1.8-10.36.1.10", freeAddr: "10.36.1.5-10.36.1.7, 10.36.1.11-10.36.1.254"}, {addrRange: []string{"10.36.1.1-10.36.1.10", "10.36.1.11-10.36.1.254"}, clearRange: "10.36.1.101-10.36.1.254", subnetIP: "10.36.1.0", subnetLen: 24, status: true, allocAddr: "10.36.1.1-10.36.1.100", freeAddr: "10.36.1.101-10.36.1.254"}, {addrRange: []string{"10.36.1.1-10.36.1.10", "10.36.1.11-10.36.1.54"}, clearRange: "10.36.1.1-10.36.1.54", subnetIP: "10.36.1.0", subnetLen: 24, status: true, allocAddr: "", freeAddr: "10.36.1.1-10.36.1.254"}, {addrRange: []string{"10.36.2.1-10.36.2.10", "10.36.0.1-10.36.0.10"}, subnetIP: "10.36.0.0", subnetLen: 16, status: true, allocAddr: "10.36.0.1-10.36.0.10, 10.36.2.3-10.36.2.10", clearRange: "10.36.2.1-10.36.2.2", freeAddr: "10.36.0.11-10.36.2.2, 10.36.2.11-10.36.255.254"}, {addrRange: []string{"10.36.1.1-10.36.1.10", "10.36.1.1-10.36.1.10"}, subnetIP: "10.36.1.0", clearRange: "10.36.2.1-10.36.2.11", subnetLen: 24, status: false}, } for _, i := range testAddrRange { amap.ClearAll() InitSubnetBitset(&amap, i.subnetLen) for _, pool := range i.addrRange { err = SetIPAddrRange(&amap, pool, i.subnetIP, i.subnetLen) assertOnTrue(t, err != nil, fmt.Sprintf("set failed %s %+v", err, i)) } err = ClearIPAddrRange(&amap, i.clearRange, i.subnetIP, i.subnetLen) assertOnTrue(t, (err != nil) == (i.status == true), fmt.Sprintf("clear failed %s %+v", err, i)) if i.status == true { assertOnTrue(t, err != nil, fmt.Sprintf("err: %s, failed for data %+v", err, i)) f := ListAvailableIPs(amap, i.subnetIP, i.subnetLen) assertOnTrue(t, f != i.freeAddr, fmt.Sprintf("got avail addr: [%s], expected [%s] failed for data %+v", f, i.freeAddr, i)) a := ListAllocatedIPs(amap, i.subnetIP, i.subnetIP, i.subnetLen) assertOnTrue(t, a != i.allocAddr, fmt.Sprintf("got allocated addr: [%s], expected [%s] failed for data %+v", a, i.allocAddr, i)) } else { assertOnTrue(t, err == nil, fmt.Sprintf("err: %s, failed for data %+v", err, i)) } } } func TestIsOverlappingSubnet(t *testing.T) { testAddrRange := []struct { src string match string overlap bool }{ {src: "10.36.0.1/32", match: "10.36.0.0/24", overlap: true}, {src: "20.20.0.20/32", match: "20.20.0.0/16", overlap: true}, {src: "20.20.5.20/32", match: "20.20.0.0/24", overlap: false}, } for _, i := range testAddrRange { overlap := IsOverlappingSubnet(i.src, i.match) assertOnTrue(t, overlap != i.overlap, fmt.Sprintf("%+v got %v ", i, overlap)) } }
{ "pile_set_name": "Github" }
/* bender-tags: balloontoolbar */ /* bender-ckeditor-plugins: toolbar,link,balloontoolbar */ /* bender-include: _helpers/default.js */ ( function() { 'use strict'; bender.editors = { editor1: { name: 'editor1', creator: 'replace', config: { extraAllowedContent: 'span[id];p{height};img[src]{margin-left}', height: 200 } }, divarea: { name: 'divarea', creator: 'replace', config: { extraPlugins: 'divarea', extraAllowedContent: 'span[id];p{height};img[src]{margin-left}', height: 200 } } }; var parentFrame = window.frameElement, originalHeight = parentFrame && parentFrame.style.height, balloonToolbar; var tests = { setUp: function() { bender.tools.ignoreUnsupportedEnvironment( 'balloontoolbar' ); if ( parentFrame ) { parentFrame.style.height = '900px'; } var doc = CKEDITOR.document.getDocumentElement(), body = CKEDITOR.document.getBody(); if ( doc.$.scrollTop ) { doc.$.scrollTop = 0; } if ( body.$.scrollTop ) { body.$.scrollTop = 0; } }, tearDown: function() { if ( parentFrame ) { parentFrame.style.height = originalHeight; } // Cleanup balloontoolbar to prevent 'Permission Denied' IE error. if ( balloonToolbar ) { balloonToolbar.destroy(); balloonToolbar = null; } }, 'test panel - out of view - bottom center': function( editor ) { if ( editor.name == 'divarea' ) { // divarea tests are failing, it's an upstream issue from balloonpanel (#1064). assert.ignore(); } var markerElement = editor.editable().findOne( '#marker' ), frame = getFrameRect( editor ), elementFrame = markerElement.getClientRect(), // When window is so small editor is out of view panel might be rendered below editor. // Mock view pane size to prevent that. viewPaneSpy = sinon.stub( CKEDITOR.dom.window.prototype, 'getViewPaneSize' ).returns( { width: 1000, height: 1000 } ), scrollTop, balloonToolbarRect, rectTop; balloonToolbar = new CKEDITOR.ui.balloonToolbarView( editor, { width: 100, height: 200 } ); balloonToolbar.attach( markerElement ); balloonToolbarRect = balloonToolbar.parts.panel.getClientRect(); rectTop = CKEDITOR.env.ie && !CKEDITOR.env.edge ? Math.round( balloonToolbarRect.top ) : balloonToolbarRect.top; viewPaneSpy.restore(); // When browser window is so small that panel doesn't fit, window will be scrolled into panel view. // Use scroll position to adjust expected result. scrollTop = CKEDITOR.document.getWindow().getScrollPosition().y; var expectedLeft = makeExpectedLeft( frame.left + elementFrame.left + elementFrame.width / 2 - 50 ); assert.areEqual( expectedLeft, balloonToolbarRect.left.toFixed( 2 ), 'left align' ); // We have to add 1px because of border. assert.areEqual( ( frame.top + frame.height - scrollTop ).toFixed( 2 ), ( rectTop + balloonToolbar.height + balloonToolbar.triangleHeight + 1 ).toFixed( 2 ), 'top align' ); }, 'test panel - out of view - hcenter top': function( editor ) { if ( editor.name == 'divarea' || ( bender.config.isTravis && bender.tools.env.isBuild ) ) { // divarea tests are failing, it's an upstream issue from balloonpanel (#1064). // Ignore test with builded editor in travis. assert.ignore(); } var markerElement = editor.editable().findOne( '#marker' ), frame = getFrameRect( editor ), elementFrame = markerElement.getClientRect(), scrollTop, balloonToolbarRect, rectTop, expectedLeft; balloonToolbar = new CKEDITOR.ui.balloonToolbarView( editor, { width: 100, height: 200 } ); markerElement.getParent().getNext().scrollIntoView( true ); balloonToolbar.attach( markerElement ); balloonToolbarRect = balloonToolbar.parts.panel.getClientRect(); rectTop = CKEDITOR.env.ie && !CKEDITOR.env.edge ? Math.round( balloonToolbarRect.top ) : balloonToolbarRect.top; // When browser window is so small that panel doesn't fit, window will be scrolled into panel view. // We need to use scroll position to adjust expected result. scrollTop = CKEDITOR.document.getWindow().getScrollPosition().y; expectedLeft = makeExpectedLeft( frame.left + elementFrame.left + elementFrame.width / 2 - 50 ); assert.areEqual( expectedLeft, balloonToolbarRect.left.toFixed( 2 ), 'left align' ); assert.areEqual( ( frame.top - scrollTop ).toFixed( 2 ), ( rectTop - balloonToolbar.triangleHeight ).toFixed( 2 ), 'top align' ); balloonToolbar.destroy(); balloonToolbar = null; }, 'test panel adds cke_balloontoolbar class': function( editor ) { var markerElement = editor.editable().findOne( '#marker' ); balloonToolbar = new CKEDITOR.ui.balloonToolbarView( editor, { width: 100, height: 200 } ); balloonToolbar.attach( markerElement ); assert.isTrue( balloonToolbar.parts.panel.hasClass( 'cke_balloontoolbar' ), 'Panel has a cke_balloontoolbar class' ); assert.isTrue( balloonToolbar.parts.panel.hasClass( 'cke_balloon' ), 'Class cke_balloon class was not removed' ); balloonToolbar.destroy(); balloonToolbar = null; }, 'test panel prefers bottom positioning': function( editor ) { balloonToolbar = new CKEDITOR.ui.balloonToolbarView( editor, { width: 100, height: 200 } ); var res = balloonToolbar._getAlignments( editor.editable().getFirst().getClientRect(), 10, 10 ); arrayAssert.itemsAreEqual( [ 'bottom hcenter', 'top hcenter' ], CKEDITOR.tools.object.keys( res ) ); }, // (#1342, #1496) 'test panel refresh position': function( editor, bot ) { // (#3868) if ( CKEDITOR.env.ie ) { assert.ignore(); } bot.setData( '<img src="' + bender.basePath + '/_assets/lena.jpg">', function() { balloonToolbar = new CKEDITOR.ui.balloonToolbarView( editor, { width: 100, height: 200 } ); var markerElement = editor.editable().findOne( 'img' ), spy = sinon.spy( balloonToolbar, 'reposition' ), // This test randomly fails when run from dashboard. That's because balloon toolbar // uses also other listeners to reposition, which might be fired before `change`. // Prevent all other event's for this TC to check if it's correctly repositions on `change` #(2979). listeners = [ editor.on( 'resize', cancelEvent ), CKEDITOR.document.getWindow().on( 'resize', cancelEvent ), editor.editable().getDocument().on( 'scroll', cancelEvent ) ], initialPosition, currentPosition; balloonToolbar.attach( markerElement ); initialPosition = balloonToolbar.parts.panel.getClientRect(); editor.once( 'change', function() { resume( function() { CKEDITOR.tools.array.forEach( listeners, function( listener ) { listener.removeListener(); } ); currentPosition = balloonToolbar.parts.panel.getClientRect(); assert.areNotSame( initialPosition.left, currentPosition.left, 'position of toolbar' ); assert.areEqual( 1, spy.callCount ); } ); } ); markerElement.setStyle( 'margin-left', '200px' ); editor.fire( 'change' ); wait(); function cancelEvent( evt ) { evt.cancel(); } } ); }, // (#1496) 'test panel reposition': function( editor, bot ) { bot.setData( '<img src="' + bender.basePath + '/_assets/lena.jpg">', function() { var markerElement = editor.editable().findOne( 'img' ), spy; balloonToolbar = new CKEDITOR.ui.balloonToolbarView( editor, { width: 100, height: 200 } ); balloonToolbar.attach( markerElement ); spy = sinon.spy( balloonToolbar, 'attach' ); balloonToolbar.reposition(); spy.restore(); assert.isTrue( markerElement.equals( spy.args[ 0 ][ 0 ] ) ); } ); }, // (#1653) 'test Balloon Toolbar should be respositioned after "window scroll" event': function( editor, bot ) { assertRepositionCall( CKEDITOR.document.getWindow(), 'scroll', bot ); }, // (#1653) 'test Balloon Toolbar should be respositioned after "window resize" event': function( editor, bot ) { assertRepositionCall( CKEDITOR.document.getWindow(), 'resize', bot ); }, // (#1653) 'test Balloon Toolbar should be respositioned after "editor change" event': function( editor, bot ) { assertRepositionCall( editor, 'change', bot ); }, // (#1653) 'test Balloon Toolbar should be respositioned after "editor resize" event': function( editor, bot ) { assertRepositionCall( editor, 'resize', bot ); }, // (#1653) 'test Balloon Toolbar should be respositioned after "editable scroll" event': function( editor, bot ) { var editable = editor.editable(), editableScrollElement = editable.isInline() ? editable : editable.getDocument(); // iOS classic editor listens on frame parent element for editor `scroll` event (#1910). // Since iOS 13, this `if` won't be necesary any longer https://bugs.webkit.org/show_bug.cgi?id=149264. if ( !editable.isInline() && CKEDITOR.env.iOS ) { editableScrollElement = editor.window.getFrame().getParent(); } assertRepositionCall( editableScrollElement, 'scroll', bot ); } }; tests = bender.tools.createTestsForEditors( CKEDITOR.tools.object.keys( bender.editors ), tests ); bender.test( tests ); // @param {CKEDITOR.dom.domObject/CKEDITOR.editor} eventTarget - target listening on a repositioning event of balloontoolbar // @param {String} eventName - name of the event which will be fired on the given target // @param {bender.editorBot} bot function assertRepositionCall( eventTarget, eventName, bot ) { bot.setData( '<p>foo <span id="bar">bar</span> baz</p>', function() { var editor = bot.editor, markerElement = editor.editable().findOne( '#bar' ), spy = sinon.spy( CKEDITOR.ui.balloonToolbarView.prototype, 'reposition' ); balloonToolbar = new CKEDITOR.ui.balloonToolbarView( editor, { width: 100, height: 200 } ); balloonToolbar.attach( markerElement ); eventTarget.once( eventName, function() { // Make it async to have sure that anything related to event will finish processing. CKEDITOR.tools.setTimeout( function() { resume( function() { spy.restore(); sinon.assert.called( spy ); assert.pass(); } ); } ); }, null, null, 100000 ); eventTarget.fire( eventName ); wait(); } ); } function makeExpectedLeft( data ) { if ( CKEDITOR.env.ie && CKEDITOR.env.version <= 9 ) { return data.toFixed( 0 ) + '.00'; } else { return data.toFixed( 2 ); } } function getFrameRect( editor ) { var frame = editor.window.getFrame(); if ( editor.editable().isInline() ) { frame = editor.editable(); } else if ( CKEDITOR.env.safari ) { // Use container because iframe has wrong rect values in mobile Safari (#1076). frame = frame.getParent(); } return frame.getClientRect(); } } )();
{ "pile_set_name": "Github" }
//< ch-0 ch-1 ch-2 ch-3 extern crate rustc_serialize; extern crate docopt; extern crate iron_kaleidoscope; use iron_kaleidoscope::driver::{main_loop, //> ch-0 ch-1 ch-2 Exec, //< ch-2 IR, //< ch-1 AST, //< ch-0 Tokens }; //< parser-main use docopt::Docopt; const USAGE: &'static str = " Usage: iron_kaleidoscope [(-l | -p | -i)] Options: -l Run only lexer and show its output. -p Run only parser and show its output. -i Run only IR builder and show its output. "; #[derive(Debug, RustcDecodable)] struct Args { flag_l: bool, flag_p: bool, flag_i: bool } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.decode()) .unwrap_or_else(|e| e.exit()); //> ch-0 let stage = if args.flag_l { Tokens //> ch-1 parser-main } else if args.flag_p { AST //< ch-1 } else if args.flag_i { //> ch-1 ch-2 ch-3 /* //< ch-1 unimplemented!(); //> ch-1 */ //< ch-2 ch-3 IR //< ch-1 parser-main } else { //> ch-1 ch-2 ch-3 parser-main /* //< ch-0 if args.flag_p || args.flag_i { unimplemented!(); } let stage = Tokens; //> ch-0 //< ch-1 parser-main AST //> ch-1 parser-main //< ch-2 IR //> ch-2 */ //< ch-3 Exec //< ch-1 ch-2 parser-main }; //< ch-0 main_loop(stage); } //> ch-0 ch-1 ch-2 ch-3 parser-main
{ "pile_set_name": "Github" }
--TEST-- MongoDB\Driver\Session::getClusterTime() --SKIPIF-- <?php require __DIR__ . "/../utils/basic-skipif.inc"; ?> <?php skip_if_not_libmongoc_crypto(); ?> <?php skip_if_not_replica_set_or_mongos_with_replica_set(); ?> <?php skip_if_server_version('<', '3.6'); ?> --FILE-- <?php require_once __DIR__ . "/../utils/basic.inc"; $manager = new MongoDB\Driver\Manager(URI); $session = $manager->startSession(); echo "Initial cluster time:\n"; var_dump($session->getClusterTime()); $command = new MongoDB\Driver\Command(['ping' => 1]); $manager->executeCommand(DATABASE_NAME, $command, ['session' => $session]); echo "\nCluster time after command:\n"; var_dump($session->getClusterTime()); ?> ===DONE=== <?php exit(0); ?> --EXPECTF-- Initial cluster time: NULL Cluster time after command: object(stdClass)#%d (%d) { ["clusterTime"]=> object(MongoDB\BSON\Timestamp)#%d (%d) { ["increment"]=> string(%d) "%d" ["timestamp"]=> string(%d) "%d" } ["signature"]=> %a } ===DONE===
{ "pile_set_name": "Github" }
<?php // +---------------------------------------------------------------------- // | 海豚PHP框架 [ DolphinPHP ] // +---------------------------------------------------------------------- // | 版权所有 2016~2019 广东卓锐软件有限公司 [ http://www.zrthink.com ] // +---------------------------------------------------------------------- // | 官方网站: http://dolphinphp.com // +---------------------------------------------------------------------- namespace app\admin\validate; use think\Validate; /** * 插件验证器 * @package app\admin\validate * @author 蔡伟明 <[email protected]> */ class Plugin extends Validate { //定义验证规则 protected $rule = [ 'name|插件名称' => 'require|unique:admin_plugin', 'title|插件标题' => 'require', ]; }
{ "pile_set_name": "Github" }
/* * jQuery UI CSS Framework 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Theming/API */ /* Layout helpers ----------------------------------*/ .ui-helper-hidden { display: none; } .ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } .ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; } .ui-helper-clearfix:after { clear: both; } .ui-helper-clearfix { zoom: 1; } .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } /* Interaction Cues ----------------------------------*/ .ui-state-disabled { cursor: default !important; } /* Icons ----------------------------------*/ /* states and images */ .ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } /* Misc visuals ----------------------------------*/ /* Overlays */ .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } /* * jQuery UI CSS Framework 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Theming/API * * To view and modify this theme, visit http://jqueryui.com/themeroller/?ctl=themeroller */ /* Component containers ----------------------------------*/ .ui-widget { font-family: Verdana,Arial,sans-serif; font-size: 1.1em; } .ui-widget .ui-widget { font-size: 1em; } .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Verdana,Arial,sans-serif; font-size: 1em; } .ui-widget-content { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_glass_75_ffffff_1x400.png) 50% 50% repeat-x; color: #222222; } .ui-widget-content a { color: #222222; } .ui-widget-header { border: 1px solid #aaaaaa; background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x; color: #222222; font-weight: bold; } .ui-widget-header a { color: #222222; } /* Interaction states ----------------------------------*/ .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #d3d3d3; background: #e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #555555; } .ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #555555; text-decoration: none; } .ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #999999; background: #dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; } .ui-state-hover a, .ui-state-hover a:hover { color: #212121; text-decoration: none; } .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #aaaaaa; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: normal; color: #212121; } .ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #212121; text-decoration: none; } .ui-widget :active { outline: none; } /* Interaction Cues ----------------------------------*/ .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x; color: #363636; } .ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; } .ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_inset-soft_95_fef1ec_1x100.png) 50% bottom repeat-x; color: #cd0a0a; } .ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; } .ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; } .ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } .ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } .ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } /* Icons ----------------------------------*/ /* states and images */ .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); } .ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } .ui-widget-header .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); } .ui-state-default .ui-icon { background-image: url(images/ui-icons_888888_256x240.png); } .ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); } .ui-state-active .ui-icon {background-image: url(images/ui-icons_454545_256x240.png); } .ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); } .ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); } /* positioning */ .ui-icon-carat-1-n { background-position: 0 0; } .ui-icon-carat-1-ne { background-position: -16px 0; } .ui-icon-carat-1-e { background-position: -32px 0; } .ui-icon-carat-1-se { background-position: -48px 0; } .ui-icon-carat-1-s { background-position: -64px 0; } .ui-icon-carat-1-sw { background-position: -80px 0; } .ui-icon-carat-1-w { background-position: -96px 0; } .ui-icon-carat-1-nw { background-position: -112px 0; } .ui-icon-carat-2-n-s { background-position: -128px 0; } .ui-icon-carat-2-e-w { background-position: -144px 0; } .ui-icon-triangle-1-n { background-position: 0 -16px; } .ui-icon-triangle-1-ne { background-position: -16px -16px; } .ui-icon-triangle-1-e { background-position: -32px -16px; } .ui-icon-triangle-1-se { background-position: -48px -16px; } .ui-icon-triangle-1-s { background-position: -64px -16px; } .ui-icon-triangle-1-sw { background-position: -80px -16px; } .ui-icon-triangle-1-w { background-position: -96px -16px; } .ui-icon-triangle-1-nw { background-position: -112px -16px; } .ui-icon-triangle-2-n-s { background-position: -128px -16px; } .ui-icon-triangle-2-e-w { background-position: -144px -16px; } .ui-icon-arrow-1-n { background-position: 0 -32px; } .ui-icon-arrow-1-ne { background-position: -16px -32px; } .ui-icon-arrow-1-e { background-position: -32px -32px; } .ui-icon-arrow-1-se { background-position: -48px -32px; } .ui-icon-arrow-1-s { background-position: -64px -32px; } .ui-icon-arrow-1-sw { background-position: -80px -32px; } .ui-icon-arrow-1-w { background-position: -96px -32px; } .ui-icon-arrow-1-nw { background-position: -112px -32px; } .ui-icon-arrow-2-n-s { background-position: -128px -32px; } .ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } .ui-icon-arrow-2-e-w { background-position: -160px -32px; } .ui-icon-arrow-2-se-nw { background-position: -176px -32px; } .ui-icon-arrowstop-1-n { background-position: -192px -32px; } .ui-icon-arrowstop-1-e { background-position: -208px -32px; } .ui-icon-arrowstop-1-s { background-position: -224px -32px; } .ui-icon-arrowstop-1-w { background-position: -240px -32px; } .ui-icon-arrowthick-1-n { background-position: 0 -48px; } .ui-icon-arrowthick-1-ne { background-position: -16px -48px; } .ui-icon-arrowthick-1-e { background-position: -32px -48px; } .ui-icon-arrowthick-1-se { background-position: -48px -48px; } .ui-icon-arrowthick-1-s { background-position: -64px -48px; } .ui-icon-arrowthick-1-sw { background-position: -80px -48px; } .ui-icon-arrowthick-1-w { background-position: -96px -48px; } .ui-icon-arrowthick-1-nw { background-position: -112px -48px; } .ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } .ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } .ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } .ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } .ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } .ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } .ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } .ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } .ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } .ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } .ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } .ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } .ui-icon-arrowreturn-1-w { background-position: -64px -64px; } .ui-icon-arrowreturn-1-n { background-position: -80px -64px; } .ui-icon-arrowreturn-1-e { background-position: -96px -64px; } .ui-icon-arrowreturn-1-s { background-position: -112px -64px; } .ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } .ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } .ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } .ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } .ui-icon-arrow-4 { background-position: 0 -80px; } .ui-icon-arrow-4-diag { background-position: -16px -80px; } .ui-icon-extlink { background-position: -32px -80px; } .ui-icon-newwin { background-position: -48px -80px; } .ui-icon-refresh { background-position: -64px -80px; } .ui-icon-shuffle { background-position: -80px -80px; } .ui-icon-transfer-e-w { background-position: -96px -80px; } .ui-icon-transferthick-e-w { background-position: -112px -80px; } .ui-icon-folder-collapsed { background-position: 0 -96px; } .ui-icon-folder-open { background-position: -16px -96px; } .ui-icon-document { background-position: -32px -96px; } .ui-icon-document-b { background-position: -48px -96px; } .ui-icon-note { background-position: -64px -96px; } .ui-icon-mail-closed { background-position: -80px -96px; } .ui-icon-mail-open { background-position: -96px -96px; } .ui-icon-suitcase { background-position: -112px -96px; } .ui-icon-comment { background-position: -128px -96px; } .ui-icon-person { background-position: -144px -96px; } .ui-icon-print { background-position: -160px -96px; } .ui-icon-trash { background-position: -176px -96px; } .ui-icon-locked { background-position: -192px -96px; } .ui-icon-unlocked { background-position: -208px -96px; } .ui-icon-bookmark { background-position: -224px -96px; } .ui-icon-tag { background-position: -240px -96px; } .ui-icon-home { background-position: 0 -112px; } .ui-icon-flag { background-position: -16px -112px; } .ui-icon-calendar { background-position: -32px -112px; } .ui-icon-cart { background-position: -48px -112px; } .ui-icon-pencil { background-position: -64px -112px; } .ui-icon-clock { background-position: -80px -112px; } .ui-icon-disk { background-position: -96px -112px; } .ui-icon-calculator { background-position: -112px -112px; } .ui-icon-zoomin { background-position: -128px -112px; } .ui-icon-zoomout { background-position: -144px -112px; } .ui-icon-search { background-position: -160px -112px; } .ui-icon-wrench { background-position: -176px -112px; } .ui-icon-gear { background-position: -192px -112px; } .ui-icon-heart { background-position: -208px -112px; } .ui-icon-star { background-position: -224px -112px; } .ui-icon-link { background-position: -240px -112px; } .ui-icon-cancel { background-position: 0 -128px; } .ui-icon-plus { background-position: -16px -128px; } .ui-icon-plusthick { background-position: -32px -128px; } .ui-icon-minus { background-position: -48px -128px; } .ui-icon-minusthick { background-position: -64px -128px; } .ui-icon-close { background-position: -80px -128px; } .ui-icon-closethick { background-position: -96px -128px; } .ui-icon-key { background-position: -112px -128px; } .ui-icon-lightbulb { background-position: -128px -128px; } .ui-icon-scissors { background-position: -144px -128px; } .ui-icon-clipboard { background-position: -160px -128px; } .ui-icon-copy { background-position: -176px -128px; } .ui-icon-contact { background-position: -192px -128px; } .ui-icon-image { background-position: -208px -128px; } .ui-icon-video { background-position: -224px -128px; } .ui-icon-script { background-position: -240px -128px; } .ui-icon-alert { background-position: 0 -144px; } .ui-icon-info { background-position: -16px -144px; } .ui-icon-notice { background-position: -32px -144px; } .ui-icon-help { background-position: -48px -144px; } .ui-icon-check { background-position: -64px -144px; } .ui-icon-bullet { background-position: -80px -144px; } .ui-icon-radio-off { background-position: -96px -144px; } .ui-icon-radio-on { background-position: -112px -144px; } .ui-icon-pin-w { background-position: -128px -144px; } .ui-icon-pin-s { background-position: -144px -144px; } .ui-icon-play { background-position: 0 -160px; } .ui-icon-pause { background-position: -16px -160px; } .ui-icon-seek-next { background-position: -32px -160px; } .ui-icon-seek-prev { background-position: -48px -160px; } .ui-icon-seek-end { background-position: -64px -160px; } .ui-icon-seek-start { background-position: -80px -160px; } /* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ .ui-icon-seek-first { background-position: -80px -160px; } .ui-icon-stop { background-position: -96px -160px; } .ui-icon-eject { background-position: -112px -160px; } .ui-icon-volume-off { background-position: -128px -160px; } .ui-icon-volume-on { background-position: -144px -160px; } .ui-icon-power { background-position: 0 -176px; } .ui-icon-signal-diag { background-position: -16px -176px; } .ui-icon-signal { background-position: -32px -176px; } .ui-icon-battery-0 { background-position: -48px -176px; } .ui-icon-battery-1 { background-position: -64px -176px; } .ui-icon-battery-2 { background-position: -80px -176px; } .ui-icon-battery-3 { background-position: -96px -176px; } .ui-icon-circle-plus { background-position: 0 -192px; } .ui-icon-circle-minus { background-position: -16px -192px; } .ui-icon-circle-close { background-position: -32px -192px; } .ui-icon-circle-triangle-e { background-position: -48px -192px; } .ui-icon-circle-triangle-s { background-position: -64px -192px; } .ui-icon-circle-triangle-w { background-position: -80px -192px; } .ui-icon-circle-triangle-n { background-position: -96px -192px; } .ui-icon-circle-arrow-e { background-position: -112px -192px; } .ui-icon-circle-arrow-s { background-position: -128px -192px; } .ui-icon-circle-arrow-w { background-position: -144px -192px; } .ui-icon-circle-arrow-n { background-position: -160px -192px; } .ui-icon-circle-zoomin { background-position: -176px -192px; } .ui-icon-circle-zoomout { background-position: -192px -192px; } .ui-icon-circle-check { background-position: -208px -192px; } .ui-icon-circlesmall-plus { background-position: 0 -208px; } .ui-icon-circlesmall-minus { background-position: -16px -208px; } .ui-icon-circlesmall-close { background-position: -32px -208px; } .ui-icon-squaresmall-plus { background-position: -48px -208px; } .ui-icon-squaresmall-minus { background-position: -64px -208px; } .ui-icon-squaresmall-close { background-position: -80px -208px; } .ui-icon-grip-dotted-vertical { background-position: 0 -224px; } .ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } .ui-icon-grip-solid-vertical { background-position: -32px -224px; } .ui-icon-grip-solid-horizontal { background-position: -48px -224px; } .ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } .ui-icon-grip-diagonal-se { background-position: -80px -224px; } /* Misc visuals ----------------------------------*/ /* Corner radius */ .ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; } .ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; } .ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; } .ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; } /* Overlays */ .ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -khtml-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* * jQuery UI Resizable 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Resizable#theming */ .ui-resizable { position: relative;} .ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block; } .ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } .ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } .ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; } .ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; } .ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; } .ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } .ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } .ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } .ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/* * jQuery UI Selectable 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Selectable#theming */ .ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; } /* * jQuery UI Accordion 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Accordion#theming */ /* IE/Win - Fix animation bug - #4615 */ .ui-accordion { width: 100%; } .ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; } .ui-accordion .ui-accordion-li-fix { display: inline; } .ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; } .ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; } .ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; } .ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } .ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; } .ui-accordion .ui-accordion-content-active { display: block; } /* * jQuery UI Autocomplete 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Autocomplete#theming */ .ui-autocomplete { position: absolute; cursor: default; } /* workarounds */ * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */ /* * jQuery UI Menu 1.8.18 * * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Menu#theming */ .ui-menu { list-style:none; padding: 2px; margin: 0; display:block; float: left; } .ui-menu .ui-menu { margin-top: -3px; } .ui-menu .ui-menu-item { margin:0; padding: 0; zoom: 1; float: left; clear: left; width: 100%; } .ui-menu .ui-menu-item a { text-decoration:none; display:block; padding:.2em .4em; line-height:1.5; zoom:1; } .ui-menu .ui-menu-item a.ui-state-hover, .ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; } /* * jQuery UI Button 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Button#theming */ .ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: hidden; *overflow: visible; } /* the overflow property removes extra width in IE */ .ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */ button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */ .ui-button-icons-only { width: 3.4em; } button.ui-button-icons-only { width: 3.7em; } /*button text element */ .ui-button .ui-button-text { display: block; line-height: 1.4; } .ui-button-text-only .ui-button-text { padding: .4em 1em; } .ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; } .ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } .ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; } .ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } /* no icon support for input elements, provide padding by default */ input.ui-button { padding: .4em 1em; } /*button icon element(s) */ .ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; } .ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; } .ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; } .ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } /*button sets*/ .ui-buttonset { margin-right: 7px; } .ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; } /* workarounds */ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */ /* * jQuery UI Dialog 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Dialog#theming */ .ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; } .ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; } .ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; } .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } .ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } .ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } .ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } .ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; } .ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; } .ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } .ui-draggable .ui-dialog-titlebar { cursor: move; } /* * jQuery UI Slider 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Slider#theming */ .ui-slider { position: relative; text-align: left; } .ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; } .ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; } .ui-slider-horizontal { height: .8em; } .ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; } .ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; } .ui-slider-horizontal .ui-slider-range-min { left: 0; } .ui-slider-horizontal .ui-slider-range-max { right: 0; } .ui-slider-vertical { width: .8em; height: 100px; } .ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; } .ui-slider-vertical .ui-slider-range { left: 0; width: 100%; } .ui-slider-vertical .ui-slider-range-min { bottom: 0; } .ui-slider-vertical .ui-slider-range-max { top: 0; }/* * jQuery UI Tabs 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Tabs#theming */ .ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ .ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } .ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } .ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } .ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } .ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } .ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ .ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; } .ui-tabs .ui-tabs-hide { display: none !important; } /* * jQuery UI Datepicker 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Datepicker#theming */ .ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; } .ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } .ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } .ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } .ui-datepicker .ui-datepicker-prev { left:2px; } .ui-datepicker .ui-datepicker-next { right:2px; } .ui-datepicker .ui-datepicker-prev-hover { left:1px; } .ui-datepicker .ui-datepicker-next-hover { right:1px; } .ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; } .ui-datepicker select.ui-datepicker-month-year {width: 100%;} .ui-datepicker select.ui-datepicker-month, .ui-datepicker select.ui-datepicker-year { width: 49%;} .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } .ui-datepicker td { border: 0; padding: 1px; } .ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } .ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } .ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } /* with multiple calendars */ .ui-datepicker.ui-datepicker-multi { width:auto; } .ui-datepicker-multi .ui-datepicker-group { float:left; } .ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } .ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } .ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } .ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } .ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } .ui-datepicker-row-break { clear:both; width:100%; font-size:0em; } /* RTL support */ .ui-datepicker-rtl { direction: rtl; } .ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } .ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } .ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } .ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } .ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } .ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } .ui-datepicker-rtl .ui-datepicker-group { float:right; } .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } /* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ .ui-datepicker-cover { display: none; /*sorry for IE5*/ display/**/: block; /*sorry for IE5*/ position: absolute; /*must have*/ z-index: -1; /*must have*/ filter: mask(); /*must have*/ top: -4px; /*must have*/ left: -4px; /*must have*/ width: 200px; /*must have*/ height: 200px; /*must have*/ }/* * jQuery UI Progressbar 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Progressbar#theming */ .ui-progressbar { height:2em; text-align: left; overflow: hidden; } .ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }
{ "pile_set_name": "Github" }
// SPDX-License-Identifier: MIT // Copyright (c) 2015-2020 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. const std = @import("../std.zig"); const io = std.io; const testing = std.testing; /// Takes a tuple of streams, and constructs a new stream that writes to all of them pub fn MultiWriter(comptime Writers: type) type { comptime var ErrSet = error{}; inline for (@typeInfo(Writers).Struct.fields) |field| { const StreamType = field.field_type; ErrSet = ErrSet || StreamType.Error; } return struct { const Self = @This(); streams: Writers, pub const Error = ErrSet; pub const Writer = io.Writer(*Self, Error, write); /// Deprecated: use `Writer` pub const OutStream = Writer; pub fn writer(self: *Self) Writer { return .{ .context = self }; } /// Deprecated: use `writer` pub fn outStream(self: *Self) OutStream { return .{ .context = self }; } pub fn write(self: *Self, bytes: []const u8) Error!usize { var batch = std.event.Batch(Error!void, self.streams.len, .auto_async).init(); comptime var i = 0; inline while (i < self.streams.len) : (i += 1) { const stream = self.streams[i]; // TODO: remove ptrCast: https://github.com/ziglang/zig/issues/5258 batch.add(@ptrCast(anyframe->Error!void, &async stream.writeAll(bytes))); } try batch.wait(); return bytes.len; } }; } pub fn multiWriter(streams: anytype) MultiWriter(@TypeOf(streams)) { return .{ .streams = streams }; } test "MultiWriter" { var buf1: [255]u8 = undefined; var fbs1 = io.fixedBufferStream(&buf1); var buf2: [255]u8 = undefined; var fbs2 = io.fixedBufferStream(&buf2); var stream = multiWriter(.{ fbs1.writer(), fbs2.writer() }); try stream.writer().print("HI", .{}); testing.expectEqualSlices(u8, "HI", fbs1.getWritten()); testing.expectEqualSlices(u8, "HI", fbs2.getWritten()); }
{ "pile_set_name": "Github" }
LIBRARY api-ms-win-core-localization-l1-2-1.dll EXPORTS EnumSystemLocalesEx@16
{ "pile_set_name": "Github" }
1 9 126 338 452 470 484 784 979 986 1007 1112 1130 1133 1321 1621 1712 1725 1737 1746 1867 1881 1893 1897 2197 2480 2505 2525 2640 2670 2970 3232 3285 3404 3420 3435 3439 3739 3783 3866 4080 4148 4259 4272 4281 4367 4368 4406 4599 4686 4929 4970 4982 4996 5105 5125 5134 5434 5728 5746 5785 5885 5902 5914 6059 6061 6066 6366 6549 6610 6704 6745 6751 6914 7034 7035 7288 7344 7357 7371 7395 7503 7515 7534 7699 7999 8169 8262 8273 8274 8299 8321 8340 8361 8383 8409 8434 8460 8481 8517 8521 8529
{ "pile_set_name": "Github" }
''' Common Themes ============= Tenable.sc CRUD within pyTenable -------------------------------- pyTenable allows for the ability to leverage both the naturalized inputs as well as passing the raw parameters within the same structure. In some cases this doesn't seem immediately obvious, however allows for the ability to pass parameters that either haven't yet been, or in some cases, may never be interpreted by the library. For example, in the alerts API, you could pass the snake_cased ``always_exec_on_trigger`` or you could pass what the API endpoint itself expects, which is ``executeOnEveryTrigger``. The snake-cased version expects a boolean value, which will be converted into the string value that camelCased variant expects. You'll see this behavior a lot throughout the library, and is intended to allow you to sidestep most things should you need to. For example, in the alerts API again, you may not want to pass a trigger as ``trigger=('sumip', '>=', '100')`` and instead pass as the parameters that are to be written into the JSON request: ``triggerName='sumip', triggerOperator='>=', triggerValue='100'``. Both of these methods will produce the same JSON request, and the the option is yours to use the right way for the job. Along these same lines, its possible to see how the JSON documents are being constructed by simply looking at the ``_constructor`` methods for each APIEndpoint class. If pyTenable is getting in your way, you can almost always sidestep it and pass the exact dictionary you wish to pass on to the API. Schedule Dictionaries --------------------- A dictionary detailing the repeating schedule within Tenable.sc. This dictionary consists of 1 or 3 parameters, depending on the type of schedule. In all of the definitions except ``ical``, a single parameter of ``type`` is passed with lone of the following values: ``ical``, ``never``, ``rollover``, and ``template``. If no document is specified, then the default of ``never`` is assumed. For repeating scans, you'll have to use the type of ``ical`` and also specify the ``start`` and ``repeatRule`` parameters as well. The ``start`` parameter is an `iCal DateTime Form #3 <https://tools.ietf.org/html/rfc5545#section-3.3.5>`_ formatted string specifying the date and time in which to start the repeating event. The ``repeatRule`` parameter is an `iCal Recurrance Rule <https://tools.ietf.org/html/rfc5545#section-3.3.10>`_ formatted string. * Example Never Declaration: .. code-block:: python {'type': 'never'} * Example daily event starting at 9am Eastern .. code-block:: python { 'type': 'ical', 'start': 'TZID=America/New_York:20190214T090000', 'repeatRule': 'FREQ=DAILY;INTERVAL=1' } * Example weekly event every Saturday at 8:30pm Eastern .. code-block:: python { 'type': 'ical', 'start': 'TZID=America/New_York:20190214T203000', 'repeatRule': 'FREQ=WEEKLY;BYDAY=SA;INTERVAL=1' } There are detailed instructions in the RFC documentation on how to construct these recurrence rules. Further there are some packages out there to aid in converting more human-readable text into recurrence rules, such as the `recurrent package <https://pypi.org/project/recurrent/>`_ for example. ''' from tenable.base import APIEndpoint, APIResultsIterator class SCEndpoint(APIEndpoint): def _combo_expansion(self, item): ''' Expands the asset combination expressions from nested tuples to the nested dictionary structure that's expected. Args: item Returns: :obj:`dict`: The dictionary structure of the expanded asset list combinations. ''' # the operator conversion dictionary. The UI uses "and", "or", and # "not" whereas the API uses "intersection", "union", and "compliment". # if the user is passing us the tuples, lets assume that they are using # the UI definitions and not the API ones. oper = { 'and': 'intersection', 'or': 'union', 'not': 'complement' } # some simple checking to ensure that we are being passed good data # before we expand the tuple. if len(item) < 2 or len(item) > 3: raise TypeError('{} must be exactly 1 operator and 1-2 items'.format(item)) self._check('operator', item[0], str, choices=oper.keys()) self._check('operand1', item[1], [int, tuple]) if len(item) == 3: self._check('operand2', item[2], [int, tuple]) resp = {'operator': oper[item[0].lower()]} # we need to expand the operand. If the item is a nested tuple, then # we will call ourselves and pass the tuple. If not, then we will # simply return a dictionary with the id value set to the integer that # was passed. if isinstance(item[1], tuple): resp['operand1'] = self._combo_expansion(item[1]) else: resp['operand1'] = {'id': str(item[1])} # if there are 2 operators in the tuple, then we will want to expand the # second one as well. If the item is a nested tuple, then we will call # ourselves and pass the tuple. If not, then we will simply return a # dictionary with the id value set to the integer that was passed. if len(item) == 3: if isinstance(item[2], tuple): resp['operand2'] = self._combo_expansion(item[2]) else: resp['operand2'] = {'id': str(item[2])} # return the response to the caller. return resp def _query_constructor(self, *filters, **kw): ''' Constructs an analysis query. This part has been pulled out of the _analysis method and placed here so that it can be re-used in other part of the library. ''' if 'filters' in kw: # if filters are explicitly called, then we will replace the # implicit filters with the explicit ones and remove the entry from # the keywords dictionary filters = self._check('filters', kw['filters'], list) del(kw['filters']) if 'query' not in kw and 'tool' in kw and 'type' in kw: kw['query'] = { 'tool': kw['tool'], 'type': kw['type'], 'filters': list() } if 'query_id' in kw: # Request the specific query ID provided and fetch only the filters query_response = self._api.get( 'query/{}?fields=filters'.format( kw['query_id'])).json()['response'] # Extract the filters or set to null if nothing is returned query_filters = query_response.get('filters', list()) kw['query']['filters'] = query_filters for f in filters: if kw['type'] == 'ticket': item = {'filterName': f[0], 'value': f[1]} else: item = {'filterName': f[0], 'operator': f[1]} if len(f) >= 3: if (isinstance(f[2], tuple) and f[1] == '~' and f[0] == 'asset'): # if this is a asset combination, then we will want to # expand the tuple into the expected dictionary # structure that the API is expecting. item['value'] = self._combo_expansion(f[2]) elif (isinstance(f[2], list) and all(isinstance(i, int) for i in f[2])): # if the value is a list and all of the items within # that list are integers, then we can safely assume that # this is a list of integer ids that need to be expanded # into a list of dictionaries. item['value'] = [dict(id=str(i)) for i in f[2]] elif (isinstance(f[2], int) and f[0] in ['asset',]): # If the value is an integer, then we will want to # expand the value into a dictionary with an id attr. item['value'] = dict(id=str(f[2])) else: # if we don't have any specific conditions set, then # simply return the value parameter assigned to the # "value" attribute item['value'] = f[2] # Added this here to make the filter list overloadable. As SC # only supports one filter of a given type, if an existing # filter is already in the list, we will overload it with the # new one. This allows for the ability to overload query # filters if need be, or to overload a saved filterset that # someone is appending to. flist = [i['filterName'] for i in kw['query']['filters']] if f[0] in flist: kw['query']['filters'].pop(flist.index(f[0])) # Add the newly expanded filter to the filters list as long as # both the operator and value are not None. If both are none, # then skip appending. This should allow for effectively # removing an unwanted filter from a query if a query id is # specified. if f[1] != None and f[2] != None: kw['query']['filters'].append(item) del(kw['type']) return kw def _schedule_constructor(self, item): ''' Handles creation of the schedule sub-document. ''' self._check('schedule:item', item, dict) item['type'] = self._check('schedule:type', item.get('type'), str, choices=['ical', 'dependent', 'never', 'rollover', 'template', 'now'], default='never') if item['type'] == 'ical': self._check('schedule:start', item.get('start'), str) self._check('schedule:repeatRule', item.get('repeatRule'), str) if item['type'] == 'dependent': self._check('schedule:dependentID', item.get('dependentID'), int) return item class SCResultsIterator(APIResultsIterator): def _get_page(self): ''' Retrieves the next page of results when the current page has been exhausted. ''' # First we need to see if there is a page limit and if there is, have # we run into that limit. If we have, then return a StopIteration # exception. if self._pages_total and self._pages_requested >= self._pages_total: raise StopIteration() # Now we need to do is construct the query with the current offset # and limits query = self._query query['startOffset'] = self._offset query['endOffset'] = self._limit + self._offset # Lets actually call the API for the data at this point. resp = self._api.get(self._resource, params=query).json() # Now that we have the response, lets reset any counters we need to, # and increment things like the page counter, offset, etc. self.page_count = 0 self._pages_requested += 1 self._offset += self._limit self._raw = resp self.page = resp['response'] # As no total is returned via the API, we will simply need to re-compute # the total to be N+1 every page as long as the page of data is equal to # the limit. If we ever get a page of data that is less than the limit, # then we will set the total to be the count + page length. if len(resp['response']) < self._limit: self.total = self.count + len(resp['response']) else: self.total = self.count + self._limit + 1
{ "pile_set_name": "Github" }
DEAL:2d::id=0 n_coarsen=4 DEAL:2d::-4.00000 DEAL:2d::-4.00000 DEAL:2d::-4.00000 DEAL:2d::2.00000 DEAL:2d::2.00000 DEAL:2d::2.00000 DEAL:2d::2.00000 DEAL::OK
{ "pile_set_name": "Github" }
maintainer: email: "[email protected]" capabilities: site: mediaTypes: - banner - video app: mediaTypes: - banner - video
{ "pile_set_name": "Github" }
/* * Atheros CARL9170 driver * * debug(fs) probing * * Copyright 2008, Johannes Berg <[email protected]> * Copyright 2009, 2010, Christian Lamparter <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; see the file COPYING. If not, see * http://www.gnu.org/licenses/. * * This file incorporates work covered by the following copyright and * permission notice: * Copyright (c) 2008-2009 Atheros Communications, Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <linux/slab.h> #include <linux/module.h> #include <linux/seq_file.h> #include <linux/vmalloc.h> #include "carl9170.h" #include "cmd.h" #define ADD(buf, off, max, fmt, args...) \ off += snprintf(&buf[off], max - off, fmt, ##args); struct carl9170_debugfs_fops { unsigned int read_bufsize; umode_t attr; char *(*read)(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *len); ssize_t (*write)(struct ar9170 *aru, const char *buf, size_t size); const struct file_operations fops; enum carl9170_device_state req_dev_state; }; static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) { struct carl9170_debugfs_fops *dfops; struct ar9170 *ar; char *buf = NULL, *res_buf = NULL; ssize_t ret = 0; int err = 0; if (!count) return 0; ar = file->private_data; if (!ar) return -ENODEV; dfops = container_of(debugfs_real_fops(file), struct carl9170_debugfs_fops, fops); if (!dfops->read) return -ENOSYS; if (dfops->read_bufsize) { buf = vmalloc(dfops->read_bufsize); if (!buf) return -ENOMEM; } mutex_lock(&ar->mutex); if (!CHK_DEV_STATE(ar, dfops->req_dev_state)) { err = -ENODEV; res_buf = buf; goto out_free; } res_buf = dfops->read(ar, buf, dfops->read_bufsize, &ret); if (ret > 0) err = simple_read_from_buffer(userbuf, count, ppos, res_buf, ret); else err = ret; WARN_ON_ONCE(dfops->read_bufsize && (res_buf != buf)); out_free: vfree(res_buf); mutex_unlock(&ar->mutex); return err; } static ssize_t carl9170_debugfs_write(struct file *file, const char __user *userbuf, size_t count, loff_t *ppos) { struct carl9170_debugfs_fops *dfops; struct ar9170 *ar; char *buf = NULL; int err = 0; if (!count) return 0; if (count > PAGE_SIZE) return -E2BIG; ar = file->private_data; if (!ar) return -ENODEV; dfops = container_of(debugfs_real_fops(file), struct carl9170_debugfs_fops, fops); if (!dfops->write) return -ENOSYS; buf = vmalloc(count); if (!buf) return -ENOMEM; if (copy_from_user(buf, userbuf, count)) { err = -EFAULT; goto out_free; } if (mutex_trylock(&ar->mutex) == 0) { err = -EAGAIN; goto out_free; } if (!CHK_DEV_STATE(ar, dfops->req_dev_state)) { err = -ENODEV; goto out_unlock; } err = dfops->write(ar, buf, count); if (err) goto out_unlock; out_unlock: mutex_unlock(&ar->mutex); out_free: vfree(buf); return err; } #define __DEBUGFS_DECLARE_FILE(name, _read, _write, _read_bufsize, \ _attr, _dstate) \ static const struct carl9170_debugfs_fops carl_debugfs_##name ##_ops = {\ .read_bufsize = _read_bufsize, \ .read = _read, \ .write = _write, \ .attr = _attr, \ .req_dev_state = _dstate, \ .fops = { \ .open = simple_open, \ .read = carl9170_debugfs_read, \ .write = carl9170_debugfs_write, \ .owner = THIS_MODULE \ }, \ } #define DEBUGFS_DECLARE_FILE(name, _read, _write, _read_bufsize, _attr) \ __DEBUGFS_DECLARE_FILE(name, _read, _write, _read_bufsize, \ _attr, CARL9170_STARTED) \ #define DEBUGFS_DECLARE_RO_FILE(name, _read_bufsize) \ DEBUGFS_DECLARE_FILE(name, carl9170_debugfs_##name ##_read, \ NULL, _read_bufsize, S_IRUSR) #define DEBUGFS_DECLARE_WO_FILE(name) \ DEBUGFS_DECLARE_FILE(name, NULL, carl9170_debugfs_##name ##_write,\ 0, S_IWUSR) #define DEBUGFS_DECLARE_RW_FILE(name, _read_bufsize) \ DEBUGFS_DECLARE_FILE(name, carl9170_debugfs_##name ##_read, \ carl9170_debugfs_##name ##_write, \ _read_bufsize, S_IRUSR | S_IWUSR) #define __DEBUGFS_DECLARE_RW_FILE(name, _read_bufsize, _dstate) \ __DEBUGFS_DECLARE_FILE(name, carl9170_debugfs_##name ##_read, \ carl9170_debugfs_##name ##_write, \ _read_bufsize, S_IRUSR | S_IWUSR, _dstate) #define DEBUGFS_READONLY_FILE(name, _read_bufsize, fmt, value...) \ static char *carl9170_debugfs_ ##name ## _read(struct ar9170 *ar, \ char *buf, size_t buf_size,\ ssize_t *len) \ { \ ADD(buf, *len, buf_size, fmt "\n", ##value); \ return buf; \ } \ DEBUGFS_DECLARE_RO_FILE(name, _read_bufsize) static char *carl9170_debugfs_mem_usage_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *len) { spin_lock_bh(&ar->mem_lock); ADD(buf, *len, bufsize, "jar: [%*pb]\n", ar->fw.mem_blocks, ar->mem_bitmap); ADD(buf, *len, bufsize, "cookies: used:%3d / total:%3d, allocs:%d\n", bitmap_weight(ar->mem_bitmap, ar->fw.mem_blocks), ar->fw.mem_blocks, atomic_read(&ar->mem_allocs)); ADD(buf, *len, bufsize, "memory: free:%3d (%3d KiB) / total:%3d KiB)\n", atomic_read(&ar->mem_free_blocks), (atomic_read(&ar->mem_free_blocks) * ar->fw.mem_block_size) / 1024, (ar->fw.mem_blocks * ar->fw.mem_block_size) / 1024); spin_unlock_bh(&ar->mem_lock); return buf; } DEBUGFS_DECLARE_RO_FILE(mem_usage, 512); static char *carl9170_debugfs_qos_stat_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *len) { ADD(buf, *len, bufsize, "%s QoS AC\n", modparam_noht ? "Hardware" : "Software"); ADD(buf, *len, bufsize, "[ VO VI " " BE BK ]\n"); spin_lock_bh(&ar->tx_stats_lock); ADD(buf, *len, bufsize, "[length/limit length/limit " "length/limit length/limit ]\n" "[ %3d/%3d %3d/%3d " " %3d/%3d %3d/%3d ]\n\n", ar->tx_stats[0].len, ar->tx_stats[0].limit, ar->tx_stats[1].len, ar->tx_stats[1].limit, ar->tx_stats[2].len, ar->tx_stats[2].limit, ar->tx_stats[3].len, ar->tx_stats[3].limit); ADD(buf, *len, bufsize, "[ total total " " total total ]\n" "[%10d %10d %10d %10d ]\n\n", ar->tx_stats[0].count, ar->tx_stats[1].count, ar->tx_stats[2].count, ar->tx_stats[3].count); spin_unlock_bh(&ar->tx_stats_lock); ADD(buf, *len, bufsize, "[ pend/waittx pend/waittx " " pend/waittx pend/waittx]\n" "[ %3d/%3d %3d/%3d " " %3d/%3d %3d/%3d ]\n\n", skb_queue_len(&ar->tx_pending[0]), skb_queue_len(&ar->tx_status[0]), skb_queue_len(&ar->tx_pending[1]), skb_queue_len(&ar->tx_status[1]), skb_queue_len(&ar->tx_pending[2]), skb_queue_len(&ar->tx_status[2]), skb_queue_len(&ar->tx_pending[3]), skb_queue_len(&ar->tx_status[3])); return buf; } DEBUGFS_DECLARE_RO_FILE(qos_stat, 512); static void carl9170_debugfs_format_frame(struct ar9170 *ar, struct sk_buff *skb, const char *prefix, char *buf, ssize_t *off, ssize_t bufsize) { struct _carl9170_tx_superframe *txc = (void *) skb->data; struct ieee80211_tx_info *txinfo = IEEE80211_SKB_CB(skb); struct carl9170_tx_info *arinfo = (void *) txinfo->rate_driver_data; struct ieee80211_hdr *hdr = (void *) txc->frame_data; ADD(buf, *off, bufsize, "%s %p, c:%2x, DA:%pM, sq:%4d, mc:%.4x, " "pc:%.8x, to:%d ms\n", prefix, skb, txc->s.cookie, ieee80211_get_DA(hdr), get_seq_h(hdr), le16_to_cpu(txc->f.mac_control), le32_to_cpu(txc->f.phy_control), jiffies_to_msecs(jiffies - arinfo->timeout)); } static char *carl9170_debugfs_ampdu_state_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *len) { struct carl9170_sta_tid *iter; struct sk_buff *skb; int cnt = 0, fc; int offset; rcu_read_lock(); list_for_each_entry_rcu(iter, &ar->tx_ampdu_list, list) { spin_lock_bh(&iter->lock); ADD(buf, *len, bufsize, "Entry: #%2d TID:%1d, BSN:%4d, " "SNX:%4d, HSN:%4d, BAW:%2d, state:%1d, toggles:%d\n", cnt, iter->tid, iter->bsn, iter->snx, iter->hsn, iter->max, iter->state, iter->counter); ADD(buf, *len, bufsize, "\tWindow: [%*pb,W]\n", CARL9170_BAW_BITS, iter->bitmap); #define BM_STR_OFF(offset) \ ((CARL9170_BAW_BITS - (offset) - 1) / 4 + \ (CARL9170_BAW_BITS - (offset) - 1) / 32 + 1) offset = BM_STR_OFF(0); ADD(buf, *len, bufsize, "\tBase Seq: %*s\n", offset, "T"); offset = BM_STR_OFF(SEQ_DIFF(iter->snx, iter->bsn)); ADD(buf, *len, bufsize, "\tNext Seq: %*s\n", offset, "W"); offset = BM_STR_OFF(((int)iter->hsn - (int)iter->bsn) % CARL9170_BAW_BITS); ADD(buf, *len, bufsize, "\tLast Seq: %*s\n", offset, "N"); ADD(buf, *len, bufsize, "\tPre-Aggregation reorder buffer: " " currently queued:%d\n", skb_queue_len(&iter->queue)); fc = 0; skb_queue_walk(&iter->queue, skb) { char prefix[32]; snprintf(prefix, sizeof(prefix), "\t\t%3d :", fc); carl9170_debugfs_format_frame(ar, skb, prefix, buf, len, bufsize); fc++; } spin_unlock_bh(&iter->lock); cnt++; } rcu_read_unlock(); return buf; } DEBUGFS_DECLARE_RO_FILE(ampdu_state, 8000); static void carl9170_debugfs_queue_dump(struct ar9170 *ar, char *buf, ssize_t *len, size_t bufsize, struct sk_buff_head *queue) { struct sk_buff *skb; char prefix[16]; int fc = 0; spin_lock_bh(&queue->lock); skb_queue_walk(queue, skb) { snprintf(prefix, sizeof(prefix), "%3d :", fc); carl9170_debugfs_format_frame(ar, skb, prefix, buf, len, bufsize); fc++; } spin_unlock_bh(&queue->lock); } #define DEBUGFS_QUEUE_DUMP(q, qi) \ static char *carl9170_debugfs_##q ##_##qi ##_read(struct ar9170 *ar, \ char *buf, size_t bufsize, ssize_t *len) \ { \ carl9170_debugfs_queue_dump(ar, buf, len, bufsize, &ar->q[qi]); \ return buf; \ } \ DEBUGFS_DECLARE_RO_FILE(q##_##qi, 8000); static char *carl9170_debugfs_sta_psm_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *len) { ADD(buf, *len, bufsize, "psm state: %s\n", (ar->ps.off_override ? "FORCE CAM" : (ar->ps.state ? "PSM" : "CAM"))); ADD(buf, *len, bufsize, "sleep duration: %d ms.\n", ar->ps.sleep_ms); ADD(buf, *len, bufsize, "last power-state transition: %d ms ago.\n", jiffies_to_msecs(jiffies - ar->ps.last_action)); ADD(buf, *len, bufsize, "last CAM->PSM transition: %d ms ago.\n", jiffies_to_msecs(jiffies - ar->ps.last_slept)); return buf; } DEBUGFS_DECLARE_RO_FILE(sta_psm, 160); static char *carl9170_debugfs_tx_stuck_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *len) { int i; for (i = 0; i < ar->hw->queues; i++) { ADD(buf, *len, bufsize, "TX queue [%d]: %10d max:%10d ms.\n", i, ieee80211_queue_stopped(ar->hw, i) ? jiffies_to_msecs(jiffies - ar->queue_stop_timeout[i]) : 0, jiffies_to_msecs(ar->max_queue_stop_timeout[i])); ar->max_queue_stop_timeout[i] = 0; } return buf; } DEBUGFS_DECLARE_RO_FILE(tx_stuck, 180); static char *carl9170_debugfs_phy_noise_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *len) { int err; err = carl9170_get_noisefloor(ar); if (err) { *len = err; return buf; } ADD(buf, *len, bufsize, "Chain 0: %10d dBm, ext. chan.:%10d dBm\n", ar->noise[0], ar->noise[2]); ADD(buf, *len, bufsize, "Chain 2: %10d dBm, ext. chan.:%10d dBm\n", ar->noise[1], ar->noise[3]); return buf; } DEBUGFS_DECLARE_RO_FILE(phy_noise, 180); static char *carl9170_debugfs_vif_dump_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *len) { struct carl9170_vif_info *iter; int i = 0; ADD(buf, *len, bufsize, "registered VIFs:%d \\ %d\n", ar->vifs, ar->fw.vif_num); ADD(buf, *len, bufsize, "VIF bitmap: [%*pb]\n", ar->fw.vif_num, &ar->vif_bitmap); rcu_read_lock(); list_for_each_entry_rcu(iter, &ar->vif_list, list) { struct ieee80211_vif *vif = carl9170_get_vif(iter); ADD(buf, *len, bufsize, "\t%d = [%s VIF, id:%d, type:%x " " mac:%pM %s]\n", i, (carl9170_get_main_vif(ar) == vif ? "Master" : " Slave"), iter->id, vif->type, vif->addr, iter->enable_beacon ? "beaconing " : ""); i++; } rcu_read_unlock(); return buf; } DEBUGFS_DECLARE_RO_FILE(vif_dump, 8000); #define UPDATE_COUNTER(ar, name) ({ \ u32 __tmp[ARRAY_SIZE(name##_regs)]; \ unsigned int __i, __err = -ENODEV; \ \ for (__i = 0; __i < ARRAY_SIZE(name##_regs); __i++) { \ __tmp[__i] = name##_regs[__i].reg; \ ar->debug.stats.name##_counter[__i] = 0; \ } \ \ if (IS_STARTED(ar)) \ __err = carl9170_read_mreg(ar, ARRAY_SIZE(name##_regs), \ __tmp, ar->debug.stats.name##_counter); \ (__err); }) #define TALLY_SUM_UP(ar, name) do { \ unsigned int __i; \ \ for (__i = 0; __i < ARRAY_SIZE(name##_regs); __i++) { \ ar->debug.stats.name##_sum[__i] += \ ar->debug.stats.name##_counter[__i]; \ } \ } while (0) #define DEBUGFS_HW_TALLY_FILE(name, f) \ static char *carl9170_debugfs_##name ## _read(struct ar9170 *ar, \ char *dum, size_t bufsize, ssize_t *ret) \ { \ char *buf; \ int i, max_len, err; \ \ max_len = ARRAY_SIZE(name##_regs) * 80; \ buf = vmalloc(max_len); \ if (!buf) \ return NULL; \ \ err = UPDATE_COUNTER(ar, name); \ if (err) { \ *ret = err; \ return buf; \ } \ \ TALLY_SUM_UP(ar, name); \ \ for (i = 0; i < ARRAY_SIZE(name##_regs); i++) { \ ADD(buf, *ret, max_len, "%22s = %" f "[+%" f "]\n", \ name##_regs[i].nreg, ar->debug.stats.name ##_sum[i],\ ar->debug.stats.name ##_counter[i]); \ } \ \ return buf; \ } \ DEBUGFS_DECLARE_RO_FILE(name, 0); #define DEBUGFS_HW_REG_FILE(name, f) \ static char *carl9170_debugfs_##name ## _read(struct ar9170 *ar, \ char *dum, size_t bufsize, ssize_t *ret) \ { \ char *buf; \ int i, max_len, err; \ \ max_len = ARRAY_SIZE(name##_regs) * 80; \ buf = vmalloc(max_len); \ if (!buf) \ return NULL; \ \ err = UPDATE_COUNTER(ar, name); \ if (err) { \ *ret = err; \ return buf; \ } \ \ for (i = 0; i < ARRAY_SIZE(name##_regs); i++) { \ ADD(buf, *ret, max_len, "%22s = %" f "\n", \ name##_regs[i].nreg, \ ar->debug.stats.name##_counter[i]); \ } \ \ return buf; \ } \ DEBUGFS_DECLARE_RO_FILE(name, 0); static ssize_t carl9170_debugfs_hw_ioread32_write(struct ar9170 *ar, const char *buf, size_t count) { int err = 0, i, n = 0, max_len = 32, res; unsigned int reg, tmp; if (!count) return 0; if (count > max_len) return -E2BIG; res = sscanf(buf, "0x%X %d", &reg, &n); if (res < 1) { err = -EINVAL; goto out; } if (res == 1) n = 1; if (n > 15) { err = -EMSGSIZE; goto out; } if ((reg >= 0x280000) || ((reg + (n << 2)) >= 0x280000)) { err = -EADDRNOTAVAIL; goto out; } if (reg & 3) { err = -EINVAL; goto out; } for (i = 0; i < n; i++) { err = carl9170_read_reg(ar, reg + (i << 2), &tmp); if (err) goto out; ar->debug.ring[ar->debug.ring_tail].reg = reg + (i << 2); ar->debug.ring[ar->debug.ring_tail].value = tmp; ar->debug.ring_tail++; ar->debug.ring_tail %= CARL9170_DEBUG_RING_SIZE; } out: return err ? err : count; } static char *carl9170_debugfs_hw_ioread32_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *ret) { int i = 0; while (ar->debug.ring_head != ar->debug.ring_tail) { ADD(buf, *ret, bufsize, "%.8x = %.8x\n", ar->debug.ring[ar->debug.ring_head].reg, ar->debug.ring[ar->debug.ring_head].value); ar->debug.ring_head++; ar->debug.ring_head %= CARL9170_DEBUG_RING_SIZE; if (i++ == 64) break; } ar->debug.ring_head = ar->debug.ring_tail; return buf; } DEBUGFS_DECLARE_RW_FILE(hw_ioread32, CARL9170_DEBUG_RING_SIZE * 40); static ssize_t carl9170_debugfs_bug_write(struct ar9170 *ar, const char *buf, size_t count) { int err; if (count < 1) return -EINVAL; switch (buf[0]) { case 'F': ar->needs_full_reset = true; break; case 'R': if (!IS_STARTED(ar)) { err = -EAGAIN; goto out; } ar->needs_full_reset = false; break; case 'M': err = carl9170_mac_reset(ar); if (err < 0) count = err; goto out; case 'P': err = carl9170_set_channel(ar, ar->hw->conf.chandef.chan, cfg80211_get_chandef_type(&ar->hw->conf.chandef)); if (err < 0) count = err; goto out; default: return -EINVAL; } carl9170_restart(ar, CARL9170_RR_USER_REQUEST); out: return count; } static char *carl9170_debugfs_bug_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *ret) { ADD(buf, *ret, bufsize, "[P]hy reinit, [R]estart, [F]ull usb reset, " "[M]ac reset\n"); ADD(buf, *ret, bufsize, "firmware restarts:%d, last reason:%d\n", ar->restart_counter, ar->last_reason); ADD(buf, *ret, bufsize, "phy reinit errors:%d (%d)\n", ar->total_chan_fail, ar->chan_fail); ADD(buf, *ret, bufsize, "reported firmware errors:%d\n", ar->fw.err_counter); ADD(buf, *ret, bufsize, "reported firmware BUGs:%d\n", ar->fw.bug_counter); ADD(buf, *ret, bufsize, "pending restart requests:%d\n", atomic_read(&ar->pending_restarts)); return buf; } __DEBUGFS_DECLARE_RW_FILE(bug, 400, CARL9170_STOPPED); static const char *const erp_modes[] = { [CARL9170_ERP_INVALID] = "INVALID", [CARL9170_ERP_AUTO] = "Automatic", [CARL9170_ERP_MAC80211] = "Set by MAC80211", [CARL9170_ERP_OFF] = "Force Off", [CARL9170_ERP_RTS] = "Force RTS", [CARL9170_ERP_CTS] = "Force CTS" }; static char *carl9170_debugfs_erp_read(struct ar9170 *ar, char *buf, size_t bufsize, ssize_t *ret) { ADD(buf, *ret, bufsize, "ERP Setting: (%d) -> %s\n", ar->erp_mode, erp_modes[ar->erp_mode]); return buf; } static ssize_t carl9170_debugfs_erp_write(struct ar9170 *ar, const char *buf, size_t count) { int res, val; if (count < 1) return -EINVAL; res = sscanf(buf, "%d", &val); if (res != 1) return -EINVAL; if (!((val > CARL9170_ERP_INVALID) && (val < __CARL9170_ERP_NUM))) return -EINVAL; ar->erp_mode = val; return count; } DEBUGFS_DECLARE_RW_FILE(erp, 80); static ssize_t carl9170_debugfs_hw_iowrite32_write(struct ar9170 *ar, const char *buf, size_t count) { int err = 0, max_len = 22, res; u32 reg, val; if (!count) return 0; if (count > max_len) return -E2BIG; res = sscanf(buf, "0x%X 0x%X", &reg, &val); if (res != 2) { err = -EINVAL; goto out; } if (reg <= 0x100000 || reg >= 0x280000) { err = -EADDRNOTAVAIL; goto out; } if (reg & 3) { err = -EINVAL; goto out; } err = carl9170_write_reg(ar, reg, val); if (err) goto out; out: return err ? err : count; } DEBUGFS_DECLARE_WO_FILE(hw_iowrite32); DEBUGFS_HW_TALLY_FILE(hw_tx_tally, "u"); DEBUGFS_HW_TALLY_FILE(hw_rx_tally, "u"); DEBUGFS_HW_TALLY_FILE(hw_phy_errors, "u"); DEBUGFS_HW_REG_FILE(hw_wlan_queue, ".8x"); DEBUGFS_HW_REG_FILE(hw_pta_queue, ".8x"); DEBUGFS_HW_REG_FILE(hw_ampdu_info, ".8x"); DEBUGFS_QUEUE_DUMP(tx_status, 0); DEBUGFS_QUEUE_DUMP(tx_status, 1); DEBUGFS_QUEUE_DUMP(tx_status, 2); DEBUGFS_QUEUE_DUMP(tx_status, 3); DEBUGFS_QUEUE_DUMP(tx_pending, 0); DEBUGFS_QUEUE_DUMP(tx_pending, 1); DEBUGFS_QUEUE_DUMP(tx_pending, 2); DEBUGFS_QUEUE_DUMP(tx_pending, 3); DEBUGFS_READONLY_FILE(usb_tx_anch_urbs, 20, "%d", atomic_read(&ar->tx_anch_urbs)); DEBUGFS_READONLY_FILE(usb_rx_anch_urbs, 20, "%d", atomic_read(&ar->rx_anch_urbs)); DEBUGFS_READONLY_FILE(usb_rx_work_urbs, 20, "%d", atomic_read(&ar->rx_work_urbs)); DEBUGFS_READONLY_FILE(usb_rx_pool_urbs, 20, "%d", atomic_read(&ar->rx_pool_urbs)); DEBUGFS_READONLY_FILE(tx_total_queued, 20, "%d", atomic_read(&ar->tx_total_queued)); DEBUGFS_READONLY_FILE(tx_ampdu_scheduler, 20, "%d", atomic_read(&ar->tx_ampdu_scheduler)); DEBUGFS_READONLY_FILE(tx_total_pending, 20, "%d", atomic_read(&ar->tx_total_pending)); DEBUGFS_READONLY_FILE(tx_ampdu_list_len, 20, "%d", ar->tx_ampdu_list_len); DEBUGFS_READONLY_FILE(tx_ampdu_upload, 20, "%d", atomic_read(&ar->tx_ampdu_upload)); DEBUGFS_READONLY_FILE(tx_janitor_last_run, 64, "last run:%d ms ago", jiffies_to_msecs(jiffies - ar->tx_janitor_last_run)); DEBUGFS_READONLY_FILE(tx_dropped, 20, "%d", ar->tx_dropped); DEBUGFS_READONLY_FILE(rx_dropped, 20, "%d", ar->rx_dropped); DEBUGFS_READONLY_FILE(sniffer_enabled, 20, "%d", ar->sniffer_enabled); DEBUGFS_READONLY_FILE(rx_software_decryption, 20, "%d", ar->rx_software_decryption); DEBUGFS_READONLY_FILE(ampdu_factor, 20, "%d", ar->current_factor); DEBUGFS_READONLY_FILE(ampdu_density, 20, "%d", ar->current_density); DEBUGFS_READONLY_FILE(beacon_int, 20, "%d TU", ar->global_beacon_int); DEBUGFS_READONLY_FILE(pretbtt, 20, "%d TU", ar->global_pretbtt); void carl9170_debugfs_register(struct ar9170 *ar) { ar->debug_dir = debugfs_create_dir(KBUILD_MODNAME, ar->hw->wiphy->debugfsdir); #define DEBUGFS_ADD(name) \ debugfs_create_file(#name, carl_debugfs_##name ##_ops.attr, \ ar->debug_dir, ar, \ &carl_debugfs_##name ## _ops.fops); DEBUGFS_ADD(usb_tx_anch_urbs); DEBUGFS_ADD(usb_rx_pool_urbs); DEBUGFS_ADD(usb_rx_anch_urbs); DEBUGFS_ADD(usb_rx_work_urbs); DEBUGFS_ADD(tx_total_queued); DEBUGFS_ADD(tx_total_pending); DEBUGFS_ADD(tx_dropped); DEBUGFS_ADD(tx_stuck); DEBUGFS_ADD(tx_ampdu_upload); DEBUGFS_ADD(tx_ampdu_scheduler); DEBUGFS_ADD(tx_ampdu_list_len); DEBUGFS_ADD(rx_dropped); DEBUGFS_ADD(sniffer_enabled); DEBUGFS_ADD(rx_software_decryption); DEBUGFS_ADD(mem_usage); DEBUGFS_ADD(qos_stat); DEBUGFS_ADD(sta_psm); DEBUGFS_ADD(ampdu_state); DEBUGFS_ADD(hw_tx_tally); DEBUGFS_ADD(hw_rx_tally); DEBUGFS_ADD(hw_phy_errors); DEBUGFS_ADD(phy_noise); DEBUGFS_ADD(hw_wlan_queue); DEBUGFS_ADD(hw_pta_queue); DEBUGFS_ADD(hw_ampdu_info); DEBUGFS_ADD(ampdu_density); DEBUGFS_ADD(ampdu_factor); DEBUGFS_ADD(tx_janitor_last_run); DEBUGFS_ADD(tx_status_0); DEBUGFS_ADD(tx_status_1); DEBUGFS_ADD(tx_status_2); DEBUGFS_ADD(tx_status_3); DEBUGFS_ADD(tx_pending_0); DEBUGFS_ADD(tx_pending_1); DEBUGFS_ADD(tx_pending_2); DEBUGFS_ADD(tx_pending_3); DEBUGFS_ADD(hw_ioread32); DEBUGFS_ADD(hw_iowrite32); DEBUGFS_ADD(bug); DEBUGFS_ADD(erp); DEBUGFS_ADD(vif_dump); DEBUGFS_ADD(beacon_int); DEBUGFS_ADD(pretbtt); #undef DEBUGFS_ADD } void carl9170_debugfs_unregister(struct ar9170 *ar) { debugfs_remove_recursive(ar->debug_dir); }
{ "pile_set_name": "Github" }
// // AppDelegate.swift // RxSwiftHello // // Created by Pepas Personal on 11/24/15. // Copyright © 2015 Pepas Labs. All rights reserved. // import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. return true } func applicationWillResignActive(application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } func applicationDidEnterBackground(application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } func applicationWillEnterForeground(application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } func applicationDidBecomeActive(application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } func applicationWillTerminate(application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } }
{ "pile_set_name": "Github" }
require('../modules/es6.date.now'); require('../modules/es6.date.to-json'); require('../modules/es6.date.to-iso-string'); require('../modules/es6.date.to-string'); require('../modules/es6.date.to-primitive'); module.exports = Date;
{ "pile_set_name": "Github" }
// // Written by Maxim Khitrov (November 2012) // package flowrate import ( "math" "strconv" "time" ) // clockRate is the resolution and precision of clock(). const clockRate = 20 * time.Millisecond // czero is the process start time rounded down to the nearest clockRate // increment. var czero = time.Duration(time.Now().UnixNano()) / clockRate * clockRate // clock returns a low resolution timestamp relative to the process start time. func clock() time.Duration { return time.Duration(time.Now().UnixNano())/clockRate*clockRate - czero } // clockToTime converts a clock() timestamp to an absolute time.Time value. func clockToTime(c time.Duration) time.Time { return time.Unix(0, int64(czero+c)) } // clockRound returns d rounded to the nearest clockRate increment. func clockRound(d time.Duration) time.Duration { return (d + clockRate>>1) / clockRate * clockRate } // round returns x rounded to the nearest int64 (non-negative values only). func round(x float64) int64 { if _, frac := math.Modf(x); frac >= 0.5 { return int64(math.Ceil(x)) } return int64(math.Floor(x)) } // Percent represents a percentage in increments of 1/1000th of a percent. type Percent uint32 // percentOf calculates what percent of the total is x. func percentOf(x, total float64) Percent { if x < 0 || total <= 0 { return 0 } else if p := round(x / total * 1e5); p <= math.MaxUint32 { return Percent(p) } return Percent(math.MaxUint32) } func (p Percent) Float() float64 { return float64(p) * 1e-3 } func (p Percent) String() string { var buf [12]byte b := strconv.AppendUint(buf[:0], uint64(p)/1000, 10) n := len(b) b = strconv.AppendUint(b, 1000+uint64(p)%1000, 10) b[n] = '.' return string(append(b, '%')) }
{ "pile_set_name": "Github" }
import { MultiArgument, ArgumentStore, Argument } from 'klasa'; export default class CoreMultiArgument extends MultiArgument { public constructor(store: ArgumentStore, directory: string, file: readonly string[]) { super(store, directory, file, { aliases: ['...argument'] }); } public get base(): Argument { return this.store.get('argument') as Argument; } }
{ "pile_set_name": "Github" }
{ "name": "bnd2-react", "version": "1.0.0", "private": true, "dependencies": { "@material-ui/core": "^4.2.0", "@material-ui/icons": "^4.2.1", "classnames": "^2.2.6", "echarts": "^4.2.1", "electron": "^5.0.6", "fetch-jsonp": "^1.1.3", "prop-types": "latest", "react": "latest", "react-dom": "latest", "react-router-dom": "^5.0.1", "react-scripts": "^3.0.1", "reconnectingwebsocket": "^1.0.0" }, "scripts": { "mock": "apimocker --config ../mock/mock.json", "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" }, "browserslist": [ ">0.2%", "not dead", "not ie <= 11", "not op_mini all" ] }
{ "pile_set_name": "Github" }
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:html="http://www.w3.org/TR/REC-html40" exclude-result-prefixes="html"> <xsl:variable name="USEPOSTFORFORMS" select="'false'" /> <xsl:include href="system/custom/xsl/SubscriptionUtil.xsl" /> <xsl:include href="system/custom/xsl/ParameterFormUtil.xsl" /> <xsl:param name="baseUrl" select="''" /> <xsl:param name="actionUrl" select="''" /> <xsl:param name="displayUrl" select="''" /> <xsl:output method="html" encoding="UTF-8" /> <!-- Proposed fix for BISERVER-238 by Ezequiel Cuellar. SubscribeForm.xsl has been merged in the DefaultParameterForm.xsl --> <xsl:template match="filters"> <xsl:choose> <xsl:when test="/filters/subscriptions/@doSubscribe='true'"> <xsl:choose> <xsl:when test="count(/filters/schedules/schedule) &lt; 0"> <html> <head> <link rel='stylesheet' type='text/css' href='/pentaho-style/pentaho.css'/> <title> <xsl:value-of select="title" disable-output-escaping="yes"/> </title> <link rel='stylesheet' type='text/css' href='/pentaho-style/active/default.css'/> </head> <body> <table border="0" width="100%" class="content_header" cellpadding="0" cellspacing="0"> <tr> <td width="100%">Subscription Error</td> </tr> </table> <span class="">You cannot subscribe to this. Contact your Pentaho administrator to request subscription capability for this.</span> </body> </html> </xsl:when> <xsl:otherwise> <xsl:call-template name="doFilters"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:call-template name="doFilters"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="doSelections"> <table> <tr></tr> <xsl:for-each select="filter"> <xsl:call-template name="doFilter"></xsl:call-template> </xsl:for-each> <xsl:for-each select="error"> <xsl:value-of select="." /> </xsl:for-each> </table> <xsl:apply-templates select="input" /> </xsl:template> <xsl:template name="doOptions"> <xsl:choose> <xsl:when test="/filters/subscriptions/@doSubscribe='true'"> <!-- subscription stuff --> <xsl:call-template name="doSubscriptions"/> </xsl:when> <xsl:otherwise> <tr> <td class="portlet-font" colspan="2"> <div> <!-- run3div --> <xsl:attribute name="id">run3div<xsl:value-of select="/filters/id" /></xsl:attribute> <table> <tr> <td> <input type="button" class="portlet-form-button"> <xsl:attribute name="value">Run Report</xsl:attribute> <xsl:attribute name="onClick">doRun("<xsl:value-of select="/filters/id" />", '<xsl:value-of select="/filters/action"/>', '<xsl:value-of select="/filters/target"/>', false);</xsl:attribute> <xsl:attribute name="id">run2button<xsl:value-of select="/filters/id" /></xsl:attribute> </input> <input type="button" class="portlet-form-button"> <xsl:attribute name="value">Run in Background</xsl:attribute> <xsl:attribute name="onClick">doRun("<xsl:value-of select="/filters/id" />", '<xsl:value-of select="/filters/action"/>', '<xsl:value-of select="/filters/target"/>', true);</xsl:attribute> <xsl:attribute name="id">run2button<xsl:value-of select="/filters/id" /></xsl:attribute> </input> </td> </tr> </table> </div> <!-- /run3div --> </td> </tr> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
{ "pile_set_name": "Github" }
template "forms/index.vue.erb", "#{PACKS_PATH}/#{name}.vue"
{ "pile_set_name": "Github" }
// Go support for Protocol Buffers - Google's data interchange format // // Copyright 2010 The Go Authors. All rights reserved. // https://github.com/golang/protobuf // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. package proto // Functions for parsing the Text protocol buffer format. // TODO: message sets. import ( "encoding" "errors" "fmt" "reflect" "strconv" "strings" "unicode/utf8" ) // Error string emitted when deserializing Any and fields are already set const anyRepeatedlyUnpacked = "Any message unpacked multiple times, or %q already set" type ParseError struct { Message string Line int // 1-based line number Offset int // 0-based byte offset from start of input } func (p *ParseError) Error() string { if p.Line == 1 { // show offset only for first line return fmt.Sprintf("line 1.%d: %v", p.Offset, p.Message) } return fmt.Sprintf("line %d: %v", p.Line, p.Message) } type token struct { value string err *ParseError line int // line number offset int // byte number from start of input, not start of line unquoted string // the unquoted version of value, if it was a quoted string } func (t *token) String() string { if t.err == nil { return fmt.Sprintf("%q (line=%d, offset=%d)", t.value, t.line, t.offset) } return fmt.Sprintf("parse error: %v", t.err) } type textParser struct { s string // remaining input done bool // whether the parsing is finished (success or error) backed bool // whether back() was called offset, line int cur token } func newTextParser(s string) *textParser { p := new(textParser) p.s = s p.line = 1 p.cur.line = 1 return p } func (p *textParser) errorf(format string, a ...interface{}) *ParseError { pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset} p.cur.err = pe p.done = true return pe } // Numbers and identifiers are matched by [-+._A-Za-z0-9] func isIdentOrNumberChar(c byte) bool { switch { case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z': return true case '0' <= c && c <= '9': return true } switch c { case '-', '+', '.', '_': return true } return false } func isWhitespace(c byte) bool { switch c { case ' ', '\t', '\n', '\r': return true } return false } func isQuote(c byte) bool { switch c { case '"', '\'': return true } return false } func (p *textParser) skipWhitespace() { i := 0 for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') { if p.s[i] == '#' { // comment; skip to end of line or input for i < len(p.s) && p.s[i] != '\n' { i++ } if i == len(p.s) { break } } if p.s[i] == '\n' { p.line++ } i++ } p.offset += i p.s = p.s[i:len(p.s)] if len(p.s) == 0 { p.done = true } } func (p *textParser) advance() { // Skip whitespace p.skipWhitespace() if p.done { return } // Start of non-whitespace p.cur.err = nil p.cur.offset, p.cur.line = p.offset, p.line p.cur.unquoted = "" switch p.s[0] { case '<', '>', '{', '}', ':', '[', ']', ';', ',', '/': // Single symbol p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)] case '"', '\'': // Quoted string i := 1 for i < len(p.s) && p.s[i] != p.s[0] && p.s[i] != '\n' { if p.s[i] == '\\' && i+1 < len(p.s) { // skip escaped char i++ } i++ } if i >= len(p.s) || p.s[i] != p.s[0] { p.errorf("unmatched quote") return } unq, err := unquoteC(p.s[1:i], rune(p.s[0])) if err != nil { p.errorf("invalid quoted string %s: %v", p.s[0:i+1], err) return } p.cur.value, p.s = p.s[0:i+1], p.s[i+1:len(p.s)] p.cur.unquoted = unq default: i := 0 for i < len(p.s) && isIdentOrNumberChar(p.s[i]) { i++ } if i == 0 { p.errorf("unexpected byte %#x", p.s[0]) return } p.cur.value, p.s = p.s[0:i], p.s[i:len(p.s)] } p.offset += len(p.cur.value) } var ( errBadUTF8 = errors.New("proto: bad UTF-8") ) func unquoteC(s string, quote rune) (string, error) { // This is based on C++'s tokenizer.cc. // Despite its name, this is *not* parsing C syntax. // For instance, "\0" is an invalid quoted string. // Avoid allocation in trivial cases. simple := true for _, r := range s { if r == '\\' || r == quote { simple = false break } } if simple { return s, nil } buf := make([]byte, 0, 3*len(s)/2) for len(s) > 0 { r, n := utf8.DecodeRuneInString(s) if r == utf8.RuneError && n == 1 { return "", errBadUTF8 } s = s[n:] if r != '\\' { if r < utf8.RuneSelf { buf = append(buf, byte(r)) } else { buf = append(buf, string(r)...) } continue } ch, tail, err := unescape(s) if err != nil { return "", err } buf = append(buf, ch...) s = tail } return string(buf), nil } func unescape(s string) (ch string, tail string, err error) { r, n := utf8.DecodeRuneInString(s) if r == utf8.RuneError && n == 1 { return "", "", errBadUTF8 } s = s[n:] switch r { case 'a': return "\a", s, nil case 'b': return "\b", s, nil case 'f': return "\f", s, nil case 'n': return "\n", s, nil case 'r': return "\r", s, nil case 't': return "\t", s, nil case 'v': return "\v", s, nil case '?': return "?", s, nil // trigraph workaround case '\'', '"', '\\': return string(r), s, nil case '0', '1', '2', '3', '4', '5', '6', '7': if len(s) < 2 { return "", "", fmt.Errorf(`\%c requires 2 following digits`, r) } ss := string(r) + s[:2] s = s[2:] i, err := strconv.ParseUint(ss, 8, 8) if err != nil { return "", "", fmt.Errorf(`\%s contains non-octal digits`, ss) } return string([]byte{byte(i)}), s, nil case 'x', 'X', 'u', 'U': var n int switch r { case 'x', 'X': n = 2 case 'u': n = 4 case 'U': n = 8 } if len(s) < n { return "", "", fmt.Errorf(`\%c requires %d following digits`, r, n) } ss := s[:n] s = s[n:] i, err := strconv.ParseUint(ss, 16, 64) if err != nil { return "", "", fmt.Errorf(`\%c%s contains non-hexadecimal digits`, r, ss) } if r == 'x' || r == 'X' { return string([]byte{byte(i)}), s, nil } if i > utf8.MaxRune { return "", "", fmt.Errorf(`\%c%s is not a valid Unicode code point`, r, ss) } return string(i), s, nil } return "", "", fmt.Errorf(`unknown escape \%c`, r) } // Back off the parser by one token. Can only be done between calls to next(). // It makes the next advance() a no-op. func (p *textParser) back() { p.backed = true } // Advances the parser and returns the new current token. func (p *textParser) next() *token { if p.backed || p.done { p.backed = false return &p.cur } p.advance() if p.done { p.cur.value = "" } else if len(p.cur.value) > 0 && isQuote(p.cur.value[0]) { // Look for multiple quoted strings separated by whitespace, // and concatenate them. cat := p.cur for { p.skipWhitespace() if p.done || !isQuote(p.s[0]) { break } p.advance() if p.cur.err != nil { return &p.cur } cat.value += " " + p.cur.value cat.unquoted += p.cur.unquoted } p.done = false // parser may have seen EOF, but we want to return cat p.cur = cat } return &p.cur } func (p *textParser) consumeToken(s string) error { tok := p.next() if tok.err != nil { return tok.err } if tok.value != s { p.back() return p.errorf("expected %q, found %q", s, tok.value) } return nil } // Return a RequiredNotSetError indicating which required field was not set. func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError { st := sv.Type() sprops := GetProperties(st) for i := 0; i < st.NumField(); i++ { if !isNil(sv.Field(i)) { continue } props := sprops.Prop[i] if props.Required { return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)} } } return &RequiredNotSetError{fmt.Sprintf("%v.<unknown field name>", st)} // should not happen } // Returns the index in the struct for the named field, as well as the parsed tag properties. func structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) { i, ok := sprops.decoderOrigNames[name] if ok { return i, sprops.Prop[i], true } return -1, nil, false } // Consume a ':' from the input stream (if the next token is a colon), // returning an error if a colon is needed but not present. func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseError { tok := p.next() if tok.err != nil { return tok.err } if tok.value != ":" { // Colon is optional when the field is a group or message. needColon := true switch props.Wire { case "group": needColon = false case "bytes": // A "bytes" field is either a message, a string, or a repeated field; // those three become *T, *string and []T respectively, so we can check for // this field being a pointer to a non-string. if typ.Kind() == reflect.Ptr { // *T or *string if typ.Elem().Kind() == reflect.String { break } } else if typ.Kind() == reflect.Slice { // []T or []*T if typ.Elem().Kind() != reflect.Ptr { break } } else if typ.Kind() == reflect.String { // The proto3 exception is for a string field, // which requires a colon. break } needColon = false } if needColon { return p.errorf("expected ':', found %q", tok.value) } p.back() } return nil } func (p *textParser) readStruct(sv reflect.Value, terminator string) error { st := sv.Type() sprops := GetProperties(st) reqCount := sprops.reqCount var reqFieldErr error fieldSet := make(map[string]bool) // A struct is a sequence of "name: value", terminated by one of // '>' or '}', or the end of the input. A name may also be // "[extension]" or "[type/url]". // // The whole struct can also be an expanded Any message, like: // [type/url] < ... struct contents ... > for { tok := p.next() if tok.err != nil { return tok.err } if tok.value == terminator { break } if tok.value == "[" { // Looks like an extension or an Any. // // TODO: Check whether we need to handle // namespace rooted names (e.g. ".something.Foo"). extName, err := p.consumeExtName() if err != nil { return err } if s := strings.LastIndex(extName, "/"); s >= 0 { // If it contains a slash, it's an Any type URL. messageName := extName[s+1:] mt := MessageType(messageName) if mt == nil { return p.errorf("unrecognized message %q in google.protobuf.Any", messageName) } tok = p.next() if tok.err != nil { return tok.err } // consume an optional colon if tok.value == ":" { tok = p.next() if tok.err != nil { return tok.err } } var terminator string switch tok.value { case "<": terminator = ">" case "{": terminator = "}" default: return p.errorf("expected '{' or '<', found %q", tok.value) } v := reflect.New(mt.Elem()) if pe := p.readStruct(v.Elem(), terminator); pe != nil { return pe } b, err := Marshal(v.Interface().(Message)) if err != nil { return p.errorf("failed to marshal message of type %q: %v", messageName, err) } if fieldSet["type_url"] { return p.errorf(anyRepeatedlyUnpacked, "type_url") } if fieldSet["value"] { return p.errorf(anyRepeatedlyUnpacked, "value") } sv.FieldByName("TypeUrl").SetString(extName) sv.FieldByName("Value").SetBytes(b) fieldSet["type_url"] = true fieldSet["value"] = true continue } var desc *ExtensionDesc // This could be faster, but it's functional. // TODO: Do something smarter than a linear scan. for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) { if d.Name == extName { desc = d break } } if desc == nil { return p.errorf("unrecognized extension %q", extName) } props := &Properties{} props.Parse(desc.Tag) typ := reflect.TypeOf(desc.ExtensionType) if err := p.checkForColon(props, typ); err != nil { return err } rep := desc.repeated() // Read the extension structure, and set it in // the value we're constructing. var ext reflect.Value if !rep { ext = reflect.New(typ).Elem() } else { ext = reflect.New(typ.Elem()).Elem() } if err := p.readAny(ext, props); err != nil { if _, ok := err.(*RequiredNotSetError); !ok { return err } reqFieldErr = err } ep := sv.Addr().Interface().(Message) if !rep { SetExtension(ep, desc, ext.Interface()) } else { old, err := GetExtension(ep, desc) var sl reflect.Value if err == nil { sl = reflect.ValueOf(old) // existing slice } else { sl = reflect.MakeSlice(typ, 0, 1) } sl = reflect.Append(sl, ext) SetExtension(ep, desc, sl.Interface()) } if err := p.consumeOptionalSeparator(); err != nil { return err } continue } // This is a normal, non-extension field. name := tok.value var dst reflect.Value fi, props, ok := structFieldByName(sprops, name) if ok { dst = sv.Field(fi) } else if oop, ok := sprops.OneofTypes[name]; ok { // It is a oneof. props = oop.Prop nv := reflect.New(oop.Type.Elem()) dst = nv.Elem().Field(0) field := sv.Field(oop.Field) if !field.IsNil() { return p.errorf("field '%s' would overwrite already parsed oneof '%s'", name, sv.Type().Field(oop.Field).Name) } field.Set(nv) } if !dst.IsValid() { return p.errorf("unknown field name %q in %v", name, st) } if dst.Kind() == reflect.Map { // Consume any colon. if err := p.checkForColon(props, dst.Type()); err != nil { return err } // Construct the map if it doesn't already exist. if dst.IsNil() { dst.Set(reflect.MakeMap(dst.Type())) } key := reflect.New(dst.Type().Key()).Elem() val := reflect.New(dst.Type().Elem()).Elem() // The map entry should be this sequence of tokens: // < key : KEY value : VALUE > // However, implementations may omit key or value, and technically // we should support them in any order. See b/28924776 for a time // this went wrong. tok := p.next() var terminator string switch tok.value { case "<": terminator = ">" case "{": terminator = "}" default: return p.errorf("expected '{' or '<', found %q", tok.value) } for { tok := p.next() if tok.err != nil { return tok.err } if tok.value == terminator { break } switch tok.value { case "key": if err := p.consumeToken(":"); err != nil { return err } if err := p.readAny(key, props.mkeyprop); err != nil { return err } if err := p.consumeOptionalSeparator(); err != nil { return err } case "value": if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil { return err } if err := p.readAny(val, props.mvalprop); err != nil { return err } if err := p.consumeOptionalSeparator(); err != nil { return err } default: p.back() return p.errorf(`expected "key", "value", or %q, found %q`, terminator, tok.value) } } dst.SetMapIndex(key, val) continue } // Check that it's not already set if it's not a repeated field. if !props.Repeated && fieldSet[name] { return p.errorf("non-repeated field %q was repeated", name) } if err := p.checkForColon(props, dst.Type()); err != nil { return err } // Parse into the field. fieldSet[name] = true if err := p.readAny(dst, props); err != nil { if _, ok := err.(*RequiredNotSetError); !ok { return err } reqFieldErr = err } if props.Required { reqCount-- } if err := p.consumeOptionalSeparator(); err != nil { return err } } if reqCount > 0 { return p.missingRequiredFieldError(sv) } return reqFieldErr } // consumeExtName consumes extension name or expanded Any type URL and the // following ']'. It returns the name or URL consumed. func (p *textParser) consumeExtName() (string, error) { tok := p.next() if tok.err != nil { return "", tok.err } // If extension name or type url is quoted, it's a single token. if len(tok.value) > 2 && isQuote(tok.value[0]) && tok.value[len(tok.value)-1] == tok.value[0] { name, err := unquoteC(tok.value[1:len(tok.value)-1], rune(tok.value[0])) if err != nil { return "", err } return name, p.consumeToken("]") } // Consume everything up to "]" var parts []string for tok.value != "]" { parts = append(parts, tok.value) tok = p.next() if tok.err != nil { return "", p.errorf("unrecognized type_url or extension name: %s", tok.err) } if p.done && tok.value != "]" { return "", p.errorf("unclosed type_url or extension name") } } return strings.Join(parts, ""), nil } // consumeOptionalSeparator consumes an optional semicolon or comma. // It is used in readStruct to provide backward compatibility. func (p *textParser) consumeOptionalSeparator() error { tok := p.next() if tok.err != nil { return tok.err } if tok.value != ";" && tok.value != "," { p.back() } return nil } func (p *textParser) readAny(v reflect.Value, props *Properties) error { tok := p.next() if tok.err != nil { return tok.err } if tok.value == "" { return p.errorf("unexpected EOF") } switch fv := v; fv.Kind() { case reflect.Slice: at := v.Type() if at.Elem().Kind() == reflect.Uint8 { // Special case for []byte if tok.value[0] != '"' && tok.value[0] != '\'' { // Deliberately written out here, as the error after // this switch statement would write "invalid []byte: ...", // which is not as user-friendly. return p.errorf("invalid string: %v", tok.value) } bytes := []byte(tok.unquoted) fv.Set(reflect.ValueOf(bytes)) return nil } // Repeated field. if tok.value == "[" { // Repeated field with list notation, like [1,2,3]. for { fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) err := p.readAny(fv.Index(fv.Len()-1), props) if err != nil { return err } tok := p.next() if tok.err != nil { return tok.err } if tok.value == "]" { break } if tok.value != "," { return p.errorf("Expected ']' or ',' found %q", tok.value) } } return nil } // One value of the repeated field. p.back() fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) return p.readAny(fv.Index(fv.Len()-1), props) case reflect.Bool: // true/1/t/True or false/f/0/False. switch tok.value { case "true", "1", "t", "True": fv.SetBool(true) return nil case "false", "0", "f", "False": fv.SetBool(false) return nil } case reflect.Float32, reflect.Float64: v := tok.value // Ignore 'f' for compatibility with output generated by C++, but don't // remove 'f' when the value is "-inf" or "inf". if strings.HasSuffix(v, "f") && tok.value != "-inf" && tok.value != "inf" { v = v[:len(v)-1] } if f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil { fv.SetFloat(f) return nil } case reflect.Int32: if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil { fv.SetInt(x) return nil } if len(props.Enum) == 0 { break } m, ok := enumValueMaps[props.Enum] if !ok { break } x, ok := m[tok.value] if !ok { break } fv.SetInt(int64(x)) return nil case reflect.Int64: if x, err := strconv.ParseInt(tok.value, 0, 64); err == nil { fv.SetInt(x) return nil } case reflect.Ptr: // A basic field (indirected through pointer), or a repeated message/group p.back() fv.Set(reflect.New(fv.Type().Elem())) return p.readAny(fv.Elem(), props) case reflect.String: if tok.value[0] == '"' || tok.value[0] == '\'' { fv.SetString(tok.unquoted) return nil } case reflect.Struct: var terminator string switch tok.value { case "{": terminator = "}" case "<": terminator = ">" default: return p.errorf("expected '{' or '<', found %q", tok.value) } // TODO: Handle nested messages which implement encoding.TextUnmarshaler. return p.readStruct(fv, terminator) case reflect.Uint32: if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { fv.SetUint(uint64(x)) return nil } case reflect.Uint64: if x, err := strconv.ParseUint(tok.value, 0, 64); err == nil { fv.SetUint(x) return nil } } return p.errorf("invalid %v: %v", v.Type(), tok.value) } // UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb // before starting to unmarshal, so any existing data in pb is always removed. // If a required field is not set and no other error occurs, // UnmarshalText returns *RequiredNotSetError. func UnmarshalText(s string, pb Message) error { if um, ok := pb.(encoding.TextUnmarshaler); ok { return um.UnmarshalText([]byte(s)) } pb.Reset() v := reflect.ValueOf(pb) return newTextParser(s).readStruct(v.Elem(), "") }
{ "pile_set_name": "Github" }
" ============================================================================= " File: autoload/ctrlp/buffertag.vim " Description: Buffer Tag extension " Maintainer: Kien Nguyen <github.com/kien> " Credits: Much of the code was taken from tagbar.vim by Jan Larres, plus " a few lines from taglist.vim by Yegappan Lakshmanan and from " buffertag.vim by Takeshi Nishida. " ============================================================================= " Init {{{1 if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag fini en let g:loaded_ctrlp_buftag = 1 cal add(g:ctrlp_ext_vars, { \ 'init': 'ctrlp#buffertag#init(s:crfile)', \ 'accept': 'ctrlp#buffertag#accept', \ 'lname': 'buffer tags', \ 'sname': 'bft', \ 'exit': 'ctrlp#buffertag#exit()', \ 'type': 'tabs', \ 'opts': 'ctrlp#buffertag#opts()', \ }) let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars) let [s:pref, s:opts] = ['g:ctrlp_buftag_', { \ 'systemenc': ['s:enc', &enc], \ 'ctags_bin': ['s:bin', ''], \ 'types': ['s:usr_types', {}], \ }] let s:bins = [ \ 'ctags-exuberant', \ 'exuberant-ctags', \ 'exctags', \ '/usr/local/bin/ctags', \ '/opt/local/bin/ctags', \ 'ctags', \ 'ctags.exe', \ 'tags', \ ] let s:types = { \ 'ant' : '%sant%sant%spt', \ 'asm' : '%sasm%sasm%sdlmt', \ 'aspperl': '%sasp%sasp%sfsv', \ 'aspvbs' : '%sasp%sasp%sfsv', \ 'awk' : '%sawk%sawk%sf', \ 'beta' : '%sbeta%sbeta%sfsv', \ 'c' : '%sc%sc%sdgsutvf', \ 'cpp' : '%sc++%sc++%snvdtcgsuf', \ 'cs' : '%sc#%sc#%sdtncEgsipm', \ 'cobol' : '%scobol%scobol%sdfgpPs', \ 'delphi' : '%spascal%spascal%sfp', \ 'dosbatch': '%sdosbatch%sdosbatch%slv', \ 'eiffel' : '%seiffel%seiffel%scf', \ 'erlang' : '%serlang%serlang%sdrmf', \ 'expect' : '%stcl%stcl%scfp', \ 'fortran': '%sfortran%sfortran%spbceiklmntvfs', \ 'go' : '%sgo%sgo%sfctv', \ 'html' : '%shtml%shtml%saf', \ 'java' : '%sjava%sjava%spcifm', \ 'javascript': '%sjavascript%sjavascript%sf', \ 'lisp' : '%slisp%slisp%sf', \ 'lua' : '%slua%slua%sf', \ 'make' : '%smake%smake%sm', \ 'matlab' : '%smatlab%smatlab%sf', \ 'ocaml' : '%socaml%socaml%scmMvtfCre', \ 'pascal' : '%spascal%spascal%sfp', \ 'perl' : '%sperl%sperl%sclps', \ 'php' : '%sphp%sphp%scdvf', \ 'python' : '%spython%spython%scmf', \ 'rexx' : '%srexx%srexx%ss', \ 'ruby' : '%sruby%sruby%scfFm', \ 'rust' : '%srust%srust%sfTgsmctid', \ 'scheme' : '%sscheme%sscheme%ssf', \ 'sh' : '%ssh%ssh%sf', \ 'csh' : '%ssh%ssh%sf', \ 'zsh' : '%ssh%ssh%sf', \ 'scala' : '%sscala%sscala%sctTmlp', \ 'slang' : '%sslang%sslang%snf', \ 'sml' : '%ssml%ssml%secsrtvf', \ 'sql' : '%ssql%ssql%scFPrstTvfp', \ 'tex' : '%stex%stex%sipcsubPGl', \ 'tcl' : '%stcl%stcl%scfmp', \ 'vera' : '%svera%svera%scdefgmpPtTvx', \ 'verilog': '%sverilog%sverilog%smcPertwpvf', \ 'vhdl' : '%svhdl%svhdl%sPctTrefp', \ 'vim' : '%svim%svim%savf', \ 'yacc' : '%syacc%syacc%sl', \ } cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")') if executable('jsctags') cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } }) en fu! ctrlp#buffertag#opts() for [ke, va] in items(s:opts) let {va[0]} = exists(s:pref.ke) ? {s:pref.ke} : va[1] endfo " Ctags bin if empty(s:bin) for bin in s:bins | if executable(bin) let s:bin = bin brea en | endfo el let s:bin = expand(s:bin, 1) en " Types cal extend(s:types, s:usr_types) endf " Utilities {{{1 fu! s:validfile(fname, ftype) if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname) \ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en retu 0 endf fu! s:exectags(cmd) if exists('+ssl') let [ssl, &ssl] = [&ssl, 0] en if &sh =~ 'cmd\.exe' let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c'] en let output = system(a:cmd) if &sh =~ 'cmd\.exe' let [&sxq, &shcf] = [sxq, shcf] en if exists('+ssl') let &ssl = ssl en retu output endf fu! s:exectagsonfile(fname, ftype) let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs --extra= --file-scope=yes ', a:ftype] if type(s:types[ft]) == 1 let ags .= s:types[ft] let bin = s:bin elsei type(s:types[ft]) == 4 let ags = s:types[ft]['args'] let bin = expand(s:types[ft]['bin'], 1) en if empty(bin) | retu '' | en let cmd = s:esctagscmd(bin, ags, a:fname) if empty(cmd) | retu '' | en let output = s:exectags(cmd) if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en retu output endf fu! s:esctagscmd(bin, args, ...) if exists('+ssl') let [ssl, &ssl] = [&ssl, 0] en let fname = a:0 ? shellescape(a:1) : '' if (has('win32') || has('win64')) let cmd = a:bin.' '.a:args.' '.fname else let cmd = shellescape(a:bin).' '.a:args.' '.fname endif if &sh =~ 'cmd\.exe' let cmd = substitute(cmd, '[&()@^<>|]', '^\0', 'g') en if exists('+ssl') let &ssl = ssl en if has('iconv') let last = s:enc != &enc ? s:enc : !empty( $LANG ) ? $LANG : &enc let cmd = iconv(cmd, &enc, last) en retu cmd endf fu! s:process(fname, ftype) if !s:validfile(a:fname, a:ftype) | retu [] | endif let ftime = getftime(a:fname) if has_key(g:ctrlp_buftags, a:fname) \ && g:ctrlp_buftags[a:fname]['time'] >= ftime let lines = g:ctrlp_buftags[a:fname]['lines'] el let data = s:exectagsonfile(a:fname, a:ftype) let [raw, lines] = [split(data, '\n\+'), []] for line in raw if line !~# '^!_TAG_' && len(split(line, ';"')) == 2 let parsed_line = s:parseline(line) if parsed_line != '' cal add(lines, parsed_line) en en endfo let cache = { a:fname : { 'time': ftime, 'lines': lines } } cal extend(g:ctrlp_buftags, cache) en retu lines endf fu! s:parseline(line) let vals = matchlist(a:line, \ '\v^([^\t]+)\t(.+)\t[?/]\^?(.{-1,})\$?[?/]\;\"\t(.+)\tline(no)?\:(\d+)') if vals == [] | retu '' | en let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')] retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3] endf fu! s:syntax() if !ctrlp#nosy() cal ctrlp#hicheck('CtrlPTagKind', 'Title') cal ctrlp#hicheck('CtrlPBufName', 'Directory') cal ctrlp#hicheck('CtrlPTabExtra', 'Comment') sy match CtrlPTagKind '\zs[^\t|]\+\ze|\d\+:[^|]\+|\d\+|' sy match CtrlPBufName '|\d\+:\zs[^|]\+\ze|\d\+|' sy match CtrlPTabExtra '\zs\t.*\ze$' contains=CtrlPBufName,CtrlPTagKind en endf fu! s:chknearby(pat) if match(getline('.'), a:pat) < 0 let [int, forw, maxl] = [1, 1, line('$')] wh !search(a:pat, 'W'.( forw ? '' : 'b' )) if !forw if int > maxl | brea | en let int += int en let forw = !forw endw en endf " Public {{{1 fu! ctrlp#buffertag#init(fname) let bufs = exists('s:btmode') && s:btmode \ ? filter(ctrlp#buffers(), 'filereadable(v:val)') \ : [exists('s:bufname') ? s:bufname : a:fname] let lines = [] for each in bufs let bname = fnamemodify(each, ':p') let tftype = get(split(getbufvar('^'.bname.'$', '&ft'), '\.'), 0, '') cal extend(lines, s:process(bname, tftype)) endfo cal s:syntax() retu lines endf fu! ctrlp#buffertag#accept(mode, str) let vals = matchlist(a:str, \ '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|\s(.+)$') let bufnr = str2nr(get(vals, 1)) if bufnr cal ctrlp#acceptfile(a:mode, bufnr) exe 'norm!' str2nr(get(vals, 2, line('.'))).'G' cal s:chknearby('\V\C'.get(vals, 3, '')) sil! norm! zvzz en endf fu! ctrlp#buffertag#cmd(mode, ...) let s:btmode = a:mode if a:0 && !empty(a:1) let s:btmode = 0 let bname = a:1 =~# '^%$\|^#\d*$' ? expand(a:1) : a:1 let s:bufname = fnamemodify(bname, ':p') en retu s:id endf fu! ctrlp#buffertag#exit() unl! s:btmode s:bufname endf "}}} " vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
{ "pile_set_name": "Github" }
KtikZ in Debian --------------- The ktikz and qtikz packages both recommend other packages that provide "standard" functionality for ktikz but it is possible to run the program without these packages being installed. ktikz recommended packages: - poppler-utils: export as EPS functionality - khelpcenter4: documentation browser (/usr/bin/khelpcenter) qtikz recommended packages: - poppler-utils: export as EPS functionality - qt4-dev-tools: documentation browser (/usr/bin/assistant)
{ "pile_set_name": "Github" }
/* * * Copyright 2012-2014 Eurocommercial Properties NV * * * Licensed under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.estatio.module.budget.integtests; import javax.inject.Inject; import org.junit.Test; import org.apache.isis.applib.Module; import org.apache.isis.applib.services.jaxb.JaxbService; import org.apache.isis.applib.services.metamodel.MetaModelService4; public class BudgetModuleBootstrapIntegTest extends BudgetModuleIntegTestAbstract { @Test public void serializes_module() throws Exception { final Module module = metaModelService4.getAppManifest2().getModule(); // final String s = jaxbService.toXml(module); // System.out.println(s); } @Inject MetaModelService4 metaModelService4; @Inject JaxbService jaxbService; }
{ "pile_set_name": "Github" }
require "test_helper" class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase # test "connects with cookies" do # cookies.signed[:user_id] = 42 # # connect # # assert_equal connection.user_id, "42" # end end
{ "pile_set_name": "Github" }
/* * ipg.c: Device Driver for the IP1000 Gigabit Ethernet Adapter * * Copyright (C) 2003, 2007 IC Plus Corp * * Original Author: * * Craig Rich * Sundance Technology, Inc. * www.sundanceti.com * [email protected] * * Current Maintainer: * * Sorbica Shieh. * http://www.icplus.com.tw * [email protected] * * Jesse Huang * http://www.icplus.com.tw * [email protected] */ #include <linux/crc32.h> #include <linux/ethtool.h> #include <linux/mii.h> #include <linux/mutex.h> #include <asm/div64.h> #define IPG_RX_RING_BYTES (sizeof(struct ipg_rx) * IPG_RFDLIST_LENGTH) #define IPG_TX_RING_BYTES (sizeof(struct ipg_tx) * IPG_TFDLIST_LENGTH) #define IPG_RESET_MASK \ (IPG_AC_GLOBAL_RESET | IPG_AC_RX_RESET | IPG_AC_TX_RESET | \ IPG_AC_DMA | IPG_AC_FIFO | IPG_AC_NETWORK | IPG_AC_HOST | \ IPG_AC_AUTO_INIT) #define ipg_w32(val32, reg) iowrite32((val32), ioaddr + (reg)) #define ipg_w16(val16, reg) iowrite16((val16), ioaddr + (reg)) #define ipg_w8(val8, reg) iowrite8((val8), ioaddr + (reg)) #define ipg_r32(reg) ioread32(ioaddr + (reg)) #define ipg_r16(reg) ioread16(ioaddr + (reg)) #define ipg_r8(reg) ioread8(ioaddr + (reg)) enum { netdev_io_size = 128 }; #include "ipg.h" #define DRV_NAME "ipg" MODULE_AUTHOR("IC Plus Corp. 2003"); MODULE_DESCRIPTION("IC Plus IP1000 Gigabit Ethernet Adapter Linux Driver"); MODULE_LICENSE("GPL"); /* * Defaults */ #define IPG_MAX_RXFRAME_SIZE 0x0600 #define IPG_RXFRAG_SIZE 0x0600 #define IPG_RXSUPPORT_SIZE 0x0600 #define IPG_IS_JUMBO false /* * Variable record -- index by leading revision/length * Revision/Length(=N*4), Address1, Data1, Address2, Data2,...,AddressN,DataN */ static unsigned short DefaultPhyParam[] = { /* 11/12/03 IP1000A v1-3 rev=0x40 */ /*-------------------------------------------------------------------------- (0x4000|(15*4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 22, 0x85bd, 24, 0xfff2, 27, 0x0c10, 28, 0x0c10, 29, 0x2c10, 31, 0x0003, 23, 0x92f6, 31, 0x0000, 23, 0x003d, 30, 0x00de, 20, 0x20e7, 9, 0x0700, --------------------------------------------------------------------------*/ /* 12/17/03 IP1000A v1-4 rev=0x40 */ (0x4000 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, 0x0000, 30, 0x005e, 9, 0x0700, /* 01/09/04 IP1000A v1-5 rev=0x41 */ (0x4100 | (07 * 4)), 31, 0x0001, 27, 0x01e0, 31, 0x0002, 27, 0xeb8e, 31, 0x0000, 30, 0x005e, 9, 0x0700, 0x0000 }; static const char *ipg_brand_name[] = { "IC PLUS IP1000 1000/100/10 based NIC", "Sundance Technology ST2021 based NIC", "Tamarack Microelectronics TC9020/9021 based NIC", "Tamarack Microelectronics TC9020/9021 based NIC", "D-Link NIC", "D-Link NIC IP1000A" }; static struct pci_device_id ipg_pci_tbl[] __devinitdata = { { PCI_VDEVICE(SUNDANCE, 0x1023), 0 }, { PCI_VDEVICE(SUNDANCE, 0x2021), 1 }, { PCI_VDEVICE(SUNDANCE, 0x1021), 2 }, { PCI_VDEVICE(DLINK, 0x9021), 3 }, { PCI_VDEVICE(DLINK, 0x4000), 4 }, { PCI_VDEVICE(DLINK, 0x4020), 5 }, { 0, } }; MODULE_DEVICE_TABLE(pci, ipg_pci_tbl); static inline void __iomem *ipg_ioaddr(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); return sp->ioaddr; } #ifdef IPG_DEBUG static void ipg_dump_rfdlist(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; unsigned int i; u32 offset; IPG_DEBUG_MSG("_dump_rfdlist\n"); printk(KERN_INFO "rx_current = %2.2x\n", sp->rx_current); printk(KERN_INFO "rx_dirty = %2.2x\n", sp->rx_dirty); printk(KERN_INFO "RFDList start address = %16.16lx\n", (unsigned long) sp->rxd_map); printk(KERN_INFO "RFDListPtr register = %8.8x%8.8x\n", ipg_r32(IPG_RFDLISTPTR1), ipg_r32(IPG_RFDLISTPTR0)); for (i = 0; i < IPG_RFDLIST_LENGTH; i++) { offset = (u32) &sp->rxd[i].next_desc - (u32) sp->rxd; printk(KERN_INFO "%2.2x %4.4x RFDNextPtr = %16.16lx\n", i, offset, (unsigned long) sp->rxd[i].next_desc); offset = (u32) &sp->rxd[i].rfs - (u32) sp->rxd; printk(KERN_INFO "%2.2x %4.4x RFS = %16.16lx\n", i, offset, (unsigned long) sp->rxd[i].rfs); offset = (u32) &sp->rxd[i].frag_info - (u32) sp->rxd; printk(KERN_INFO "%2.2x %4.4x frag_info = %16.16lx\n", i, offset, (unsigned long) sp->rxd[i].frag_info); } } static void ipg_dump_tfdlist(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; unsigned int i; u32 offset; IPG_DEBUG_MSG("_dump_tfdlist\n"); printk(KERN_INFO "tx_current = %2.2x\n", sp->tx_current); printk(KERN_INFO "tx_dirty = %2.2x\n", sp->tx_dirty); printk(KERN_INFO "TFDList start address = %16.16lx\n", (unsigned long) sp->txd_map); printk(KERN_INFO "TFDListPtr register = %8.8x%8.8x\n", ipg_r32(IPG_TFDLISTPTR1), ipg_r32(IPG_TFDLISTPTR0)); for (i = 0; i < IPG_TFDLIST_LENGTH; i++) { offset = (u32) &sp->txd[i].next_desc - (u32) sp->txd; printk(KERN_INFO "%2.2x %4.4x TFDNextPtr = %16.16lx\n", i, offset, (unsigned long) sp->txd[i].next_desc); offset = (u32) &sp->txd[i].tfc - (u32) sp->txd; printk(KERN_INFO "%2.2x %4.4x TFC = %16.16lx\n", i, offset, (unsigned long) sp->txd[i].tfc); offset = (u32) &sp->txd[i].frag_info - (u32) sp->txd; printk(KERN_INFO "%2.2x %4.4x frag_info = %16.16lx\n", i, offset, (unsigned long) sp->txd[i].frag_info); } } #endif static void ipg_write_phy_ctl(void __iomem *ioaddr, u8 data) { ipg_w8(IPG_PC_RSVD_MASK & data, PHY_CTRL); ndelay(IPG_PC_PHYCTRLWAIT_NS); } static void ipg_drive_phy_ctl_low_high(void __iomem *ioaddr, u8 data) { ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_LO | data); ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_HI | data); } static void send_three_state(void __iomem *ioaddr, u8 phyctrlpolarity) { phyctrlpolarity |= (IPG_PC_MGMTDATA & 0) | IPG_PC_MGMTDIR; ipg_drive_phy_ctl_low_high(ioaddr, phyctrlpolarity); } static void send_end(void __iomem *ioaddr, u8 phyctrlpolarity) { ipg_w8((IPG_PC_MGMTCLK_LO | (IPG_PC_MGMTDATA & 0) | IPG_PC_MGMTDIR | phyctrlpolarity) & IPG_PC_RSVD_MASK, PHY_CTRL); } static u16 read_phy_bit(void __iomem *ioaddr, u8 phyctrlpolarity) { u16 bit_data; ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_LO | phyctrlpolarity); bit_data = ((ipg_r8(PHY_CTRL) & IPG_PC_MGMTDATA) >> 1) & 1; ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_HI | phyctrlpolarity); return bit_data; } /* * Read a register from the Physical Layer device located * on the IPG NIC, using the IPG PHYCTRL register. */ static int mdio_read(struct net_device *dev, int phy_id, int phy_reg) { void __iomem *ioaddr = ipg_ioaddr(dev); /* * The GMII mangement frame structure for a read is as follows: * * |Preamble|st|op|phyad|regad|ta| data |idle| * |< 32 1s>|01|10|AAAAA|RRRRR|z0|DDDDDDDDDDDDDDDD|z | * * <32 1s> = 32 consecutive logic 1 values * A = bit of Physical Layer device address (MSB first) * R = bit of register address (MSB first) * z = High impedance state * D = bit of read data (MSB first) * * Transmission order is 'Preamble' field first, bits transmitted * left to right (first to last). */ struct { u32 field; unsigned int len; } p[] = { { GMII_PREAMBLE, 32 }, /* Preamble */ { GMII_ST, 2 }, /* ST */ { GMII_READ, 2 }, /* OP */ { phy_id, 5 }, /* PHYAD */ { phy_reg, 5 }, /* REGAD */ { 0x0000, 2 }, /* TA */ { 0x0000, 16 }, /* DATA */ { 0x0000, 1 } /* IDLE */ }; unsigned int i, j; u8 polarity, data; polarity = ipg_r8(PHY_CTRL); polarity &= (IPG_PC_DUPLEX_POLARITY | IPG_PC_LINK_POLARITY); /* Create the Preamble, ST, OP, PHYAD, and REGAD field. */ for (j = 0; j < 5; j++) { for (i = 0; i < p[j].len; i++) { /* For each variable length field, the MSB must be * transmitted first. Rotate through the field bits, * starting with the MSB, and move each bit into the * the 1st (2^1) bit position (this is the bit position * corresponding to the MgmtData bit of the PhyCtrl * register for the IPG). * * Example: ST = 01; * * First write a '0' to bit 1 of the PhyCtrl * register, then write a '1' to bit 1 of the * PhyCtrl register. * * To do this, right shift the MSB of ST by the value: * [field length - 1 - #ST bits already written] * then left shift this result by 1. */ data = (p[j].field >> (p[j].len - 1 - i)) << 1; data &= IPG_PC_MGMTDATA; data |= polarity | IPG_PC_MGMTDIR; ipg_drive_phy_ctl_low_high(ioaddr, data); } } send_three_state(ioaddr, polarity); read_phy_bit(ioaddr, polarity); /* * For a read cycle, the bits for the next two fields (TA and * DATA) are driven by the PHY (the IPG reads these bits). */ for (i = 0; i < p[6].len; i++) { p[6].field |= (read_phy_bit(ioaddr, polarity) << (p[6].len - 1 - i)); } send_three_state(ioaddr, polarity); send_three_state(ioaddr, polarity); send_three_state(ioaddr, polarity); send_end(ioaddr, polarity); /* Return the value of the DATA field. */ return p[6].field; } /* * Write to a register from the Physical Layer device located * on the IPG NIC, using the IPG PHYCTRL register. */ static void mdio_write(struct net_device *dev, int phy_id, int phy_reg, int val) { void __iomem *ioaddr = ipg_ioaddr(dev); /* * The GMII mangement frame structure for a read is as follows: * * |Preamble|st|op|phyad|regad|ta| data |idle| * |< 32 1s>|01|10|AAAAA|RRRRR|z0|DDDDDDDDDDDDDDDD|z | * * <32 1s> = 32 consecutive logic 1 values * A = bit of Physical Layer device address (MSB first) * R = bit of register address (MSB first) * z = High impedance state * D = bit of write data (MSB first) * * Transmission order is 'Preamble' field first, bits transmitted * left to right (first to last). */ struct { u32 field; unsigned int len; } p[] = { { GMII_PREAMBLE, 32 }, /* Preamble */ { GMII_ST, 2 }, /* ST */ { GMII_WRITE, 2 }, /* OP */ { phy_id, 5 }, /* PHYAD */ { phy_reg, 5 }, /* REGAD */ { 0x0002, 2 }, /* TA */ { val & 0xffff, 16 }, /* DATA */ { 0x0000, 1 } /* IDLE */ }; unsigned int i, j; u8 polarity, data; polarity = ipg_r8(PHY_CTRL); polarity &= (IPG_PC_DUPLEX_POLARITY | IPG_PC_LINK_POLARITY); /* Create the Preamble, ST, OP, PHYAD, and REGAD field. */ for (j = 0; j < 7; j++) { for (i = 0; i < p[j].len; i++) { /* For each variable length field, the MSB must be * transmitted first. Rotate through the field bits, * starting with the MSB, and move each bit into the * the 1st (2^1) bit position (this is the bit position * corresponding to the MgmtData bit of the PhyCtrl * register for the IPG). * * Example: ST = 01; * * First write a '0' to bit 1 of the PhyCtrl * register, then write a '1' to bit 1 of the * PhyCtrl register. * * To do this, right shift the MSB of ST by the value: * [field length - 1 - #ST bits already written] * then left shift this result by 1. */ data = (p[j].field >> (p[j].len - 1 - i)) << 1; data &= IPG_PC_MGMTDATA; data |= polarity | IPG_PC_MGMTDIR; ipg_drive_phy_ctl_low_high(ioaddr, data); } } /* The last cycle is a tri-state, so read from the PHY. */ for (j = 7; j < 8; j++) { for (i = 0; i < p[j].len; i++) { ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_LO | polarity); p[j].field |= ((ipg_r8(PHY_CTRL) & IPG_PC_MGMTDATA) >> 1) << (p[j].len - 1 - i); ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_HI | polarity); } } } static void ipg_set_led_mode(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; u32 mode; mode = ipg_r32(ASIC_CTRL); mode &= ~(IPG_AC_LED_MODE_BIT_1 | IPG_AC_LED_MODE | IPG_AC_LED_SPEED); if ((sp->led_mode & 0x03) > 1) mode |= IPG_AC_LED_MODE_BIT_1; /* Write Asic Control Bit 29 */ if ((sp->led_mode & 0x01) == 1) mode |= IPG_AC_LED_MODE; /* Write Asic Control Bit 14 */ if ((sp->led_mode & 0x08) == 8) mode |= IPG_AC_LED_SPEED; /* Write Asic Control Bit 27 */ ipg_w32(mode, ASIC_CTRL); } static void ipg_set_phy_set(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; int physet; physet = ipg_r8(PHY_SET); physet &= ~(IPG_PS_MEM_LENB9B | IPG_PS_MEM_LEN9 | IPG_PS_NON_COMPDET); physet |= ((sp->led_mode & 0x70) >> 4); ipg_w8(physet, PHY_SET); } static int ipg_reset(struct net_device *dev, u32 resetflags) { /* Assert functional resets via the IPG AsicCtrl * register as specified by the 'resetflags' input * parameter. */ void __iomem *ioaddr = ipg_ioaddr(dev); unsigned int timeout_count = 0; IPG_DEBUG_MSG("_reset\n"); ipg_w32(ipg_r32(ASIC_CTRL) | resetflags, ASIC_CTRL); /* Delay added to account for problem with 10Mbps reset. */ mdelay(IPG_AC_RESETWAIT); while (IPG_AC_RESET_BUSY & ipg_r32(ASIC_CTRL)) { mdelay(IPG_AC_RESETWAIT); if (++timeout_count > IPG_AC_RESET_TIMEOUT) return -ETIME; } /* Set LED Mode in Asic Control */ ipg_set_led_mode(dev); /* Set PHYSet Register Value */ ipg_set_phy_set(dev); return 0; } /* Find the GMII PHY address. */ static int ipg_find_phyaddr(struct net_device *dev) { unsigned int phyaddr, i; for (i = 0; i < 32; i++) { u32 status; /* Search for the correct PHY address among 32 possible. */ phyaddr = (IPG_NIC_PHY_ADDRESS + i) % 32; /* 10/22/03 Grace change verify from GMII_PHY_STATUS to GMII_PHY_ID1 */ status = mdio_read(dev, phyaddr, MII_BMSR); if ((status != 0xFFFF) && (status != 0)) return phyaddr; } return 0x1f; } /* * Configure IPG based on result of IEEE 802.3 PHY * auto-negotiation. */ static int ipg_config_autoneg(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; unsigned int txflowcontrol; unsigned int rxflowcontrol; unsigned int fullduplex; u32 mac_ctrl_val; u32 asicctrl; u8 phyctrl; IPG_DEBUG_MSG("_config_autoneg\n"); asicctrl = ipg_r32(ASIC_CTRL); phyctrl = ipg_r8(PHY_CTRL); mac_ctrl_val = ipg_r32(MAC_CTRL); /* Set flags for use in resolving auto-negotation, assuming * non-1000Mbps, half duplex, no flow control. */ fullduplex = 0; txflowcontrol = 0; rxflowcontrol = 0; /* To accomodate a problem in 10Mbps operation, * set a global flag if PHY running in 10Mbps mode. */ sp->tenmbpsmode = 0; printk(KERN_INFO "%s: Link speed = ", dev->name); /* Determine actual speed of operation. */ switch (phyctrl & IPG_PC_LINK_SPEED) { case IPG_PC_LINK_SPEED_10MBPS: printk("10Mbps.\n"); printk(KERN_INFO "%s: 10Mbps operational mode enabled.\n", dev->name); sp->tenmbpsmode = 1; break; case IPG_PC_LINK_SPEED_100MBPS: printk("100Mbps.\n"); break; case IPG_PC_LINK_SPEED_1000MBPS: printk("1000Mbps.\n"); break; default: printk("undefined!\n"); return 0; } if (phyctrl & IPG_PC_DUPLEX_STATUS) { fullduplex = 1; txflowcontrol = 1; rxflowcontrol = 1; } /* Configure full duplex, and flow control. */ if (fullduplex == 1) { /* Configure IPG for full duplex operation. */ printk(KERN_INFO "%s: setting full duplex, ", dev->name); mac_ctrl_val |= IPG_MC_DUPLEX_SELECT_FD; if (txflowcontrol == 1) { printk("TX flow control"); mac_ctrl_val |= IPG_MC_TX_FLOW_CONTROL_ENABLE; } else { printk("no TX flow control"); mac_ctrl_val &= ~IPG_MC_TX_FLOW_CONTROL_ENABLE; } if (rxflowcontrol == 1) { printk(", RX flow control."); mac_ctrl_val |= IPG_MC_RX_FLOW_CONTROL_ENABLE; } else { printk(", no RX flow control."); mac_ctrl_val &= ~IPG_MC_RX_FLOW_CONTROL_ENABLE; } printk("\n"); } else { /* Configure IPG for half duplex operation. */ printk(KERN_INFO "%s: setting half duplex, " "no TX flow control, no RX flow control.\n", dev->name); mac_ctrl_val &= ~IPG_MC_DUPLEX_SELECT_FD & ~IPG_MC_TX_FLOW_CONTROL_ENABLE & ~IPG_MC_RX_FLOW_CONTROL_ENABLE; } ipg_w32(mac_ctrl_val, MAC_CTRL); return 0; } /* Determine and configure multicast operation and set * receive mode for IPG. */ static void ipg_nic_set_multicast_list(struct net_device *dev) { void __iomem *ioaddr = ipg_ioaddr(dev); struct dev_mc_list *mc_list_ptr; unsigned int hashindex; u32 hashtable[2]; u8 receivemode; IPG_DEBUG_MSG("_nic_set_multicast_list\n"); receivemode = IPG_RM_RECEIVEUNICAST | IPG_RM_RECEIVEBROADCAST; if (dev->flags & IFF_PROMISC) { /* NIC to be configured in promiscuous mode. */ receivemode = IPG_RM_RECEIVEALLFRAMES; } else if ((dev->flags & IFF_ALLMULTI) || ((dev->flags & IFF_MULTICAST) && (dev->mc_count > IPG_MULTICAST_HASHTABLE_SIZE))) { /* NIC to be configured to receive all multicast * frames. */ receivemode |= IPG_RM_RECEIVEMULTICAST; } else if ((dev->flags & IFF_MULTICAST) && (dev->mc_count > 0)) { /* NIC to be configured to receive selected * multicast addresses. */ receivemode |= IPG_RM_RECEIVEMULTICASTHASH; } /* Calculate the bits to set for the 64 bit, IPG HASHTABLE. * The IPG applies a cyclic-redundancy-check (the same CRC * used to calculate the frame data FCS) to the destination * address all incoming multicast frames whose destination * address has the multicast bit set. The least significant * 6 bits of the CRC result are used as an addressing index * into the hash table. If the value of the bit addressed by * this index is a 1, the frame is passed to the host system. */ /* Clear hashtable. */ hashtable[0] = 0x00000000; hashtable[1] = 0x00000000; /* Cycle through all multicast addresses to filter. */ for (mc_list_ptr = dev->mc_list; mc_list_ptr != NULL; mc_list_ptr = mc_list_ptr->next) { /* Calculate CRC result for each multicast address. */ hashindex = crc32_le(0xffffffff, mc_list_ptr->dmi_addr, ETH_ALEN); /* Use only the least significant 6 bits. */ hashindex = hashindex & 0x3F; /* Within "hashtable", set bit number "hashindex" * to a logic 1. */ set_bit(hashindex, (void *)hashtable); } /* Write the value of the hashtable, to the 4, 16 bit * HASHTABLE IPG registers. */ ipg_w32(hashtable[0], HASHTABLE_0); ipg_w32(hashtable[1], HASHTABLE_1); ipg_w8(IPG_RM_RSVD_MASK & receivemode, RECEIVE_MODE); IPG_DEBUG_MSG("ReceiveMode = %x\n", ipg_r8(RECEIVE_MODE)); } static int ipg_io_config(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = ipg_ioaddr(dev); u32 origmacctrl; u32 restoremacctrl; IPG_DEBUG_MSG("_io_config\n"); origmacctrl = ipg_r32(MAC_CTRL); restoremacctrl = origmacctrl | IPG_MC_STATISTICS_ENABLE; /* Based on compilation option, determine if FCS is to be * stripped on receive frames by IPG. */ if (!IPG_STRIP_FCS_ON_RX) restoremacctrl |= IPG_MC_RCV_FCS; /* Determine if transmitter and/or receiver are * enabled so we may restore MACCTRL correctly. */ if (origmacctrl & IPG_MC_TX_ENABLED) restoremacctrl |= IPG_MC_TX_ENABLE; if (origmacctrl & IPG_MC_RX_ENABLED) restoremacctrl |= IPG_MC_RX_ENABLE; /* Transmitter and receiver must be disabled before setting * IFSSelect. */ ipg_w32((origmacctrl & (IPG_MC_RX_DISABLE | IPG_MC_TX_DISABLE)) & IPG_MC_RSVD_MASK, MAC_CTRL); /* Now that transmitter and receiver are disabled, write * to IFSSelect. */ ipg_w32((origmacctrl & IPG_MC_IFS_96BIT) & IPG_MC_RSVD_MASK, MAC_CTRL); /* Set RECEIVEMODE register. */ ipg_nic_set_multicast_list(dev); ipg_w16(sp->max_rxframe_size, MAX_FRAME_SIZE); ipg_w8(IPG_RXDMAPOLLPERIOD_VALUE, RX_DMA_POLL_PERIOD); ipg_w8(IPG_RXDMAURGENTTHRESH_VALUE, RX_DMA_URGENT_THRESH); ipg_w8(IPG_RXDMABURSTTHRESH_VALUE, RX_DMA_BURST_THRESH); ipg_w8(IPG_TXDMAPOLLPERIOD_VALUE, TX_DMA_POLL_PERIOD); ipg_w8(IPG_TXDMAURGENTTHRESH_VALUE, TX_DMA_URGENT_THRESH); ipg_w8(IPG_TXDMABURSTTHRESH_VALUE, TX_DMA_BURST_THRESH); ipg_w16((IPG_IE_HOST_ERROR | IPG_IE_TX_DMA_COMPLETE | IPG_IE_TX_COMPLETE | IPG_IE_INT_REQUESTED | IPG_IE_UPDATE_STATS | IPG_IE_LINK_EVENT | IPG_IE_RX_DMA_COMPLETE | IPG_IE_RX_DMA_PRIORITY), INT_ENABLE); ipg_w16(IPG_FLOWONTHRESH_VALUE, FLOW_ON_THRESH); ipg_w16(IPG_FLOWOFFTHRESH_VALUE, FLOW_OFF_THRESH); /* IPG multi-frag frame bug workaround. * Per silicon revision B3 eratta. */ ipg_w16(ipg_r16(DEBUG_CTRL) | 0x0200, DEBUG_CTRL); /* IPG TX poll now bug workaround. * Per silicon revision B3 eratta. */ ipg_w16(ipg_r16(DEBUG_CTRL) | 0x0010, DEBUG_CTRL); /* IPG RX poll now bug workaround. * Per silicon revision B3 eratta. */ ipg_w16(ipg_r16(DEBUG_CTRL) | 0x0020, DEBUG_CTRL); /* Now restore MACCTRL to original setting. */ ipg_w32(IPG_MC_RSVD_MASK & restoremacctrl, MAC_CTRL); /* Disable unused RMON statistics. */ ipg_w32(IPG_RZ_ALL, RMON_STATISTICS_MASK); /* Disable unused MIB statistics. */ ipg_w32(IPG_SM_MACCONTROLFRAMESXMTD | IPG_SM_MACCONTROLFRAMESRCVD | IPG_SM_BCSTOCTETXMTOK_BCSTFRAMESXMTDOK | IPG_SM_TXJUMBOFRAMES | IPG_SM_MCSTOCTETXMTOK_MCSTFRAMESXMTDOK | IPG_SM_RXJUMBOFRAMES | IPG_SM_BCSTOCTETRCVDOK_BCSTFRAMESRCVDOK | IPG_SM_UDPCHECKSUMERRORS | IPG_SM_TCPCHECKSUMERRORS | IPG_SM_IPCHECKSUMERRORS, STATISTICS_MASK); return 0; } /* * Create a receive buffer within system memory and update * NIC private structure appropriately. */ static int ipg_get_rxbuff(struct net_device *dev, int entry) { struct ipg_nic_private *sp = netdev_priv(dev); struct ipg_rx *rxfd = sp->rxd + entry; struct sk_buff *skb; u64 rxfragsize; IPG_DEBUG_MSG("_get_rxbuff\n"); skb = netdev_alloc_skb_ip_align(dev, sp->rxsupport_size); if (!skb) { sp->rx_buff[entry] = NULL; return -ENOMEM; } /* Associate the receive buffer with the IPG NIC. */ skb->dev = dev; /* Save the address of the sk_buff structure. */ sp->rx_buff[entry] = skb; rxfd->frag_info = cpu_to_le64(pci_map_single(sp->pdev, skb->data, sp->rx_buf_sz, PCI_DMA_FROMDEVICE)); /* Set the RFD fragment length. */ rxfragsize = sp->rxfrag_size; rxfd->frag_info |= cpu_to_le64((rxfragsize << 48) & IPG_RFI_FRAGLEN); return 0; } static int init_rfdlist(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; unsigned int i; IPG_DEBUG_MSG("_init_rfdlist\n"); for (i = 0; i < IPG_RFDLIST_LENGTH; i++) { struct ipg_rx *rxfd = sp->rxd + i; if (sp->rx_buff[i]) { pci_unmap_single(sp->pdev, le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN, sp->rx_buf_sz, PCI_DMA_FROMDEVICE); dev_kfree_skb_irq(sp->rx_buff[i]); sp->rx_buff[i] = NULL; } /* Clear out the RFS field. */ rxfd->rfs = 0x0000000000000000; if (ipg_get_rxbuff(dev, i) < 0) { /* * A receive buffer was not ready, break the * RFD list here. */ IPG_DEBUG_MSG("Cannot allocate Rx buffer.\n"); /* Just in case we cannot allocate a single RFD. * Should not occur. */ if (i == 0) { printk(KERN_ERR "%s: No memory available" " for RFD list.\n", dev->name); return -ENOMEM; } } rxfd->next_desc = cpu_to_le64(sp->rxd_map + sizeof(struct ipg_rx)*(i + 1)); } sp->rxd[i - 1].next_desc = cpu_to_le64(sp->rxd_map); sp->rx_current = 0; sp->rx_dirty = 0; /* Write the location of the RFDList to the IPG. */ ipg_w32((u32) sp->rxd_map, RFD_LIST_PTR_0); ipg_w32(0x00000000, RFD_LIST_PTR_1); return 0; } static void init_tfdlist(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; unsigned int i; IPG_DEBUG_MSG("_init_tfdlist\n"); for (i = 0; i < IPG_TFDLIST_LENGTH; i++) { struct ipg_tx *txfd = sp->txd + i; txfd->tfc = cpu_to_le64(IPG_TFC_TFDDONE); if (sp->tx_buff[i]) { dev_kfree_skb_irq(sp->tx_buff[i]); sp->tx_buff[i] = NULL; } txfd->next_desc = cpu_to_le64(sp->txd_map + sizeof(struct ipg_tx)*(i + 1)); } sp->txd[i - 1].next_desc = cpu_to_le64(sp->txd_map); sp->tx_current = 0; sp->tx_dirty = 0; /* Write the location of the TFDList to the IPG. */ IPG_DDEBUG_MSG("Starting TFDListPtr = %8.8x\n", (u32) sp->txd_map); ipg_w32((u32) sp->txd_map, TFD_LIST_PTR_0); ipg_w32(0x00000000, TFD_LIST_PTR_1); sp->reset_current_tfd = 1; } /* * Free all transmit buffers which have already been transfered * via DMA to the IPG. */ static void ipg_nic_txfree(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); unsigned int released, pending, dirty; IPG_DEBUG_MSG("_nic_txfree\n"); pending = sp->tx_current - sp->tx_dirty; dirty = sp->tx_dirty % IPG_TFDLIST_LENGTH; for (released = 0; released < pending; released++) { struct sk_buff *skb = sp->tx_buff[dirty]; struct ipg_tx *txfd = sp->txd + dirty; IPG_DEBUG_MSG("TFC = %16.16lx\n", (unsigned long) txfd->tfc); /* Look at each TFD's TFC field beginning * at the last freed TFD up to the current TFD. * If the TFDDone bit is set, free the associated * buffer. */ if (!(txfd->tfc & cpu_to_le64(IPG_TFC_TFDDONE))) break; /* Free the transmit buffer. */ if (skb) { pci_unmap_single(sp->pdev, le64_to_cpu(txfd->frag_info) & ~IPG_TFI_FRAGLEN, skb->len, PCI_DMA_TODEVICE); dev_kfree_skb_irq(skb); sp->tx_buff[dirty] = NULL; } dirty = (dirty + 1) % IPG_TFDLIST_LENGTH; } sp->tx_dirty += released; if (netif_queue_stopped(dev) && (sp->tx_current != (sp->tx_dirty + IPG_TFDLIST_LENGTH))) { netif_wake_queue(dev); } } static void ipg_tx_timeout(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; ipg_reset(dev, IPG_AC_TX_RESET | IPG_AC_DMA | IPG_AC_NETWORK | IPG_AC_FIFO); spin_lock_irq(&sp->lock); /* Re-configure after DMA reset. */ if (ipg_io_config(dev) < 0) { printk(KERN_INFO "%s: Error during re-configuration.\n", dev->name); } init_tfdlist(dev); spin_unlock_irq(&sp->lock); ipg_w32((ipg_r32(MAC_CTRL) | IPG_MC_TX_ENABLE) & IPG_MC_RSVD_MASK, MAC_CTRL); } /* * For TxComplete interrupts, free all transmit * buffers which have already been transfered via DMA * to the IPG. */ static void ipg_nic_txcleanup(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; unsigned int i; IPG_DEBUG_MSG("_nic_txcleanup\n"); for (i = 0; i < IPG_TFDLIST_LENGTH; i++) { /* Reading the TXSTATUS register clears the * TX_COMPLETE interrupt. */ u32 txstatusdword = ipg_r32(TX_STATUS); IPG_DEBUG_MSG("TxStatus = %8.8x\n", txstatusdword); /* Check for Transmit errors. Error bits only valid if * TX_COMPLETE bit in the TXSTATUS register is a 1. */ if (!(txstatusdword & IPG_TS_TX_COMPLETE)) break; /* If in 10Mbps mode, indicate transmit is ready. */ if (sp->tenmbpsmode) { netif_wake_queue(dev); } /* Transmit error, increment stat counters. */ if (txstatusdword & IPG_TS_TX_ERROR) { IPG_DEBUG_MSG("Transmit error.\n"); sp->stats.tx_errors++; } /* Late collision, re-enable transmitter. */ if (txstatusdword & IPG_TS_LATE_COLLISION) { IPG_DEBUG_MSG("Late collision on transmit.\n"); ipg_w32((ipg_r32(MAC_CTRL) | IPG_MC_TX_ENABLE) & IPG_MC_RSVD_MASK, MAC_CTRL); } /* Maximum collisions, re-enable transmitter. */ if (txstatusdword & IPG_TS_TX_MAX_COLL) { IPG_DEBUG_MSG("Maximum collisions on transmit.\n"); ipg_w32((ipg_r32(MAC_CTRL) | IPG_MC_TX_ENABLE) & IPG_MC_RSVD_MASK, MAC_CTRL); } /* Transmit underrun, reset and re-enable * transmitter. */ if (txstatusdword & IPG_TS_TX_UNDERRUN) { IPG_DEBUG_MSG("Transmitter underrun.\n"); sp->stats.tx_fifo_errors++; ipg_reset(dev, IPG_AC_TX_RESET | IPG_AC_DMA | IPG_AC_NETWORK | IPG_AC_FIFO); /* Re-configure after DMA reset. */ if (ipg_io_config(dev) < 0) { printk(KERN_INFO "%s: Error during re-configuration.\n", dev->name); } init_tfdlist(dev); ipg_w32((ipg_r32(MAC_CTRL) | IPG_MC_TX_ENABLE) & IPG_MC_RSVD_MASK, MAC_CTRL); } } ipg_nic_txfree(dev); } /* Provides statistical information about the IPG NIC. */ static struct net_device_stats *ipg_nic_get_stats(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; u16 temp1; u16 temp2; IPG_DEBUG_MSG("_nic_get_stats\n"); /* Check to see if the NIC has been initialized via nic_open, * before trying to read statistic registers. */ if (!test_bit(__LINK_STATE_START, &dev->state)) return &sp->stats; sp->stats.rx_packets += ipg_r32(IPG_FRAMESRCVDOK); sp->stats.tx_packets += ipg_r32(IPG_FRAMESXMTDOK); sp->stats.rx_bytes += ipg_r32(IPG_OCTETRCVOK); sp->stats.tx_bytes += ipg_r32(IPG_OCTETXMTOK); temp1 = ipg_r16(IPG_FRAMESLOSTRXERRORS); sp->stats.rx_errors += temp1; sp->stats.rx_missed_errors += temp1; temp1 = ipg_r32(IPG_SINGLECOLFRAMES) + ipg_r32(IPG_MULTICOLFRAMES) + ipg_r32(IPG_LATECOLLISIONS); temp2 = ipg_r16(IPG_CARRIERSENSEERRORS); sp->stats.collisions += temp1; sp->stats.tx_dropped += ipg_r16(IPG_FRAMESABORTXSCOLLS); sp->stats.tx_errors += ipg_r16(IPG_FRAMESWEXDEFERRAL) + ipg_r32(IPG_FRAMESWDEFERREDXMT) + temp1 + temp2; sp->stats.multicast += ipg_r32(IPG_MCSTOCTETRCVDOK); /* detailed tx_errors */ sp->stats.tx_carrier_errors += temp2; /* detailed rx_errors */ sp->stats.rx_length_errors += ipg_r16(IPG_INRANGELENGTHERRORS) + ipg_r16(IPG_FRAMETOOLONGERRRORS); sp->stats.rx_crc_errors += ipg_r16(IPG_FRAMECHECKSEQERRORS); /* Unutilized IPG statistic registers. */ ipg_r32(IPG_MCSTFRAMESRCVDOK); return &sp->stats; } /* Restore used receive buffers. */ static int ipg_nic_rxrestore(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); const unsigned int curr = sp->rx_current; unsigned int dirty = sp->rx_dirty; IPG_DEBUG_MSG("_nic_rxrestore\n"); for (dirty = sp->rx_dirty; curr - dirty > 0; dirty++) { unsigned int entry = dirty % IPG_RFDLIST_LENGTH; /* rx_copybreak may poke hole here and there. */ if (sp->rx_buff[entry]) continue; /* Generate a new receive buffer to replace the * current buffer (which will be released by the * Linux system). */ if (ipg_get_rxbuff(dev, entry) < 0) { IPG_DEBUG_MSG("Cannot allocate new Rx buffer.\n"); break; } /* Reset the RFS field. */ sp->rxd[entry].rfs = 0x0000000000000000; } sp->rx_dirty = dirty; return 0; } /* use jumboindex and jumbosize to control jumbo frame status * initial status is jumboindex=-1 and jumbosize=0 * 1. jumboindex = -1 and jumbosize=0 : previous jumbo frame has been done. * 2. jumboindex != -1 and jumbosize != 0 : jumbo frame is not over size and receiving * 3. jumboindex = -1 and jumbosize != 0 : jumbo frame is over size, already dump * previous receiving and need to continue dumping the current one */ enum { NORMAL_PACKET, ERROR_PACKET }; enum { FRAME_NO_START_NO_END = 0, FRAME_WITH_START = 1, FRAME_WITH_END = 10, FRAME_WITH_START_WITH_END = 11 }; static void ipg_nic_rx_free_skb(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); unsigned int entry = sp->rx_current % IPG_RFDLIST_LENGTH; if (sp->rx_buff[entry]) { struct ipg_rx *rxfd = sp->rxd + entry; pci_unmap_single(sp->pdev, le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN, sp->rx_buf_sz, PCI_DMA_FROMDEVICE); dev_kfree_skb_irq(sp->rx_buff[entry]); sp->rx_buff[entry] = NULL; } } static int ipg_nic_rx_check_frame_type(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); struct ipg_rx *rxfd = sp->rxd + (sp->rx_current % IPG_RFDLIST_LENGTH); int type = FRAME_NO_START_NO_END; if (le64_to_cpu(rxfd->rfs) & IPG_RFS_FRAMESTART) type += FRAME_WITH_START; if (le64_to_cpu(rxfd->rfs) & IPG_RFS_FRAMEEND) type += FRAME_WITH_END; return type; } static int ipg_nic_rx_check_error(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); unsigned int entry = sp->rx_current % IPG_RFDLIST_LENGTH; struct ipg_rx *rxfd = sp->rxd + entry; if (IPG_DROP_ON_RX_ETH_ERRORS && (le64_to_cpu(rxfd->rfs) & (IPG_RFS_RXFIFOOVERRUN | IPG_RFS_RXRUNTFRAME | IPG_RFS_RXALIGNMENTERROR | IPG_RFS_RXFCSERROR | IPG_RFS_RXOVERSIZEDFRAME | IPG_RFS_RXLENGTHERROR))) { IPG_DEBUG_MSG("Rx error, RFS = %16.16lx\n", (unsigned long) rxfd->rfs); /* Increment general receive error statistic. */ sp->stats.rx_errors++; /* Increment detailed receive error statistics. */ if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFIFOOVERRUN) { IPG_DEBUG_MSG("RX FIFO overrun occured.\n"); sp->stats.rx_fifo_errors++; } if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXRUNTFRAME) { IPG_DEBUG_MSG("RX runt occured.\n"); sp->stats.rx_length_errors++; } /* Do nothing for IPG_RFS_RXOVERSIZEDFRAME, * error count handled by a IPG statistic register. */ if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXALIGNMENTERROR) { IPG_DEBUG_MSG("RX alignment error occured.\n"); sp->stats.rx_frame_errors++; } /* Do nothing for IPG_RFS_RXFCSERROR, error count * handled by a IPG statistic register. */ /* Free the memory associated with the RX * buffer since it is erroneous and we will * not pass it to higher layer processes. */ if (sp->rx_buff[entry]) { pci_unmap_single(sp->pdev, le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN, sp->rx_buf_sz, PCI_DMA_FROMDEVICE); dev_kfree_skb_irq(sp->rx_buff[entry]); sp->rx_buff[entry] = NULL; } return ERROR_PACKET; } return NORMAL_PACKET; } static void ipg_nic_rx_with_start_and_end(struct net_device *dev, struct ipg_nic_private *sp, struct ipg_rx *rxfd, unsigned entry) { struct ipg_jumbo *jumbo = &sp->jumbo; struct sk_buff *skb; int framelen; if (jumbo->found_start) { dev_kfree_skb_irq(jumbo->skb); jumbo->found_start = 0; jumbo->current_size = 0; jumbo->skb = NULL; } /* 1: found error, 0 no error */ if (ipg_nic_rx_check_error(dev) != NORMAL_PACKET) return; skb = sp->rx_buff[entry]; if (!skb) return; /* accept this frame and send to upper layer */ framelen = le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFRAMELEN; if (framelen > sp->rxfrag_size) framelen = sp->rxfrag_size; skb_put(skb, framelen); skb->protocol = eth_type_trans(skb, dev); skb->ip_summed = CHECKSUM_NONE; netif_rx(skb); sp->rx_buff[entry] = NULL; } static void ipg_nic_rx_with_start(struct net_device *dev, struct ipg_nic_private *sp, struct ipg_rx *rxfd, unsigned entry) { struct ipg_jumbo *jumbo = &sp->jumbo; struct pci_dev *pdev = sp->pdev; struct sk_buff *skb; /* 1: found error, 0 no error */ if (ipg_nic_rx_check_error(dev) != NORMAL_PACKET) return; /* accept this frame and send to upper layer */ skb = sp->rx_buff[entry]; if (!skb) return; if (jumbo->found_start) dev_kfree_skb_irq(jumbo->skb); pci_unmap_single(pdev, le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN, sp->rx_buf_sz, PCI_DMA_FROMDEVICE); skb_put(skb, sp->rxfrag_size); jumbo->found_start = 1; jumbo->current_size = sp->rxfrag_size; jumbo->skb = skb; sp->rx_buff[entry] = NULL; } static void ipg_nic_rx_with_end(struct net_device *dev, struct ipg_nic_private *sp, struct ipg_rx *rxfd, unsigned entry) { struct ipg_jumbo *jumbo = &sp->jumbo; /* 1: found error, 0 no error */ if (ipg_nic_rx_check_error(dev) == NORMAL_PACKET) { struct sk_buff *skb = sp->rx_buff[entry]; if (!skb) return; if (jumbo->found_start) { int framelen, endframelen; framelen = le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFRAMELEN; endframelen = framelen - jumbo->current_size; if (framelen > sp->rxsupport_size) dev_kfree_skb_irq(jumbo->skb); else { memcpy(skb_put(jumbo->skb, endframelen), skb->data, endframelen); jumbo->skb->protocol = eth_type_trans(jumbo->skb, dev); jumbo->skb->ip_summed = CHECKSUM_NONE; netif_rx(jumbo->skb); } } jumbo->found_start = 0; jumbo->current_size = 0; jumbo->skb = NULL; ipg_nic_rx_free_skb(dev); } else { dev_kfree_skb_irq(jumbo->skb); jumbo->found_start = 0; jumbo->current_size = 0; jumbo->skb = NULL; } } static void ipg_nic_rx_no_start_no_end(struct net_device *dev, struct ipg_nic_private *sp, struct ipg_rx *rxfd, unsigned entry) { struct ipg_jumbo *jumbo = &sp->jumbo; /* 1: found error, 0 no error */ if (ipg_nic_rx_check_error(dev) == NORMAL_PACKET) { struct sk_buff *skb = sp->rx_buff[entry]; if (skb) { if (jumbo->found_start) { jumbo->current_size += sp->rxfrag_size; if (jumbo->current_size <= sp->rxsupport_size) { memcpy(skb_put(jumbo->skb, sp->rxfrag_size), skb->data, sp->rxfrag_size); } } ipg_nic_rx_free_skb(dev); } } else { dev_kfree_skb_irq(jumbo->skb); jumbo->found_start = 0; jumbo->current_size = 0; jumbo->skb = NULL; } } static int ipg_nic_rx_jumbo(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); unsigned int curr = sp->rx_current; void __iomem *ioaddr = sp->ioaddr; unsigned int i; IPG_DEBUG_MSG("_nic_rx\n"); for (i = 0; i < IPG_MAXRFDPROCESS_COUNT; i++, curr++) { unsigned int entry = curr % IPG_RFDLIST_LENGTH; struct ipg_rx *rxfd = sp->rxd + entry; if (!(rxfd->rfs & cpu_to_le64(IPG_RFS_RFDDONE))) break; switch (ipg_nic_rx_check_frame_type(dev)) { case FRAME_WITH_START_WITH_END: ipg_nic_rx_with_start_and_end(dev, sp, rxfd, entry); break; case FRAME_WITH_START: ipg_nic_rx_with_start(dev, sp, rxfd, entry); break; case FRAME_WITH_END: ipg_nic_rx_with_end(dev, sp, rxfd, entry); break; case FRAME_NO_START_NO_END: ipg_nic_rx_no_start_no_end(dev, sp, rxfd, entry); break; } } sp->rx_current = curr; if (i == IPG_MAXRFDPROCESS_COUNT) { /* There are more RFDs to process, however the * allocated amount of RFD processing time has * expired. Assert Interrupt Requested to make * sure we come back to process the remaining RFDs. */ ipg_w32(ipg_r32(ASIC_CTRL) | IPG_AC_INT_REQUEST, ASIC_CTRL); } ipg_nic_rxrestore(dev); return 0; } static int ipg_nic_rx(struct net_device *dev) { /* Transfer received Ethernet frames to higher network layers. */ struct ipg_nic_private *sp = netdev_priv(dev); unsigned int curr = sp->rx_current; void __iomem *ioaddr = sp->ioaddr; struct ipg_rx *rxfd; unsigned int i; IPG_DEBUG_MSG("_nic_rx\n"); #define __RFS_MASK \ cpu_to_le64(IPG_RFS_RFDDONE | IPG_RFS_FRAMESTART | IPG_RFS_FRAMEEND) for (i = 0; i < IPG_MAXRFDPROCESS_COUNT; i++, curr++) { unsigned int entry = curr % IPG_RFDLIST_LENGTH; struct sk_buff *skb = sp->rx_buff[entry]; unsigned int framelen; rxfd = sp->rxd + entry; if (((rxfd->rfs & __RFS_MASK) != __RFS_MASK) || !skb) break; /* Get received frame length. */ framelen = le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFRAMELEN; /* Check for jumbo frame arrival with too small * RXFRAG_SIZE. */ if (framelen > sp->rxfrag_size) { IPG_DEBUG_MSG ("RFS FrameLen > allocated fragment size.\n"); framelen = sp->rxfrag_size; } if ((IPG_DROP_ON_RX_ETH_ERRORS && (le64_to_cpu(rxfd->rfs) & (IPG_RFS_RXFIFOOVERRUN | IPG_RFS_RXRUNTFRAME | IPG_RFS_RXALIGNMENTERROR | IPG_RFS_RXFCSERROR | IPG_RFS_RXOVERSIZEDFRAME | IPG_RFS_RXLENGTHERROR)))) { IPG_DEBUG_MSG("Rx error, RFS = %16.16lx\n", (unsigned long int) rxfd->rfs); /* Increment general receive error statistic. */ sp->stats.rx_errors++; /* Increment detailed receive error statistics. */ if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFIFOOVERRUN) { IPG_DEBUG_MSG("RX FIFO overrun occured.\n"); sp->stats.rx_fifo_errors++; } if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXRUNTFRAME) { IPG_DEBUG_MSG("RX runt occured.\n"); sp->stats.rx_length_errors++; } if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXOVERSIZEDFRAME) ; /* Do nothing, error count handled by a IPG * statistic register. */ if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXALIGNMENTERROR) { IPG_DEBUG_MSG("RX alignment error occured.\n"); sp->stats.rx_frame_errors++; } if (le64_to_cpu(rxfd->rfs) & IPG_RFS_RXFCSERROR) ; /* Do nothing, error count handled by a IPG * statistic register. */ /* Free the memory associated with the RX * buffer since it is erroneous and we will * not pass it to higher layer processes. */ if (skb) { __le64 info = rxfd->frag_info; pci_unmap_single(sp->pdev, le64_to_cpu(info) & ~IPG_RFI_FRAGLEN, sp->rx_buf_sz, PCI_DMA_FROMDEVICE); dev_kfree_skb_irq(skb); } } else { /* Adjust the new buffer length to accomodate the size * of the received frame. */ skb_put(skb, framelen); /* Set the buffer's protocol field to Ethernet. */ skb->protocol = eth_type_trans(skb, dev); /* The IPG encountered an error with (or * there were no) IP/TCP/UDP checksums. * This may or may not indicate an invalid * IP/TCP/UDP frame was received. Let the * upper layer decide. */ skb->ip_summed = CHECKSUM_NONE; /* Hand off frame for higher layer processing. * The function netif_rx() releases the sk_buff * when processing completes. */ netif_rx(skb); } /* Assure RX buffer is not reused by IPG. */ sp->rx_buff[entry] = NULL; } /* * If there are more RFDs to proces and the allocated amount of RFD * processing time has expired, assert Interrupt Requested to make * sure we come back to process the remaining RFDs. */ if (i == IPG_MAXRFDPROCESS_COUNT) ipg_w32(ipg_r32(ASIC_CTRL) | IPG_AC_INT_REQUEST, ASIC_CTRL); #ifdef IPG_DEBUG /* Check if the RFD list contained no receive frame data. */ if (!i) sp->EmptyRFDListCount++; #endif while ((le64_to_cpu(rxfd->rfs) & IPG_RFS_RFDDONE) && !((le64_to_cpu(rxfd->rfs) & IPG_RFS_FRAMESTART) && (le64_to_cpu(rxfd->rfs) & IPG_RFS_FRAMEEND))) { unsigned int entry = curr++ % IPG_RFDLIST_LENGTH; rxfd = sp->rxd + entry; IPG_DEBUG_MSG("Frame requires multiple RFDs.\n"); /* An unexpected event, additional code needed to handle * properly. So for the time being, just disregard the * frame. */ /* Free the memory associated with the RX * buffer since it is erroneous and we will * not pass it to higher layer processes. */ if (sp->rx_buff[entry]) { pci_unmap_single(sp->pdev, le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN, sp->rx_buf_sz, PCI_DMA_FROMDEVICE); dev_kfree_skb_irq(sp->rx_buff[entry]); } /* Assure RX buffer is not reused by IPG. */ sp->rx_buff[entry] = NULL; } sp->rx_current = curr; /* Check to see if there are a minimum number of used * RFDs before restoring any (should improve performance.) */ if ((curr - sp->rx_dirty) >= IPG_MINUSEDRFDSTOFREE) ipg_nic_rxrestore(dev); return 0; } static void ipg_reset_after_host_error(struct work_struct *work) { struct ipg_nic_private *sp = container_of(work, struct ipg_nic_private, task.work); struct net_device *dev = sp->dev; IPG_DDEBUG_MSG("DMACtrl = %8.8x\n", ioread32(sp->ioaddr + IPG_DMACTRL)); /* * Acknowledge HostError interrupt by resetting * IPG DMA and HOST. */ ipg_reset(dev, IPG_AC_GLOBAL_RESET | IPG_AC_HOST | IPG_AC_DMA); init_rfdlist(dev); init_tfdlist(dev); if (ipg_io_config(dev) < 0) { printk(KERN_INFO "%s: Cannot recover from PCI error.\n", dev->name); schedule_delayed_work(&sp->task, HZ); } } static irqreturn_t ipg_interrupt_handler(int irq, void *dev_inst) { struct net_device *dev = dev_inst; struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; unsigned int handled = 0; u16 status; IPG_DEBUG_MSG("_interrupt_handler\n"); if (sp->is_jumbo) ipg_nic_rxrestore(dev); spin_lock(&sp->lock); /* Get interrupt source information, and acknowledge * some (i.e. TxDMAComplete, RxDMAComplete, RxEarly, * IntRequested, MacControlFrame, LinkEvent) interrupts * if issued. Also, all IPG interrupts are disabled by * reading IntStatusAck. */ status = ipg_r16(INT_STATUS_ACK); IPG_DEBUG_MSG("IntStatusAck = %4.4x\n", status); /* Shared IRQ of remove event. */ if (!(status & IPG_IS_RSVD_MASK)) goto out_enable; handled = 1; if (unlikely(!netif_running(dev))) goto out_unlock; /* If RFDListEnd interrupt, restore all used RFDs. */ if (status & IPG_IS_RFD_LIST_END) { IPG_DEBUG_MSG("RFDListEnd Interrupt.\n"); /* The RFD list end indicates an RFD was encountered * with a 0 NextPtr, or with an RFDDone bit set to 1 * (indicating the RFD is not read for use by the * IPG.) Try to restore all RFDs. */ ipg_nic_rxrestore(dev); #ifdef IPG_DEBUG /* Increment the RFDlistendCount counter. */ sp->RFDlistendCount++; #endif } /* If RFDListEnd, RxDMAPriority, RxDMAComplete, or * IntRequested interrupt, process received frames. */ if ((status & IPG_IS_RX_DMA_PRIORITY) || (status & IPG_IS_RFD_LIST_END) || (status & IPG_IS_RX_DMA_COMPLETE) || (status & IPG_IS_INT_REQUESTED)) { #ifdef IPG_DEBUG /* Increment the RFD list checked counter if interrupted * only to check the RFD list. */ if (status & (~(IPG_IS_RX_DMA_PRIORITY | IPG_IS_RFD_LIST_END | IPG_IS_RX_DMA_COMPLETE | IPG_IS_INT_REQUESTED) & (IPG_IS_HOST_ERROR | IPG_IS_TX_DMA_COMPLETE | IPG_IS_LINK_EVENT | IPG_IS_TX_COMPLETE | IPG_IS_UPDATE_STATS))) sp->RFDListCheckedCount++; #endif if (sp->is_jumbo) ipg_nic_rx_jumbo(dev); else ipg_nic_rx(dev); } /* If TxDMAComplete interrupt, free used TFDs. */ if (status & IPG_IS_TX_DMA_COMPLETE) ipg_nic_txfree(dev); /* TxComplete interrupts indicate one of numerous actions. * Determine what action to take based on TXSTATUS register. */ if (status & IPG_IS_TX_COMPLETE) ipg_nic_txcleanup(dev); /* If UpdateStats interrupt, update Linux Ethernet statistics */ if (status & IPG_IS_UPDATE_STATS) ipg_nic_get_stats(dev); /* If HostError interrupt, reset IPG. */ if (status & IPG_IS_HOST_ERROR) { IPG_DDEBUG_MSG("HostError Interrupt\n"); schedule_delayed_work(&sp->task, 0); } /* If LinkEvent interrupt, resolve autonegotiation. */ if (status & IPG_IS_LINK_EVENT) { if (ipg_config_autoneg(dev) < 0) printk(KERN_INFO "%s: Auto-negotiation error.\n", dev->name); } /* If MACCtrlFrame interrupt, do nothing. */ if (status & IPG_IS_MAC_CTRL_FRAME) IPG_DEBUG_MSG("MACCtrlFrame interrupt.\n"); /* If RxComplete interrupt, do nothing. */ if (status & IPG_IS_RX_COMPLETE) IPG_DEBUG_MSG("RxComplete interrupt.\n"); /* If RxEarly interrupt, do nothing. */ if (status & IPG_IS_RX_EARLY) IPG_DEBUG_MSG("RxEarly interrupt.\n"); out_enable: /* Re-enable IPG interrupts. */ ipg_w16(IPG_IE_TX_DMA_COMPLETE | IPG_IE_RX_DMA_COMPLETE | IPG_IE_HOST_ERROR | IPG_IE_INT_REQUESTED | IPG_IE_TX_COMPLETE | IPG_IE_LINK_EVENT | IPG_IE_UPDATE_STATS, INT_ENABLE); out_unlock: spin_unlock(&sp->lock); return IRQ_RETVAL(handled); } static void ipg_rx_clear(struct ipg_nic_private *sp) { unsigned int i; for (i = 0; i < IPG_RFDLIST_LENGTH; i++) { if (sp->rx_buff[i]) { struct ipg_rx *rxfd = sp->rxd + i; dev_kfree_skb_irq(sp->rx_buff[i]); sp->rx_buff[i] = NULL; pci_unmap_single(sp->pdev, le64_to_cpu(rxfd->frag_info) & ~IPG_RFI_FRAGLEN, sp->rx_buf_sz, PCI_DMA_FROMDEVICE); } } } static void ipg_tx_clear(struct ipg_nic_private *sp) { unsigned int i; for (i = 0; i < IPG_TFDLIST_LENGTH; i++) { if (sp->tx_buff[i]) { struct ipg_tx *txfd = sp->txd + i; pci_unmap_single(sp->pdev, le64_to_cpu(txfd->frag_info) & ~IPG_TFI_FRAGLEN, sp->tx_buff[i]->len, PCI_DMA_TODEVICE); dev_kfree_skb_irq(sp->tx_buff[i]); sp->tx_buff[i] = NULL; } } } static int ipg_nic_open(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; struct pci_dev *pdev = sp->pdev; int rc; IPG_DEBUG_MSG("_nic_open\n"); sp->rx_buf_sz = sp->rxsupport_size; /* Check for interrupt line conflicts, and request interrupt * line for IPG. * * IMPORTANT: Disable IPG interrupts prior to registering * IRQ. */ ipg_w16(0x0000, INT_ENABLE); /* Register the interrupt line to be used by the IPG within * the Linux system. */ rc = request_irq(pdev->irq, ipg_interrupt_handler, IRQF_SHARED, dev->name, dev); if (rc < 0) { printk(KERN_INFO "%s: Error when requesting interrupt.\n", dev->name); goto out; } dev->irq = pdev->irq; rc = -ENOMEM; sp->rxd = dma_alloc_coherent(&pdev->dev, IPG_RX_RING_BYTES, &sp->rxd_map, GFP_KERNEL); if (!sp->rxd) goto err_free_irq_0; sp->txd = dma_alloc_coherent(&pdev->dev, IPG_TX_RING_BYTES, &sp->txd_map, GFP_KERNEL); if (!sp->txd) goto err_free_rx_1; rc = init_rfdlist(dev); if (rc < 0) { printk(KERN_INFO "%s: Error during configuration.\n", dev->name); goto err_free_tx_2; } init_tfdlist(dev); rc = ipg_io_config(dev); if (rc < 0) { printk(KERN_INFO "%s: Error during configuration.\n", dev->name); goto err_release_tfdlist_3; } /* Resolve autonegotiation. */ if (ipg_config_autoneg(dev) < 0) printk(KERN_INFO "%s: Auto-negotiation error.\n", dev->name); /* initialize JUMBO Frame control variable */ sp->jumbo.found_start = 0; sp->jumbo.current_size = 0; sp->jumbo.skb = NULL; /* Enable transmit and receive operation of the IPG. */ ipg_w32((ipg_r32(MAC_CTRL) | IPG_MC_RX_ENABLE | IPG_MC_TX_ENABLE) & IPG_MC_RSVD_MASK, MAC_CTRL); netif_start_queue(dev); out: return rc; err_release_tfdlist_3: ipg_tx_clear(sp); ipg_rx_clear(sp); err_free_tx_2: dma_free_coherent(&pdev->dev, IPG_TX_RING_BYTES, sp->txd, sp->txd_map); err_free_rx_1: dma_free_coherent(&pdev->dev, IPG_RX_RING_BYTES, sp->rxd, sp->rxd_map); err_free_irq_0: free_irq(pdev->irq, dev); goto out; } static int ipg_nic_stop(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; struct pci_dev *pdev = sp->pdev; IPG_DEBUG_MSG("_nic_stop\n"); netif_stop_queue(dev); IPG_DDEBUG_MSG("RFDlistendCount = %i\n", sp->RFDlistendCount); IPG_DDEBUG_MSG("RFDListCheckedCount = %i\n", sp->rxdCheckedCount); IPG_DDEBUG_MSG("EmptyRFDListCount = %i\n", sp->EmptyRFDListCount); IPG_DUMPTFDLIST(dev); do { (void) ipg_r16(INT_STATUS_ACK); ipg_reset(dev, IPG_AC_GLOBAL_RESET | IPG_AC_HOST | IPG_AC_DMA); synchronize_irq(pdev->irq); } while (ipg_r16(INT_ENABLE) & IPG_IE_RSVD_MASK); ipg_rx_clear(sp); ipg_tx_clear(sp); pci_free_consistent(pdev, IPG_RX_RING_BYTES, sp->rxd, sp->rxd_map); pci_free_consistent(pdev, IPG_TX_RING_BYTES, sp->txd, sp->txd_map); free_irq(pdev->irq, dev); return 0; } static netdev_tx_t ipg_nic_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; unsigned int entry = sp->tx_current % IPG_TFDLIST_LENGTH; unsigned long flags; struct ipg_tx *txfd; IPG_DDEBUG_MSG("_nic_hard_start_xmit\n"); /* If in 10Mbps mode, stop the transmit queue so * no more transmit frames are accepted. */ if (sp->tenmbpsmode) netif_stop_queue(dev); if (sp->reset_current_tfd) { sp->reset_current_tfd = 0; entry = 0; } txfd = sp->txd + entry; sp->tx_buff[entry] = skb; /* Clear all TFC fields, except TFDDONE. */ txfd->tfc = cpu_to_le64(IPG_TFC_TFDDONE); /* Specify the TFC field within the TFD. */ txfd->tfc |= cpu_to_le64(IPG_TFC_WORDALIGNDISABLED | (IPG_TFC_FRAMEID & sp->tx_current) | (IPG_TFC_FRAGCOUNT & (1 << 24))); /* * 16--17 (WordAlign) <- 3 (disable), * 0--15 (FrameId) <- sp->tx_current, * 24--27 (FragCount) <- 1 */ /* Request TxComplete interrupts at an interval defined * by the constant IPG_FRAMESBETWEENTXCOMPLETES. * Request TxComplete interrupt for every frame * if in 10Mbps mode to accomodate problem with 10Mbps * processing. */ if (sp->tenmbpsmode) txfd->tfc |= cpu_to_le64(IPG_TFC_TXINDICATE); txfd->tfc |= cpu_to_le64(IPG_TFC_TXDMAINDICATE); /* Based on compilation option, determine if FCS is to be * appended to transmit frame by IPG. */ if (!(IPG_APPEND_FCS_ON_TX)) txfd->tfc |= cpu_to_le64(IPG_TFC_FCSAPPENDDISABLE); /* Based on compilation option, determine if IP, TCP and/or * UDP checksums are to be added to transmit frame by IPG. */ if (IPG_ADD_IPCHECKSUM_ON_TX) txfd->tfc |= cpu_to_le64(IPG_TFC_IPCHECKSUMENABLE); if (IPG_ADD_TCPCHECKSUM_ON_TX) txfd->tfc |= cpu_to_le64(IPG_TFC_TCPCHECKSUMENABLE); if (IPG_ADD_UDPCHECKSUM_ON_TX) txfd->tfc |= cpu_to_le64(IPG_TFC_UDPCHECKSUMENABLE); /* Based on compilation option, determine if VLAN tag info is to be * inserted into transmit frame by IPG. */ if (IPG_INSERT_MANUAL_VLAN_TAG) { txfd->tfc |= cpu_to_le64(IPG_TFC_VLANTAGINSERT | ((u64) IPG_MANUAL_VLAN_VID << 32) | ((u64) IPG_MANUAL_VLAN_CFI << 44) | ((u64) IPG_MANUAL_VLAN_USERPRIORITY << 45)); } /* The fragment start location within system memory is defined * by the sk_buff structure's data field. The physical address * of this location within the system's virtual memory space * is determined using the IPG_HOST2BUS_MAP function. */ txfd->frag_info = cpu_to_le64(pci_map_single(sp->pdev, skb->data, skb->len, PCI_DMA_TODEVICE)); /* The length of the fragment within system memory is defined by * the sk_buff structure's len field. */ txfd->frag_info |= cpu_to_le64(IPG_TFI_FRAGLEN & ((u64) (skb->len & 0xffff) << 48)); /* Clear the TFDDone bit last to indicate the TFD is ready * for transfer to the IPG. */ txfd->tfc &= cpu_to_le64(~IPG_TFC_TFDDONE); spin_lock_irqsave(&sp->lock, flags); sp->tx_current++; mmiowb(); ipg_w32(IPG_DC_TX_DMA_POLL_NOW, DMA_CTRL); if (sp->tx_current == (sp->tx_dirty + IPG_TFDLIST_LENGTH)) netif_stop_queue(dev); spin_unlock_irqrestore(&sp->lock, flags); return NETDEV_TX_OK; } static void ipg_set_phy_default_param(unsigned char rev, struct net_device *dev, int phy_address) { unsigned short length; unsigned char revision; unsigned short *phy_param; unsigned short address, value; phy_param = &DefaultPhyParam[0]; length = *phy_param & 0x00FF; revision = (unsigned char)((*phy_param) >> 8); phy_param++; while (length != 0) { if (rev == revision) { while (length > 1) { address = *phy_param; value = *(phy_param + 1); phy_param += 2; mdio_write(dev, phy_address, address, value); length -= 4; } break; } else { phy_param += length / 2; length = *phy_param & 0x00FF; revision = (unsigned char)((*phy_param) >> 8); phy_param++; } } } static int read_eeprom(struct net_device *dev, int eep_addr) { void __iomem *ioaddr = ipg_ioaddr(dev); unsigned int i; int ret = 0; u16 value; value = IPG_EC_EEPROM_READOPCODE | (eep_addr & 0xff); ipg_w16(value, EEPROM_CTRL); for (i = 0; i < 1000; i++) { u16 data; mdelay(10); data = ipg_r16(EEPROM_CTRL); if (!(data & IPG_EC_EEPROM_BUSY)) { ret = ipg_r16(EEPROM_DATA); break; } } return ret; } static void ipg_init_mii(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); struct mii_if_info *mii_if = &sp->mii_if; int phyaddr; mii_if->dev = dev; mii_if->mdio_read = mdio_read; mii_if->mdio_write = mdio_write; mii_if->phy_id_mask = 0x1f; mii_if->reg_num_mask = 0x1f; mii_if->phy_id = phyaddr = ipg_find_phyaddr(dev); if (phyaddr != 0x1f) { u16 mii_phyctrl, mii_1000cr; u8 revisionid = 0; mii_1000cr = mdio_read(dev, phyaddr, MII_CTRL1000); mii_1000cr |= ADVERTISE_1000FULL | ADVERTISE_1000HALF | GMII_PHY_1000BASETCONTROL_PreferMaster; mdio_write(dev, phyaddr, MII_CTRL1000, mii_1000cr); mii_phyctrl = mdio_read(dev, phyaddr, MII_BMCR); /* Set default phyparam */ pci_read_config_byte(sp->pdev, PCI_REVISION_ID, &revisionid); ipg_set_phy_default_param(revisionid, dev, phyaddr); /* Reset PHY */ mii_phyctrl |= BMCR_RESET | BMCR_ANRESTART; mdio_write(dev, phyaddr, MII_BMCR, mii_phyctrl); } } static int ipg_hw_init(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); void __iomem *ioaddr = sp->ioaddr; unsigned int i; int rc; /* Read/Write and Reset EEPROM Value */ /* Read LED Mode Configuration from EEPROM */ sp->led_mode = read_eeprom(dev, 6); /* Reset all functions within the IPG. Do not assert * RST_OUT as not compatible with some PHYs. */ rc = ipg_reset(dev, IPG_RESET_MASK); if (rc < 0) goto out; ipg_init_mii(dev); /* Read MAC Address from EEPROM */ for (i = 0; i < 3; i++) sp->station_addr[i] = read_eeprom(dev, 16 + i); for (i = 0; i < 3; i++) ipg_w16(sp->station_addr[i], STATION_ADDRESS_0 + 2*i); /* Set station address in ethernet_device structure. */ dev->dev_addr[0] = ipg_r16(STATION_ADDRESS_0) & 0x00ff; dev->dev_addr[1] = (ipg_r16(STATION_ADDRESS_0) & 0xff00) >> 8; dev->dev_addr[2] = ipg_r16(STATION_ADDRESS_1) & 0x00ff; dev->dev_addr[3] = (ipg_r16(STATION_ADDRESS_1) & 0xff00) >> 8; dev->dev_addr[4] = ipg_r16(STATION_ADDRESS_2) & 0x00ff; dev->dev_addr[5] = (ipg_r16(STATION_ADDRESS_2) & 0xff00) >> 8; out: return rc; } static int ipg_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { struct ipg_nic_private *sp = netdev_priv(dev); int rc; mutex_lock(&sp->mii_mutex); rc = generic_mii_ioctl(&sp->mii_if, if_mii(ifr), cmd, NULL); mutex_unlock(&sp->mii_mutex); return rc; } static int ipg_nic_change_mtu(struct net_device *dev, int new_mtu) { struct ipg_nic_private *sp = netdev_priv(dev); int err; /* Function to accomodate changes to Maximum Transfer Unit * (or MTU) of IPG NIC. Cannot use default function since * the default will not allow for MTU > 1500 bytes. */ IPG_DEBUG_MSG("_nic_change_mtu\n"); /* * Check that the new MTU value is between 68 (14 byte header, 46 byte * payload, 4 byte FCS) and 10 KB, which is the largest supported MTU. */ if (new_mtu < 68 || new_mtu > 10240) return -EINVAL; err = ipg_nic_stop(dev); if (err) return err; dev->mtu = new_mtu; sp->max_rxframe_size = new_mtu; sp->rxfrag_size = new_mtu; if (sp->rxfrag_size > 4088) sp->rxfrag_size = 4088; sp->rxsupport_size = sp->max_rxframe_size; if (new_mtu > 0x0600) sp->is_jumbo = true; else sp->is_jumbo = false; return ipg_nic_open(dev); } static int ipg_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { struct ipg_nic_private *sp = netdev_priv(dev); int rc; mutex_lock(&sp->mii_mutex); rc = mii_ethtool_gset(&sp->mii_if, cmd); mutex_unlock(&sp->mii_mutex); return rc; } static int ipg_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) { struct ipg_nic_private *sp = netdev_priv(dev); int rc; mutex_lock(&sp->mii_mutex); rc = mii_ethtool_sset(&sp->mii_if, cmd); mutex_unlock(&sp->mii_mutex); return rc; } static int ipg_nway_reset(struct net_device *dev) { struct ipg_nic_private *sp = netdev_priv(dev); int rc; mutex_lock(&sp->mii_mutex); rc = mii_nway_restart(&sp->mii_if); mutex_unlock(&sp->mii_mutex); return rc; } static const struct ethtool_ops ipg_ethtool_ops = { .get_settings = ipg_get_settings, .set_settings = ipg_set_settings, .nway_reset = ipg_nway_reset, }; static void __devexit ipg_remove(struct pci_dev *pdev) { struct net_device *dev = pci_get_drvdata(pdev); struct ipg_nic_private *sp = netdev_priv(dev); IPG_DEBUG_MSG("_remove\n"); /* Un-register Ethernet device. */ unregister_netdev(dev); pci_iounmap(pdev, sp->ioaddr); pci_release_regions(pdev); free_netdev(dev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); } static const struct net_device_ops ipg_netdev_ops = { .ndo_open = ipg_nic_open, .ndo_stop = ipg_nic_stop, .ndo_start_xmit = ipg_nic_hard_start_xmit, .ndo_get_stats = ipg_nic_get_stats, .ndo_set_multicast_list = ipg_nic_set_multicast_list, .ndo_do_ioctl = ipg_ioctl, .ndo_tx_timeout = ipg_tx_timeout, .ndo_change_mtu = ipg_nic_change_mtu, .ndo_set_mac_address = eth_mac_addr, .ndo_validate_addr = eth_validate_addr, }; static int __devinit ipg_probe(struct pci_dev *pdev, const struct pci_device_id *id) { unsigned int i = id->driver_data; struct ipg_nic_private *sp; struct net_device *dev; void __iomem *ioaddr; int rc; rc = pci_enable_device(pdev); if (rc < 0) goto out; printk(KERN_INFO "%s: %s\n", pci_name(pdev), ipg_brand_name[i]); pci_set_master(pdev); rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(40)); if (rc < 0) { rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); if (rc < 0) { printk(KERN_ERR "%s: DMA config failed.\n", pci_name(pdev)); goto err_disable_0; } } /* * Initialize net device. */ dev = alloc_etherdev(sizeof(struct ipg_nic_private)); if (!dev) { printk(KERN_ERR "%s: alloc_etherdev failed\n", pci_name(pdev)); rc = -ENOMEM; goto err_disable_0; } sp = netdev_priv(dev); spin_lock_init(&sp->lock); mutex_init(&sp->mii_mutex); sp->is_jumbo = IPG_IS_JUMBO; sp->rxfrag_size = IPG_RXFRAG_SIZE; sp->rxsupport_size = IPG_RXSUPPORT_SIZE; sp->max_rxframe_size = IPG_MAX_RXFRAME_SIZE; /* Declare IPG NIC functions for Ethernet device methods. */ dev->netdev_ops = &ipg_netdev_ops; SET_NETDEV_DEV(dev, &pdev->dev); SET_ETHTOOL_OPS(dev, &ipg_ethtool_ops); rc = pci_request_regions(pdev, DRV_NAME); if (rc) goto err_free_dev_1; ioaddr = pci_iomap(pdev, 1, pci_resource_len(pdev, 1)); if (!ioaddr) { printk(KERN_ERR "%s cannot map MMIO\n", pci_name(pdev)); rc = -EIO; goto err_release_regions_2; } /* Save the pointer to the PCI device information. */ sp->ioaddr = ioaddr; sp->pdev = pdev; sp->dev = dev; INIT_DELAYED_WORK(&sp->task, ipg_reset_after_host_error); pci_set_drvdata(pdev, dev); rc = ipg_hw_init(dev); if (rc < 0) goto err_unmap_3; rc = register_netdev(dev); if (rc < 0) goto err_unmap_3; printk(KERN_INFO "Ethernet device registered as: %s\n", dev->name); out: return rc; err_unmap_3: pci_iounmap(pdev, ioaddr); err_release_regions_2: pci_release_regions(pdev); err_free_dev_1: free_netdev(dev); err_disable_0: pci_disable_device(pdev); goto out; } static struct pci_driver ipg_pci_driver = { .name = IPG_DRIVER_NAME, .id_table = ipg_pci_tbl, .probe = ipg_probe, .remove = __devexit_p(ipg_remove), }; static int __init ipg_init_module(void) { return pci_register_driver(&ipg_pci_driver); } static void __exit ipg_exit_module(void) { pci_unregister_driver(&ipg_pci_driver); } module_init(ipg_init_module); module_exit(ipg_exit_module);
{ "pile_set_name": "Github" }
/* Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview The "filebrowser" plugin, it adds support for file uploads and * browsing. * * When file is selected inside of the file browser or uploaded, its url is * inserted automatically to a field, which is described in the 'filebrowser' * attribute. To specify field that should be updated, pass the tab id and * element id, separated with a colon. * * Example 1: (Browse) * * <pre> * { * type : 'button', * id : 'browse', * filebrowser : 'tabId:elementId', * label : editor.lang.common.browseServer * } * </pre> * * If you set the 'filebrowser' attribute on any element other than * 'fileButton', the 'Browse' action will be triggered. * * Example 2: (Quick Upload) * * <pre> * { * type : 'fileButton', * id : 'uploadButton', * filebrowser : 'tabId:elementId', * label : editor.lang.common.uploadSubmit, * 'for' : [ 'upload', 'upload' ] * } * </pre> * * If you set the 'filebrowser' attribute on a fileButton element, the * 'QuickUpload' action will be executed. * * Filebrowser plugin also supports more advanced configuration (through * javascript object). * * The following settings are supported: * * <pre> * [action] - Browse or QuickUpload * [target] - field to update, tabId:elementId * [params] - additional arguments to be passed to the server connector (optional) * [onSelect] - function to execute when file is selected/uploaded (optional) * [url] - the URL to be called (optional) * </pre> * * Example 3: (Quick Upload) * * <pre> * { * type : 'fileButton', * label : editor.lang.common.uploadSubmit, * id : 'buttonId', * filebrowser : * { * action : 'QuickUpload', //required * target : 'tab1:elementId', //required * params : //optional * { * type : 'Files', * currentFolder : '/folder/' * }, * onSelect : function( fileUrl, errorMessage ) //optional * { * // Do not call the built-in selectFuntion * // return false; * } * }, * 'for' : [ 'tab1', 'myFile' ] * } * </pre> * * Suppose we have a file element with id 'myFile', text field with id * 'elementId' and a fileButton. If filebowser.url is not specified explicitly, * form action will be set to 'filebrowser[DialogName]UploadUrl' or, if not * specified, to 'filebrowserUploadUrl'. Additional parameters from 'params' * object will be added to the query string. It is possible to create your own * uploadHandler and cancel the built-in updateTargetElement command. * * Example 4: (Browse) * * <pre> * { * type : 'button', * id : 'buttonId', * label : editor.lang.common.browseServer, * filebrowser : * { * action : 'Browse', * url : '/ckfinder/ckfinder.html&amp;type=Images', * target : 'tab1:elementId' * } * } * </pre> * * In this example, after pressing a button, file browser will be opened in a * popup. If we don't specify filebrowser.url attribute, * 'filebrowser[DialogName]BrowseUrl' or 'filebrowserBrowseUrl' will be used. * After selecting a file in a file browser, an element with id 'elementId' will * be updated. Just like in the third example, a custom 'onSelect' function may be * defined. */ ( function() { /** * Adds (additional) arguments to given url. * * @param {String} * url The url. * @param {Object} * params Additional parameters. */ function addQueryString( url, params ) { var queryString = []; if ( !params ) return url; else { for ( var i in params ) queryString.push( i + "=" + encodeURIComponent( params[ i ] ) ); } return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" ); } /** * Make a string's first character uppercase. * * @param {String} * str String. */ function ucFirst( str ) { str += ''; var f = str.charAt( 0 ).toUpperCase(); return f + str.substr( 1 ); } /** * The onlick function assigned to the 'Browse Server' button. Opens the * file browser and updates target field when file is selected. * * @param {CKEDITOR.event} * evt The event object. */ function browseServer( evt ) { var dialog = this.getDialog(); var editor = dialog.getParentEditor(); editor._.filebrowserSe = this; var width = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowWidth' ] || editor.config.filebrowserWindowWidth || '80%'; var height = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowHeight' ] || editor.config.filebrowserWindowHeight || '70%'; var params = this.filebrowser.params || {}; params.CKEditor = editor.name; params.CKEditorFuncNum = editor._.filebrowserFn; if ( !params.langCode ) params.langCode = editor.langCode; var url = addQueryString( this.filebrowser.url, params ); editor.popup( url, width, height ); } /** * The onlick function assigned to the 'Upload' button. Makes the final * decision whether form is really submitted and updates target field when * file is uploaded. * * @param {CKEDITOR.event} * evt The event object. */ function uploadFile( evt ) { var dialog = this.getDialog(); var editor = dialog.getParentEditor(); editor._.filebrowserSe = this; // If user didn't select the file, stop the upload. if ( !dialog.getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] ).getInputElement().$.value ) return false; if ( !dialog.getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] ).getAction() ) return false; return true; } /** * Setups the file element. * * @param {CKEDITOR.ui.dialog.file} * fileInput The file element used during file upload. * @param {Object} * filebrowser Object containing filebrowser settings assigned to * the fileButton associated with this file element. */ function setupFileElement( editor, fileInput, filebrowser ) { var params = filebrowser.params || {}; params.CKEditor = editor.name; params.CKEditorFuncNum = editor._.filebrowserFn; if ( !params.langCode ) params.langCode = editor.langCode; fileInput.action = addQueryString( filebrowser.url, params ); fileInput.filebrowser = filebrowser; } /** * Traverse through the content definition and attach filebrowser to * elements with 'filebrowser' attribute. * * @param String * dialogName Dialog name. * @param {CKEDITOR.dialog.dialogDefinitionObject} * definition Dialog definition. * @param {Array} * elements Array of {@link CKEDITOR.dialog.contentDefinition} * objects. */ function attachFileBrowser( editor, dialogName, definition, elements ) { var element, fileInput; for ( var i in elements ) { element = elements[ i ]; if ( element.type == 'hbox' || element.type == 'vbox' ) attachFileBrowser( editor, dialogName, definition, element.children ); if ( !element.filebrowser ) continue; if ( typeof element.filebrowser == 'string' ) { var fb = { action : ( element.type == 'fileButton' ) ? 'QuickUpload' : 'Browse', target : element.filebrowser }; element.filebrowser = fb; } if ( element.filebrowser.action == 'Browse' ) { var url = element.filebrowser.url || editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'BrowseUrl' ] || editor.config.filebrowserBrowseUrl; if ( url ) { element.onClick = browseServer; element.filebrowser.url = url; element.hidden = false; } } else if ( element.filebrowser.action == 'QuickUpload' && element[ 'for' ] ) { url = element.filebrowser.url || editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'UploadUrl' ] || editor.config.filebrowserUploadUrl; if ( url ) { element.onClick = uploadFile; element.filebrowser.url = url; element.hidden = false; setupFileElement( editor, definition.getContents( element[ 'for' ][ 0 ] ).get( element[ 'for' ][ 1 ] ), element.filebrowser ); } } } } /** * Updates the target element with the url of uploaded/selected file. * * @param {String} * url The url of a file. */ function updateTargetElement( url, sourceElement ) { var dialog = sourceElement.getDialog(); var targetElement = sourceElement.filebrowser.target || null; url = url.replace( /#/g, '%23' ); // If there is a reference to targetElement, update it. if ( targetElement ) { var target = targetElement.split( ':' ); var element = dialog.getContentElement( target[ 0 ], target[ 1 ] ); if ( element ) { element.setValue( url ); dialog.selectPage( target[ 0 ] ); } } } /** * Returns true if filebrowser is configured in one of the elements. * * @param {CKEDITOR.dialog.dialogDefinitionObject} * definition Dialog definition. * @param String * tabId The tab id where element(s) can be found. * @param String * elementId The element id (or ids, separated with a semicolon) to check. */ function isConfigured( definition, tabId, elementId ) { if ( elementId.indexOf( ";" ) !== -1 ) { var ids = elementId.split( ";" ); for ( var i = 0 ; i < ids.length ; i++ ) { if ( isConfigured( definition, tabId, ids[i]) ) return true; } return false; } return ( definition.getContents( tabId ).get( elementId ).filebrowser && definition.getContents( tabId ).get( elementId ).filebrowser.url ); } function setUrl( fileUrl, data ) { var dialog = this._.filebrowserSe.getDialog(), targetInput = this._.filebrowserSe[ 'for' ], onSelect = this._.filebrowserSe.filebrowser.onSelect; if ( targetInput ) dialog.getContentElement( targetInput[ 0 ], targetInput[ 1 ] ).reset(); if ( onSelect && onSelect.call( this._.filebrowserSe, fileUrl, data ) === false ) return; // The "data" argument may be used to pass the error message to the editor. if ( typeof data == 'string' && data ) alert( data ); if ( fileUrl ) updateTargetElement( fileUrl, this._.filebrowserSe ); } CKEDITOR.plugins.add( 'filebrowser', { init : function( editor, pluginPath ) { editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUrl, editor ); CKEDITOR.on( 'dialogDefinition', function( evt ) { // Associate filebrowser to elements with 'filebrowser' attribute. for ( var i in evt.data.definition.contents ) { attachFileBrowser( evt.editor, evt.data.name, evt.data.definition, evt.data.definition.contents[ i ].elements ); if ( evt.data.definition.contents[ i ].hidden && evt.data.definition.contents[ i ].filebrowser ) { evt.data.definition.contents[ i ].hidden = !isConfigured( evt.data.definition, evt.data.definition.contents[ i ][ 'id' ], evt.data.definition.contents[ i ].filebrowser ); } } } ); } } ); } )();
{ "pile_set_name": "Github" }
/* * SCSI RDMA (SRP) transport class * * Copyright (C) 2007 FUJITA Tomonori <[email protected]> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, version 2 of the * License. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA */ #include <linux/init.h> #include <linux/module.h> #include <linux/jiffies.h> #include <linux/err.h> #include <linux/slab.h> #include <linux/string.h> #include <scsi/scsi.h> #include <scsi/scsi_device.h> #include <scsi/scsi_host.h> #include <scsi/scsi_transport.h> #include <scsi/scsi_transport_srp.h> #include "scsi_transport_srp_internal.h" struct srp_host_attrs { atomic_t next_port_id; }; #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data) #define SRP_HOST_ATTRS 0 #define SRP_RPORT_ATTRS 2 struct srp_internal { struct scsi_transport_template t; struct srp_function_template *f; struct device_attribute *host_attrs[SRP_HOST_ATTRS + 1]; struct device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1]; struct device_attribute private_rport_attrs[SRP_RPORT_ATTRS]; struct transport_container rport_attr_cont; }; #define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t) #define dev_to_rport(d) container_of(d, struct srp_rport, dev) #define transport_class_to_srp_rport(dev) dev_to_rport((dev)->parent) static int srp_host_setup(struct transport_container *tc, struct device *dev, struct device *cdev) { struct Scsi_Host *shost = dev_to_shost(dev); struct srp_host_attrs *srp_host = to_srp_host_attrs(shost); atomic_set(&srp_host->next_port_id, 0); return 0; } static DECLARE_TRANSPORT_CLASS(srp_host_class, "srp_host", srp_host_setup, NULL, NULL); static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports", NULL, NULL, NULL); #define SETUP_TEMPLATE(attrb, field, perm, test, ro_test, ro_perm) \ i->private_##attrb[count] = dev_attr_##field; \ i->private_##attrb[count].attr.mode = perm; \ if (ro_test) { \ i->private_##attrb[count].attr.mode = ro_perm; \ i->private_##attrb[count].store = NULL; \ } \ i->attrb[count] = &i->private_##attrb[count]; \ if (test) \ count++ #define SETUP_RPORT_ATTRIBUTE_RD(field) \ SETUP_TEMPLATE(rport_attrs, field, S_IRUGO, 1, 0, 0) #define SETUP_RPORT_ATTRIBUTE_RW(field) \ SETUP_TEMPLATE(rport_attrs, field, S_IRUGO | S_IWUSR, \ 1, 1, S_IRUGO) #define SRP_PID(p) \ (p)->port_id[0], (p)->port_id[1], (p)->port_id[2], (p)->port_id[3], \ (p)->port_id[4], (p)->port_id[5], (p)->port_id[6], (p)->port_id[7], \ (p)->port_id[8], (p)->port_id[9], (p)->port_id[10], (p)->port_id[11], \ (p)->port_id[12], (p)->port_id[13], (p)->port_id[14], (p)->port_id[15] #define SRP_PID_FMT "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:" \ "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" static ssize_t show_srp_rport_id(struct device *dev, struct device_attribute *attr, char *buf) { struct srp_rport *rport = transport_class_to_srp_rport(dev); return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport)); } static DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL); static const struct { u32 value; char *name; } srp_rport_role_names[] = { {SRP_RPORT_ROLE_INITIATOR, "SRP Initiator"}, {SRP_RPORT_ROLE_TARGET, "SRP Target"}, }; static ssize_t show_srp_rport_roles(struct device *dev, struct device_attribute *attr, char *buf) { struct srp_rport *rport = transport_class_to_srp_rport(dev); int i; char *name = NULL; for (i = 0; i < ARRAY_SIZE(srp_rport_role_names); i++) if (srp_rport_role_names[i].value == rport->roles) { name = srp_rport_role_names[i].name; break; } return sprintf(buf, "%s\n", name ? : "unknown"); } static DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL); static void srp_rport_release(struct device *dev) { struct srp_rport *rport = dev_to_rport(dev); put_device(dev->parent); kfree(rport); } static int scsi_is_srp_rport(const struct device *dev) { return dev->release == srp_rport_release; } static int srp_rport_match(struct attribute_container *cont, struct device *dev) { struct Scsi_Host *shost; struct srp_internal *i; if (!scsi_is_srp_rport(dev)) return 0; shost = dev_to_shost(dev->parent); if (!shost->transportt) return 0; if (shost->transportt->host_attrs.ac.class != &srp_host_class.class) return 0; i = to_srp_internal(shost->transportt); return &i->rport_attr_cont.ac == cont; } static int srp_host_match(struct attribute_container *cont, struct device *dev) { struct Scsi_Host *shost; struct srp_internal *i; if (!scsi_is_host_device(dev)) return 0; shost = dev_to_shost(dev); if (!shost->transportt) return 0; if (shost->transportt->host_attrs.ac.class != &srp_host_class.class) return 0; i = to_srp_internal(shost->transportt); return &i->t.host_attrs.ac == cont; } /** * srp_rport_add - add a SRP remote port to the device hierarchy * @shost: scsi host the remote port is connected to. * @ids: The port id for the remote port. * * Publishes a port to the rest of the system. */ struct srp_rport *srp_rport_add(struct Scsi_Host *shost, struct srp_rport_identifiers *ids) { struct srp_rport *rport; struct device *parent = &shost->shost_gendev; int id, ret; rport = kzalloc(sizeof(*rport), GFP_KERNEL); if (!rport) return ERR_PTR(-ENOMEM); device_initialize(&rport->dev); rport->dev.parent = get_device(parent); rport->dev.release = srp_rport_release; memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id)); rport->roles = ids->roles; id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id); dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id); transport_setup_device(&rport->dev); ret = device_add(&rport->dev); if (ret) { transport_destroy_device(&rport->dev); put_device(&rport->dev); return ERR_PTR(ret); } if (shost->active_mode & MODE_TARGET && ids->roles == SRP_RPORT_ROLE_INITIATOR) { ret = srp_tgt_it_nexus_create(shost, (unsigned long)rport, rport->port_id); if (ret) { device_del(&rport->dev); transport_destroy_device(&rport->dev); put_device(&rport->dev); return ERR_PTR(ret); } } transport_add_device(&rport->dev); transport_configure_device(&rport->dev); return rport; } EXPORT_SYMBOL_GPL(srp_rport_add); /** * srp_rport_del - remove a SRP remote port * @rport: SRP remote port to remove * * Removes the specified SRP remote port. */ void srp_rport_del(struct srp_rport *rport) { struct device *dev = &rport->dev; struct Scsi_Host *shost = dev_to_shost(dev->parent); if (shost->active_mode & MODE_TARGET && rport->roles == SRP_RPORT_ROLE_INITIATOR) srp_tgt_it_nexus_destroy(shost, (unsigned long)rport); transport_remove_device(dev); device_del(dev); transport_destroy_device(dev); put_device(dev); } EXPORT_SYMBOL_GPL(srp_rport_del); static int do_srp_rport_del(struct device *dev, void *data) { if (scsi_is_srp_rport(dev)) srp_rport_del(dev_to_rport(dev)); return 0; } /** * srp_remove_host - tear down a Scsi_Host's SRP data structures * @shost: Scsi Host that is torn down * * Removes all SRP remote ports for a given Scsi_Host. * Must be called just before scsi_remove_host for SRP HBAs. */ void srp_remove_host(struct Scsi_Host *shost) { device_for_each_child(&shost->shost_gendev, NULL, do_srp_rport_del); } EXPORT_SYMBOL_GPL(srp_remove_host); static int srp_tsk_mgmt_response(struct Scsi_Host *shost, u64 nexus, u64 tm_id, int result) { struct srp_internal *i = to_srp_internal(shost->transportt); return i->f->tsk_mgmt_response(shost, nexus, tm_id, result); } static int srp_it_nexus_response(struct Scsi_Host *shost, u64 nexus, int result) { struct srp_internal *i = to_srp_internal(shost->transportt); return i->f->it_nexus_response(shost, nexus, result); } /** * srp_attach_transport - instantiate SRP transport template * @ft: SRP transport class function template */ struct scsi_transport_template * srp_attach_transport(struct srp_function_template *ft) { int count; struct srp_internal *i; i = kzalloc(sizeof(*i), GFP_KERNEL); if (!i) return NULL; i->t.tsk_mgmt_response = srp_tsk_mgmt_response; i->t.it_nexus_response = srp_it_nexus_response; i->t.host_size = sizeof(struct srp_host_attrs); i->t.host_attrs.ac.attrs = &i->host_attrs[0]; i->t.host_attrs.ac.class = &srp_host_class.class; i->t.host_attrs.ac.match = srp_host_match; i->host_attrs[0] = NULL; transport_container_register(&i->t.host_attrs); i->rport_attr_cont.ac.attrs = &i->rport_attrs[0]; i->rport_attr_cont.ac.class = &srp_rport_class.class; i->rport_attr_cont.ac.match = srp_rport_match; transport_container_register(&i->rport_attr_cont); count = 0; SETUP_RPORT_ATTRIBUTE_RD(port_id); SETUP_RPORT_ATTRIBUTE_RD(roles); i->rport_attrs[count] = NULL; i->f = ft; return &i->t; } EXPORT_SYMBOL_GPL(srp_attach_transport); /** * srp_release_transport - release SRP transport template instance * @t: transport template instance */ void srp_release_transport(struct scsi_transport_template *t) { struct srp_internal *i = to_srp_internal(t); transport_container_unregister(&i->t.host_attrs); transport_container_unregister(&i->rport_attr_cont); kfree(i); } EXPORT_SYMBOL_GPL(srp_release_transport); static __init int srp_transport_init(void) { int ret; ret = transport_class_register(&srp_host_class); if (ret) return ret; ret = transport_class_register(&srp_rport_class); if (ret) goto unregister_host_class; return 0; unregister_host_class: transport_class_unregister(&srp_host_class); return ret; } static void __exit srp_transport_exit(void) { transport_class_unregister(&srp_host_class); transport_class_unregister(&srp_rport_class); } MODULE_AUTHOR("FUJITA Tomonori"); MODULE_DESCRIPTION("SRP Transport Attributes"); MODULE_LICENSE("GPL"); module_init(srp_transport_init); module_exit(srp_transport_exit);
{ "pile_set_name": "Github" }
1999-03-02 09:44:33 10HmaX-0005vi-00 <= [email protected] U=CALLER P=local S=sss 1999-03-02 09:44:33 U=CALLER F=<> temporarily rejected RCPT <[email protected]>: failed to expand ACL string "${lookup dnsdb{defer_strict,a=$domain}}": lookup of "defer_strict,a=test.again.dns" gave DEFER:
{ "pile_set_name": "Github" }
// // impl/read_at.hpp // ~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef ASIO_IMPL_READ_AT_HPP #define ASIO_IMPL_READ_AT_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include <algorithm> #include "asio/associated_allocator.hpp" #include "asio/associated_executor.hpp" #include "asio/buffer.hpp" #include "asio/completion_condition.hpp" #include "asio/detail/array_fwd.hpp" #include "asio/detail/base_from_completion_cond.hpp" #include "asio/detail/bind_handler.hpp" #include "asio/detail/consuming_buffers.hpp" #include "asio/detail/dependent_type.hpp" #include "asio/detail/handler_alloc_helpers.hpp" #include "asio/detail/handler_cont_helpers.hpp" #include "asio/detail/handler_invoke_helpers.hpp" #include "asio/detail/handler_type_requirements.hpp" #include "asio/detail/throw_error.hpp" #include "asio/error.hpp" #include "asio/detail/push_options.hpp" namespace asio { namespace detail { template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition> std::size_t read_at_buffer_sequence(SyncRandomAccessReadDevice& d, uint64_t offset, const MutableBufferSequence& buffers, const MutableBufferIterator&, CompletionCondition completion_condition, asio::error_code& ec) { ec = asio::error_code(); asio::detail::consuming_buffers<mutable_buffer, MutableBufferSequence, MutableBufferIterator> tmp(buffers); while (!tmp.empty()) { if (std::size_t max_size = detail::adapt_completion_condition_result( completion_condition(ec, tmp.total_consumed()))) { tmp.consume(d.read_some_at(offset + tmp.total_consumed(), tmp.prepare(max_size), ec)); } else break; } return tmp.total_consumed();; } } // namespace detail template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition> std::size_t read_at(SyncRandomAccessReadDevice& d, uint64_t offset, const MutableBufferSequence& buffers, CompletionCondition completion_condition, asio::error_code& ec) { return detail::read_at_buffer_sequence(d, offset, buffers, asio::buffer_sequence_begin(buffers), completion_condition, ec); } template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence> inline std::size_t read_at(SyncRandomAccessReadDevice& d, uint64_t offset, const MutableBufferSequence& buffers) { asio::error_code ec; std::size_t bytes_transferred = read_at( d, offset, buffers, transfer_all(), ec); asio::detail::throw_error(ec, "read_at"); return bytes_transferred; } template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence> inline std::size_t read_at(SyncRandomAccessReadDevice& d, uint64_t offset, const MutableBufferSequence& buffers, asio::error_code& ec) { return read_at(d, offset, buffers, transfer_all(), ec); } template <typename SyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition> inline std::size_t read_at(SyncRandomAccessReadDevice& d, uint64_t offset, const MutableBufferSequence& buffers, CompletionCondition completion_condition) { asio::error_code ec; std::size_t bytes_transferred = read_at( d, offset, buffers, completion_condition, ec); asio::detail::throw_error(ec, "read_at"); return bytes_transferred; } #if !defined(ASIO_NO_EXTENSIONS) #if !defined(ASIO_NO_IOSTREAM) template <typename SyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition> std::size_t read_at(SyncRandomAccessReadDevice& d, uint64_t offset, asio::basic_streambuf<Allocator>& b, CompletionCondition completion_condition, asio::error_code& ec) { ec = asio::error_code(); std::size_t total_transferred = 0; std::size_t max_size = detail::adapt_completion_condition_result( completion_condition(ec, total_transferred)); std::size_t bytes_available = read_size_helper(b, max_size); while (bytes_available > 0) { std::size_t bytes_transferred = d.read_some_at( offset + total_transferred, b.prepare(bytes_available), ec); b.commit(bytes_transferred); total_transferred += bytes_transferred; max_size = detail::adapt_completion_condition_result( completion_condition(ec, total_transferred)); bytes_available = read_size_helper(b, max_size); } return total_transferred; } template <typename SyncRandomAccessReadDevice, typename Allocator> inline std::size_t read_at(SyncRandomAccessReadDevice& d, uint64_t offset, asio::basic_streambuf<Allocator>& b) { asio::error_code ec; std::size_t bytes_transferred = read_at( d, offset, b, transfer_all(), ec); asio::detail::throw_error(ec, "read_at"); return bytes_transferred; } template <typename SyncRandomAccessReadDevice, typename Allocator> inline std::size_t read_at(SyncRandomAccessReadDevice& d, uint64_t offset, asio::basic_streambuf<Allocator>& b, asio::error_code& ec) { return read_at(d, offset, b, transfer_all(), ec); } template <typename SyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition> inline std::size_t read_at(SyncRandomAccessReadDevice& d, uint64_t offset, asio::basic_streambuf<Allocator>& b, CompletionCondition completion_condition) { asio::error_code ec; std::size_t bytes_transferred = read_at( d, offset, b, completion_condition, ec); asio::detail::throw_error(ec, "read_at"); return bytes_transferred; } #endif // !defined(ASIO_NO_IOSTREAM) #endif // !defined(ASIO_NO_EXTENSIONS) namespace detail { template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition, typename ReadHandler> class read_at_op : detail::base_from_completion_cond<CompletionCondition> { public: read_at_op(AsyncRandomAccessReadDevice& device, uint64_t offset, const MutableBufferSequence& buffers, CompletionCondition completion_condition, ReadHandler& handler) : detail::base_from_completion_cond< CompletionCondition>(completion_condition), device_(device), offset_(offset), buffers_(buffers), start_(0), handler_(ASIO_MOVE_CAST(ReadHandler)(handler)) { } #if defined(ASIO_HAS_MOVE) read_at_op(const read_at_op& other) : detail::base_from_completion_cond<CompletionCondition>(other), device_(other.device_), offset_(other.offset_), buffers_(other.buffers_), start_(other.start_), handler_(other.handler_) { } read_at_op(read_at_op&& other) : detail::base_from_completion_cond<CompletionCondition>(other), device_(other.device_), offset_(other.offset_), buffers_(other.buffers_), start_(other.start_), handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_)) { } #endif // defined(ASIO_HAS_MOVE) void operator()(const asio::error_code& ec, std::size_t bytes_transferred, int start = 0) { std::size_t max_size; switch (start_ = start) { case 1: max_size = this->check_for_completion(ec, buffers_.total_consumed()); do { device_.async_read_some_at( offset_ + buffers_.total_consumed(), buffers_.prepare(max_size), ASIO_MOVE_CAST(read_at_op)(*this)); return; default: buffers_.consume(bytes_transferred); if ((!ec && bytes_transferred == 0) || buffers_.empty()) break; max_size = this->check_for_completion(ec, buffers_.total_consumed()); } while (max_size > 0); handler_(ec, buffers_.total_consumed()); } } //private: AsyncRandomAccessReadDevice& device_; uint64_t offset_; asio::detail::consuming_buffers<mutable_buffer, MutableBufferSequence, MutableBufferIterator> buffers_; int start_; ReadHandler handler_; }; template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition, typename ReadHandler> inline void* asio_handler_allocate(std::size_t size, read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler) { return asio_handler_alloc_helpers::allocate( size, this_handler->handler_); } template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition, typename ReadHandler> inline void asio_handler_deallocate(void* pointer, std::size_t size, read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler) { asio_handler_alloc_helpers::deallocate( pointer, size, this_handler->handler_); } template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition, typename ReadHandler> inline bool asio_handler_is_continuation( read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler) { return this_handler->start_ == 0 ? true : asio_handler_cont_helpers::is_continuation( this_handler->handler_); } template <typename Function, typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition, typename ReadHandler> inline void asio_handler_invoke(Function& function, read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler) { asio_handler_invoke_helpers::invoke( function, this_handler->handler_); } template <typename Function, typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition, typename ReadHandler> inline void asio_handler_invoke(const Function& function, read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>* this_handler) { asio_handler_invoke_helpers::invoke( function, this_handler->handler_); } template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition, typename ReadHandler> inline void start_read_at_buffer_sequence_op(AsyncRandomAccessReadDevice& d, uint64_t offset, const MutableBufferSequence& buffers, const MutableBufferIterator&, CompletionCondition completion_condition, ReadHandler& handler) { detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>( d, offset, buffers, completion_condition, handler)( asio::error_code(), 0, 1); } } // namespace detail #if !defined(GENERATING_DOCUMENTATION) template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition, typename ReadHandler, typename Allocator> struct associated_allocator< detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>, Allocator> { typedef typename associated_allocator<ReadHandler, Allocator>::type type; static type get( const detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>& h, const Allocator& a = Allocator()) ASIO_NOEXCEPT { return associated_allocator<ReadHandler, Allocator>::get(h.handler_, a); } }; template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename MutableBufferIterator, typename CompletionCondition, typename ReadHandler, typename Executor> struct associated_executor< detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>, Executor> { typedef typename associated_executor<ReadHandler, Executor>::type type; static type get( const detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence, MutableBufferIterator, CompletionCondition, ReadHandler>& h, const Executor& ex = Executor()) ASIO_NOEXCEPT { return associated_executor<ReadHandler, Executor>::get(h.handler_, ex); } }; #endif // !defined(GENERATING_DOCUMENTATION) template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename CompletionCondition, typename ReadHandler> inline ASIO_INITFN_RESULT_TYPE(ReadHandler, void (asio::error_code, std::size_t)) async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset, const MutableBufferSequence& buffers, CompletionCondition completion_condition, ASIO_MOVE_ARG(ReadHandler) handler) { // If you get an error on the following line it means that your handler does // not meet the documented type requirements for a ReadHandler. ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; async_completion<ReadHandler, void (asio::error_code, std::size_t)> init(handler); detail::start_read_at_buffer_sequence_op(d, offset, buffers, asio::buffer_sequence_begin(buffers), completion_condition, init.completion_handler); return init.result.get(); } template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence, typename ReadHandler> inline ASIO_INITFN_RESULT_TYPE(ReadHandler, void (asio::error_code, std::size_t)) async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset, const MutableBufferSequence& buffers, ASIO_MOVE_ARG(ReadHandler) handler) { // If you get an error on the following line it means that your handler does // not meet the documented type requirements for a ReadHandler. ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; async_completion<ReadHandler, void (asio::error_code, std::size_t)> init(handler); detail::start_read_at_buffer_sequence_op(d, offset, buffers, asio::buffer_sequence_begin(buffers), transfer_all(), init.completion_handler); return init.result.get(); } #if !defined(ASIO_NO_EXTENSIONS) #if !defined(ASIO_NO_IOSTREAM) namespace detail { template <typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler> class read_at_streambuf_op : detail::base_from_completion_cond<CompletionCondition> { public: read_at_streambuf_op(AsyncRandomAccessReadDevice& device, uint64_t offset, basic_streambuf<Allocator>& streambuf, CompletionCondition completion_condition, ReadHandler& handler) : detail::base_from_completion_cond< CompletionCondition>(completion_condition), device_(device), offset_(offset), streambuf_(streambuf), start_(0), total_transferred_(0), handler_(ASIO_MOVE_CAST(ReadHandler)(handler)) { } #if defined(ASIO_HAS_MOVE) read_at_streambuf_op(const read_at_streambuf_op& other) : detail::base_from_completion_cond<CompletionCondition>(other), device_(other.device_), offset_(other.offset_), streambuf_(other.streambuf_), start_(other.start_), total_transferred_(other.total_transferred_), handler_(other.handler_) { } read_at_streambuf_op(read_at_streambuf_op&& other) : detail::base_from_completion_cond<CompletionCondition>(other), device_(other.device_), offset_(other.offset_), streambuf_(other.streambuf_), start_(other.start_), total_transferred_(other.total_transferred_), handler_(ASIO_MOVE_CAST(ReadHandler)(other.handler_)) { } #endif // defined(ASIO_HAS_MOVE) void operator()(const asio::error_code& ec, std::size_t bytes_transferred, int start = 0) { std::size_t max_size, bytes_available; switch (start_ = start) { case 1: max_size = this->check_for_completion(ec, total_transferred_); bytes_available = read_size_helper(streambuf_, max_size); for (;;) { device_.async_read_some_at(offset_ + total_transferred_, streambuf_.prepare(bytes_available), ASIO_MOVE_CAST(read_at_streambuf_op)(*this)); return; default: total_transferred_ += bytes_transferred; streambuf_.commit(bytes_transferred); max_size = this->check_for_completion(ec, total_transferred_); bytes_available = read_size_helper(streambuf_, max_size); if ((!ec && bytes_transferred == 0) || bytes_available == 0) break; } handler_(ec, static_cast<const std::size_t&>(total_transferred_)); } } //private: AsyncRandomAccessReadDevice& device_; uint64_t offset_; asio::basic_streambuf<Allocator>& streambuf_; int start_; std::size_t total_transferred_; ReadHandler handler_; }; template <typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler> inline void* asio_handler_allocate(std::size_t size, read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, CompletionCondition, ReadHandler>* this_handler) { return asio_handler_alloc_helpers::allocate( size, this_handler->handler_); } template <typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler> inline void asio_handler_deallocate(void* pointer, std::size_t size, read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, CompletionCondition, ReadHandler>* this_handler) { asio_handler_alloc_helpers::deallocate( pointer, size, this_handler->handler_); } template <typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler> inline bool asio_handler_is_continuation( read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, CompletionCondition, ReadHandler>* this_handler) { return this_handler->start_ == 0 ? true : asio_handler_cont_helpers::is_continuation( this_handler->handler_); } template <typename Function, typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler> inline void asio_handler_invoke(Function& function, read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, CompletionCondition, ReadHandler>* this_handler) { asio_handler_invoke_helpers::invoke( function, this_handler->handler_); } template <typename Function, typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler> inline void asio_handler_invoke(const Function& function, read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, CompletionCondition, ReadHandler>* this_handler) { asio_handler_invoke_helpers::invoke( function, this_handler->handler_); } } // namespace detail #if !defined(GENERATING_DOCUMENTATION) template <typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler, typename Allocator1> struct associated_allocator< detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, CompletionCondition, ReadHandler>, Allocator1> { typedef typename associated_allocator<ReadHandler, Allocator1>::type type; static type get( const detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, CompletionCondition, ReadHandler>& h, const Allocator1& a = Allocator1()) ASIO_NOEXCEPT { return associated_allocator<ReadHandler, Allocator1>::get(h.handler_, a); } }; template <typename AsyncRandomAccessReadDevice, typename Executor, typename CompletionCondition, typename ReadHandler, typename Executor1> struct associated_executor< detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Executor, CompletionCondition, ReadHandler>, Executor1> { typedef typename associated_executor<ReadHandler, Executor1>::type type; static type get( const detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Executor, CompletionCondition, ReadHandler>& h, const Executor1& ex = Executor1()) ASIO_NOEXCEPT { return associated_executor<ReadHandler, Executor1>::get(h.handler_, ex); } }; #endif // !defined(GENERATING_DOCUMENTATION) template <typename AsyncRandomAccessReadDevice, typename Allocator, typename CompletionCondition, typename ReadHandler> inline ASIO_INITFN_RESULT_TYPE(ReadHandler, void (asio::error_code, std::size_t)) async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset, asio::basic_streambuf<Allocator>& b, CompletionCondition completion_condition, ASIO_MOVE_ARG(ReadHandler) handler) { // If you get an error on the following line it means that your handler does // not meet the documented type requirements for a ReadHandler. ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; async_completion<ReadHandler, void (asio::error_code, std::size_t)> init(handler); detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, CompletionCondition, ASIO_HANDLER_TYPE(ReadHandler, void (asio::error_code, std::size_t))>( d, offset, b, completion_condition, init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); } template <typename AsyncRandomAccessReadDevice, typename Allocator, typename ReadHandler> inline ASIO_INITFN_RESULT_TYPE(ReadHandler, void (asio::error_code, std::size_t)) async_read_at(AsyncRandomAccessReadDevice& d, uint64_t offset, asio::basic_streambuf<Allocator>& b, ASIO_MOVE_ARG(ReadHandler) handler) { // If you get an error on the following line it means that your handler does // not meet the documented type requirements for a ReadHandler. ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check; async_completion<ReadHandler, void (asio::error_code, std::size_t)> init(handler); detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator, detail::transfer_all_t, ASIO_HANDLER_TYPE(ReadHandler, void (asio::error_code, std::size_t))>( d, offset, b, transfer_all(), init.completion_handler)( asio::error_code(), 0, 1); return init.result.get(); } #endif // !defined(ASIO_NO_IOSTREAM) #endif // !defined(ASIO_NO_EXTENSIONS) } // namespace asio #include "asio/detail/pop_options.hpp" #endif // ASIO_IMPL_READ_AT_HPP
{ "pile_set_name": "Github" }
<?php namespace App\Admin\ElectedRepresentative; use App\Address\Address; use App\ElectedRepresentative\ElectedRepresentativeEvent; use App\ElectedRepresentative\ElectedRepresentativeEvents; use App\ElectedRepresentative\ElectedRepresentativeMandatesOrderer; use App\ElectedRepresentative\UserListDefinitionHistoryManager; use App\Election\VoteListNuanceEnum; use App\Entity\ElectedRepresentative\ElectedRepresentative; use App\Entity\ElectedRepresentative\LabelNameEnum; use App\Entity\ElectedRepresentative\MandateTypeEnum; use App\Entity\ElectedRepresentative\PoliticalFunctionNameEnum; use App\Entity\ElectedRepresentative\Zone; use App\Entity\ElectedRepresentative\ZoneCategory; use App\Entity\UserListDefinition; use App\Entity\UserListDefinitionEnum; use App\Form\AdherentEmailType; use App\Form\ElectedRepresentative\SponsorshipType; use App\Form\GenderType; use App\ValueObject\Genders; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query\Expr; use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType; use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Datagrid\DatagridMapper; use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Form\FormMapper; use Sonata\AdminBundle\Form\Type\ModelAutocompleteType; use Sonata\AdminBundle\Route\RouteCollection; use Sonata\AdminBundle\Show\ShowMapper; use Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery; use Sonata\DoctrineORMAdminBundle\Filter\CallbackFilter; use Sonata\DoctrineORMAdminBundle\Filter\ModelAutocompleteFilter; use Sonata\Form\Type\BooleanType; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; class ElectedRepresentativeAdmin extends AbstractAdmin { protected $datagridValues = [ '_page' => 1, '_per_page' => 32, '_sort_order' => 'DESC', '_sort_by' => 'id', ]; private $dispatcher; private $userListDefinitionHistoryManager; /** * @var UserListDefinition[]|array */ private $userListDefinitionsBeforeUpdate; public function __construct( $code, $class, $baseControllerName, EventDispatcherInterface $dispatcher, UserListDefinitionHistoryManager $userListDefinitionHistoryManager ) { parent::__construct($code, $class, $baseControllerName); $this->dispatcher = $dispatcher; $this->userListDefinitionHistoryManager = $userListDefinitionHistoryManager; } protected function configureRoutes(RouteCollection $collection) { $collection ->remove('show') ->remove('create') ->remove('delete') ; } public function createQuery($context = 'list') { $query = parent::createQuery(); $alias = $query->getRootAlias(); $query ->leftJoin("$alias.mandates", 'mandate') ->leftJoin("$alias.politicalFunctions", 'politicalFunction') ->leftJoin("$alias.labels", 'label') ; return $query; } protected function configureListFields(ListMapper $listMapper) { $listMapper ->add('lastName', null, [ 'label' => 'Nom', ]) ->add('firstName', null, [ 'label' => 'Prénom', ]) ->add('currentMandates', null, [ 'label' => 'Mandats actuels (nuance politique)', 'template' => 'admin/elected_representative/list_mandates.html.twig', ]) ->add('currentZones', null, [ 'label' => 'Périmètre(s) géographique(s)', 'template' => 'admin/elected_representative/list_zones.html.twig', ]) ->add('currentPoliticalFunctions', null, [ 'label' => 'Fonctions actuelles', 'template' => 'admin/elected_representative/list_political_functions.html.twig', ]) ->add('type', null, [ 'label' => 'Qualifications', 'template' => 'admin/elected_representative/list_type.html.twig', ]) ->add('_action', null, [ 'virtual_field' => true, 'template' => 'admin/elected_representative/list_actions.html.twig', ]) ; } protected function configureShowFields(ShowMapper $showMapper) { $showMapper ->with('Identité', ['class' => 'col-md-6']) ->add('lastName', null, [ 'label' => 'Nom', ]) ->add('firstName', null, [ 'label' => 'Prénom', ]) ->add('gender', null, [ 'label' => 'Genre', ]) ->add('emailAddress', EmailType::class, [ 'mapped' => false, 'label' => 'Adresse e-mail de l\'adhérent', 'template' => 'admin/elected_representative/show_email.html.twig', ]) ->add('contactEmail', null, [ 'label' => 'Autre e-mail de contact', ]) ->add('phone', null, [ 'mapped' => false, 'label' => 'Téléphone', 'template' => 'admin/elected_representative/show_phone.html.twig', ]) ->add('contactPhone', null, [ 'label' => 'Autre téléphone de contact', 'template' => 'admin/elected_representative/show_contact_phone.html.twig', ]) ->add('birthDate', null, [ 'label' => 'Date de naissance', ]) ->add('birthPlace', null, [ 'label' => 'Lieu de naissance', ]) ->add('hasFollowedTraining', null, [ 'label' => 'Formation Tous Politiques !', ]) ->end() ; } protected function configureFormFields(FormMapper $formMapper) { $formMapper ->with('Identité', ['class' => 'col-md-6']) ->add('gender', GenderType::class, [ 'label' => 'Genre', 'placeholder' => 'common.gender.unknown', 'required' => false, 'choices' => [ 'common.gender.woman' => Genders::FEMALE, 'common.gender.man' => Genders::MALE, ], ]) ->add('lastName', null, [ 'label' => 'Nom', ]) ->add('firstName', null, [ 'label' => 'Prénom', ]) ->add('adherent', AdherentEmailType::class, [ 'required' => false, 'label' => 'Adresse e-mail', 'help' => 'Attention, changer l\'e-mail ici fera que l\'élu sera associé à un autre compte adhérent.' .' Si vous souhaitez ajouter un autre mail de contact, faites-le ci-dessous.', ]) ->add('contactEmail', null, [ 'label' => 'Autre e-mail de contact', 'required' => false, ]) ->add('contactPhone', PhoneNumberType::class, [ 'required' => false, 'label' => 'Autre téléphone de contact', 'widget' => PhoneNumberType::WIDGET_COUNTRY_CHOICE, 'default_region' => Address::FRANCE, 'preferred_country_choices' => [Address::FRANCE], 'attr' => ['class' => 'phone'], ]) ->add('birthDate', 'sonata_type_date_picker', [ 'label' => 'Date de naissance', ]) ->add('birthPlace', null, [ 'required' => false, 'label' => 'Lieu de naissance', ]) ->add('userListDefinitions', null, [ 'label' => 'Labels', 'query_builder' => function (EntityRepository $er) { return $er ->createQueryBuilder('uld') ->andWhere('uld.type IN (:type)') ->setParameter('type', [ UserListDefinitionEnum::TYPE_ELECTED_REPRESENTATIVE, UserListDefinitionEnum::TYPE_LRE, ]) ->orderBy('uld.label', 'ASC') ; }, ]) ->add('hasFollowedTraining', null, [ 'label' => 'Formation Tous Politiques !', ]) ->end() ->with( 'Réseaux sociaux', [ 'class' => 'col-md-6', ] ) ->add('socialNetworkLinks', 'sonata_type_collection', [ 'by_reference' => false, 'label' => false, ], [ 'edit' => 'inline', 'inline' => 'table', 'admin_code' => 'app.admin.elected_representative.social_network_link', ]) ->end() ->with( 'Étiquettes', [ 'class' => 'col-md-6', ] ) ->add('labels', 'sonata_type_collection', [ 'by_reference' => false, 'label' => false, ], [ 'edit' => 'inline', 'inline' => 'table', 'admin_code' => 'app.admin.elected_representative.label', ]) ->end() ->with( 'Parrainages', [ 'class' => 'col-md-6', ] ) ->add('sponsorships', CollectionType::class, [ 'entry_type' => SponsorshipType::class, 'label' => false, 'by_reference' => false, ]) ->end() ->with('Mandats') ->add('mandates', 'sonata_type_collection', [ 'by_reference' => false, 'label' => false, ], [ 'edit' => 'inline', 'inline' => 'table', 'admin_code' => 'app.admin.elected_representative.mandate', ]) ->end() ->with('Fonctions') ->add('politicalFunctions', 'sonata_type_collection', [ 'by_reference' => false, 'label' => false, ], [ 'edit' => 'inline', 'inline' => 'table', 'admin_code' => 'app.admin.elected_representative.political_function', ]) ->end() ; $formMapper->getFormBuilder()->addEventListener(FormEvents::SUBMIT, [$this, 'submit']); } public function submit(FormEvent $event): void { /** @var ElectedRepresentative $electedRepresentative */ $electedRepresentative = $event->getData(); // change mandates order if (!$electedRepresentative->getMandates()->isEmpty()) { ElectedRepresentativeMandatesOrderer::updateOrder($electedRepresentative->getMandates()); } } protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper ->add('lastName', null, [ 'label' => 'Nom', 'show_filter' => true, ]) ->add('firstName', null, [ 'label' => 'Prénom', 'show_filter' => true, ]) ->add('mandatesType', CallbackFilter::class, [ 'label' => 'Mandats', 'show_filter' => true, 'field_type' => ChoiceType::class, 'field_options' => [ 'choices' => MandateTypeEnum::CHOICES, 'multiple' => true, ], 'callback' => function (ProxyQuery $qb, string $alias, string $field, array $value) { if (!$value['value']) { return false; } $where = new Expr\Orx(); foreach ($value['value'] as $mandate) { $where->add("mandate.type = :mandate_$mandate"); $qb->setParameter("mandate_$mandate", $mandate); } $qb->andWhere($where); return true; }, ]) ->add('mandatesOnGoing', CallbackFilter::class, [ 'label' => 'Mandat en cours ?', 'show_filter' => true, 'field_type' => BooleanType::class, 'callback' => function (ProxyQuery $qb, string $alias, string $field, array $value) { if (!$value['value']) { return false; } switch ($value['value']) { case BooleanType::TYPE_YES: $qb->andWhere('mandate.onGoing = 1'); break; case BooleanType::TYPE_NO: $qb->andWhere('mandate.onGoing = 0'); break; } return true; }, ]) ->add('politicalFunctionsName', CallbackFilter::class, [ 'label' => 'Fonctions', 'show_filter' => true, 'field_type' => ChoiceType::class, 'field_options' => [ 'choices' => PoliticalFunctionNameEnum::CHOICES, 'multiple' => true, ], 'callback' => function (ProxyQuery $qb, string $alias, string $field, array $value) { if (!$value['value']) { return false; } $where = new Expr\Orx(); foreach ($value['value'] as $politicalFunctions) { $where->add("politicalFunction.name = :function_$politicalFunctions"); $qb->setParameter("function_$politicalFunctions", $politicalFunctions); } $qb->andWhere($where); return true; }, ]) ->add('politicalFunctionsOnGoing', CallbackFilter::class, [ 'label' => 'Fonction en cours ?', 'show_filter' => true, 'field_type' => BooleanType::class, 'callback' => function (ProxyQuery $qb, string $alias, string $field, array $value) { if (!$value['value']) { return false; } switch ($value['value']) { case BooleanType::TYPE_YES: $qb->andWhere('politicalFunction.onGoing = 1'); break; case BooleanType::TYPE_NO: $qb->andWhere('politicalFunction.onGoing = 0'); break; } return true; }, ]) ->add('mandates.politicalAffiliation', CallbackFilter::class, [ 'label' => 'Nuance politique', 'show_filter' => true, 'field_type' => ChoiceType::class, 'field_options' => [ 'choices' => VoteListNuanceEnum::toArray(), 'multiple' => true, ], 'callback' => function (ProxyQuery $qb, string $alias, string $field, array $value) { if (!$value['value']) { return false; } $where = new Expr\Orx(); foreach ($value['value'] as $politicalAffiliation) { $where->add("$alias.politicalAffiliation = :pa_".$politicalAffiliation); $qb->setParameter('pa_'.$politicalAffiliation, $politicalAffiliation); } $qb->andWhere($where); $qb->andWhere("$alias.onGoing = 1"); return true; }, ]) ->add('mandates.zone', CallbackFilter::class, [ 'label' => 'Périmètres géographiques', 'show_filter' => true, 'field_type' => ModelAutocompleteType::class, 'field_options' => [ 'model_manager' => $this->getModelManager(), 'admin_code' => $this->getCode(), 'context' => 'filter', 'class' => Zone::class, 'multiple' => true, 'property' => 'name', 'minimum_input_length' => 1, 'items_per_page' => 20, 'callback' => function ($admin, $property, $value) { $datagrid = $admin->getDatagrid(); $queryBuilder = $datagrid->getQuery(); $queryBuilder ->leftJoin($queryBuilder->getRootAlias().'.category', 'category') ->andWhere('category.name != :district') ->setParameter('district', ZoneCategory::DISTRICT) ->orderBy($queryBuilder->getRootAlias().'.name', 'ASC') ; $datagrid->setValue($property, null, $value); }, ], 'callback' => function (ProxyQuery $qb, string $alias, string $field, array $value) { if (!$value['value']) { return false; } $where = new Expr\Orx(); if (!\in_array('zone', $qb->getAllAliases(), true)) { $qb->leftJoin("$alias.$field", 'zone'); } /** @var Zone $zone */ foreach ($value['value'] as $key => $zone) { switch ($zone->getCategory()->getName()) { case ZoneCategory::REGION: if (!\in_array('referentTag', $qb->getAllAliases())) { $qb->leftJoin('zone.referentTags', 'referentTag'); } $where->add('referentTag IN (:tags)'); $qb->setParameter('tags', $zone->getReferentTags()); break; case ZoneCategory::DEPARTMENT: if (!\in_array('category', $qb->getAllAliases(), true)) { $qb->leftJoin('zone.category', 'category'); } if (!\in_array('referentTag', $qb->getAllAliases(), true)) { $qb->leftJoin('zone.referentTags', 'referentTag'); } $where->add('(referentTag IN (:tags) AND category.name != :category_name)'); $qb ->setParameter('tags', $zone->getReferentTags()) ->setParameter('category_name', ZoneCategory::REGION) ; break; default: $where->add("$alias.$field = :zone_$key"); $qb->setParameter("zone_$key", $zone); } } $qb->andWhere($where); return true; }, ]) ->add('isAdherent', CallbackFilter::class, [ 'label' => 'Est adhérent ?', 'show_filter' => true, 'field_type' => ChoiceType::class, 'field_options' => [ 'choices' => [ 'yes', 'no', ], 'choice_label' => function (string $choice) { return 'global.'.$choice; }, ], 'callback' => function (ProxyQuery $qb, string $alias, string $field, array $value) { switch ($value['value']) { case 'yes': $qb->andWhere("$alias.adherent IS NOT NULL"); return true; case 'no': $qb->andWhere("$alias.adherent IS NULL"); return true; default: return false; } }, ]) ->add('userListDefinitions', ModelAutocompleteFilter::class, [ 'label' => 'Labels', 'show_filter' => true, 'field_options' => [ 'minimum_input_length' => 0, 'items_per_page' => 20, 'multiple' => true, 'property' => 'label', 'callback' => function ($admin, $property, $value) { $datagrid = $admin->getDatagrid(); $qb = $datagrid->getQuery(); $alias = $qb->getRootAlias(); $qb ->andWhere($alias.'.type IN (:type)') ->setParameter('type', [ UserListDefinitionEnum::TYPE_ELECTED_REPRESENTATIVE, UserListDefinitionEnum::TYPE_LRE, ]) ->orderBy($alias.'.label', 'ASC') ; $datagrid->setValue($property, null, $value); }, ], ]) ->add('labelsName', CallbackFilter::class, [ 'label' => 'Étiquettes', 'show_filter' => true, 'field_type' => ChoiceType::class, 'field_options' => [ 'choices' => LabelNameEnum::ALL, 'multiple' => true, 'choice_label' => function (string $choice) { return $choice; }, ], 'callback' => function (ProxyQuery $qb, string $alias, string $field, array $value) { if (!$value['value']) { return false; } $qb->andWhere('label.name IN (:label_names)'); $qb->setParameter('label_names', $value['value']); return true; }, ]) ; } /** * @param ElectedRepresentative $subject */ public function setSubject($subject) { if (null === $this->userListDefinitionsBeforeUpdate) { $this->userListDefinitionsBeforeUpdate = $subject->getUserListDefinitions()->toArray(); $this->dispatcher->dispatch(ElectedRepresentativeEvents::BEFORE_UPDATE, new ElectedRepresentativeEvent($subject)); } parent::setSubject($subject); } /** * @param ElectedRepresentative $object */ public function preUpdate($object) { parent::preUpdate($object); $this->userListDefinitionHistoryManager->handleChanges($object, $this->userListDefinitionsBeforeUpdate); } /** * @param ElectedRepresentative $object */ public function postUpdate($object) { parent::postUpdate($object); $this->dispatcher->dispatch(ElectedRepresentativeEvents::POST_UPDATE, new ElectedRepresentativeEvent($object)); } public function getExportFields() { return [ 'Nom' => 'lastName', 'Prénom' => 'firstName', 'Mandats actuels (nuance politique)' => 'exportMandates', 'Fonctions actuelles' => 'exportPoliticalFunctions', 'Adhérent' => 'exportIsAdherent', ]; } public function getExportFormats() { return ['csv', 'xls']; } }
{ "pile_set_name": "Github" }
from bear1 import TestBear as ImportedTestBear __additional_bears__ = [ImportedTestBear]
{ "pile_set_name": "Github" }
# coding: utf-8 # Copyright (c) 2017-present, BigCommerce Pty. Ltd. All rights reserved # # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated # documentation files (the "Software"), to deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the # Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # require 'spec_helper' class TestLogging include Gruf::Logger end class TestGrpcLogging include Gruf::GrpcLogger end describe Gruf::Logger do let(:cls) { TestLogging.new } subject { cls.logger } it 'should add a logger method when included' do expect(subject).to eq Gruf.logger end end describe Gruf::GrpcLogger do let(:cls) { TestGrpcLogging.new } subject { cls.logger } it 'should add a logger method when included' do expect(subject).to eq Gruf.grpc_logger end end
{ "pile_set_name": "Github" }
<html> <head> <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> <title>Thebe activate button</title> <link rel="stylesheet" type="text/css" href="index.css" /> <link rel="stylesheet" type="text/css" href="status_button.css" /> <!-- Thebe configuration !--> <script type="text/x-thebe-config"> { binderOptions: { repo: "binder-examples/requirements" }, stripPrompts: { inPrompt: 'sage: ', continuationPrompt: '....: ', selector: '.sage-input', }, requestKernel: true } </script> <!-- Dependency: jquery !--> <script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script> <!-- Style sheet and javascript for the status field !--> <script src="thebe_status_field.js" type="text/javascript" ></script> <link href="thebe_status_field.css" rel="stylesheet" type="text/css"/> <script><!-- use window.onload to defer the execution until the page is loaded !--> window.onload = function () { thebe_place_activate_button(); }; </script> </head> <body> <h1>Support for activate button</h1> <p>This page illustrates the use of an activation button.</p> Status: <span class="thebe_status_field"></span> <p>This cell will turn into the live cell:</p> <pre class="sage-input" data-language="python"> sage: 1 + 1 2 sage: x = 3 sage: y = 4 sage: z = 5 sage: x + y + \ ....: z 12 </pre> </body> </html>
{ "pile_set_name": "Github" }
test_that("homr", { skip_on_cran() skip_on_ci() vcr::use_cassette("homr", { # qid a <- homr(qid = 'COOP:046742') # headersonly b <- homr(headersOnly=TRUE, qid='TRANS:') # qid with preceding colon d <- homr(qid = ':046742') # qidmod e <- homr(qidMod='starts', qid='COOP:0467') # state f <- homr(headersOnly=TRUE, state='DE') # state and county g <- homr(headersOnly=TRUE, state='NC', county='BUNCOMBE') # name h <- homr(name='CLAYTON') }) # class expect_is(a, "homr") expect_is(unclass(a), "list") expect_is(a$`20002078`, "list") expect_is(a$`20002078`$head, "data.frame") expect_is(a$`20002078`$platform, "character") expect_equal(a$`20002078`$platform, "COOP") expect_is(b, "homr") expect_is(d, "homr") expect_is(e, "homr") expect_is(f, "homr") expect_is(g, "homr") expect_is(h, "homr") # dimensions expect_equal(length(a), 1) expect_equal(length(a$`20002078`), 11) expect_gt(length(b), 10) expect_equal(NROW(d$`20002078`$head), 1) expect_gt(length(e), 1) expect_match(f$`20004167`$head$preferredName, "DE") })
{ "pile_set_name": "Github" }
/* Pojoaque Style by Jason Tate http://web-cms-designs.com/ftopict-10-pojoaque-style-for-highlight-js-code-highlighter.html Based on Solarized Style from http://ethanschoonover.com/solarized */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #dccf8f; background: url(./pojoaque.jpg) repeat scroll left top #181914; } .hljs-comment, .hljs-quote { color: #586e75; font-style: italic; } .hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-addition { color: #b64926; } .hljs-number, .hljs-string, .hljs-doctag, .hljs-regexp { color: #468966; } .hljs-title, .hljs-section, .hljs-built_in, .hljs-name { color: #ffb03b; } .hljs-variable, .hljs-template-variable, .hljs-class .hljs-title, .hljs-type, .hljs-tag { color: #b58900; } .hljs-attribute { color: #b89859; } .hljs-symbol, .hljs-bullet, .hljs-link, .hljs-subst, .hljs-meta { color: #cb4b16; } .hljs-deletion { color: #dc322f; } .hljs-selector-id, .hljs-selector-class { color: #d3a60c; } .hljs-formula { background: #073642; } .hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: bold; }
{ "pile_set_name": "Github" }
// // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // // Microsoft Cognitive Services (formerly Project Oxford): https://www.microsoft.com/cognitive-services // // Microsoft Cognitive Services (formerly Project Oxford) GitHub: // https://github.com/Microsoft/ProjectOxford-ClientSDK // // Copyright (c) Microsoft Corporation // All rights reserved. // // MIT License: // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace Microsoft.ProjectOxford.SpeakerRecognition.Contract { /// <summary> /// A class encapsulating a speaker enrollment for verification/identification /// </summary> public class EnrollmentBase { /// <summary> /// The enrollment status of the profile /// </summary> [JsonConverter(typeof(StringEnumConverter))] public EnrollmentStatus EnrollmentStatus { get; set; } } }
{ "pile_set_name": "Github" }
package com.haroldadmin.moonshotRepository import com.haroldadmin.cnradapter.NetworkResponse import com.haroldadmin.moonshot.core.Resource import com.haroldadmin.moonshot.core.last import io.kotlintest.matchers.types.shouldBeTypeOf import io.kotlintest.shouldBe import io.kotlintest.specs.DescribeSpec import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.collect import java.io.IOException private class Api { var fetchCount = 0 var fetchErrorCount = 0 fun get(): NetworkResponse.Success<Unit> { fetchCount++ return NetworkResponse.Success(Unit) } fun getErrorThenSuccess(): NetworkResponse<Unit, IOException> { return if (fetchErrorCount == 0) { fetchErrorCount++ fetchCount++ NetworkResponse.NetworkError(IOException()) } else { fetchCount++ NetworkResponse.Success(Unit) } } } @ExperimentalCoroutinesApi internal class SingleFetchNetworkBoundResourceTest : DescribeSpec({ describe("Single fetch behaviour") { context("Data has not been fetched yet") { val api = Api() val resource = singleFetchNetworkBoundFlow( dbFetcher = { _, _, _ -> Unit }, cacheValidator = { cached -> cached != null }, apiFetcher = { api.get() }, dataPersister = { Unit } ) it("Should fetch data from API when invoked") { resource.collect() api.fetchCount shouldBe 1 } it("Should not fetch data from API again when invoked again") { resource.collect() api.fetchCount shouldBe 1 } } context("Last network request resulted in error") { val api = Api() val resource = singleFetchNetworkBoundFlow( dbFetcher = { _, _, _ -> Unit }, cacheValidator = { cached -> cached != null }, apiFetcher = { api.getErrorThenSuccess() }, dataPersister = { Unit } ) it("Should fetch data from API when invoked") { val res = resource.last() api.fetchCount shouldBe 1 res.shouldBeTypeOf<Resource.Error<Unit, IOException>>() } it("Should fetch data again from API when invoked") { val res = resource.last() api.fetchCount shouldBe 2 res.shouldBeTypeOf<Resource.Success<Unit>>() } } } })
{ "pile_set_name": "Github" }
======== ``mptt`` ======== .. toctree:: :maxdepth: 1 mptt.admin mptt.exceptions mptt.fields mptt.forms mptt.managers mptt.models mptt.querysets mptt.utils .. automodule:: mptt :members: :undoc-members:
{ "pile_set_name": "Github" }
if (true) { var x: number = 5; } console.log(x); //5
{ "pile_set_name": "Github" }
/* * Copyright 2002-2016 jamod & j2mod development teams * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ghgande.j2mod.modbus.msg; import com.ghgande.j2mod.modbus.Modbus; import com.ghgande.j2mod.modbus.net.AbstractModbusListener; import java.io.DataInput; import java.io.DataOutput; import java.io.EOFException; import java.io.IOException; /** * Class implementing a <tt>Read MEI Data</tt> request. * * @author jfhaugh ([email protected]) * @author Steve O'Hara (4NG) * @version 2.0 (March 2016) */ public class ReadMEIRequest extends ModbusRequest { // instance attributes private int subCode; private int fieldLevel; private int fieldId; /** * Constructs a new <tt>Read MEI Data request</tt> instance. */ public ReadMEIRequest() { super(); setFunctionCode(Modbus.READ_MEI); subCode = 0x0E; // 3 bytes (unit id and function code is excluded) setDataLength(3); } /** * Constructs a new <tt>Read MEI Data request</tt> instance with a given * reference and count of coils (i.e. bits) to be read. * <p> * * @param level the reference number of the register to read from. * @param id the number of bits to be read. */ public ReadMEIRequest(int level, int id) { super(); setFunctionCode(Modbus.READ_MEI); subCode = 0x0E; // 3 bytes (unit id and function code is excluded) setDataLength(3); setLevel(level); setFieldId(id); } @Override public ModbusResponse getResponse() { // Any other sub-function is an error. if (getSubCode() != 0x0E) { IllegalFunctionExceptionResponse error = new IllegalFunctionExceptionResponse(); return updateResponseWithHeader(error); } return updateResponseWithHeader(new ReadMEIResponse()); } @Override public ModbusResponse createResponse(AbstractModbusListener listener) { return createExceptionResponse(Modbus.ILLEGAL_FUNCTION_EXCEPTION); } /** * Gets the MEI subcode associated with this request. * @return The MEI sub code */ public int getSubCode() { return subCode; } /** * Returns the reference of the register to to start reading from with this * <tt>ReadCoilsRequest</tt>. * <p> * * @return the reference of the register to start reading from as * <tt>int</tt>. */ public int getLevel() { return fieldLevel; } /** * Sets the reference of the register to start reading from with this * <tt>ReadCoilsRequest</tt>. * <p> * * @param level the reference of the register to start reading from. */ public void setLevel(int level) { fieldLevel = level; } /** * Returns the number of bits (i.e. coils) to be read with this * <tt>ReadCoilsRequest</tt>. * <p> * * @return the number of bits to be read. */ public int getFieldId() { return fieldId; } /** * Sets the number of bits (i.e. coils) to be read with this * <tt>ReadCoilsRequest</tt>. * <p> * * @param id the number of bits to be read. */ public void setFieldId(int id) { fieldId = id; } @Override public void writeData(DataOutput dout) throws IOException { byte[] results = new byte[3]; results[0] = (byte)subCode; results[1] = (byte)fieldLevel; results[2] = (byte)fieldId; dout.write(results); } @Override public void readData(DataInput din) throws IOException { subCode = din.readUnsignedByte(); if (subCode != 0xE) { try { while (din.readByte() >= 0) { // noop } } catch (EOFException x) { // do nothing. } return; } fieldLevel = din.readUnsignedByte(); fieldId = din.readUnsignedByte(); } @Override public byte[] getMessage() { byte[] results = new byte[3]; results[0] = (byte)subCode; results[1] = (byte)fieldLevel; results[2] = (byte)fieldId; return results; } }
{ "pile_set_name": "Github" }
// RUN: not llvm-tblgen -I %p %s 2>&1 | FileCheck %s // CHECK: error: Expected macro name after #ifdef #ifdef #else #else #endif
{ "pile_set_name": "Github" }
define("ace/snippets/razor",["require","exports","module"], function(require, exports, module) { "use strict"; exports.snippetText = "snippet if\n\ (${1} == ${2}) {\n\ ${3}\n\ }"; exports.scope = "razor"; });
{ "pile_set_name": "Github" }
# Doxyfile 1.5.5 #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = gms PROJECT_NUMBER = 0.1 OUTPUT_DIRECTORY = ./doc-doxygen/ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = YES STRIP_FROM_PATH = ./ STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO DETAILS_AT_TOP = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 4 ALIASES = OPTIMIZE_OUTPUT_FOR_C = YES OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO DISTRIBUTE_GROUP_DOC = NO SUBGROUPING = YES TYPEDEF_HIDES_STRUCT = NO #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = NO EXTRACT_PRIVATE = NO EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO SORT_GROUP_NAMES = NO SORT_BY_SCOPE_NAME = NO GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES SHOW_DIRECTORIES = NO FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = ../src INPUT_ENCODING = UTF-8 FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.d \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.idl \ *.odl \ *.cs \ *.php \ *.php3 \ *.inc \ *.m \ *.mm \ *.dox \ *.py \ *.f90 \ *.f \ *.vhd \ *.vhdl \ *.C \ *.CC \ *.C++ \ *.II \ *.I++ \ *.H \ *.HH \ *.H++ \ *.CS \ *.PHP \ *.PHP3 \ *.M \ *.MM \ *.PY \ *.F90 \ *.F \ *.VHD \ *.VHDL RECURSIVE = NO EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = EXAMPLE_PATH = EXAMPLE_PATTERNS = * EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = YES INLINE_SOURCES = YES STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = NO REFERENCES_RELATION = NO REFERENCES_LINK_SOURCE = YES USE_HTAGS = NO VERBATIM_HEADERS = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = NO COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" DOCSET_BUNDLE_ID = org.doxygen.Project HTML_DYNAMIC_SECTIONS = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO BINARY_TOC = NO TOC_EXPAND = NO DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = YES USE_PDFLATEX = YES LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml XML_SCHEMA = XML_DTD = XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = NO MSCGEN_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = YES CLASS_GRAPH = YES COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES UML_LOOK = NO TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES CALL_GRAPH = YES CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 1000 DOT_TRANSPARENT = YES DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = NO
{ "pile_set_name": "Github" }
<?php /** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * @category Zend * @package Zend_Config * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ */ /** * @see Zend_Config */ //require_once 'Zend/Config.php'; /** * @see Zend_Json */ //require_once 'Zend/Json.php'; /** * JSON Adapter for Zend_Config * * @category Zend * @package Zend_Config * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Config_Json extends Zend_Config { /** * Name of object key indicating section current section extends */ const EXTENDS_NAME = "_extends"; /** * Whether or not to ignore constants in the JSON string * * Note: if you do not have constant names in quotations in your JSON * string, they may lead to syntax errors when parsing. * * @var bool */ protected $_ignoreConstants = false; /** * Whether to skip extends or not * * @var boolean */ protected $_skipExtends = false; /** * Loads the section $section from the config file encoded as JSON * * Sections are defined as properties of the main object * * In order to extend another section, a section defines the "_extends" * property having a value of the section name from which the extending * section inherits values. * * Note that the keys in $section will override any keys of the same * name in the sections that have been included via "_extends". * * @param string $json JSON file or string to process * @param mixed $section Section to process * @param boolean $options Whether modifiacations are allowed at runtime * @throws Zend_Config_Exception When JSON text is not set or cannot be loaded * @throws Zend_Config_Exception When section $sectionName cannot be found in $json */ public function __construct($json, $section = null, $options = false) { if (empty($json)) { //require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception('Filename is not set'); } $allowModifications = false; if (is_bool($options)) { $allowModifications = $options; } elseif (is_array($options)) { foreach ($options as $key => $value) { switch (strtolower($key)) { case 'allow_modifications': case 'allowmodifications': $allowModifications = (bool) $value; break; case 'skip_extends': case 'skipextends': $this->_skipExtends = (bool) $value; break; case 'ignore_constants': case 'ignoreconstants': $this->_ignoreConstants = (bool) $value; break; default: break; } } } set_error_handler(array($this, '_loadFileErrorHandler')); // Warnings and errors are suppressed if ($json[0] != '{') { $json = file_get_contents($json); } restore_error_handler(); // Check if there was a error while loading file if ($this->_loadFileErrorStr !== null) { //require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception($this->_loadFileErrorStr); } // Replace constants if (!$this->_ignoreConstants) { $json = $this->_replaceConstants($json); } // Parse/decode try { $config = Zend_Json::decode($json); } catch (Zend_Json_Exception $e) { // decode failed //require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception("Error parsing JSON data"); } if ($section === null) { $dataArray = array(); foreach ($config as $sectionName => $sectionData) { $dataArray[$sectionName] = $this->_processExtends($config, $sectionName); } parent::__construct($dataArray, $allowModifications); } elseif (is_array($section)) { $dataArray = array(); foreach ($section as $sectionName) { if (!isset($config[$sectionName])) { //require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $sectionName)); } $dataArray = array_merge($this->_processExtends($config, $sectionName), $dataArray); } parent::__construct($dataArray, $allowModifications); } else { if (!isset($config[$section])) { //require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $section)); } $dataArray = $this->_processExtends($config, $section); if (!is_array($dataArray)) { // Section in the JSON data contains just one top level string $dataArray = array($section => $dataArray); } parent::__construct($dataArray, $allowModifications); } $this->_loadedSection = $section; } /** * Helper function to process each element in the section and handle * the "_extends" inheritance attribute. * * @param array $data Data array to process * @param string $section Section to process * @param array $config Configuration which was parsed yet * @throws Zend_Config_Exception When $section cannot be found * @return array */ protected function _processExtends(array $data, $section, array $config = array()) { if (!isset($data[$section])) { //require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception(sprintf('Section "%s" cannot be found', $section)); } $thisSection = $data[$section]; if (is_array($thisSection) && isset($thisSection[self::EXTENDS_NAME])) { if (is_array($thisSection[self::EXTENDS_NAME])) { //require_once 'Zend/Config/Exception.php'; throw new Zend_Config_Exception('Invalid extends clause: must be a string; array received'); } $this->_assertValidExtend($section, $thisSection[self::EXTENDS_NAME]); if (!$this->_skipExtends) { $config = $this->_processExtends($data, $thisSection[self::EXTENDS_NAME], $config); } unset($thisSection[self::EXTENDS_NAME]); } $config = $this->_arrayMergeRecursive($config, $thisSection); return $config; } /** * Replace any constants referenced in a string with their values * * @param string $value * @return string */ protected function _replaceConstants($value) { foreach ($this->_getConstants() as $constant) { if (strstr($value, $constant)) { // handle backslashes that may represent windows path names for instance $replacement = str_replace('\\', '\\\\', constant($constant)); $value = str_replace($constant, $replacement, $value); } } return $value; } /** * Get (reverse) sorted list of defined constant names * * @return array */ protected function _getConstants() { $constants = array_keys(get_defined_constants()); rsort($constants, SORT_STRING); return $constants; } }
{ "pile_set_name": "Github" }
// Copyright 2009 the Sputnik authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /** * @name: S15.4.4.13_A1_T1; * @section: 15.4.4.13; * @assertion: The arguments are prepended to the start of the array, such that * their order within the array is the same as the order in which they appear in * the argument list; * @description: Checking case when unsift is given no arguments or one argument; */ //CHECK#1 x = new Array(); var unshift = x.unshift(1); if (unshift !== 1) { $ERROR('#1: x = new Array(); x.unshift(1) === 1. Actual: ' + (unshift)); } //CHECK#2 if (x[0] !== 1) { $ERROR('#2: x = new Array(); x.unshift(1); x[0] === 1. Actual: ' + (x[0])); } //CHECK#3 var unshift = x.unshift(); if (unshift !== 1) { $ERROR('#3: x = new Array(); x.unshift(1); x.unshift() === 1. Actual: ' + (unshift)); } //CHECK#4 if (x[1] !== undefined) { $ERROR('#4: x = new Array(); x.unshift(1); x.unshift(); x[1] === unedfined. Actual: ' + (x[1])); } //CHECK#5 var unshift = x.unshift(-1); if (unshift !== 2) { $ERROR('#5: x = new Array(); x.unshift(1); x.unshift(); x.unshift(-1) === 2. Actual: ' + (unshift)); } //CHECK#6 if (x[0] !== -1) { $ERROR('#6: x = new Array(); x.unshift(1); x.unshift(-1); x[0] === -1. Actual: ' + (x[0])); } //CHECK#7 if (x[1] !== 1) { $ERROR('#7: x = new Array(); x.unshift(1); x.unshift(-1); x[1] === 1. Actual: ' + (x[1])); } //CHECK#8 if (x.length !== 2) { $ERROR('#8: x = new Array(); x.unshift(1); x.unshift(); x.unshift(-1); x.length === 2. Actual: ' + (x.length)); }
{ "pile_set_name": "Github" }