hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 98
values | lang stringclasses 21
values | max_stars_repo_path stringlengths 3 945 | max_stars_repo_name stringlengths 4 118 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses listlengths 1 10 | max_stars_count int64 1 368k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 3 945 | max_issues_repo_name stringlengths 4 118 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 10 | max_issues_count int64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 945 | max_forks_repo_name stringlengths 4 135 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 10 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1 1.03M | max_line_length int64 2 1.03M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
985df7f1fc4f75ed241e72afab428e39cfff3fcc | 2,433 | swift | Swift | HackerNews/Common/Extensions/Date+.swift | nik3212/HackerNews | 42c88898397506b51f2b43f9ad9dca32e2334078 | [
"MIT"
] | 15 | 2019-11-17T06:59:14.000Z | 2022-01-06T05:40:58.000Z | HackerNews/Common/Extensions/Date+.swift | nik3212/HackerNews | 42c88898397506b51f2b43f9ad9dca32e2334078 | [
"MIT"
] | null | null | null | HackerNews/Common/Extensions/Date+.swift | nik3212/HackerNews | 42c88898397506b51f2b43f9ad9dca32e2334078 | [
"MIT"
] | 2 | 2020-07-21T12:26:27.000Z | 2020-08-27T12:41:39.000Z | //
// Date+.swift
// HackerNews
//
// Created by Никита Васильев on 29/09/2018.
// Copyright © 2018 Никита Васильев. All rights reserved.
//
import Foundation
extension Date {
// Returns the number of years
func yearsCount(from date: Date) -> Int {
return Calendar.current.dateComponents([.year], from: date, to: self).year ?? 0
}
// Returns the number of months
func monthsCount(from date: Date) -> Int {
return Calendar.current.dateComponents([.month], from: date, to: self).month ?? 0
}
// Returns the number of weeks
func weeksCount(from date: Date) -> Int {
return Calendar.current.dateComponents([.weekOfMonth], from: date, to: self).weekOfMonth ?? 0
}
// Returns the number of days
func daysCount(from date: Date) -> Int {
return Calendar.current.dateComponents([.day], from: date, to: self).day ?? 0
}
// Returns the number of hours
func hoursCount(from date: Date) -> Int {
return Calendar.current.dateComponents([.hour], from: date, to: self).hour ?? 0
}
// Returns the number of minutes
func minutesCount(from date: Date) -> Int {
return Calendar.current.dateComponents([.minute], from: date, to: self).minute ?? 0
}
// Returns the number of seconds
func secondsCount(from date: Date) -> Int {
return Calendar.current.dateComponents([.second], from: date, to: self).second ?? 0
}
// Returns time ago by checking if the time differences between two dates are in year or months or weeks or days or hours or minutes or seconds
func timeAgo(from date: Date) -> String {
if yearsCount(from: date) > 0 { return "\(yearsCount(from: date)) years ago" }
if monthsCount(from: date) > 0 { return "\(monthsCount(from: date)) months ago" }
if weeksCount(from: date) > 0 { return "\(weeksCount(from: date)) weeks ago" }
if daysCount(from: date) > 0 { return "\(daysCount(from: date)) days ago" }
if hoursCount(from: date) > 0 { return "\(hoursCount(from: date)) hrs ago" }
if minutesCount(from: date) > 0 { return "\(minutesCount(from: date)) min ago" }
if secondsCount(from: date) > 0 { return "\(secondsCount(from: date)) sec ago" }
return ""
}
func timeAgo(from seconds: Int) -> String {
let date = Date(timeIntervalSince1970: TimeInterval(seconds))
return timeAgo(from: date)
}
}
| 41.948276 | 147 | 0.637074 |
fd838938120e6420a6fd8338cb9eba4ccac36ebf | 2,687 | h | C | sourcecode/iOS-Blocks/headers/SpringBoard/SpringBoard.h | nickkgar/Nepeta-Mirror | fee9095771a9754982a560d3e3fd86bf94a8da5d | [
"MIT"
] | 1 | 2020-04-05T07:00:22.000Z | 2020-04-05T07:00:22.000Z | sourcecode/iOS-Blocks/headers/SpringBoard/SpringBoard.h | nickkgar/Nepeta-Mirror | fee9095771a9754982a560d3e3fd86bf94a8da5d | [
"MIT"
] | 7 | 2020-09-08T01:12:27.000Z | 2022-02-27T02:26:35.000Z | sourcecode/iOS-Blocks/headers/SpringBoard/SpringBoard.h | digic3ll/Nepeta-Mirror | 903a8134f649f180c944b82df9b7509fb3fcf0e3 | [
"MIT"
] | null | null | null | #import "_UISettingsKeyObserver-Protocol.h"
#import "SBApplication.h"
#import "SBApplicationController.h"
#import "SBApplicationIcon.h"
#import "SBApplicationRestrictionDataSource-Protocol.h"
#import "SBApplicationRestrictionObserver-Protocol.h"
#import "SBDarkeningImageViewDelegate-Protocol.h"
#import "SBDisplayProtocol-Protocol.h"
#import "SBDockIconListView.h"
#import "SBFolder.h"
#import "SBFolderController.h"
#import "SBFolderControllerDelegate-Protocol.h"
#import "SBFolderIcon.h"
#import "SBFolderObserver-Protocol.h"
#import "SBFolderView.h"
#import "SBFolderViewDelegate-Protocol.h"
#import "SBIcon.h"
#import "SBIconAccessoryView-Protocol.h"
#import "SBIconBadgeView.h"
#import "SBIconContentView.h"
#import "SBIconController.h"
#import "SBIconImageCrossfadeView.h"
#import "SBIconImageView.h"
#import "SBIconIndexMutableList.h"
#import "SBIconIndexMutableListObserver-Protocol.h"
#import "SBIconIndexNode-Protocol.h"
#import "SBIconIndexNodeObserver-Protocol.h"
#import "SBIconListLayoutDelegate-Protocol.h"
#import "SBIconListModel.h"
#import "SBIconListModelObserver-Protocol.h"
#import "SBIconListPageControlDelegate-Protocol.h"
#import "SBIconListView.h"
#import "SBIconModel.h"
#import "SBIconModelApplicationDataSource-Protocol.h"
#import "SBIconModelDelegate-Protocol.h"
#import "SBIconModelStore-Protocol.h"
#import "SBIconObserver-Protocol.h"
#import "SBIconProgressViewDelegate-Protocol.h"
#import "SBIconScrollView.h"
#import "SBIconScrollViewDelegate-Protocol.h"
#import "SBIconView.h"
#import "SBIconViewDelegate-Protocol.h"
#import "SBIconViewMap.h"
#import "SBIconViewMapDelegate-Protocol.h"
#import "SBIconViewObserver-Protocol.h"
#import "SBInteractionPassThroughView.h"
#import "SBLeafIcon.h"
#import "SBLeafIconDataSource-Protocol.h"
#import "SBLSApplicationLifecycleObserver-Protocol.h"
#import "SBMediaController.h"
#import "SBPlaceholderIcon.h"
#import "SBRootFolder.h"
#import "SBRootFolderController.h"
#import "SBRootFolderView.h"
#import "SBRootIconListView.h"
#import "SBScreenObserver-Protocol.h"
#import "SBSearchGestureObserver-Protocol.h"
#import "SBSystemLocalNotificationAlertDelegate-Protocol.h"
#import "SBUIBiometricEventMonitor.h"
#import "SBUIBiometricEventMonitorDelegate-Protocol.h"
#import "SBUIPasscodeLockViewBase.h"
#import "SBUIPasscodeLockViewDelegate-Protocol.h"
#import "SBUIPasscodeLockViewFactory.h"
#import "SBWindowContextHostManagerDelegate-Protocol.h"
#import "SBWindowContextManagerDelegate-Protocol.h"
#import "_SBUIBiometricKitInterface.h"
#import "SpringBoard-Structs.h"
#import <SpringBoard/SpringBoard.h>
#import "SBMediaController.h"
@interface SpringBoard (Private)
-(dispatch_queue_t)bulletinBoardQueue;
@end | 36.808219 | 59 | 0.828061 |
26bbe1409238c4e6954511469f485a0bc6ca3e08 | 529 | java | Java | organisations/src/main/java/org/restful/test/instances/repository/PositionRepository.java | tsu-cources/rest-api-test-instances | 95625215acc89c89b1b2bf1b9b3dac38a7129857 | [
"MIT"
] | null | null | null | organisations/src/main/java/org/restful/test/instances/repository/PositionRepository.java | tsu-cources/rest-api-test-instances | 95625215acc89c89b1b2bf1b9b3dac38a7129857 | [
"MIT"
] | 1 | 2022-01-21T23:44:37.000Z | 2022-01-21T23:44:37.000Z | organisations/src/main/java/org/restful/test/instances/repository/PositionRepository.java | innopolis-university-java-team/restful-test-instances | 0379a62da803f94d688db087852b7a085b5595fb | [
"MIT"
] | null | null | null | package org.restful.test.instances.repository;
import org.restful.test.instances.model.entity.Employ;
import org.restful.test.instances.model.entity.Position;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @project restful-test-instances
* @created 03.04.2021 10:19
* <p>
* @author Alexander A. Kropotin
*/
public interface PositionRepository extends JpaRepository<Position, Long>,
JpaSpecificationExecutor<Position> {
} | 33.0625 | 74 | 0.795841 |
aea20084fe98ed0cbc86af647d89dc9815c0ebc1 | 459 | swift | Swift | Sources/Fluent/Schema/Creator.swift | cardoso/fluent | 82b6a8644387babbbecbc7fcd70971770d3c1bdc | [
"MIT"
] | null | null | null | Sources/Fluent/Schema/Creator.swift | cardoso/fluent | 82b6a8644387babbbecbc7fcd70971770d3c1bdc | [
"MIT"
] | null | null | null | Sources/Fluent/Schema/Creator.swift | cardoso/fluent | 82b6a8644387babbbecbc7fcd70971770d3c1bdc | [
"MIT"
] | null | null | null | /// A schema builder for creating schema
public final class Creator: Builder {
/// Entity being built
public var entity: Entity.Type
/// The fields to be created
public var fields: [RawOr<Field>]
/// The foreign keys to be created
public var foreignKeys: [RawOr<ForeignKey>]
/// Creates a new schema creator
public init(_ e: Entity.Type) {
entity = e
fields = []
foreignKeys = []
}
}
| 24.157895 | 47 | 0.603486 |
ae87e3a568424a6f67351991c035bfb574664cd0 | 2,451 | lua | Lua | MMOCoreORB/bin/scripts/mobile/conversations/junk_dealer/junk_dealer_reggi_conv.lua | V-Fib/FlurryClone | 40e0ca7245ec31b3815eb6459329fd9e70f88936 | [
"Zlib",
"OpenSSL"
] | 18 | 2017-02-09T15:36:05.000Z | 2021-12-21T04:22:15.000Z | MMOCoreORB/bin/scripts/mobile/conversations/junk_dealer/junk_dealer_reggi_conv.lua | V-Fib/FlurryClone | 40e0ca7245ec31b3815eb6459329fd9e70f88936 | [
"Zlib",
"OpenSSL"
] | 61 | 2016-12-30T21:51:10.000Z | 2021-12-10T20:25:56.000Z | MMOCoreORB/bin/scripts/mobile/conversations/junk_dealer/junk_dealer_reggi_conv.lua | V-Fib/FlurryClone | 40e0ca7245ec31b3815eb6459329fd9e70f88936 | [
"Zlib",
"OpenSSL"
] | 71 | 2017-01-01T05:34:38.000Z | 2022-03-29T01:04:00.000Z | junkDealerReggiConvoTemplate = ConvoTemplate:new {
initialScreen = "init",
templateType = "Lua",
luaClassHandler = "JunkDealerReggiConvoHandler",
screens = {}
}
init = ConvoScreen:new {
id = "init",
leftDialog = "@conversation/junk_reggi_nym:s_60d2f507", -- Looking for work? I don't know that for sure but normally people who come around here are always looking for something.
stopConversation = "false",
options = {
{"@conversation/junk_reggi_nym:s_ef8c7236", "ask_for_loot"}, -- I am always looking for work.
{"@conversation/junk_reggi_nym:s_53d778d8", "true_words"}, -- Not really...work has never suited me.
}
}
junkDealerReggiConvoTemplate:addScreen(init);
true_words = ConvoScreen:new {
id = "true_words",
leftDialog = "@conversation/junk_reggi_nym:s_f25d9c2", -- Truer words have never been spoken. But if you ever change your mind you know where to find me.
stopConversation = "true",
options = {}
}
junkDealerReggiConvoTemplate:addScreen(true_words);
ask_for_loot = ConvoScreen:new {
id = "ask_for_loot",
leftDialog = "@conversation/junk_reggi_nym:s_14e5bdc0", -- I don't really have to much in the way of jobs but Nym is always looking to buy weapons and such. He also has some bounties out on those cursed Blood Razors and Canyon Cosairs who haven't figured out their place yet.
stopConversation = "false",
options = {
--{"@conversation/junk_reggi_nym:s_b8e27f3c", "start_sale"}, -- Well this looks like my lucky day.
--{"@conversation/junk_reggi_nym:s_2e005077", "no_loot"}, -- It doesn't look like I have anything Nym would like to buy.
}
}
junkDealerReggiConvoTemplate:addScreen(ask_for_loot);
no_loot = ConvoScreen:new {
id = "no_loot",
leftDialog = "@conversation/junk_reggi_nym:s_233f3214", -- Not a problem. Like I said Nym is always looking for these things so if you run across any come on back.
stopConversation = "true",
options = {}
}
junkDealerReggiConvoTemplate:addScreen(no_loot);
start_sale = ConvoScreen:new {
id = "start_sale",
leftDialog = "@conversation/junk_reggi_nym:s_5c453a2f", -- Being lucky is one of the best things in the world. Lets take a look at what you have to offer. Nym isn't much for bartering so you can take the price I give or you can leave it. Makes no difference to me really.
stopConversation = "true",
options = {}
}
junkDealerReggiConvoTemplate:addScreen(start_sale);
addConversationTemplate("junkDealerReggiConvoTemplate", junkDealerReggiConvoTemplate);
| 44.563636 | 276 | 0.758058 |
80c64b39b09aed0ae9c451989a531199039ca149 | 3,583 | java | Java | src/main/java/io/github/PheonixVX/ThreeDShareware/gui/screen/DOSScreen.java | BoogieMonster1O1/Modern3DShareware | 5bbd34d493153215f317a93576b1560510750ebc | [
"MIT"
] | null | null | null | src/main/java/io/github/PheonixVX/ThreeDShareware/gui/screen/DOSScreen.java | BoogieMonster1O1/Modern3DShareware | 5bbd34d493153215f317a93576b1560510750ebc | [
"MIT"
] | null | null | null | src/main/java/io/github/PheonixVX/ThreeDShareware/gui/screen/DOSScreen.java | BoogieMonster1O1/Modern3DShareware | 5bbd34d493153215f317a93576b1560510750ebc | [
"MIT"
] | null | null | null | package io.github.PheonixVX.ThreeDShareware.gui.screen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.ResourceTexture;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.resource.DefaultResourcePack;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.ResourceType;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
public class DOSScreen extends Screen {
private static final Identifier field_19193 = new Identifier("sound.sys");
protected DOSScreen (Text title) {
super(new LiteralText("Credits"));
}
@Override
public void render (MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.client.getTextureManager().bindTexture(field_19193);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vertexConsumer = tessellator.getBuffer();
vertexConsumer.begin(7, VertexFormats.POSITION_TEXTURE_COLOR);
vertexConsumer.vertex(0.0D, this.height, this.getZOffset()).texture(0.0F, 1.0F).next();
vertexConsumer.vertex(this.width, this.height, this.getZOffset()).texture(1.0F, 1.0F).next();
vertexConsumer.vertex(this.width, 0.0D, this.getZOffset()).texture(1.0F, 0.0F).next();
vertexConsumer.vertex(0.0D, 0.0D, this.getZOffset()).texture(0.0F, 0.0F).next();
tessellator.draw();
}
public static class class_4282 extends ResourceTexture {
private final Identifier field_19194;
public class_4282 (Identifier var1) {
super(var1);
this.field_19194 = var1;
}
protected ResourceTexture.TextureData loadTextureData (ResourceManager var1) {
MinecraftClient var2 = MinecraftClient.getInstance();
DefaultResourcePack var3 = var2.getResourcePackDownloader().getPack();
byte[] var4 = new byte[4];
try {
InputStream var5 = var3.open(ResourceType.CLIENT_RESOURCES, this.field_19194);
Throwable var6 = null;
Object var9;
try {
var5.read(var4);
InputStream var7 = new FilterInputStream(var5) {
public int read () throws IOException {
return super.read() ^ 113;
}
public int read (byte[] var1, int var2, int var3) throws IOException {
int var4 = super.read(var1, var2, var3);
for (int var5 = 0; var5 < var4; ++var5) {
var1[var5 + var2] = (byte) (var1[var5 + var2] ^ 113);
}
return var4;
}
};
Throwable var8 = null;
try {
var9 = new ResourceTexture.TextureData(null, NativeImage.read(var7));
} catch (Throwable var34) {
throw var34;
} finally {
if (var7 != null) {
if (var8 != null) {
try {
var7.close();
} catch (Throwable var33) {
var8.addSuppressed(var33);
}
} else {
var7.close();
}
}
}
} catch (Throwable var36) {
throw var36;
} finally {
if (var5 != null) {
if (var6 != null) {
try {
var5.close();
} catch (Throwable var32) {
var6.addSuppressed(var32);
}
} else {
var5.close();
}
}
}
return (ResourceTexture.TextureData) var9;
} catch (IOException var38) {
return new ResourceTexture.TextureData(var38);
}
}
}
}
| 29.61157 | 95 | 0.681831 |
c2ccfcec714742a6cc303e6693fc66e436303896 | 1,259 | go | Go | ccc_builder_go/src/deps/DepsUpdate.go | Jecced/ccc_buider | 6cdfd214b20e37445d413a8c95aa94dc90b1df9e | [
"MIT"
] | 21 | 2020-04-15T06:08:21.000Z | 2020-11-13T08:26:37.000Z | ccc_builder_go/src/deps/DepsUpdate.go | Jecced/ccc_buider | 6cdfd214b20e37445d413a8c95aa94dc90b1df9e | [
"MIT"
] | null | null | null | ccc_builder_go/src/deps/DepsUpdate.go | Jecced/ccc_buider | 6cdfd214b20e37445d413a8c95aa94dc90b1df9e | [
"MIT"
] | 2 | 2020-04-15T12:29:21.000Z | 2020-04-16T08:40:53.000Z | package deps
import (
"ccc_builder_go/src/util/fileutil"
"log"
"strings"
)
// 更新一个脚本的依赖
func Update(jsPath string) {
text, err := fileutil.ReadText(jsPath)
if err != nil {
log.Println("读取js文件失败", jsPath, err.Error())
return
}
var temp string
list := make([]string, 0)
indexStart, indexEnd := -1, -1
for end, index := -1, strings.Index(text, " = require(\""); index != -1; {
temp = text[index:]
end = strings.Index(temp, ")")
temp = text[index : end+index]
text = text[end+index:]
index = strings.Index(text, " = require(\"")
//list = append(list, temp)
indexStart = strings.Index(temp, "\"")
indexEnd = strings.LastIndex(temp, "\"")
list = append(list, temp[indexStart+1:indexEnd])
}
indexStart = strings.LastIndex(jsPath, "/")
indexEnd = strings.LastIndex(jsPath, ".")
name := jsPath[indexStart+1 : indexEnd]
i, has := indexCache[name]
if !has {
log.Println("该脚本当前没有依赖缓存")
return
}
// 获取当前依赖信息
info := &scripts[i]
info.Deps = make(map[string]int)
for _, v := range list {
indexStart = strings.LastIndex(v, "/")
depsIndex, has2 := indexCache[v[indexStart+1:]]
if !has2 {
log.Println("依赖索引没找到", v)
continue
}
info.Deps[v] = depsIndex
}
log.Println("脚本依赖刷新完成", name, info.Deps)
}
| 19.075758 | 75 | 0.633836 |
5052108ab23f360e10eb06bc7d67b0cdc81c6e45 | 1,316 | html | HTML | index.html | DivyanshuED/divyanshued.github.io | e3829e91dea8ca7b04770d491b4a24ad91c6bd38 | [
"Apache-2.0"
] | null | null | null | index.html | DivyanshuED/divyanshued.github.io | e3829e91dea8ca7b04770d491b4a24ad91c6bd38 | [
"Apache-2.0"
] | null | null | null | index.html | DivyanshuED/divyanshued.github.io | e3829e91dea8ca7b04770d491b4a24ad91c6bd38 | [
"Apache-2.0"
] | null | null | null | <!DOCTYPE html>
<html lang="en">
<head>
<title>Divyanshu`s Github</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="jumbotron text-center">
<h1>Let`s Roll</h1>
<p>Hey my name is Divyanshu!</p>
</div>
<div class="container">
<div class="row">
<div class="col-sm-4">
<h3>Document</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
</div>
<div class="col-sm-4">
<h3>Develop</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
</div>
<div class="col-sm-4">
<h3>Delpoy</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
</div>
</div>
</div>
</body>
</html>
| 32.9 | 102 | 0.646657 |
4ac4039f4b0ce6af1bd4e0bea30187b90af42bb9 | 972 | cs | C# | src/MyTested.AspNetCore.Mvc.ViewFeatures/ActionAttributesTestBuilderViewFeaturesExtensions.cs | vmmarko/MyTested.AspNetCore.Mvc | 7d587aaa3cb33463dd11a165206aee13e1c4737c | [
"MS-PL"
] | null | null | null | src/MyTested.AspNetCore.Mvc.ViewFeatures/ActionAttributesTestBuilderViewFeaturesExtensions.cs | vmmarko/MyTested.AspNetCore.Mvc | 7d587aaa3cb33463dd11a165206aee13e1c4737c | [
"MS-PL"
] | null | null | null | src/MyTested.AspNetCore.Mvc.ViewFeatures/ActionAttributesTestBuilderViewFeaturesExtensions.cs | vmmarko/MyTested.AspNetCore.Mvc | 7d587aaa3cb33463dd11a165206aee13e1c4737c | [
"MS-PL"
] | null | null | null | namespace MyTested.AspNetCore.Mvc
{
using Builders.Contracts.Attributes;
using Microsoft.AspNetCore.Mvc;
/// <summary>
/// Contains view features extension methods for <see cref="IActionAttributesTestBuilder"/>.
/// </summary>
public static class ActionAttributesTestBuilderViewFeaturesExtensions
{
/// <summary>
/// Tests whether the action attributes contain <see cref="ValidateAntiForgeryTokenAttribute"/>.
/// </summary>
/// <param name="actionAttributesTestBuilder">Instance of <see cref="IActionAttributesTestBuilder"/> type.</param>
/// <returns>The same <see cref="IAndActionAttributesTestBuilder"/>.</returns>
public static IAndActionAttributesTestBuilder ValidatingAntiForgeryToken(this IActionAttributesTestBuilder actionAttributesTestBuilder)
{
return actionAttributesTestBuilder.ContainingAttributeOfType<ValidateAntiForgeryTokenAttribute>();
}
}
}
| 44.181818 | 143 | 0.723251 |
06acd8e166d5a239f580090f23ee398f2adbcf70 | 733 | cpp | C++ | example/avl_example.cpp | Usman-Naeem/Data_Structure | 044d1f5067798f33b32fad167f71aedbcc78e989 | [
"MIT"
] | 5 | 2021-04-04T22:10:59.000Z | 2021-07-17T05:45:32.000Z | example/avl_example.cpp | Usman-Naeem/Data_Structure | 044d1f5067798f33b32fad167f71aedbcc78e989 | [
"MIT"
] | 1 | 2021-05-26T12:33:39.000Z | 2021-06-01T05:36:33.000Z | example/avl_example.cpp | Usman-Naeem/Data_Structure | 044d1f5067798f33b32fad167f71aedbcc78e989 | [
"MIT"
] | 2 | 2021-05-07T10:05:02.000Z | 2021-06-30T03:07:49.000Z | #include <iostream>
#include "../trees/AVL/AVL.cpp"
int main ()
{
AVL<int> a;
a.insert(20);
a.insert(11);
a.insert(15);
a.insert(25);
// remove 12 from the tree.
a.remove(15);
// height is 2
std::cout << "height " << a.root->height << std::endl;
// As root is 12, left is 11 and right is 20, so hence tree is balanced.
std::cout << "\t" << a.root->data << std::endl;
std::cout << " " << "/" << " " << "\\" << std::endl;
std::cout << " " << a.root->left->data ;
std::cout << " " << a.root->right->data << std::endl;
/*
* Tree look like that.
12
/ \
11 20
*/
// transverse.
a.inorder();
return 0;
}
| 22.212121 | 76 | 0.461119 |
90d986c25659ff1563a5192d0ff4f837a77cb0a1 | 1,757 | py | Python | src/profile.py | alan20062006/InstaComments2Excel | 54cd5cb380949d6c5640fea39d32a2cf2ce59833 | [
"MIT"
] | 1 | 2021-07-19T22:38:26.000Z | 2021-07-19T22:38:26.000Z | src/profile.py | alan20062006/InstaComments2Excel | 54cd5cb380949d6c5640fea39d32a2cf2ce59833 | [
"MIT"
] | null | null | null | src/profile.py | alan20062006/InstaComments2Excel | 54cd5cb380949d6c5640fea39d32a2cf2ce59833 | [
"MIT"
] | null | null | null | from typing import List, Dict
import re
NUM_RECENT_POSTS = 12
class AccountProfile(object):
def __init__(self, username):
self.username = username
self.n_followers = 0
self.n_following = 0
self.n_posts = 0
self.biography = ""
self.email = ""
# post fields
self.n_comments = []
self.n_likes = []
self.captions = []
self.hashtags = []
self.url_codes = []
def profile_parser(username, profile_graphql) -> AccountProfile:
profile = AccountProfile(username)
json_user = profile_graphql.get('graphql').get('user')
# parse number of follower & following
profile.n_followers = json_user.get('edge_followed_by').get('count')
profile.n_following = json_user.get('edge_follow').get('count')
# parse bio & email
profile.biography = json_user.get('biography')
profile.email = json_user.get('business_email')
json_posts = json_user.get('edge_owner_to_timeline_media')
# parse recent posts
profile.n_posts = json_posts.get('count')
for i in range(NUM_RECENT_POSTS):
profile.n_comments.append(json_posts.get('edges')[i].get('node').get('edge_media_to_comment').get('count'))
profile.n_likes.append(json_posts.get('edges')[i].get('node').get('edge_liked_by').get('count'))
caption = json_posts.get('edges')[i].get('node').get('edge_media_to_caption').get('edges')[0].get('node').get('text')
profile.captions.append(caption)
profile.hashtags.append(re.findall(r"#(\w+)", caption))
profile.url_codes.append(json_posts.get('edges')[i].get('node').get('shortcode'))
print(profile)
return profile
def get_post_link(profile_graphql):
pass | 32.537037 | 125 | 0.65111 |
7e2b5c32ebae953514651dcb855587e0f995e52c | 540 | ps1 | PowerShell | scripts/run-visualizer.ps1 | ameyag/windows10-docker-swarm | 88f06d0e41a9f263cc6d0ebbabb035b5d61cf872 | [
"MIT"
] | 67 | 2017-03-01T18:34:22.000Z | 2022-02-07T19:22:43.000Z | scripts/run-visualizer.ps1 | ameyag/windows10-docker-swarm | 88f06d0e41a9f263cc6d0ebbabb035b5d61cf872 | [
"MIT"
] | 3 | 2017-03-05T16:08:46.000Z | 2019-06-24T13:50:05.000Z | prepare-hardware/up-win10/usb/scripts/run-visualizer.ps1 | AlexRogalskiy/tiny-cloud | aa2bfbb4c33210dbf9890b48681d7fee9037db73 | [
"MIT"
] | 11 | 2017-08-25T14:13:43.000Z | 2022-02-07T19:22:44.000Z | $ip=(Get-NetIPAddress -AddressFamily IPv4 `
| Where-Object -FilterScript { $_.InterfaceAlias -Eq "vEthernet (HNS Internal NIC)" } `
).IPAddress
if (Test-Path $env:USERPROFILE\.docker\ca.pem) {
docker run -d -p 8080:8080 `
-e DOCKER_HOST=${ip}:2376 -e DOCKER_TLS_VERIFY=1 `
-v "$env:USERPROFILE\.docker:C:\Users\ContainerAdministrator\.docker" `
--name=visualizer stefanscherer/visualizer-windows
} else {
docker run -d -p 8080:8080 `
-e DOCKER_HOST=${ip}:2375 --name=visualizer stefanscherer/visualizer-windows
}
| 38.571429 | 90 | 0.705556 |
c1fa3a079a1644ecb8e6da087b789b2713265915 | 562 | sql | SQL | openGaussBase/testcase/KEYWORDS/Collation_Schema/Opengauss_Function_Keyword_Collation_Schema_Case0032.sql | opengauss-mirror/Yat | aef107a8304b94e5d99b4f1f36eb46755eb8919e | [
"MulanPSL-1.0"
] | null | null | null | openGaussBase/testcase/KEYWORDS/Collation_Schema/Opengauss_Function_Keyword_Collation_Schema_Case0032.sql | opengauss-mirror/Yat | aef107a8304b94e5d99b4f1f36eb46755eb8919e | [
"MulanPSL-1.0"
] | null | null | null | openGaussBase/testcase/KEYWORDS/Collation_Schema/Opengauss_Function_Keyword_Collation_Schema_Case0032.sql | opengauss-mirror/Yat | aef107a8304b94e5d99b4f1f36eb46755eb8919e | [
"MulanPSL-1.0"
] | null | null | null | -- @testpoint: opengauss关键字collation_schema(非保留),作为用户名 合理报错
--关键字collation_schema作为用户名不带引号,创建成功
drop user if exists collation_schema;
CREATE USER collation_schema PASSWORD 'Bigdata@123';
drop user collation_schema;
--关键字collation_schema作为用户名加双引号,创建成功
drop user if exists "collation_schema";
CREATE USER "collation_schema" PASSWORD 'Bigdata@123';
drop user "collation_schema";
--关键字collation_schema作为用户名加单引号,合理报错
CREATE USER 'collation_schema' PASSWORD 'Bigdata@123';
--关键字collation_schema作为用户名加反引号,合理报错
CREATE USER `collation_schema` PASSWORD 'Bigdata@123';
| 31.222222 | 59 | 0.827402 |
b5473f38e553cc97364778dfd5a9ebe8b1972b64 | 1,035 | kt | Kotlin | recruitment-blinkist/app/src/main/java/gs/kar/rblinkist/Models.kt | kargs/justeat-recruitmenttest | 7f5dd4cdb2b218088f65062bd19f7b50dcd22134 | [
"Apache-2.0"
] | null | null | null | recruitment-blinkist/app/src/main/java/gs/kar/rblinkist/Models.kt | kargs/justeat-recruitmenttest | 7f5dd4cdb2b218088f65062bd19f7b50dcd22134 | [
"Apache-2.0"
] | null | null | null | recruitment-blinkist/app/src/main/java/gs/kar/rblinkist/Models.kt | kargs/justeat-recruitmenttest | 7f5dd4cdb2b218088f65062bd19f7b50dcd22134 | [
"Apache-2.0"
] | 1 | 2019-03-12T15:05:04.000Z | 2019-03-12T15:05:04.000Z | package gs.kar.rblinkist
import com.github.kittinunf.fuel.core.ResponseDeserializable
import com.google.gson.Gson
data class Blinks(val items: List<Blink>) {
class Deserializer : ResponseDeserializable<Blinks> {
override fun deserialize(content: String) = Gson().fromJson(content, Blinks::class.java)
}
}
data class Blink(
val id: String,
val volumeInfo: BlinkInfo
) {
override fun equals(other: Any?): Boolean {
return if (other is Blink) id.equals(other.id)
else false
}
override fun hashCode(): Int {
return id.hashCode()
}
}
data class BlinkInfo(
val title: String,
val authors: List<String>?,
val imageLinks: BlinkImages?
) {
fun allAuthors(): String {
return authors?.joinToString(", ") ?: ""
}
}
data class BlinkImages(
val smallThumbnail: String?,
val thumbnail: String?,
val small: String?
) {
fun default(): String {
return small ?: thumbnail ?: smallThumbnail!!
}
}
| 23 | 96 | 0.628019 |
540496ceb2a3ab457285223d799b313e9c65edc9 | 893 | asm | Assembly | data/pokemon/base_stats/clefairy.asm | opiter09/ASM-Machina | 75d8e457b3e82cc7a99b8e70ada643ab02863ada | [
"CC0-1.0"
] | 1 | 2022-02-15T00:19:44.000Z | 2022-02-15T00:19:44.000Z | data/pokemon/base_stats/clefairy.asm | opiter09/ASM-Machina | 75d8e457b3e82cc7a99b8e70ada643ab02863ada | [
"CC0-1.0"
] | null | null | null | data/pokemon/base_stats/clefairy.asm | opiter09/ASM-Machina | 75d8e457b3e82cc7a99b8e70ada643ab02863ada | [
"CC0-1.0"
] | null | null | null | db DEX_CLEFAIRY ; pokedex id
db 70, 45, 48, 35, 60
; hp atk def spd spc
db SOUND, SOUND ; type
db 150 ; catch rate
db 68 ; base exp
INCBIN "gfx/pokemon/front/clefairy.pic", 0, 1 ; sprite dimensions
dw ClefairyPicFront, ClefairyPicBack
db POUND, GROWL, NO_MOVE, NO_MOVE ; level 1 learnset
db GROWTH_FAST ; growth rate
; tm/hm learnset
tmhm MEGA_PUNCH, MEGA_KICK, TOXIC, BODY_SLAM, TAKE_DOWN, \
DOUBLE_EDGE, BUBBLEBEAM, WATER_GUN, ICE_BEAM, BLIZZARD, \
SUBMISSION, COUNTER, SEISMIC_TOSS, RAGE, SOLARBEAM, \
THUNDERBOLT, THUNDER, PSYCHIC_M, TELEPORT, MIMIC, \
DOUBLE_TEAM, REFLECT, BIDE, METRONOME, FIRE_BLAST, \
SKULL_BASH, REST, THUNDER_WAVE, PSYWAVE, TRI_ATTACK, \
SUBSTITUTE, STRENGTH, FLASH
; end
db 0 ; padding
| 33.074074 | 77 | 0.606943 |
0a29aaf67f29d93f46436763c02a30abd472d4e0 | 169 | ts | TypeScript | projects/angular-stl-model-viewer/src/public-api.ts | joseAndresGomezTovar/angular-stl-model-viewer | 4fb6730df456123dc4d55d199bd9ba540ba365bb | [
"MIT"
] | 19 | 2019-04-15T08:56:55.000Z | 2020-05-20T21:50:51.000Z | projects/angular-stl-model-viewer/src/public-api.ts | joseAndresGomezTovar/angular-stl-model-viewer | 4fb6730df456123dc4d55d199bd9ba540ba365bb | [
"MIT"
] | 141 | 2019-01-30T15:31:25.000Z | 2020-05-28T09:01:08.000Z | projects/angular-stl-model-viewer/src/public-api.ts | joseAndresGomezTovar/angular-stl-model-viewer | 4fb6730df456123dc4d55d199bd9ba540ba365bb | [
"MIT"
] | 9 | 2020-07-20T10:58:58.000Z | 2022-02-24T12:36:26.000Z | /*
* Public API Surface of angular-stl-model-viewer
*/
export * from './lib/angular-stl-model-viewer.component'
export * from './lib/angular-stl-model-viewer.module'
| 24.142857 | 56 | 0.721893 |
963c5382ffcb8f76181be47fe38d8f5f89d6947e | 103 | lua | Lua | packages/athena-webpack-loader/test/contract.lua | aergoio/athena | f1b9bb48a31003b53bb51cf649b9918044662a6a | [
"MIT"
] | 3 | 2019-04-24T05:45:46.000Z | 2020-02-17T05:03:12.000Z | packages/athena-webpack-loader/test/contract.lua | aergoio/athena | f1b9bb48a31003b53bb51cf649b9918044662a6a | [
"MIT"
] | 1 | 2019-05-13T06:11:18.000Z | 2019-05-17T11:27:22.000Z | packages/athena-webpack-loader/test/contract.lua | aergoio/athena | f1b9bb48a31003b53bb51cf649b9918044662a6a | [
"MIT"
] | 3 | 2019-08-03T10:59:54.000Z | 2020-05-19T04:45:41.000Z | function getContractCreator()
return system.getCreator()
end
abi.register_view(getContractCreator) | 20.6 | 37 | 0.825243 |
8d94394ea3b90cfe86c2a7d233120b4ef9fb2feb | 3,719 | dart | Dart | lib/views/pages/category/collect_page.dart | coscx/geen | 5d9e3becd881433db37006cd2b44ea143f356f7a | [
"MIT"
] | null | null | null | lib/views/pages/category/collect_page.dart | coscx/geen | 5d9e3becd881433db37006cd2b44ea143f356f7a | [
"MIT"
] | null | null | null | lib/views/pages/category/collect_page.dart | coscx/geen | 5d9e3becd881433db37006cd2b44ea143f356f7a | [
"MIT"
] | null | null | null | import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_geen/app/router.dart';
import 'package:flutter_geen/blocs/bloc_exp.dart';
import 'package:flutter_geen/components/permanent/circle_image.dart';
import 'package:flutter_geen/components/permanent/feedback_widget.dart';
import 'category_page.dart';
import 'default_collect_page.dart';
class CollectPage extends StatefulWidget {
@override
_CollectPageState createState() => _CollectPageState();
}
class _CollectPageState extends State<CollectPage>
with AutomaticKeepAliveClientMixin {
final _tabs = [
'收藏集录',
'默认收藏',
];
@override
Widget build(BuildContext context) {
super.build(context);
BuildContext _topContext = context;
return Scaffold(
backgroundColor:
BlocProvider.of<HomeBloc>(context).activeHomeColor.withAlpha(11),
body: DefaultTabController(
length: _tabs.length, // This is the number of tabs.
child: NestedScrollView(
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverOverlapAbsorber(
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(
context),
sliver: _buildAppBar(_topContext, innerBoxIsScrolled)),
];
},
body: TabBarView(
children: <Widget>[
CategoryPage(),
DefaultCollectPage(),
],
),
),
));
}
Widget _buildAppBar(BuildContext context, bool index) {
return SliverAppBar(
leading: Container(
margin: EdgeInsets.all(10),
child: FeedbackWidget(
onPressed: (){
Navigator.of(context).pushNamed(UnitRouter.login);
},
child: CircleImage(
image: AssetImage('assets/images/icon_head.webp'),
borderSize: 1.5,
),
)),
backgroundColor: BlocProvider.of<HomeBloc>(context).activeHomeColor,
actions: <Widget>[_buildAddActionBuilder(context)],
title: Text(
'收藏集',
style: TextStyle(
color: Colors.white, //标题
fontSize: 18,
shadows: [
Shadow(color: Colors.blue, offset: Offset(1, 1), blurRadius: 2)
]),
),
pinned: true,
expandedHeight: 150.0,
flexibleSpace: FlexibleSpaceBar(
collapseMode: CollapseMode.parallax, //视差效果
background: Image.asset(
"assets/images/caver.webp",
fit: BoxFit.cover,
),
),
forceElevated: index,
bottom: PreferredSize(
preferredSize: Size.fromHeight(30),
child: TabBar(
indicatorColor: Colors.transparent,
unselectedLabelColor: Colors.white,
labelColor: Colors.black,
labelStyle: TextStyle(fontSize: 16, shadows: [
Shadow(
color: Theme.of(context).primaryColor,
offset: Offset(1, 1),
blurRadius: 10)
]),
tabs: _tabs
.map((String name) => Container(
margin: EdgeInsets.only(bottom: 5),
alignment: Alignment.center,
child: Text(name)))
.toList(),
),
),
);
}
Widget _buildAddActionBuilder(BuildContext context) => IconButton(
icon: Icon(
Icons.add,
size: 30,
),
onPressed: () => Scaffold.of(context).openEndDrawer());
@override
bool get wantKeepAlive => true;
}
| 30.735537 | 77 | 0.581339 |
c513d717fc2a56aa8b6e08e287584e86250d46c7 | 1,114 | cpp | C++ | requirments/003_thread.cpp | dreamingodd/crb | a96362dff73b7e658443436466122f73503f7cf0 | [
"MIT"
] | null | null | null | requirments/003_thread.cpp | dreamingodd/crb | a96362dff73b7e658443436466122f73503f7cf0 | [
"MIT"
] | null | null | null | requirments/003_thread.cpp | dreamingodd/crb | a96362dff73b7e658443436466122f73503f7cf0 | [
"MIT"
] | null | null | null | // example3.cpp
#include "boost/thread.hpp"
#include <iostream>
using namespace std;
boost::mutex mutex;
void wait(int sec){
boost::this_thread::sleep(boost::posix_time::seconds(sec));
}
void work(){
for(int i=0;i<5;i++){
wait(1);
cout << "id: " << 1 << " " << i << endl;
}
}
void work1(int id){
for(int i=0;i<5;i++){
wait(1);
cout << "id: " << id << " " << i << endl;
}
}
void work2(int id){
for(int i=0;i<5;i++){
mutex.lock();
cout << "id: " << id << " " << i << endl;
mutex.unlock();
/******** 其他互斥锁
boost::lock_guard<boost::mutex> lock(mutex); lock_guard在内部构造和析构函数分别自动调用lock()和unlock(),所以能自动将当前域设为互斥访问区域。
更多资料请参考: http://zh.highscore.de/cpp/boost/multithreading.html
********************/
}
}
int main(){
// 最简单的调用,不带任何参数
boost::thread th1(&work);
// bind的一个重要应用,绑定参数!这里两个线程不加任何互斥,打印出来的是乱序
boost::thread th2(boost::bind(&work1, 2));
boost::thread th3(boost::bind(&work1, 3));
// 4,5线程加简单的互斥锁,结果按次序打印
boost::thread th4(boost::bind(&work2, 4));
boost::thread th5(boost::bind(&work2, 5));
th4.join();
th5.join();
return 0;
}
| 21.423077 | 110 | 0.579892 |
babebf5321bbc2d6814c4ffd5368a1d9e6d802b9 | 50 | sql | SQL | biblioteca_Oauth2_Swagger/target/classes/data.sql | mjlbnu/codenation | b598ce69db15f10ba68e3b37c808743a12116819 | [
"MIT"
] | 1 | 2019-10-28T18:22:34.000Z | 2019-10-28T18:22:34.000Z | biblioteca_clean_code/target/classes/data.sql | mjlbnu/codenation | b598ce69db15f10ba68e3b37c808743a12116819 | [
"MIT"
] | 4 | 2020-06-17T18:27:28.000Z | 2020-06-17T18:27:40.000Z | biblioteca_clean_code/target/classes/data.sql | mjlbnu/codenation | b598ce69db15f10ba68e3b37c808743a12116819 | [
"MIT"
] | null | null | null | INSERT INTO usuario
VALUES
(1, 'vinicius', '123'); | 16.666667 | 23 | 0.7 |
a01925962362b7c4cfe948f29edaf5186890621d | 6,389 | lua | Lua | 01_krepios/lang/de/side_missions/de_pirate_base.lua | czenker/lively-epsilon-missions | c06cea55b58da8fc32429533fe0440764d37eda7 | [
"MIT"
] | 4 | 2019-08-01T11:17:19.000Z | 2021-11-21T02:27:45.000Z | 01_krepios/lang/de/side_missions/de_pirate_base.lua | czenker/lively-epsilon-missions | c06cea55b58da8fc32429533fe0440764d37eda7 | [
"MIT"
] | 2 | 2020-01-29T02:45:49.000Z | 2020-10-24T12:42:41.000Z | 01_krepios/lang/de/side_missions/de_pirate_base.lua | czenker/lively-epsilon-missions | c06cea55b58da8fc32429533fe0440764d37eda7 | [
"MIT"
] | null | null | null | local f = string.format
My.Translator:register("de", {
side_mission_pirate_base_station = function(sectorName)
return f("Feindstation in Sektor %s zerstören", sectorName)
end,
side_mission_pirate_base_jammer = function(sectorName)
return f("Warp Jammer in Sektor %s zerstören", sectorName)
end,
side_mission_pirate_base_station_briefing = function(difficulty, sectorName, payment)
local descriptionSize
if difficulty == 1 then descriptionSize = "schwache"
elseif difficulty == 2 then descriptionSize = "kleine"
elseif difficulty == 3 then descriptionSize = "ernst zu nehmende"
elseif difficulty == 4 then descriptionSize = "große"
elseif difficulty == 5 then descriptionSize = "mächtige"
end
return Util.random({
f("Unsere Sensoren haben eine mögliche Feindstation im Sektor %s geortet.", sectorName),
f("Unser Science Officer hat uns verdächtige Feindaktivitäten in Sektor %s gemeldet. Es sieht nach einer neuen Station aus.", sectorName),
f("Wie es aussieht versuchen die Piraten einmal mehr Fuß in Sektor %s zu fassen und eine Station zu errichten.", sectorName),
f("Wir haben eine Baustelle im Sektor %s entdeckt. Da sie nicht angemeldet ist, müssen wir davon ausgehen, dass unsere Feinde versuchen eine Basis in Sektor %s zu errichten.", sectorName, sectorName),
}) .. " " .. Util.random({
"Das ist natürlich nicht hinnehmbar.",
"Das ist für uns natürlich sehr unerfreulich.",
"Wir sollten ihr Vorhaben schnell unterbinden.",
}) .. " ".. Util.random({
f("Die Station wird von einer %sn Flotte beschützt.", descriptionSize),
f("Um die Station ist eine %s Flotte stationiert.", descriptionSize),
f("Der Feind lässt die Station von einer %sn Flotte beschützen.", descriptionSize),
}) .. "\n\n" .. Util.random({
f("Für die Vernichtung der Station und der begleitenden Flotte ist ein Kopfgeld von %0.2fRP ausgelobt.", payment),
f("%0.2fRP werden an den Captain bezahlt, der die Station und die Flotte vernichtet.", payment),
})
end,
side_mission_pirate_base_jammer_briefing = function(difficulty, sectorName, payment)
local descriptionSize
if difficulty == 1 then descriptionSize = "schwache"
elseif difficulty == 2 then descriptionSize = "kleine"
elseif difficulty == 3 then descriptionSize = "ernst zu nehmende"
elseif difficulty == 4 then descriptionSize = "große"
elseif difficulty == 5 then descriptionSize = "mächtige"
end
return Util.random({
f("Im Sektor %s wurde ein feindlicher Warp Jammer geortet.", sectorName),
f("Unsere Feinde haben im Sektor %s einen Warp Jammer installiert, um unsere Handelsrouten zu stören.", sectorName),
}) .. " " .. Util.random({
"Das ist natürlich nicht hinnehmbar.",
"Ohne Frage muss er zerstört werden.",
}) .. " ".. Util.random({
f("Er wird vom Feind mit einer %sn Flotte beschützt.", descriptionSize),
f("Eine %s Flotte hindert uns daran ihn zu zerstören.", descriptionSize),
}) .. "\n\n" .. Util.random({
f("Wenn Sie diese Gefahr eliminieren zeigen wir uns mit %0.2fRP erkenntlich.", payment),
f("Dem Schiff, das unseren Feind vernichtet winken %0.2fRP als Belohnung.", payment),
f("Wenn Sie uns helfen die Handelsrouten wieder sicher zu machen zahlen wir Ihnen %0.2fRP als Belohnung.", payment),
})
end,
side_mission_pirate_base_comms_too_close = "Sie halten sich zu nah am Zielgebiet auf. Wir wollen Sie nicht unnötig gefährden. Bitte halten Sie mehr Abstand, um den Auftrag anzunehmen.",
side_mission_pirate_base_station_description = "Eine Baustelle der Piraten. Die Station ist noch nicht funktionsfähig und kaum über den Rohbau hinaus.",
side_mission_pirate_base_jammer_description = "Ein Warp Jammer der Piraten, der die nahe gelegenen Handelsrouten stört.",
side_mission_pirate_base_station_start_hint = function(sectorName)
return f("Finden Sie die Station im Sektor %s", sectorName)
end,
side_mission_pirate_base_jammer_start_hint = function(sectorName)
return f("Finden Sie den Warp Jammer im Sektor %s", sectorName)
end,
side_mission_pirate_base_station_destruction_hint = function(numberOfShips, stationValid)
if stationValid then
if numberOfShips == 0 then
return "Zerstören Sie die Station"
elseif numberOfShips == 1 then
return "Zerstören Sie den letzen Verteidiger und die Station"
else
return f("Zerstören Sie %d Verteidiger und die Station", numberOfShips)
end
else
if numberOfShips == 1 then
return "Zerstören Sie das letzte Schiff"
else
return f("Zerstören Sie die %d Verteidiger", numberOfShips)
end
end
end,
side_mission_pirate_base_jammer_destruction_hint = function(numberOfShips, stationValid)
if stationValid then
if numberOfShips == 0 then
return "Zerstören Sie den Warp Jammer"
elseif numberOfShips == 1 then
return "Zerstören Sie den letzen Verteidiger und den WarpJammer"
else
return f("Zerstören Sie %d Verteidiger und den Warp Jammer", numberOfShips)
end
else
if numberOfShips == 1 then
return "Zerstören Sie das letzte Schiff"
else
return f("Zerstören Sie die %d Verteidiger", numberOfShips)
end
end
end,
side_mission_pirate_base_destruction_last_hint = "Abschuss des letzten Verteidigers bestätigt",
side_mission_pirate_base_destruction_ship_hint = "Abschuss bestätigt",
side_mission_pirate_base_destruction_station_hint = "Abschuss der Station bestätigt",
side_mission_pirate_base_destruction_jammer_hint = "Abschuss des Warp Jammers bestätigt",
side_mission_pirate_base_success_comms = function(payment)
return f("Ihr Heldenmut hat uns vor diesem Feind geschützt. Ihre Bezahlung von %0.2fRP haben Sie sich redlich verdient.", payment)
end,
}) | 56.04386 | 212 | 0.669275 |
d1b35484eb024197b244a67af8fd678c2a4a6ea6 | 1,299 | kt | Kotlin | src/main/kotlin/com/github/ledoyen/junitmigration/transformation/ReplaceBasicAnnotations.kt | ledoyen/junit-migration | 4ca2ea0d60ebf4b14395b257de27dfc914d96723 | [
"Apache-2.0"
] | 1 | 2021-09-19T05:04:27.000Z | 2021-09-19T05:04:27.000Z | src/main/kotlin/com/github/ledoyen/junitmigration/transformation/ReplaceBasicAnnotations.kt | ledoyen/junit-migration | 4ca2ea0d60ebf4b14395b257de27dfc914d96723 | [
"Apache-2.0"
] | null | null | null | src/main/kotlin/com/github/ledoyen/junitmigration/transformation/ReplaceBasicAnnotations.kt | ledoyen/junit-migration | 4ca2ea0d60ebf4b14395b257de27dfc914d96723 | [
"Apache-2.0"
] | null | null | null | package com.github.ledoyen.junitmigration.transformation
import com.github.ledoyen.minimaldiffparser.MinimalDiffCompilationUnit
import com.github.ledoyen.minimaldiffparser.MinimalDiffVisitorAdapter
class ReplaceBasicAnnotations : MinimalDiffVisitorAdapter() {
override fun visit(cu: MinimalDiffCompilationUnit) {
cu.replaceTextByRegex("import\\s+org\\.junit\\.Test;", "import org.junit.jupiter.api.Test;")
cu.replaceTextByRegex("import\\s+org\\.junit\\.\\*;", "import org.junit.jupiter.api.*;")
cu.replaceTextByRegex("import\\s+org\\.junit\\.BeforeClass;", "import org.junit.jupiter.api.BeforeAll;")
cu.replaceTextByRegex("@BeforeClass(\\s)") { m -> "@BeforeAll" + m.group(1) }
cu.replaceTextByRegex("import\\s+org\\.junit\\.AfterClass;", "import org.junit.jupiter.api.AfterAll;")
cu.replaceTextByRegex("@AfterClass(\\s)") { m -> "@AfterAll" + m.group(1) }
cu.replaceTextByRegex("import\\s+org\\.junit\\.Before;", "import org.junit.jupiter.api.BeforeEach;")
cu.replaceTextByRegex("@Before(\\s)") { m -> "@BeforeEach" + m.group(1) }
cu.replaceTextByRegex("import\\s+org\\.junit\\.After;", "import org.junit.jupiter.api.AfterEach;")
cu.replaceTextByRegex("@After(\\s)") { m -> "@AfterEach" + m.group(1) }
}
} | 59.045455 | 112 | 0.685912 |
c067106d4d083f8538bd1e474fbe54092382bd04 | 194,922 | asm | Assembly | oslab6/obj/user/lsfd.asm | jasha64/OperatingSystems-lab | 25a473adb754171d5c10c6bde391e0e07a2a43de | [
"MIT"
] | null | null | null | oslab6/obj/user/lsfd.asm | jasha64/OperatingSystems-lab | 25a473adb754171d5c10c6bde391e0e07a2a43de | [
"MIT"
] | null | null | null | oslab6/obj/user/lsfd.asm | jasha64/OperatingSystems-lab | 25a473adb754171d5c10c6bde391e0e07a2a43de | [
"MIT"
] | null | null | null |
obj/user/lsfd.debug: 文件格式 elf32-i386
Disassembly of section .text:
00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
// See if we were started with arguments on the stack
cmpl $USTACKTOP, %esp
800020: 81 fc 00 e0 bf ee cmp $0xeebfe000,%esp
jne args_exist
800026: 75 04 jne 80002c <args_exist>
// If not, push dummy argc/argv arguments.
// This happens when we are loaded by the kernel,
// because the kernel does not know about passing arguments.
pushl $0
800028: 6a 00 push $0x0
pushl $0
80002a: 6a 00 push $0x0
0080002c <args_exist>:
args_exist:
call libmain
80002c: e8 e0 00 00 00 call 800111 <libmain>
1: jmp 1b
800031: eb fe jmp 800031 <args_exist+0x5>
00800033 <usage>:
#include <inc/lib.h>
void
usage(void)
{
800033: 55 push %ebp
800034: 89 e5 mov %esp,%ebp
800036: 83 ec 14 sub $0x14,%esp
cprintf("usage: lsfd [-1]\n");
800039: 68 40 21 80 00 push $0x802140
80003e: e8 bb 01 00 00 call 8001fe <cprintf>
exit();
800043: e8 0f 01 00 00 call 800157 <exit>
}
800048: 83 c4 10 add $0x10,%esp
80004b: c9 leave
80004c: c3 ret
0080004d <umain>:
void
umain(int argc, char **argv)
{
80004d: 55 push %ebp
80004e: 89 e5 mov %esp,%ebp
800050: 57 push %edi
800051: 56 push %esi
800052: 53 push %ebx
800053: 81 ec b0 00 00 00 sub $0xb0,%esp
int i, usefprint = 0;
struct Stat st;
struct Argstate args;
argstart(&argc, argv, &args);
800059: 8d 85 4c ff ff ff lea -0xb4(%ebp),%eax
80005f: 50 push %eax
800060: ff 75 0c pushl 0xc(%ebp)
800063: 8d 45 08 lea 0x8(%ebp),%eax
800066: 50 push %eax
800067: e8 9b 0d 00 00 call 800e07 <argstart>
while ((i = argnext(&args)) >= 0)
80006c: 83 c4 10 add $0x10,%esp
int i, usefprint = 0;
80006f: bf 00 00 00 00 mov $0x0,%edi
while ((i = argnext(&args)) >= 0)
800074: 8d 9d 4c ff ff ff lea -0xb4(%ebp),%ebx
if (i == '1')
usefprint = 1;
80007a: be 01 00 00 00 mov $0x1,%esi
while ((i = argnext(&args)) >= 0)
80007f: 83 ec 0c sub $0xc,%esp
800082: 53 push %ebx
800083: e8 af 0d 00 00 call 800e37 <argnext>
800088: 83 c4 10 add $0x10,%esp
80008b: 85 c0 test %eax,%eax
80008d: 78 10 js 80009f <umain+0x52>
if (i == '1')
80008f: 83 f8 31 cmp $0x31,%eax
800092: 75 04 jne 800098 <umain+0x4b>
usefprint = 1;
800094: 89 f7 mov %esi,%edi
800096: eb e7 jmp 80007f <umain+0x32>
else
usage();
800098: e8 96 ff ff ff call 800033 <usage>
80009d: eb e0 jmp 80007f <umain+0x32>
for (i = 0; i < 32; i++)
80009f: bb 00 00 00 00 mov $0x0,%ebx
if (fstat(i, &st) >= 0) {
8000a4: 8d b5 5c ff ff ff lea -0xa4(%ebp),%esi
8000aa: eb 26 jmp 8000d2 <umain+0x85>
if (usefprint)
fprintf(1, "fd %d: name %s isdir %d size %d dev %s\n",
i, st.st_name, st.st_isdir,
st.st_size, st.st_dev->dev_name);
else
cprintf("fd %d: name %s isdir %d size %d dev %s\n",
8000ac: 83 ec 08 sub $0x8,%esp
8000af: 8b 45 e4 mov -0x1c(%ebp),%eax
8000b2: ff 70 04 pushl 0x4(%eax)
8000b5: ff 75 dc pushl -0x24(%ebp)
8000b8: ff 75 e0 pushl -0x20(%ebp)
8000bb: 56 push %esi
8000bc: 53 push %ebx
8000bd: 68 54 21 80 00 push $0x802154
8000c2: e8 37 01 00 00 call 8001fe <cprintf>
8000c7: 83 c4 20 add $0x20,%esp
for (i = 0; i < 32; i++)
8000ca: 83 c3 01 add $0x1,%ebx
8000cd: 83 fb 20 cmp $0x20,%ebx
8000d0: 74 37 je 800109 <umain+0xbc>
if (fstat(i, &st) >= 0) {
8000d2: 83 ec 08 sub $0x8,%esp
8000d5: 56 push %esi
8000d6: 53 push %ebx
8000d7: e8 5e 13 00 00 call 80143a <fstat>
8000dc: 83 c4 10 add $0x10,%esp
8000df: 85 c0 test %eax,%eax
8000e1: 78 e7 js 8000ca <umain+0x7d>
if (usefprint)
8000e3: 85 ff test %edi,%edi
8000e5: 74 c5 je 8000ac <umain+0x5f>
fprintf(1, "fd %d: name %s isdir %d size %d dev %s\n",
8000e7: 83 ec 04 sub $0x4,%esp
8000ea: 8b 45 e4 mov -0x1c(%ebp),%eax
8000ed: ff 70 04 pushl 0x4(%eax)
8000f0: ff 75 dc pushl -0x24(%ebp)
8000f3: ff 75 e0 pushl -0x20(%ebp)
8000f6: 56 push %esi
8000f7: 53 push %ebx
8000f8: 68 54 21 80 00 push $0x802154
8000fd: 6a 01 push $0x1
8000ff: e8 79 17 00 00 call 80187d <fprintf>
800104: 83 c4 20 add $0x20,%esp
800107: eb c1 jmp 8000ca <umain+0x7d>
i, st.st_name, st.st_isdir,
st.st_size, st.st_dev->dev_name);
}
}
800109: 8d 65 f4 lea -0xc(%ebp),%esp
80010c: 5b pop %ebx
80010d: 5e pop %esi
80010e: 5f pop %edi
80010f: 5d pop %ebp
800110: c3 ret
00800111 <libmain>:
const volatile struct Env *thisenv;
const char *binaryname = "<unknown>";
void
libmain(int argc, char **argv)
{
800111: 55 push %ebp
800112: 89 e5 mov %esp,%ebp
800114: 56 push %esi
800115: 53 push %ebx
800116: 8b 5d 08 mov 0x8(%ebp),%ebx
800119: 8b 75 0c mov 0xc(%ebp),%esi
// set thisenv to point at our Env structure in envs[].
// LAB 3: Your code here.
envid_t envid = sys_getenvid();
80011c: e8 b7 0a 00 00 call 800bd8 <sys_getenvid>
thisenv = envs + ENVX(envid);
800121: 25 ff 03 00 00 and $0x3ff,%eax
800126: 6b c0 7c imul $0x7c,%eax,%eax
800129: 05 00 00 c0 ee add $0xeec00000,%eax
80012e: a3 04 40 80 00 mov %eax,0x804004
// save the name of the program so that panic() can use it
if (argc > 0)
800133: 85 db test %ebx,%ebx
800135: 7e 07 jle 80013e <libmain+0x2d>
binaryname = argv[0];
800137: 8b 06 mov (%esi),%eax
800139: a3 00 30 80 00 mov %eax,0x803000
// call user main routine
umain(argc, argv);
80013e: 83 ec 08 sub $0x8,%esp
800141: 56 push %esi
800142: 53 push %ebx
800143: e8 05 ff ff ff call 80004d <umain>
// exit gracefully
exit();
800148: e8 0a 00 00 00 call 800157 <exit>
}
80014d: 83 c4 10 add $0x10,%esp
800150: 8d 65 f8 lea -0x8(%ebp),%esp
800153: 5b pop %ebx
800154: 5e pop %esi
800155: 5d pop %ebp
800156: c3 ret
00800157 <exit>:
#include <inc/lib.h>
void
exit(void)
{
800157: 55 push %ebp
800158: 89 e5 mov %esp,%ebp
80015a: 83 ec 14 sub $0x14,%esp
// close_all();
sys_env_destroy(0);
80015d: 6a 00 push $0x0
80015f: e8 33 0a 00 00 call 800b97 <sys_env_destroy>
}
800164: 83 c4 10 add $0x10,%esp
800167: c9 leave
800168: c3 ret
00800169 <putch>:
};
static void
putch(int ch, struct printbuf *b)
{
800169: 55 push %ebp
80016a: 89 e5 mov %esp,%ebp
80016c: 53 push %ebx
80016d: 83 ec 04 sub $0x4,%esp
800170: 8b 5d 0c mov 0xc(%ebp),%ebx
b->buf[b->idx++] = ch;
800173: 8b 13 mov (%ebx),%edx
800175: 8d 42 01 lea 0x1(%edx),%eax
800178: 89 03 mov %eax,(%ebx)
80017a: 8b 4d 08 mov 0x8(%ebp),%ecx
80017d: 88 4c 13 08 mov %cl,0x8(%ebx,%edx,1)
if (b->idx == 256-1) {
800181: 3d ff 00 00 00 cmp $0xff,%eax
800186: 74 09 je 800191 <putch+0x28>
sys_cputs(b->buf, b->idx);
b->idx = 0;
}
b->cnt++;
800188: 83 43 04 01 addl $0x1,0x4(%ebx)
}
80018c: 8b 5d fc mov -0x4(%ebp),%ebx
80018f: c9 leave
800190: c3 ret
sys_cputs(b->buf, b->idx);
800191: 83 ec 08 sub $0x8,%esp
800194: 68 ff 00 00 00 push $0xff
800199: 8d 43 08 lea 0x8(%ebx),%eax
80019c: 50 push %eax
80019d: e8 b8 09 00 00 call 800b5a <sys_cputs>
b->idx = 0;
8001a2: c7 03 00 00 00 00 movl $0x0,(%ebx)
8001a8: 83 c4 10 add $0x10,%esp
8001ab: eb db jmp 800188 <putch+0x1f>
008001ad <vcprintf>:
int
vcprintf(const char *fmt, va_list ap)
{
8001ad: 55 push %ebp
8001ae: 89 e5 mov %esp,%ebp
8001b0: 81 ec 18 01 00 00 sub $0x118,%esp
struct printbuf b;
b.idx = 0;
8001b6: c7 85 f0 fe ff ff 00 movl $0x0,-0x110(%ebp)
8001bd: 00 00 00
b.cnt = 0;
8001c0: c7 85 f4 fe ff ff 00 movl $0x0,-0x10c(%ebp)
8001c7: 00 00 00
vprintfmt((void*)putch, &b, fmt, ap);
8001ca: ff 75 0c pushl 0xc(%ebp)
8001cd: ff 75 08 pushl 0x8(%ebp)
8001d0: 8d 85 f0 fe ff ff lea -0x110(%ebp),%eax
8001d6: 50 push %eax
8001d7: 68 69 01 80 00 push $0x800169
8001dc: e8 1a 01 00 00 call 8002fb <vprintfmt>
sys_cputs(b.buf, b.idx);
8001e1: 83 c4 08 add $0x8,%esp
8001e4: ff b5 f0 fe ff ff pushl -0x110(%ebp)
8001ea: 8d 85 f8 fe ff ff lea -0x108(%ebp),%eax
8001f0: 50 push %eax
8001f1: e8 64 09 00 00 call 800b5a <sys_cputs>
return b.cnt;
}
8001f6: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax
8001fc: c9 leave
8001fd: c3 ret
008001fe <cprintf>:
int
cprintf(const char *fmt, ...)
{
8001fe: 55 push %ebp
8001ff: 89 e5 mov %esp,%ebp
800201: 83 ec 10 sub $0x10,%esp
va_list ap;
int cnt;
va_start(ap, fmt);
800204: 8d 45 0c lea 0xc(%ebp),%eax
cnt = vcprintf(fmt, ap);
800207: 50 push %eax
800208: ff 75 08 pushl 0x8(%ebp)
80020b: e8 9d ff ff ff call 8001ad <vcprintf>
va_end(ap);
return cnt;
}
800210: c9 leave
800211: c3 ret
00800212 <printnum>:
* using specified putch function and associated pointer putdat.
*/
static void
printnum(void (*putch)(int, void*), void *putdat,
unsigned long long num, unsigned base, int width, int padc)
{
800212: 55 push %ebp
800213: 89 e5 mov %esp,%ebp
800215: 57 push %edi
800216: 56 push %esi
800217: 53 push %ebx
800218: 83 ec 1c sub $0x1c,%esp
80021b: 89 c7 mov %eax,%edi
80021d: 89 d6 mov %edx,%esi
80021f: 8b 45 08 mov 0x8(%ebp),%eax
800222: 8b 55 0c mov 0xc(%ebp),%edx
800225: 89 45 d8 mov %eax,-0x28(%ebp)
800228: 89 55 dc mov %edx,-0x24(%ebp)
// first recursively print all preceding (more significant) digits
if (num >= base) {
80022b: 8b 4d 10 mov 0x10(%ebp),%ecx
80022e: bb 00 00 00 00 mov $0x0,%ebx
800233: 89 4d e0 mov %ecx,-0x20(%ebp)
800236: 89 5d e4 mov %ebx,-0x1c(%ebp)
800239: 39 d3 cmp %edx,%ebx
80023b: 72 05 jb 800242 <printnum+0x30>
80023d: 39 45 10 cmp %eax,0x10(%ebp)
800240: 77 7a ja 8002bc <printnum+0xaa>
printnum(putch, putdat, num / base, base, width - 1, padc);
800242: 83 ec 0c sub $0xc,%esp
800245: ff 75 18 pushl 0x18(%ebp)
800248: 8b 45 14 mov 0x14(%ebp),%eax
80024b: 8d 58 ff lea -0x1(%eax),%ebx
80024e: 53 push %ebx
80024f: ff 75 10 pushl 0x10(%ebp)
800252: 83 ec 08 sub $0x8,%esp
800255: ff 75 e4 pushl -0x1c(%ebp)
800258: ff 75 e0 pushl -0x20(%ebp)
80025b: ff 75 dc pushl -0x24(%ebp)
80025e: ff 75 d8 pushl -0x28(%ebp)
800261: e8 8a 1c 00 00 call 801ef0 <__udivdi3>
800266: 83 c4 18 add $0x18,%esp
800269: 52 push %edx
80026a: 50 push %eax
80026b: 89 f2 mov %esi,%edx
80026d: 89 f8 mov %edi,%eax
80026f: e8 9e ff ff ff call 800212 <printnum>
800274: 83 c4 20 add $0x20,%esp
800277: eb 13 jmp 80028c <printnum+0x7a>
} else {
// print any needed pad characters before first digit
while (--width > 0)
putch(padc, putdat);
800279: 83 ec 08 sub $0x8,%esp
80027c: 56 push %esi
80027d: ff 75 18 pushl 0x18(%ebp)
800280: ff d7 call *%edi
800282: 83 c4 10 add $0x10,%esp
while (--width > 0)
800285: 83 eb 01 sub $0x1,%ebx
800288: 85 db test %ebx,%ebx
80028a: 7f ed jg 800279 <printnum+0x67>
}
// then print this (the least significant) digit
putch("0123456789abcdef"[num % base], putdat);
80028c: 83 ec 08 sub $0x8,%esp
80028f: 56 push %esi
800290: 83 ec 04 sub $0x4,%esp
800293: ff 75 e4 pushl -0x1c(%ebp)
800296: ff 75 e0 pushl -0x20(%ebp)
800299: ff 75 dc pushl -0x24(%ebp)
80029c: ff 75 d8 pushl -0x28(%ebp)
80029f: e8 6c 1d 00 00 call 802010 <__umoddi3>
8002a4: 83 c4 14 add $0x14,%esp
8002a7: 0f be 80 86 21 80 00 movsbl 0x802186(%eax),%eax
8002ae: 50 push %eax
8002af: ff d7 call *%edi
}
8002b1: 83 c4 10 add $0x10,%esp
8002b4: 8d 65 f4 lea -0xc(%ebp),%esp
8002b7: 5b pop %ebx
8002b8: 5e pop %esi
8002b9: 5f pop %edi
8002ba: 5d pop %ebp
8002bb: c3 ret
8002bc: 8b 5d 14 mov 0x14(%ebp),%ebx
8002bf: eb c4 jmp 800285 <printnum+0x73>
008002c1 <sprintputch>:
int cnt;
};
static void
sprintputch(int ch, struct sprintbuf *b)
{
8002c1: 55 push %ebp
8002c2: 89 e5 mov %esp,%ebp
8002c4: 8b 45 0c mov 0xc(%ebp),%eax
b->cnt++;
8002c7: 83 40 08 01 addl $0x1,0x8(%eax)
if (b->buf < b->ebuf)
8002cb: 8b 10 mov (%eax),%edx
8002cd: 3b 50 04 cmp 0x4(%eax),%edx
8002d0: 73 0a jae 8002dc <sprintputch+0x1b>
*b->buf++ = ch;
8002d2: 8d 4a 01 lea 0x1(%edx),%ecx
8002d5: 89 08 mov %ecx,(%eax)
8002d7: 8b 45 08 mov 0x8(%ebp),%eax
8002da: 88 02 mov %al,(%edx)
}
8002dc: 5d pop %ebp
8002dd: c3 ret
008002de <printfmt>:
{
8002de: 55 push %ebp
8002df: 89 e5 mov %esp,%ebp
8002e1: 83 ec 08 sub $0x8,%esp
va_start(ap, fmt);
8002e4: 8d 45 14 lea 0x14(%ebp),%eax
vprintfmt(putch, putdat, fmt, ap);
8002e7: 50 push %eax
8002e8: ff 75 10 pushl 0x10(%ebp)
8002eb: ff 75 0c pushl 0xc(%ebp)
8002ee: ff 75 08 pushl 0x8(%ebp)
8002f1: e8 05 00 00 00 call 8002fb <vprintfmt>
}
8002f6: 83 c4 10 add $0x10,%esp
8002f9: c9 leave
8002fa: c3 ret
008002fb <vprintfmt>:
{
8002fb: 55 push %ebp
8002fc: 89 e5 mov %esp,%ebp
8002fe: 57 push %edi
8002ff: 56 push %esi
800300: 53 push %ebx
800301: 83 ec 2c sub $0x2c,%esp
800304: 8b 75 08 mov 0x8(%ebp),%esi
800307: 8b 5d 0c mov 0xc(%ebp),%ebx
80030a: 8b 7d 10 mov 0x10(%ebp),%edi
80030d: e9 c1 03 00 00 jmp 8006d3 <vprintfmt+0x3d8>
padc = ' ';
800312: c6 45 d4 20 movb $0x20,-0x2c(%ebp)
altflag = 0;
800316: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp)
precision = -1;
80031d: c7 45 d0 ff ff ff ff movl $0xffffffff,-0x30(%ebp)
width = -1;
800324: c7 45 e0 ff ff ff ff movl $0xffffffff,-0x20(%ebp)
lflag = 0;
80032b: b9 00 00 00 00 mov $0x0,%ecx
switch (ch = *(unsigned char *) fmt++) {
800330: 8d 47 01 lea 0x1(%edi),%eax
800333: 89 45 e4 mov %eax,-0x1c(%ebp)
800336: 0f b6 17 movzbl (%edi),%edx
800339: 8d 42 dd lea -0x23(%edx),%eax
80033c: 3c 55 cmp $0x55,%al
80033e: 0f 87 12 04 00 00 ja 800756 <vprintfmt+0x45b>
800344: 0f b6 c0 movzbl %al,%eax
800347: ff 24 85 c0 22 80 00 jmp *0x8022c0(,%eax,4)
80034e: 8b 7d e4 mov -0x1c(%ebp),%edi
padc = '-';
800351: c6 45 d4 2d movb $0x2d,-0x2c(%ebp)
800355: eb d9 jmp 800330 <vprintfmt+0x35>
switch (ch = *(unsigned char *) fmt++) {
800357: 8b 7d e4 mov -0x1c(%ebp),%edi
padc = '0';
80035a: c6 45 d4 30 movb $0x30,-0x2c(%ebp)
80035e: eb d0 jmp 800330 <vprintfmt+0x35>
switch (ch = *(unsigned char *) fmt++) {
800360: 0f b6 d2 movzbl %dl,%edx
800363: 8b 7d e4 mov -0x1c(%ebp),%edi
for (precision = 0; ; ++fmt) {
800366: b8 00 00 00 00 mov $0x0,%eax
80036b: 89 4d e4 mov %ecx,-0x1c(%ebp)
precision = precision * 10 + ch - '0';
80036e: 8d 04 80 lea (%eax,%eax,4),%eax
800371: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
ch = *fmt;
800375: 0f be 17 movsbl (%edi),%edx
if (ch < '0' || ch > '9')
800378: 8d 4a d0 lea -0x30(%edx),%ecx
80037b: 83 f9 09 cmp $0x9,%ecx
80037e: 77 55 ja 8003d5 <vprintfmt+0xda>
for (precision = 0; ; ++fmt) {
800380: 83 c7 01 add $0x1,%edi
precision = precision * 10 + ch - '0';
800383: eb e9 jmp 80036e <vprintfmt+0x73>
precision = va_arg(ap, int);
800385: 8b 45 14 mov 0x14(%ebp),%eax
800388: 8b 00 mov (%eax),%eax
80038a: 89 45 d0 mov %eax,-0x30(%ebp)
80038d: 8b 45 14 mov 0x14(%ebp),%eax
800390: 8d 40 04 lea 0x4(%eax),%eax
800393: 89 45 14 mov %eax,0x14(%ebp)
switch (ch = *(unsigned char *) fmt++) {
800396: 8b 7d e4 mov -0x1c(%ebp),%edi
if (width < 0)
800399: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
80039d: 79 91 jns 800330 <vprintfmt+0x35>
width = precision, precision = -1;
80039f: 8b 45 d0 mov -0x30(%ebp),%eax
8003a2: 89 45 e0 mov %eax,-0x20(%ebp)
8003a5: c7 45 d0 ff ff ff ff movl $0xffffffff,-0x30(%ebp)
8003ac: eb 82 jmp 800330 <vprintfmt+0x35>
8003ae: 8b 45 e0 mov -0x20(%ebp),%eax
8003b1: 85 c0 test %eax,%eax
8003b3: ba 00 00 00 00 mov $0x0,%edx
8003b8: 0f 49 d0 cmovns %eax,%edx
8003bb: 89 55 e0 mov %edx,-0x20(%ebp)
switch (ch = *(unsigned char *) fmt++) {
8003be: 8b 7d e4 mov -0x1c(%ebp),%edi
8003c1: e9 6a ff ff ff jmp 800330 <vprintfmt+0x35>
8003c6: 8b 7d e4 mov -0x1c(%ebp),%edi
altflag = 1;
8003c9: c7 45 d8 01 00 00 00 movl $0x1,-0x28(%ebp)
goto reswitch;
8003d0: e9 5b ff ff ff jmp 800330 <vprintfmt+0x35>
8003d5: 8b 4d e4 mov -0x1c(%ebp),%ecx
8003d8: 89 45 d0 mov %eax,-0x30(%ebp)
8003db: eb bc jmp 800399 <vprintfmt+0x9e>
lflag++;
8003dd: 83 c1 01 add $0x1,%ecx
switch (ch = *(unsigned char *) fmt++) {
8003e0: 8b 7d e4 mov -0x1c(%ebp),%edi
goto reswitch;
8003e3: e9 48 ff ff ff jmp 800330 <vprintfmt+0x35>
putch(va_arg(ap, int), putdat);
8003e8: 8b 45 14 mov 0x14(%ebp),%eax
8003eb: 8d 78 04 lea 0x4(%eax),%edi
8003ee: 83 ec 08 sub $0x8,%esp
8003f1: 53 push %ebx
8003f2: ff 30 pushl (%eax)
8003f4: ff d6 call *%esi
break;
8003f6: 83 c4 10 add $0x10,%esp
putch(va_arg(ap, int), putdat);
8003f9: 89 7d 14 mov %edi,0x14(%ebp)
break;
8003fc: e9 cf 02 00 00 jmp 8006d0 <vprintfmt+0x3d5>
err = va_arg(ap, int);
800401: 8b 45 14 mov 0x14(%ebp),%eax
800404: 8d 78 04 lea 0x4(%eax),%edi
800407: 8b 00 mov (%eax),%eax
800409: 99 cltd
80040a: 31 d0 xor %edx,%eax
80040c: 29 d0 sub %edx,%eax
if (err >= MAXERROR || (p = error_string[err]) == NULL)
80040e: 83 f8 0f cmp $0xf,%eax
800411: 7f 23 jg 800436 <vprintfmt+0x13b>
800413: 8b 14 85 20 24 80 00 mov 0x802420(,%eax,4),%edx
80041a: 85 d2 test %edx,%edx
80041c: 74 18 je 800436 <vprintfmt+0x13b>
printfmt(putch, putdat, "%s", p);
80041e: 52 push %edx
80041f: 68 51 25 80 00 push $0x802551
800424: 53 push %ebx
800425: 56 push %esi
800426: e8 b3 fe ff ff call 8002de <printfmt>
80042b: 83 c4 10 add $0x10,%esp
err = va_arg(ap, int);
80042e: 89 7d 14 mov %edi,0x14(%ebp)
800431: e9 9a 02 00 00 jmp 8006d0 <vprintfmt+0x3d5>
printfmt(putch, putdat, "error %d", err);
800436: 50 push %eax
800437: 68 9e 21 80 00 push $0x80219e
80043c: 53 push %ebx
80043d: 56 push %esi
80043e: e8 9b fe ff ff call 8002de <printfmt>
800443: 83 c4 10 add $0x10,%esp
err = va_arg(ap, int);
800446: 89 7d 14 mov %edi,0x14(%ebp)
printfmt(putch, putdat, "error %d", err);
800449: e9 82 02 00 00 jmp 8006d0 <vprintfmt+0x3d5>
if ((p = va_arg(ap, char *)) == NULL)
80044e: 8b 45 14 mov 0x14(%ebp),%eax
800451: 83 c0 04 add $0x4,%eax
800454: 89 45 cc mov %eax,-0x34(%ebp)
800457: 8b 45 14 mov 0x14(%ebp),%eax
80045a: 8b 38 mov (%eax),%edi
p = "(null)";
80045c: 85 ff test %edi,%edi
80045e: b8 97 21 80 00 mov $0x802197,%eax
800463: 0f 44 f8 cmove %eax,%edi
if (width > 0 && padc != '-')
800466: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
80046a: 0f 8e bd 00 00 00 jle 80052d <vprintfmt+0x232>
800470: 80 7d d4 2d cmpb $0x2d,-0x2c(%ebp)
800474: 75 0e jne 800484 <vprintfmt+0x189>
800476: 89 75 08 mov %esi,0x8(%ebp)
800479: 8b 75 d0 mov -0x30(%ebp),%esi
80047c: 89 5d 0c mov %ebx,0xc(%ebp)
80047f: 8b 5d e0 mov -0x20(%ebp),%ebx
800482: eb 6d jmp 8004f1 <vprintfmt+0x1f6>
for (width -= strnlen(p, precision); width > 0; width--)
800484: 83 ec 08 sub $0x8,%esp
800487: ff 75 d0 pushl -0x30(%ebp)
80048a: 57 push %edi
80048b: e8 6e 03 00 00 call 8007fe <strnlen>
800490: 8b 4d e0 mov -0x20(%ebp),%ecx
800493: 29 c1 sub %eax,%ecx
800495: 89 4d c8 mov %ecx,-0x38(%ebp)
800498: 83 c4 10 add $0x10,%esp
putch(padc, putdat);
80049b: 0f be 45 d4 movsbl -0x2c(%ebp),%eax
80049f: 89 45 e0 mov %eax,-0x20(%ebp)
8004a2: 89 7d d4 mov %edi,-0x2c(%ebp)
8004a5: 89 cf mov %ecx,%edi
for (width -= strnlen(p, precision); width > 0; width--)
8004a7: eb 0f jmp 8004b8 <vprintfmt+0x1bd>
putch(padc, putdat);
8004a9: 83 ec 08 sub $0x8,%esp
8004ac: 53 push %ebx
8004ad: ff 75 e0 pushl -0x20(%ebp)
8004b0: ff d6 call *%esi
for (width -= strnlen(p, precision); width > 0; width--)
8004b2: 83 ef 01 sub $0x1,%edi
8004b5: 83 c4 10 add $0x10,%esp
8004b8: 85 ff test %edi,%edi
8004ba: 7f ed jg 8004a9 <vprintfmt+0x1ae>
8004bc: 8b 7d d4 mov -0x2c(%ebp),%edi
8004bf: 8b 4d c8 mov -0x38(%ebp),%ecx
8004c2: 85 c9 test %ecx,%ecx
8004c4: b8 00 00 00 00 mov $0x0,%eax
8004c9: 0f 49 c1 cmovns %ecx,%eax
8004cc: 29 c1 sub %eax,%ecx
8004ce: 89 75 08 mov %esi,0x8(%ebp)
8004d1: 8b 75 d0 mov -0x30(%ebp),%esi
8004d4: 89 5d 0c mov %ebx,0xc(%ebp)
8004d7: 89 cb mov %ecx,%ebx
8004d9: eb 16 jmp 8004f1 <vprintfmt+0x1f6>
if (altflag && (ch < ' ' || ch > '~'))
8004db: 83 7d d8 00 cmpl $0x0,-0x28(%ebp)
8004df: 75 31 jne 800512 <vprintfmt+0x217>
putch(ch, putdat);
8004e1: 83 ec 08 sub $0x8,%esp
8004e4: ff 75 0c pushl 0xc(%ebp)
8004e7: 50 push %eax
8004e8: ff 55 08 call *0x8(%ebp)
8004eb: 83 c4 10 add $0x10,%esp
for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
8004ee: 83 eb 01 sub $0x1,%ebx
8004f1: 83 c7 01 add $0x1,%edi
8004f4: 0f b6 57 ff movzbl -0x1(%edi),%edx
8004f8: 0f be c2 movsbl %dl,%eax
8004fb: 85 c0 test %eax,%eax
8004fd: 74 59 je 800558 <vprintfmt+0x25d>
8004ff: 85 f6 test %esi,%esi
800501: 78 d8 js 8004db <vprintfmt+0x1e0>
800503: 83 ee 01 sub $0x1,%esi
800506: 79 d3 jns 8004db <vprintfmt+0x1e0>
800508: 89 df mov %ebx,%edi
80050a: 8b 75 08 mov 0x8(%ebp),%esi
80050d: 8b 5d 0c mov 0xc(%ebp),%ebx
800510: eb 37 jmp 800549 <vprintfmt+0x24e>
if (altflag && (ch < ' ' || ch > '~'))
800512: 0f be d2 movsbl %dl,%edx
800515: 83 ea 20 sub $0x20,%edx
800518: 83 fa 5e cmp $0x5e,%edx
80051b: 76 c4 jbe 8004e1 <vprintfmt+0x1e6>
putch('?', putdat);
80051d: 83 ec 08 sub $0x8,%esp
800520: ff 75 0c pushl 0xc(%ebp)
800523: 6a 3f push $0x3f
800525: ff 55 08 call *0x8(%ebp)
800528: 83 c4 10 add $0x10,%esp
80052b: eb c1 jmp 8004ee <vprintfmt+0x1f3>
80052d: 89 75 08 mov %esi,0x8(%ebp)
800530: 8b 75 d0 mov -0x30(%ebp),%esi
800533: 89 5d 0c mov %ebx,0xc(%ebp)
800536: 8b 5d e0 mov -0x20(%ebp),%ebx
800539: eb b6 jmp 8004f1 <vprintfmt+0x1f6>
putch(' ', putdat);
80053b: 83 ec 08 sub $0x8,%esp
80053e: 53 push %ebx
80053f: 6a 20 push $0x20
800541: ff d6 call *%esi
for (; width > 0; width--)
800543: 83 ef 01 sub $0x1,%edi
800546: 83 c4 10 add $0x10,%esp
800549: 85 ff test %edi,%edi
80054b: 7f ee jg 80053b <vprintfmt+0x240>
if ((p = va_arg(ap, char *)) == NULL)
80054d: 8b 45 cc mov -0x34(%ebp),%eax
800550: 89 45 14 mov %eax,0x14(%ebp)
800553: e9 78 01 00 00 jmp 8006d0 <vprintfmt+0x3d5>
800558: 89 df mov %ebx,%edi
80055a: 8b 75 08 mov 0x8(%ebp),%esi
80055d: 8b 5d 0c mov 0xc(%ebp),%ebx
800560: eb e7 jmp 800549 <vprintfmt+0x24e>
if (lflag >= 2)
800562: 83 f9 01 cmp $0x1,%ecx
800565: 7e 3f jle 8005a6 <vprintfmt+0x2ab>
return va_arg(*ap, long long);
800567: 8b 45 14 mov 0x14(%ebp),%eax
80056a: 8b 50 04 mov 0x4(%eax),%edx
80056d: 8b 00 mov (%eax),%eax
80056f: 89 45 d8 mov %eax,-0x28(%ebp)
800572: 89 55 dc mov %edx,-0x24(%ebp)
800575: 8b 45 14 mov 0x14(%ebp),%eax
800578: 8d 40 08 lea 0x8(%eax),%eax
80057b: 89 45 14 mov %eax,0x14(%ebp)
if ((long long) num < 0) {
80057e: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
800582: 79 5c jns 8005e0 <vprintfmt+0x2e5>
putch('-', putdat);
800584: 83 ec 08 sub $0x8,%esp
800587: 53 push %ebx
800588: 6a 2d push $0x2d
80058a: ff d6 call *%esi
num = -(long long) num;
80058c: 8b 55 d8 mov -0x28(%ebp),%edx
80058f: 8b 4d dc mov -0x24(%ebp),%ecx
800592: f7 da neg %edx
800594: 83 d1 00 adc $0x0,%ecx
800597: f7 d9 neg %ecx
800599: 83 c4 10 add $0x10,%esp
base = 10;
80059c: b8 0a 00 00 00 mov $0xa,%eax
8005a1: e9 10 01 00 00 jmp 8006b6 <vprintfmt+0x3bb>
else if (lflag)
8005a6: 85 c9 test %ecx,%ecx
8005a8: 75 1b jne 8005c5 <vprintfmt+0x2ca>
return va_arg(*ap, int);
8005aa: 8b 45 14 mov 0x14(%ebp),%eax
8005ad: 8b 00 mov (%eax),%eax
8005af: 89 45 d8 mov %eax,-0x28(%ebp)
8005b2: 89 c1 mov %eax,%ecx
8005b4: c1 f9 1f sar $0x1f,%ecx
8005b7: 89 4d dc mov %ecx,-0x24(%ebp)
8005ba: 8b 45 14 mov 0x14(%ebp),%eax
8005bd: 8d 40 04 lea 0x4(%eax),%eax
8005c0: 89 45 14 mov %eax,0x14(%ebp)
8005c3: eb b9 jmp 80057e <vprintfmt+0x283>
return va_arg(*ap, long);
8005c5: 8b 45 14 mov 0x14(%ebp),%eax
8005c8: 8b 00 mov (%eax),%eax
8005ca: 89 45 d8 mov %eax,-0x28(%ebp)
8005cd: 89 c1 mov %eax,%ecx
8005cf: c1 f9 1f sar $0x1f,%ecx
8005d2: 89 4d dc mov %ecx,-0x24(%ebp)
8005d5: 8b 45 14 mov 0x14(%ebp),%eax
8005d8: 8d 40 04 lea 0x4(%eax),%eax
8005db: 89 45 14 mov %eax,0x14(%ebp)
8005de: eb 9e jmp 80057e <vprintfmt+0x283>
num = getint(&ap, lflag);
8005e0: 8b 55 d8 mov -0x28(%ebp),%edx
8005e3: 8b 4d dc mov -0x24(%ebp),%ecx
base = 10;
8005e6: b8 0a 00 00 00 mov $0xa,%eax
8005eb: e9 c6 00 00 00 jmp 8006b6 <vprintfmt+0x3bb>
if (lflag >= 2)
8005f0: 83 f9 01 cmp $0x1,%ecx
8005f3: 7e 18 jle 80060d <vprintfmt+0x312>
return va_arg(*ap, unsigned long long);
8005f5: 8b 45 14 mov 0x14(%ebp),%eax
8005f8: 8b 10 mov (%eax),%edx
8005fa: 8b 48 04 mov 0x4(%eax),%ecx
8005fd: 8d 40 08 lea 0x8(%eax),%eax
800600: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
800603: b8 0a 00 00 00 mov $0xa,%eax
800608: e9 a9 00 00 00 jmp 8006b6 <vprintfmt+0x3bb>
else if (lflag)
80060d: 85 c9 test %ecx,%ecx
80060f: 75 1a jne 80062b <vprintfmt+0x330>
return va_arg(*ap, unsigned int);
800611: 8b 45 14 mov 0x14(%ebp),%eax
800614: 8b 10 mov (%eax),%edx
800616: b9 00 00 00 00 mov $0x0,%ecx
80061b: 8d 40 04 lea 0x4(%eax),%eax
80061e: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
800621: b8 0a 00 00 00 mov $0xa,%eax
800626: e9 8b 00 00 00 jmp 8006b6 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
80062b: 8b 45 14 mov 0x14(%ebp),%eax
80062e: 8b 10 mov (%eax),%edx
800630: b9 00 00 00 00 mov $0x0,%ecx
800635: 8d 40 04 lea 0x4(%eax),%eax
800638: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
80063b: b8 0a 00 00 00 mov $0xa,%eax
800640: eb 74 jmp 8006b6 <vprintfmt+0x3bb>
if (lflag >= 2)
800642: 83 f9 01 cmp $0x1,%ecx
800645: 7e 15 jle 80065c <vprintfmt+0x361>
return va_arg(*ap, unsigned long long);
800647: 8b 45 14 mov 0x14(%ebp),%eax
80064a: 8b 10 mov (%eax),%edx
80064c: 8b 48 04 mov 0x4(%eax),%ecx
80064f: 8d 40 08 lea 0x8(%eax),%eax
800652: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
800655: b8 08 00 00 00 mov $0x8,%eax
80065a: eb 5a jmp 8006b6 <vprintfmt+0x3bb>
else if (lflag)
80065c: 85 c9 test %ecx,%ecx
80065e: 75 17 jne 800677 <vprintfmt+0x37c>
return va_arg(*ap, unsigned int);
800660: 8b 45 14 mov 0x14(%ebp),%eax
800663: 8b 10 mov (%eax),%edx
800665: b9 00 00 00 00 mov $0x0,%ecx
80066a: 8d 40 04 lea 0x4(%eax),%eax
80066d: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
800670: b8 08 00 00 00 mov $0x8,%eax
800675: eb 3f jmp 8006b6 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
800677: 8b 45 14 mov 0x14(%ebp),%eax
80067a: 8b 10 mov (%eax),%edx
80067c: b9 00 00 00 00 mov $0x0,%ecx
800681: 8d 40 04 lea 0x4(%eax),%eax
800684: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
800687: b8 08 00 00 00 mov $0x8,%eax
80068c: eb 28 jmp 8006b6 <vprintfmt+0x3bb>
putch('0', putdat);
80068e: 83 ec 08 sub $0x8,%esp
800691: 53 push %ebx
800692: 6a 30 push $0x30
800694: ff d6 call *%esi
putch('x', putdat);
800696: 83 c4 08 add $0x8,%esp
800699: 53 push %ebx
80069a: 6a 78 push $0x78
80069c: ff d6 call *%esi
num = (unsigned long long)
80069e: 8b 45 14 mov 0x14(%ebp),%eax
8006a1: 8b 10 mov (%eax),%edx
8006a3: b9 00 00 00 00 mov $0x0,%ecx
goto number;
8006a8: 83 c4 10 add $0x10,%esp
(uintptr_t) va_arg(ap, void *);
8006ab: 8d 40 04 lea 0x4(%eax),%eax
8006ae: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
8006b1: b8 10 00 00 00 mov $0x10,%eax
printnum(putch, putdat, num, base, width, padc);
8006b6: 83 ec 0c sub $0xc,%esp
8006b9: 0f be 7d d4 movsbl -0x2c(%ebp),%edi
8006bd: 57 push %edi
8006be: ff 75 e0 pushl -0x20(%ebp)
8006c1: 50 push %eax
8006c2: 51 push %ecx
8006c3: 52 push %edx
8006c4: 89 da mov %ebx,%edx
8006c6: 89 f0 mov %esi,%eax
8006c8: e8 45 fb ff ff call 800212 <printnum>
break;
8006cd: 83 c4 20 add $0x20,%esp
err = va_arg(ap, int);
8006d0: 8b 7d e4 mov -0x1c(%ebp),%edi
while ((ch = *(unsigned char *) fmt++) != '%') { //先将非格式化字符输出到控制台。
8006d3: 83 c7 01 add $0x1,%edi
8006d6: 0f b6 47 ff movzbl -0x1(%edi),%eax
8006da: 83 f8 25 cmp $0x25,%eax
8006dd: 0f 84 2f fc ff ff je 800312 <vprintfmt+0x17>
if (ch == '\0') //如果没有格式化字符直接返回
8006e3: 85 c0 test %eax,%eax
8006e5: 0f 84 8b 00 00 00 je 800776 <vprintfmt+0x47b>
putch(ch, putdat);
8006eb: 83 ec 08 sub $0x8,%esp
8006ee: 53 push %ebx
8006ef: 50 push %eax
8006f0: ff d6 call *%esi
8006f2: 83 c4 10 add $0x10,%esp
8006f5: eb dc jmp 8006d3 <vprintfmt+0x3d8>
if (lflag >= 2)
8006f7: 83 f9 01 cmp $0x1,%ecx
8006fa: 7e 15 jle 800711 <vprintfmt+0x416>
return va_arg(*ap, unsigned long long);
8006fc: 8b 45 14 mov 0x14(%ebp),%eax
8006ff: 8b 10 mov (%eax),%edx
800701: 8b 48 04 mov 0x4(%eax),%ecx
800704: 8d 40 08 lea 0x8(%eax),%eax
800707: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
80070a: b8 10 00 00 00 mov $0x10,%eax
80070f: eb a5 jmp 8006b6 <vprintfmt+0x3bb>
else if (lflag)
800711: 85 c9 test %ecx,%ecx
800713: 75 17 jne 80072c <vprintfmt+0x431>
return va_arg(*ap, unsigned int);
800715: 8b 45 14 mov 0x14(%ebp),%eax
800718: 8b 10 mov (%eax),%edx
80071a: b9 00 00 00 00 mov $0x0,%ecx
80071f: 8d 40 04 lea 0x4(%eax),%eax
800722: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
800725: b8 10 00 00 00 mov $0x10,%eax
80072a: eb 8a jmp 8006b6 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
80072c: 8b 45 14 mov 0x14(%ebp),%eax
80072f: 8b 10 mov (%eax),%edx
800731: b9 00 00 00 00 mov $0x0,%ecx
800736: 8d 40 04 lea 0x4(%eax),%eax
800739: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
80073c: b8 10 00 00 00 mov $0x10,%eax
800741: e9 70 ff ff ff jmp 8006b6 <vprintfmt+0x3bb>
putch(ch, putdat);
800746: 83 ec 08 sub $0x8,%esp
800749: 53 push %ebx
80074a: 6a 25 push $0x25
80074c: ff d6 call *%esi
break;
80074e: 83 c4 10 add $0x10,%esp
800751: e9 7a ff ff ff jmp 8006d0 <vprintfmt+0x3d5>
putch('%', putdat);
800756: 83 ec 08 sub $0x8,%esp
800759: 53 push %ebx
80075a: 6a 25 push $0x25
80075c: ff d6 call *%esi
for (fmt--; fmt[-1] != '%'; fmt--)
80075e: 83 c4 10 add $0x10,%esp
800761: 89 f8 mov %edi,%eax
800763: eb 03 jmp 800768 <vprintfmt+0x46d>
800765: 83 e8 01 sub $0x1,%eax
800768: 80 78 ff 25 cmpb $0x25,-0x1(%eax)
80076c: 75 f7 jne 800765 <vprintfmt+0x46a>
80076e: 89 45 e4 mov %eax,-0x1c(%ebp)
800771: e9 5a ff ff ff jmp 8006d0 <vprintfmt+0x3d5>
}
800776: 8d 65 f4 lea -0xc(%ebp),%esp
800779: 5b pop %ebx
80077a: 5e pop %esi
80077b: 5f pop %edi
80077c: 5d pop %ebp
80077d: c3 ret
0080077e <vsnprintf>:
int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
80077e: 55 push %ebp
80077f: 89 e5 mov %esp,%ebp
800781: 83 ec 18 sub $0x18,%esp
800784: 8b 45 08 mov 0x8(%ebp),%eax
800787: 8b 55 0c mov 0xc(%ebp),%edx
struct sprintbuf b = {buf, buf+n-1, 0};
80078a: 89 45 ec mov %eax,-0x14(%ebp)
80078d: 8d 4c 10 ff lea -0x1(%eax,%edx,1),%ecx
800791: 89 4d f0 mov %ecx,-0x10(%ebp)
800794: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if (buf == NULL || n < 1)
80079b: 85 c0 test %eax,%eax
80079d: 74 26 je 8007c5 <vsnprintf+0x47>
80079f: 85 d2 test %edx,%edx
8007a1: 7e 22 jle 8007c5 <vsnprintf+0x47>
return -E_INVAL;
// print the string to the buffer
vprintfmt((void*)sprintputch, &b, fmt, ap);
8007a3: ff 75 14 pushl 0x14(%ebp)
8007a6: ff 75 10 pushl 0x10(%ebp)
8007a9: 8d 45 ec lea -0x14(%ebp),%eax
8007ac: 50 push %eax
8007ad: 68 c1 02 80 00 push $0x8002c1
8007b2: e8 44 fb ff ff call 8002fb <vprintfmt>
// null terminate the buffer
*b.buf = '\0';
8007b7: 8b 45 ec mov -0x14(%ebp),%eax
8007ba: c6 00 00 movb $0x0,(%eax)
return b.cnt;
8007bd: 8b 45 f4 mov -0xc(%ebp),%eax
8007c0: 83 c4 10 add $0x10,%esp
}
8007c3: c9 leave
8007c4: c3 ret
return -E_INVAL;
8007c5: b8 fd ff ff ff mov $0xfffffffd,%eax
8007ca: eb f7 jmp 8007c3 <vsnprintf+0x45>
008007cc <snprintf>:
int
snprintf(char *buf, int n, const char *fmt, ...)
{
8007cc: 55 push %ebp
8007cd: 89 e5 mov %esp,%ebp
8007cf: 83 ec 08 sub $0x8,%esp
va_list ap;
int rc;
va_start(ap, fmt);
8007d2: 8d 45 14 lea 0x14(%ebp),%eax
rc = vsnprintf(buf, n, fmt, ap);
8007d5: 50 push %eax
8007d6: ff 75 10 pushl 0x10(%ebp)
8007d9: ff 75 0c pushl 0xc(%ebp)
8007dc: ff 75 08 pushl 0x8(%ebp)
8007df: e8 9a ff ff ff call 80077e <vsnprintf>
va_end(ap);
return rc;
}
8007e4: c9 leave
8007e5: c3 ret
008007e6 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1
int
strlen(const char *s)
{
8007e6: 55 push %ebp
8007e7: 89 e5 mov %esp,%ebp
8007e9: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for (n = 0; *s != '\0'; s++)
8007ec: b8 00 00 00 00 mov $0x0,%eax
8007f1: eb 03 jmp 8007f6 <strlen+0x10>
n++;
8007f3: 83 c0 01 add $0x1,%eax
for (n = 0; *s != '\0'; s++)
8007f6: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
8007fa: 75 f7 jne 8007f3 <strlen+0xd>
return n;
}
8007fc: 5d pop %ebp
8007fd: c3 ret
008007fe <strnlen>:
int
strnlen(const char *s, size_t size)
{
8007fe: 55 push %ebp
8007ff: 89 e5 mov %esp,%ebp
800801: 8b 4d 08 mov 0x8(%ebp),%ecx
800804: 8b 55 0c mov 0xc(%ebp),%edx
int n;
for (n = 0; size > 0 && *s != '\0'; s++, size--)
800807: b8 00 00 00 00 mov $0x0,%eax
80080c: eb 03 jmp 800811 <strnlen+0x13>
n++;
80080e: 83 c0 01 add $0x1,%eax
for (n = 0; size > 0 && *s != '\0'; s++, size--)
800811: 39 d0 cmp %edx,%eax
800813: 74 06 je 80081b <strnlen+0x1d>
800815: 80 3c 01 00 cmpb $0x0,(%ecx,%eax,1)
800819: 75 f3 jne 80080e <strnlen+0x10>
return n;
}
80081b: 5d pop %ebp
80081c: c3 ret
0080081d <strcpy>:
char *
strcpy(char *dst, const char *src)
{
80081d: 55 push %ebp
80081e: 89 e5 mov %esp,%ebp
800820: 53 push %ebx
800821: 8b 45 08 mov 0x8(%ebp),%eax
800824: 8b 4d 0c mov 0xc(%ebp),%ecx
char *ret;
ret = dst;
while ((*dst++ = *src++) != '\0')
800827: 89 c2 mov %eax,%edx
800829: 83 c1 01 add $0x1,%ecx
80082c: 83 c2 01 add $0x1,%edx
80082f: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
800833: 88 5a ff mov %bl,-0x1(%edx)
800836: 84 db test %bl,%bl
800838: 75 ef jne 800829 <strcpy+0xc>
/* do nothing */;
return ret;
}
80083a: 5b pop %ebx
80083b: 5d pop %ebp
80083c: c3 ret
0080083d <strcat>:
char *
strcat(char *dst, const char *src)
{
80083d: 55 push %ebp
80083e: 89 e5 mov %esp,%ebp
800840: 53 push %ebx
800841: 8b 5d 08 mov 0x8(%ebp),%ebx
int len = strlen(dst);
800844: 53 push %ebx
800845: e8 9c ff ff ff call 8007e6 <strlen>
80084a: 83 c4 04 add $0x4,%esp
strcpy(dst + len, src);
80084d: ff 75 0c pushl 0xc(%ebp)
800850: 01 d8 add %ebx,%eax
800852: 50 push %eax
800853: e8 c5 ff ff ff call 80081d <strcpy>
return dst;
}
800858: 89 d8 mov %ebx,%eax
80085a: 8b 5d fc mov -0x4(%ebp),%ebx
80085d: c9 leave
80085e: c3 ret
0080085f <strncpy>:
char *
strncpy(char *dst, const char *src, size_t size) {
80085f: 55 push %ebp
800860: 89 e5 mov %esp,%ebp
800862: 56 push %esi
800863: 53 push %ebx
800864: 8b 75 08 mov 0x8(%ebp),%esi
800867: 8b 4d 0c mov 0xc(%ebp),%ecx
80086a: 89 f3 mov %esi,%ebx
80086c: 03 5d 10 add 0x10(%ebp),%ebx
size_t i;
char *ret;
ret = dst;
for (i = 0; i < size; i++) {
80086f: 89 f2 mov %esi,%edx
800871: eb 0f jmp 800882 <strncpy+0x23>
*dst++ = *src;
800873: 83 c2 01 add $0x1,%edx
800876: 0f b6 01 movzbl (%ecx),%eax
800879: 88 42 ff mov %al,-0x1(%edx)
// If strlen(src) < size, null-pad 'dst' out to 'size' chars
if (*src != '\0')
src++;
80087c: 80 39 01 cmpb $0x1,(%ecx)
80087f: 83 d9 ff sbb $0xffffffff,%ecx
for (i = 0; i < size; i++) {
800882: 39 da cmp %ebx,%edx
800884: 75 ed jne 800873 <strncpy+0x14>
}
return ret;
}
800886: 89 f0 mov %esi,%eax
800888: 5b pop %ebx
800889: 5e pop %esi
80088a: 5d pop %ebp
80088b: c3 ret
0080088c <strlcpy>:
size_t
strlcpy(char *dst, const char *src, size_t size)
{
80088c: 55 push %ebp
80088d: 89 e5 mov %esp,%ebp
80088f: 56 push %esi
800890: 53 push %ebx
800891: 8b 75 08 mov 0x8(%ebp),%esi
800894: 8b 55 0c mov 0xc(%ebp),%edx
800897: 8b 4d 10 mov 0x10(%ebp),%ecx
80089a: 89 f0 mov %esi,%eax
80089c: 8d 5c 0e ff lea -0x1(%esi,%ecx,1),%ebx
char *dst_in;
dst_in = dst;
if (size > 0) {
8008a0: 85 c9 test %ecx,%ecx
8008a2: 75 0b jne 8008af <strlcpy+0x23>
8008a4: eb 17 jmp 8008bd <strlcpy+0x31>
while (--size > 0 && *src != '\0')
*dst++ = *src++;
8008a6: 83 c2 01 add $0x1,%edx
8008a9: 83 c0 01 add $0x1,%eax
8008ac: 88 48 ff mov %cl,-0x1(%eax)
while (--size > 0 && *src != '\0')
8008af: 39 d8 cmp %ebx,%eax
8008b1: 74 07 je 8008ba <strlcpy+0x2e>
8008b3: 0f b6 0a movzbl (%edx),%ecx
8008b6: 84 c9 test %cl,%cl
8008b8: 75 ec jne 8008a6 <strlcpy+0x1a>
*dst = '\0';
8008ba: c6 00 00 movb $0x0,(%eax)
}
return dst - dst_in;
8008bd: 29 f0 sub %esi,%eax
}
8008bf: 5b pop %ebx
8008c0: 5e pop %esi
8008c1: 5d pop %ebp
8008c2: c3 ret
008008c3 <strcmp>:
int
strcmp(const char *p, const char *q)
{
8008c3: 55 push %ebp
8008c4: 89 e5 mov %esp,%ebp
8008c6: 8b 4d 08 mov 0x8(%ebp),%ecx
8008c9: 8b 55 0c mov 0xc(%ebp),%edx
while (*p && *p == *q)
8008cc: eb 06 jmp 8008d4 <strcmp+0x11>
p++, q++;
8008ce: 83 c1 01 add $0x1,%ecx
8008d1: 83 c2 01 add $0x1,%edx
while (*p && *p == *q)
8008d4: 0f b6 01 movzbl (%ecx),%eax
8008d7: 84 c0 test %al,%al
8008d9: 74 04 je 8008df <strcmp+0x1c>
8008db: 3a 02 cmp (%edx),%al
8008dd: 74 ef je 8008ce <strcmp+0xb>
return (int) ((unsigned char) *p - (unsigned char) *q);
8008df: 0f b6 c0 movzbl %al,%eax
8008e2: 0f b6 12 movzbl (%edx),%edx
8008e5: 29 d0 sub %edx,%eax
}
8008e7: 5d pop %ebp
8008e8: c3 ret
008008e9 <strncmp>:
int
strncmp(const char *p, const char *q, size_t n)
{
8008e9: 55 push %ebp
8008ea: 89 e5 mov %esp,%ebp
8008ec: 53 push %ebx
8008ed: 8b 45 08 mov 0x8(%ebp),%eax
8008f0: 8b 55 0c mov 0xc(%ebp),%edx
8008f3: 89 c3 mov %eax,%ebx
8008f5: 03 5d 10 add 0x10(%ebp),%ebx
while (n > 0 && *p && *p == *q)
8008f8: eb 06 jmp 800900 <strncmp+0x17>
n--, p++, q++;
8008fa: 83 c0 01 add $0x1,%eax
8008fd: 83 c2 01 add $0x1,%edx
while (n > 0 && *p && *p == *q)
800900: 39 d8 cmp %ebx,%eax
800902: 74 16 je 80091a <strncmp+0x31>
800904: 0f b6 08 movzbl (%eax),%ecx
800907: 84 c9 test %cl,%cl
800909: 74 04 je 80090f <strncmp+0x26>
80090b: 3a 0a cmp (%edx),%cl
80090d: 74 eb je 8008fa <strncmp+0x11>
if (n == 0)
return 0;
else
return (int) ((unsigned char) *p - (unsigned char) *q);
80090f: 0f b6 00 movzbl (%eax),%eax
800912: 0f b6 12 movzbl (%edx),%edx
800915: 29 d0 sub %edx,%eax
}
800917: 5b pop %ebx
800918: 5d pop %ebp
800919: c3 ret
return 0;
80091a: b8 00 00 00 00 mov $0x0,%eax
80091f: eb f6 jmp 800917 <strncmp+0x2e>
00800921 <strchr>:
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
800921: 55 push %ebp
800922: 89 e5 mov %esp,%ebp
800924: 8b 45 08 mov 0x8(%ebp),%eax
800927: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for (; *s; s++)
80092b: 0f b6 10 movzbl (%eax),%edx
80092e: 84 d2 test %dl,%dl
800930: 74 09 je 80093b <strchr+0x1a>
if (*s == c)
800932: 38 ca cmp %cl,%dl
800934: 74 0a je 800940 <strchr+0x1f>
for (; *s; s++)
800936: 83 c0 01 add $0x1,%eax
800939: eb f0 jmp 80092b <strchr+0xa>
return (char *) s;
return 0;
80093b: b8 00 00 00 00 mov $0x0,%eax
}
800940: 5d pop %ebp
800941: c3 ret
00800942 <strfind>:
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
800942: 55 push %ebp
800943: 89 e5 mov %esp,%ebp
800945: 8b 45 08 mov 0x8(%ebp),%eax
800948: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for (; *s; s++)
80094c: eb 03 jmp 800951 <strfind+0xf>
80094e: 83 c0 01 add $0x1,%eax
800951: 0f b6 10 movzbl (%eax),%edx
if (*s == c)
800954: 38 ca cmp %cl,%dl
800956: 74 04 je 80095c <strfind+0x1a>
800958: 84 d2 test %dl,%dl
80095a: 75 f2 jne 80094e <strfind+0xc>
break;
return (char *) s;
}
80095c: 5d pop %ebp
80095d: c3 ret
0080095e <memset>:
#if ASM
void *
memset(void *v, int c, size_t n)
{
80095e: 55 push %ebp
80095f: 89 e5 mov %esp,%ebp
800961: 57 push %edi
800962: 56 push %esi
800963: 53 push %ebx
800964: 8b 7d 08 mov 0x8(%ebp),%edi
800967: 8b 4d 10 mov 0x10(%ebp),%ecx
char *p;
if (n == 0)
80096a: 85 c9 test %ecx,%ecx
80096c: 74 13 je 800981 <memset+0x23>
return v;
if ((int)v%4 == 0 && n%4 == 0) {
80096e: f7 c7 03 00 00 00 test $0x3,%edi
800974: 75 05 jne 80097b <memset+0x1d>
800976: f6 c1 03 test $0x3,%cl
800979: 74 0d je 800988 <memset+0x2a>
c = (c<<24)|(c<<16)|(c<<8)|c;
asm volatile("cld; rep stosl\n"
:: "D" (v), "a" (c), "c" (n/4)
: "cc", "memory");
} else
asm volatile("cld; rep stosb\n"
80097b: 8b 45 0c mov 0xc(%ebp),%eax
80097e: fc cld
80097f: f3 aa rep stos %al,%es:(%edi)
:: "D" (v), "a" (c), "c" (n)
: "cc", "memory");
return v;
}
800981: 89 f8 mov %edi,%eax
800983: 5b pop %ebx
800984: 5e pop %esi
800985: 5f pop %edi
800986: 5d pop %ebp
800987: c3 ret
c &= 0xFF;
800988: 0f b6 55 0c movzbl 0xc(%ebp),%edx
c = (c<<24)|(c<<16)|(c<<8)|c;
80098c: 89 d3 mov %edx,%ebx
80098e: c1 e3 08 shl $0x8,%ebx
800991: 89 d0 mov %edx,%eax
800993: c1 e0 18 shl $0x18,%eax
800996: 89 d6 mov %edx,%esi
800998: c1 e6 10 shl $0x10,%esi
80099b: 09 f0 or %esi,%eax
80099d: 09 c2 or %eax,%edx
80099f: 09 da or %ebx,%edx
:: "D" (v), "a" (c), "c" (n/4)
8009a1: c1 e9 02 shr $0x2,%ecx
asm volatile("cld; rep stosl\n"
8009a4: 89 d0 mov %edx,%eax
8009a6: fc cld
8009a7: f3 ab rep stos %eax,%es:(%edi)
8009a9: eb d6 jmp 800981 <memset+0x23>
008009ab <memmove>:
void *
memmove(void *dst, const void *src, size_t n)
{
8009ab: 55 push %ebp
8009ac: 89 e5 mov %esp,%ebp
8009ae: 57 push %edi
8009af: 56 push %esi
8009b0: 8b 45 08 mov 0x8(%ebp),%eax
8009b3: 8b 75 0c mov 0xc(%ebp),%esi
8009b6: 8b 4d 10 mov 0x10(%ebp),%ecx
const char *s;
char *d;
s = src;
d = dst;
if (s < d && s + n > d) {
8009b9: 39 c6 cmp %eax,%esi
8009bb: 73 35 jae 8009f2 <memmove+0x47>
8009bd: 8d 14 0e lea (%esi,%ecx,1),%edx
8009c0: 39 c2 cmp %eax,%edx
8009c2: 76 2e jbe 8009f2 <memmove+0x47>
s += n;
d += n;
8009c4: 8d 3c 08 lea (%eax,%ecx,1),%edi
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
8009c7: 89 d6 mov %edx,%esi
8009c9: 09 fe or %edi,%esi
8009cb: f7 c6 03 00 00 00 test $0x3,%esi
8009d1: 74 0c je 8009df <memmove+0x34>
asm volatile("std; rep movsl\n"
:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
else
asm volatile("std; rep movsb\n"
:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
8009d3: 83 ef 01 sub $0x1,%edi
8009d6: 8d 72 ff lea -0x1(%edx),%esi
asm volatile("std; rep movsb\n"
8009d9: fd std
8009da: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
// Some versions of GCC rely on DF being clear
asm volatile("cld" ::: "cc");
8009dc: fc cld
8009dd: eb 21 jmp 800a00 <memmove+0x55>
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
8009df: f6 c1 03 test $0x3,%cl
8009e2: 75 ef jne 8009d3 <memmove+0x28>
:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
8009e4: 83 ef 04 sub $0x4,%edi
8009e7: 8d 72 fc lea -0x4(%edx),%esi
8009ea: c1 e9 02 shr $0x2,%ecx
asm volatile("std; rep movsl\n"
8009ed: fd std
8009ee: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
8009f0: eb ea jmp 8009dc <memmove+0x31>
} else {
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
8009f2: 89 f2 mov %esi,%edx
8009f4: 09 c2 or %eax,%edx
8009f6: f6 c2 03 test $0x3,%dl
8009f9: 74 09 je 800a04 <memmove+0x59>
asm volatile("cld; rep movsl\n"
:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
else
asm volatile("cld; rep movsb\n"
8009fb: 89 c7 mov %eax,%edi
8009fd: fc cld
8009fe: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
}
return dst;
}
800a00: 5e pop %esi
800a01: 5f pop %edi
800a02: 5d pop %ebp
800a03: c3 ret
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
800a04: f6 c1 03 test $0x3,%cl
800a07: 75 f2 jne 8009fb <memmove+0x50>
:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
800a09: c1 e9 02 shr $0x2,%ecx
asm volatile("cld; rep movsl\n"
800a0c: 89 c7 mov %eax,%edi
800a0e: fc cld
800a0f: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
800a11: eb ed jmp 800a00 <memmove+0x55>
00800a13 <memcpy>:
}
#endif
void *
memcpy(void *dst, const void *src, size_t n)
{
800a13: 55 push %ebp
800a14: 89 e5 mov %esp,%ebp
return memmove(dst, src, n);
800a16: ff 75 10 pushl 0x10(%ebp)
800a19: ff 75 0c pushl 0xc(%ebp)
800a1c: ff 75 08 pushl 0x8(%ebp)
800a1f: e8 87 ff ff ff call 8009ab <memmove>
}
800a24: c9 leave
800a25: c3 ret
00800a26 <memcmp>:
int
memcmp(const void *v1, const void *v2, size_t n)
{
800a26: 55 push %ebp
800a27: 89 e5 mov %esp,%ebp
800a29: 56 push %esi
800a2a: 53 push %ebx
800a2b: 8b 45 08 mov 0x8(%ebp),%eax
800a2e: 8b 55 0c mov 0xc(%ebp),%edx
800a31: 89 c6 mov %eax,%esi
800a33: 03 75 10 add 0x10(%ebp),%esi
const uint8_t *s1 = (const uint8_t *) v1;
const uint8_t *s2 = (const uint8_t *) v2;
while (n-- > 0) {
800a36: 39 f0 cmp %esi,%eax
800a38: 74 1c je 800a56 <memcmp+0x30>
if (*s1 != *s2)
800a3a: 0f b6 08 movzbl (%eax),%ecx
800a3d: 0f b6 1a movzbl (%edx),%ebx
800a40: 38 d9 cmp %bl,%cl
800a42: 75 08 jne 800a4c <memcmp+0x26>
return (int) *s1 - (int) *s2;
s1++, s2++;
800a44: 83 c0 01 add $0x1,%eax
800a47: 83 c2 01 add $0x1,%edx
800a4a: eb ea jmp 800a36 <memcmp+0x10>
return (int) *s1 - (int) *s2;
800a4c: 0f b6 c1 movzbl %cl,%eax
800a4f: 0f b6 db movzbl %bl,%ebx
800a52: 29 d8 sub %ebx,%eax
800a54: eb 05 jmp 800a5b <memcmp+0x35>
}
return 0;
800a56: b8 00 00 00 00 mov $0x0,%eax
}
800a5b: 5b pop %ebx
800a5c: 5e pop %esi
800a5d: 5d pop %ebp
800a5e: c3 ret
00800a5f <memfind>:
void *
memfind(const void *s, int c, size_t n)
{
800a5f: 55 push %ebp
800a60: 89 e5 mov %esp,%ebp
800a62: 8b 45 08 mov 0x8(%ebp),%eax
800a65: 8b 4d 0c mov 0xc(%ebp),%ecx
const void *ends = (const char *) s + n;
800a68: 89 c2 mov %eax,%edx
800a6a: 03 55 10 add 0x10(%ebp),%edx
for (; s < ends; s++)
800a6d: 39 d0 cmp %edx,%eax
800a6f: 73 09 jae 800a7a <memfind+0x1b>
if (*(const unsigned char *) s == (unsigned char) c)
800a71: 38 08 cmp %cl,(%eax)
800a73: 74 05 je 800a7a <memfind+0x1b>
for (; s < ends; s++)
800a75: 83 c0 01 add $0x1,%eax
800a78: eb f3 jmp 800a6d <memfind+0xe>
break;
return (void *) s;
}
800a7a: 5d pop %ebp
800a7b: c3 ret
00800a7c <strtol>:
long
strtol(const char *s, char **endptr, int base)
{
800a7c: 55 push %ebp
800a7d: 89 e5 mov %esp,%ebp
800a7f: 57 push %edi
800a80: 56 push %esi
800a81: 53 push %ebx
800a82: 8b 4d 08 mov 0x8(%ebp),%ecx
800a85: 8b 5d 10 mov 0x10(%ebp),%ebx
int neg = 0;
long val = 0;
// gobble initial whitespace
while (*s == ' ' || *s == '\t')
800a88: eb 03 jmp 800a8d <strtol+0x11>
s++;
800a8a: 83 c1 01 add $0x1,%ecx
while (*s == ' ' || *s == '\t')
800a8d: 0f b6 01 movzbl (%ecx),%eax
800a90: 3c 20 cmp $0x20,%al
800a92: 74 f6 je 800a8a <strtol+0xe>
800a94: 3c 09 cmp $0x9,%al
800a96: 74 f2 je 800a8a <strtol+0xe>
// plus/minus sign
if (*s == '+')
800a98: 3c 2b cmp $0x2b,%al
800a9a: 74 2e je 800aca <strtol+0x4e>
int neg = 0;
800a9c: bf 00 00 00 00 mov $0x0,%edi
s++;
else if (*s == '-')
800aa1: 3c 2d cmp $0x2d,%al
800aa3: 74 2f je 800ad4 <strtol+0x58>
s++, neg = 1;
// hex or octal base prefix
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
800aa5: f7 c3 ef ff ff ff test $0xffffffef,%ebx
800aab: 75 05 jne 800ab2 <strtol+0x36>
800aad: 80 39 30 cmpb $0x30,(%ecx)
800ab0: 74 2c je 800ade <strtol+0x62>
s += 2, base = 16;
else if (base == 0 && s[0] == '0')
800ab2: 85 db test %ebx,%ebx
800ab4: 75 0a jne 800ac0 <strtol+0x44>
s++, base = 8;
else if (base == 0)
base = 10;
800ab6: bb 0a 00 00 00 mov $0xa,%ebx
else if (base == 0 && s[0] == '0')
800abb: 80 39 30 cmpb $0x30,(%ecx)
800abe: 74 28 je 800ae8 <strtol+0x6c>
base = 10;
800ac0: b8 00 00 00 00 mov $0x0,%eax
800ac5: 89 5d 10 mov %ebx,0x10(%ebp)
800ac8: eb 50 jmp 800b1a <strtol+0x9e>
s++;
800aca: 83 c1 01 add $0x1,%ecx
int neg = 0;
800acd: bf 00 00 00 00 mov $0x0,%edi
800ad2: eb d1 jmp 800aa5 <strtol+0x29>
s++, neg = 1;
800ad4: 83 c1 01 add $0x1,%ecx
800ad7: bf 01 00 00 00 mov $0x1,%edi
800adc: eb c7 jmp 800aa5 <strtol+0x29>
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
800ade: 80 79 01 78 cmpb $0x78,0x1(%ecx)
800ae2: 74 0e je 800af2 <strtol+0x76>
else if (base == 0 && s[0] == '0')
800ae4: 85 db test %ebx,%ebx
800ae6: 75 d8 jne 800ac0 <strtol+0x44>
s++, base = 8;
800ae8: 83 c1 01 add $0x1,%ecx
800aeb: bb 08 00 00 00 mov $0x8,%ebx
800af0: eb ce jmp 800ac0 <strtol+0x44>
s += 2, base = 16;
800af2: 83 c1 02 add $0x2,%ecx
800af5: bb 10 00 00 00 mov $0x10,%ebx
800afa: eb c4 jmp 800ac0 <strtol+0x44>
while (1) {
int dig;
if (*s >= '0' && *s <= '9')
dig = *s - '0';
else if (*s >= 'a' && *s <= 'z')
800afc: 8d 72 9f lea -0x61(%edx),%esi
800aff: 89 f3 mov %esi,%ebx
800b01: 80 fb 19 cmp $0x19,%bl
800b04: 77 29 ja 800b2f <strtol+0xb3>
dig = *s - 'a' + 10;
800b06: 0f be d2 movsbl %dl,%edx
800b09: 83 ea 57 sub $0x57,%edx
else if (*s >= 'A' && *s <= 'Z')
dig = *s - 'A' + 10;
else
break;
if (dig >= base)
800b0c: 3b 55 10 cmp 0x10(%ebp),%edx
800b0f: 7d 30 jge 800b41 <strtol+0xc5>
break;
s++, val = (val * base) + dig;
800b11: 83 c1 01 add $0x1,%ecx
800b14: 0f af 45 10 imul 0x10(%ebp),%eax
800b18: 01 d0 add %edx,%eax
if (*s >= '0' && *s <= '9')
800b1a: 0f b6 11 movzbl (%ecx),%edx
800b1d: 8d 72 d0 lea -0x30(%edx),%esi
800b20: 89 f3 mov %esi,%ebx
800b22: 80 fb 09 cmp $0x9,%bl
800b25: 77 d5 ja 800afc <strtol+0x80>
dig = *s - '0';
800b27: 0f be d2 movsbl %dl,%edx
800b2a: 83 ea 30 sub $0x30,%edx
800b2d: eb dd jmp 800b0c <strtol+0x90>
else if (*s >= 'A' && *s <= 'Z')
800b2f: 8d 72 bf lea -0x41(%edx),%esi
800b32: 89 f3 mov %esi,%ebx
800b34: 80 fb 19 cmp $0x19,%bl
800b37: 77 08 ja 800b41 <strtol+0xc5>
dig = *s - 'A' + 10;
800b39: 0f be d2 movsbl %dl,%edx
800b3c: 83 ea 37 sub $0x37,%edx
800b3f: eb cb jmp 800b0c <strtol+0x90>
// we don't properly detect overflow!
}
if (endptr)
800b41: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
800b45: 74 05 je 800b4c <strtol+0xd0>
*endptr = (char *) s;
800b47: 8b 75 0c mov 0xc(%ebp),%esi
800b4a: 89 0e mov %ecx,(%esi)
return (neg ? -val : val);
800b4c: 89 c2 mov %eax,%edx
800b4e: f7 da neg %edx
800b50: 85 ff test %edi,%edi
800b52: 0f 45 c2 cmovne %edx,%eax
}
800b55: 5b pop %ebx
800b56: 5e pop %esi
800b57: 5f pop %edi
800b58: 5d pop %ebp
800b59: c3 ret
00800b5a <sys_cputs>:
return ret;
}
void
sys_cputs(const char *s, size_t len)
{
800b5a: 55 push %ebp
800b5b: 89 e5 mov %esp,%ebp
800b5d: 57 push %edi
800b5e: 56 push %esi
800b5f: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800b60: b8 00 00 00 00 mov $0x0,%eax
800b65: 8b 55 08 mov 0x8(%ebp),%edx
800b68: 8b 4d 0c mov 0xc(%ebp),%ecx
800b6b: 89 c3 mov %eax,%ebx
800b6d: 89 c7 mov %eax,%edi
800b6f: 89 c6 mov %eax,%esi
800b71: cd 30 int $0x30
syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
800b73: 5b pop %ebx
800b74: 5e pop %esi
800b75: 5f pop %edi
800b76: 5d pop %ebp
800b77: c3 ret
00800b78 <sys_cgetc>:
int
sys_cgetc(void)
{
800b78: 55 push %ebp
800b79: 89 e5 mov %esp,%ebp
800b7b: 57 push %edi
800b7c: 56 push %esi
800b7d: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800b7e: ba 00 00 00 00 mov $0x0,%edx
800b83: b8 01 00 00 00 mov $0x1,%eax
800b88: 89 d1 mov %edx,%ecx
800b8a: 89 d3 mov %edx,%ebx
800b8c: 89 d7 mov %edx,%edi
800b8e: 89 d6 mov %edx,%esi
800b90: cd 30 int $0x30
return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
800b92: 5b pop %ebx
800b93: 5e pop %esi
800b94: 5f pop %edi
800b95: 5d pop %ebp
800b96: c3 ret
00800b97 <sys_env_destroy>:
int
sys_env_destroy(envid_t envid)
{
800b97: 55 push %ebp
800b98: 89 e5 mov %esp,%ebp
800b9a: 57 push %edi
800b9b: 56 push %esi
800b9c: 53 push %ebx
800b9d: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800ba0: b9 00 00 00 00 mov $0x0,%ecx
800ba5: 8b 55 08 mov 0x8(%ebp),%edx
800ba8: b8 03 00 00 00 mov $0x3,%eax
800bad: 89 cb mov %ecx,%ebx
800baf: 89 cf mov %ecx,%edi
800bb1: 89 ce mov %ecx,%esi
800bb3: cd 30 int $0x30
if(check && ret > 0)
800bb5: 85 c0 test %eax,%eax
800bb7: 7f 08 jg 800bc1 <sys_env_destroy+0x2a>
return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
800bb9: 8d 65 f4 lea -0xc(%ebp),%esp
800bbc: 5b pop %ebx
800bbd: 5e pop %esi
800bbe: 5f pop %edi
800bbf: 5d pop %ebp
800bc0: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800bc1: 83 ec 0c sub $0xc,%esp
800bc4: 50 push %eax
800bc5: 6a 03 push $0x3
800bc7: 68 7f 24 80 00 push $0x80247f
800bcc: 6a 23 push $0x23
800bce: 68 9c 24 80 00 push $0x80249c
800bd3: e8 9c 11 00 00 call 801d74 <_panic>
00800bd8 <sys_getenvid>:
envid_t
sys_getenvid(void)
{
800bd8: 55 push %ebp
800bd9: 89 e5 mov %esp,%ebp
800bdb: 57 push %edi
800bdc: 56 push %esi
800bdd: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800bde: ba 00 00 00 00 mov $0x0,%edx
800be3: b8 02 00 00 00 mov $0x2,%eax
800be8: 89 d1 mov %edx,%ecx
800bea: 89 d3 mov %edx,%ebx
800bec: 89 d7 mov %edx,%edi
800bee: 89 d6 mov %edx,%esi
800bf0: cd 30 int $0x30
return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
800bf2: 5b pop %ebx
800bf3: 5e pop %esi
800bf4: 5f pop %edi
800bf5: 5d pop %ebp
800bf6: c3 ret
00800bf7 <sys_yield>:
void
sys_yield(void)
{
800bf7: 55 push %ebp
800bf8: 89 e5 mov %esp,%ebp
800bfa: 57 push %edi
800bfb: 56 push %esi
800bfc: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800bfd: ba 00 00 00 00 mov $0x0,%edx
800c02: b8 0b 00 00 00 mov $0xb,%eax
800c07: 89 d1 mov %edx,%ecx
800c09: 89 d3 mov %edx,%ebx
800c0b: 89 d7 mov %edx,%edi
800c0d: 89 d6 mov %edx,%esi
800c0f: cd 30 int $0x30
syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
800c11: 5b pop %ebx
800c12: 5e pop %esi
800c13: 5f pop %edi
800c14: 5d pop %ebp
800c15: c3 ret
00800c16 <sys_page_alloc>:
int
sys_page_alloc(envid_t envid, void *va, int perm)
{
800c16: 55 push %ebp
800c17: 89 e5 mov %esp,%ebp
800c19: 57 push %edi
800c1a: 56 push %esi
800c1b: 53 push %ebx
800c1c: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800c1f: be 00 00 00 00 mov $0x0,%esi
800c24: 8b 55 08 mov 0x8(%ebp),%edx
800c27: 8b 4d 0c mov 0xc(%ebp),%ecx
800c2a: b8 04 00 00 00 mov $0x4,%eax
800c2f: 8b 5d 10 mov 0x10(%ebp),%ebx
800c32: 89 f7 mov %esi,%edi
800c34: cd 30 int $0x30
if(check && ret > 0)
800c36: 85 c0 test %eax,%eax
800c38: 7f 08 jg 800c42 <sys_page_alloc+0x2c>
return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
800c3a: 8d 65 f4 lea -0xc(%ebp),%esp
800c3d: 5b pop %ebx
800c3e: 5e pop %esi
800c3f: 5f pop %edi
800c40: 5d pop %ebp
800c41: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800c42: 83 ec 0c sub $0xc,%esp
800c45: 50 push %eax
800c46: 6a 04 push $0x4
800c48: 68 7f 24 80 00 push $0x80247f
800c4d: 6a 23 push $0x23
800c4f: 68 9c 24 80 00 push $0x80249c
800c54: e8 1b 11 00 00 call 801d74 <_panic>
00800c59 <sys_page_map>:
int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
800c59: 55 push %ebp
800c5a: 89 e5 mov %esp,%ebp
800c5c: 57 push %edi
800c5d: 56 push %esi
800c5e: 53 push %ebx
800c5f: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800c62: 8b 55 08 mov 0x8(%ebp),%edx
800c65: 8b 4d 0c mov 0xc(%ebp),%ecx
800c68: b8 05 00 00 00 mov $0x5,%eax
800c6d: 8b 5d 10 mov 0x10(%ebp),%ebx
800c70: 8b 7d 14 mov 0x14(%ebp),%edi
800c73: 8b 75 18 mov 0x18(%ebp),%esi
800c76: cd 30 int $0x30
if(check && ret > 0)
800c78: 85 c0 test %eax,%eax
800c7a: 7f 08 jg 800c84 <sys_page_map+0x2b>
return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
800c7c: 8d 65 f4 lea -0xc(%ebp),%esp
800c7f: 5b pop %ebx
800c80: 5e pop %esi
800c81: 5f pop %edi
800c82: 5d pop %ebp
800c83: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800c84: 83 ec 0c sub $0xc,%esp
800c87: 50 push %eax
800c88: 6a 05 push $0x5
800c8a: 68 7f 24 80 00 push $0x80247f
800c8f: 6a 23 push $0x23
800c91: 68 9c 24 80 00 push $0x80249c
800c96: e8 d9 10 00 00 call 801d74 <_panic>
00800c9b <sys_page_unmap>:
int
sys_page_unmap(envid_t envid, void *va)
{
800c9b: 55 push %ebp
800c9c: 89 e5 mov %esp,%ebp
800c9e: 57 push %edi
800c9f: 56 push %esi
800ca0: 53 push %ebx
800ca1: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800ca4: bb 00 00 00 00 mov $0x0,%ebx
800ca9: 8b 55 08 mov 0x8(%ebp),%edx
800cac: 8b 4d 0c mov 0xc(%ebp),%ecx
800caf: b8 06 00 00 00 mov $0x6,%eax
800cb4: 89 df mov %ebx,%edi
800cb6: 89 de mov %ebx,%esi
800cb8: cd 30 int $0x30
if(check && ret > 0)
800cba: 85 c0 test %eax,%eax
800cbc: 7f 08 jg 800cc6 <sys_page_unmap+0x2b>
return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
800cbe: 8d 65 f4 lea -0xc(%ebp),%esp
800cc1: 5b pop %ebx
800cc2: 5e pop %esi
800cc3: 5f pop %edi
800cc4: 5d pop %ebp
800cc5: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800cc6: 83 ec 0c sub $0xc,%esp
800cc9: 50 push %eax
800cca: 6a 06 push $0x6
800ccc: 68 7f 24 80 00 push $0x80247f
800cd1: 6a 23 push $0x23
800cd3: 68 9c 24 80 00 push $0x80249c
800cd8: e8 97 10 00 00 call 801d74 <_panic>
00800cdd <sys_env_set_status>:
// sys_exofork is inlined in lib.h
int
sys_env_set_status(envid_t envid, int status)
{
800cdd: 55 push %ebp
800cde: 89 e5 mov %esp,%ebp
800ce0: 57 push %edi
800ce1: 56 push %esi
800ce2: 53 push %ebx
800ce3: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800ce6: bb 00 00 00 00 mov $0x0,%ebx
800ceb: 8b 55 08 mov 0x8(%ebp),%edx
800cee: 8b 4d 0c mov 0xc(%ebp),%ecx
800cf1: b8 08 00 00 00 mov $0x8,%eax
800cf6: 89 df mov %ebx,%edi
800cf8: 89 de mov %ebx,%esi
800cfa: cd 30 int $0x30
if(check && ret > 0)
800cfc: 85 c0 test %eax,%eax
800cfe: 7f 08 jg 800d08 <sys_env_set_status+0x2b>
return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
800d00: 8d 65 f4 lea -0xc(%ebp),%esp
800d03: 5b pop %ebx
800d04: 5e pop %esi
800d05: 5f pop %edi
800d06: 5d pop %ebp
800d07: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800d08: 83 ec 0c sub $0xc,%esp
800d0b: 50 push %eax
800d0c: 6a 08 push $0x8
800d0e: 68 7f 24 80 00 push $0x80247f
800d13: 6a 23 push $0x23
800d15: 68 9c 24 80 00 push $0x80249c
800d1a: e8 55 10 00 00 call 801d74 <_panic>
00800d1f <sys_env_set_trapframe>:
int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
800d1f: 55 push %ebp
800d20: 89 e5 mov %esp,%ebp
800d22: 57 push %edi
800d23: 56 push %esi
800d24: 53 push %ebx
800d25: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800d28: bb 00 00 00 00 mov $0x0,%ebx
800d2d: 8b 55 08 mov 0x8(%ebp),%edx
800d30: 8b 4d 0c mov 0xc(%ebp),%ecx
800d33: b8 09 00 00 00 mov $0x9,%eax
800d38: 89 df mov %ebx,%edi
800d3a: 89 de mov %ebx,%esi
800d3c: cd 30 int $0x30
if(check && ret > 0)
800d3e: 85 c0 test %eax,%eax
800d40: 7f 08 jg 800d4a <sys_env_set_trapframe+0x2b>
return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
800d42: 8d 65 f4 lea -0xc(%ebp),%esp
800d45: 5b pop %ebx
800d46: 5e pop %esi
800d47: 5f pop %edi
800d48: 5d pop %ebp
800d49: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800d4a: 83 ec 0c sub $0xc,%esp
800d4d: 50 push %eax
800d4e: 6a 09 push $0x9
800d50: 68 7f 24 80 00 push $0x80247f
800d55: 6a 23 push $0x23
800d57: 68 9c 24 80 00 push $0x80249c
800d5c: e8 13 10 00 00 call 801d74 <_panic>
00800d61 <sys_env_set_pgfault_upcall>:
int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
800d61: 55 push %ebp
800d62: 89 e5 mov %esp,%ebp
800d64: 57 push %edi
800d65: 56 push %esi
800d66: 53 push %ebx
800d67: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800d6a: bb 00 00 00 00 mov $0x0,%ebx
800d6f: 8b 55 08 mov 0x8(%ebp),%edx
800d72: 8b 4d 0c mov 0xc(%ebp),%ecx
800d75: b8 0a 00 00 00 mov $0xa,%eax
800d7a: 89 df mov %ebx,%edi
800d7c: 89 de mov %ebx,%esi
800d7e: cd 30 int $0x30
if(check && ret > 0)
800d80: 85 c0 test %eax,%eax
800d82: 7f 08 jg 800d8c <sys_env_set_pgfault_upcall+0x2b>
return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
800d84: 8d 65 f4 lea -0xc(%ebp),%esp
800d87: 5b pop %ebx
800d88: 5e pop %esi
800d89: 5f pop %edi
800d8a: 5d pop %ebp
800d8b: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800d8c: 83 ec 0c sub $0xc,%esp
800d8f: 50 push %eax
800d90: 6a 0a push $0xa
800d92: 68 7f 24 80 00 push $0x80247f
800d97: 6a 23 push $0x23
800d99: 68 9c 24 80 00 push $0x80249c
800d9e: e8 d1 0f 00 00 call 801d74 <_panic>
00800da3 <sys_ipc_try_send>:
int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
800da3: 55 push %ebp
800da4: 89 e5 mov %esp,%ebp
800da6: 57 push %edi
800da7: 56 push %esi
800da8: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800da9: 8b 55 08 mov 0x8(%ebp),%edx
800dac: 8b 4d 0c mov 0xc(%ebp),%ecx
800daf: b8 0c 00 00 00 mov $0xc,%eax
800db4: be 00 00 00 00 mov $0x0,%esi
800db9: 8b 5d 10 mov 0x10(%ebp),%ebx
800dbc: 8b 7d 14 mov 0x14(%ebp),%edi
800dbf: cd 30 int $0x30
return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
}
800dc1: 5b pop %ebx
800dc2: 5e pop %esi
800dc3: 5f pop %edi
800dc4: 5d pop %ebp
800dc5: c3 ret
00800dc6 <sys_ipc_recv>:
int
sys_ipc_recv(void *dstva)
{
800dc6: 55 push %ebp
800dc7: 89 e5 mov %esp,%ebp
800dc9: 57 push %edi
800dca: 56 push %esi
800dcb: 53 push %ebx
800dcc: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800dcf: b9 00 00 00 00 mov $0x0,%ecx
800dd4: 8b 55 08 mov 0x8(%ebp),%edx
800dd7: b8 0d 00 00 00 mov $0xd,%eax
800ddc: 89 cb mov %ecx,%ebx
800dde: 89 cf mov %ecx,%edi
800de0: 89 ce mov %ecx,%esi
800de2: cd 30 int $0x30
if(check && ret > 0)
800de4: 85 c0 test %eax,%eax
800de6: 7f 08 jg 800df0 <sys_ipc_recv+0x2a>
return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
800de8: 8d 65 f4 lea -0xc(%ebp),%esp
800deb: 5b pop %ebx
800dec: 5e pop %esi
800ded: 5f pop %edi
800dee: 5d pop %ebp
800def: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800df0: 83 ec 0c sub $0xc,%esp
800df3: 50 push %eax
800df4: 6a 0d push $0xd
800df6: 68 7f 24 80 00 push $0x80247f
800dfb: 6a 23 push $0x23
800dfd: 68 9c 24 80 00 push $0x80249c
800e02: e8 6d 0f 00 00 call 801d74 <_panic>
00800e07 <argstart>:
#include <inc/args.h>
#include <inc/string.h>
void
argstart(int *argc, char **argv, struct Argstate *args)
{
800e07: 55 push %ebp
800e08: 89 e5 mov %esp,%ebp
800e0a: 8b 55 08 mov 0x8(%ebp),%edx
800e0d: 8b 4d 0c mov 0xc(%ebp),%ecx
800e10: 8b 45 10 mov 0x10(%ebp),%eax
args->argc = argc;
800e13: 89 10 mov %edx,(%eax)
args->argv = (const char **) argv;
800e15: 89 48 04 mov %ecx,0x4(%eax)
args->curarg = (*argc > 1 && argv ? "" : 0);
800e18: 83 3a 01 cmpl $0x1,(%edx)
800e1b: 7e 09 jle 800e26 <argstart+0x1f>
800e1d: ba 51 21 80 00 mov $0x802151,%edx
800e22: 85 c9 test %ecx,%ecx
800e24: 75 05 jne 800e2b <argstart+0x24>
800e26: ba 00 00 00 00 mov $0x0,%edx
800e2b: 89 50 08 mov %edx,0x8(%eax)
args->argvalue = 0;
800e2e: c7 40 0c 00 00 00 00 movl $0x0,0xc(%eax)
}
800e35: 5d pop %ebp
800e36: c3 ret
00800e37 <argnext>:
int
argnext(struct Argstate *args)
{
800e37: 55 push %ebp
800e38: 89 e5 mov %esp,%ebp
800e3a: 53 push %ebx
800e3b: 83 ec 04 sub $0x4,%esp
800e3e: 8b 5d 08 mov 0x8(%ebp),%ebx
int arg;
args->argvalue = 0;
800e41: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx)
// Done processing arguments if args->curarg == 0
if (args->curarg == 0)
800e48: 8b 43 08 mov 0x8(%ebx),%eax
800e4b: 85 c0 test %eax,%eax
800e4d: 74 72 je 800ec1 <argnext+0x8a>
return -1;
if (!*args->curarg) {
800e4f: 80 38 00 cmpb $0x0,(%eax)
800e52: 75 48 jne 800e9c <argnext+0x65>
// Need to process the next argument
// Check for end of argument list
if (*args->argc == 1
800e54: 8b 0b mov (%ebx),%ecx
800e56: 83 39 01 cmpl $0x1,(%ecx)
800e59: 74 58 je 800eb3 <argnext+0x7c>
|| args->argv[1][0] != '-'
800e5b: 8b 53 04 mov 0x4(%ebx),%edx
800e5e: 8b 42 04 mov 0x4(%edx),%eax
800e61: 80 38 2d cmpb $0x2d,(%eax)
800e64: 75 4d jne 800eb3 <argnext+0x7c>
|| args->argv[1][1] == '\0')
800e66: 80 78 01 00 cmpb $0x0,0x1(%eax)
800e6a: 74 47 je 800eb3 <argnext+0x7c>
goto endofargs;
// Shift arguments down one
args->curarg = args->argv[1] + 1;
800e6c: 83 c0 01 add $0x1,%eax
800e6f: 89 43 08 mov %eax,0x8(%ebx)
memmove(args->argv + 1, args->argv + 2, sizeof(const char *) * (*args->argc - 1));
800e72: 83 ec 04 sub $0x4,%esp
800e75: 8b 01 mov (%ecx),%eax
800e77: 8d 04 85 fc ff ff ff lea -0x4(,%eax,4),%eax
800e7e: 50 push %eax
800e7f: 8d 42 08 lea 0x8(%edx),%eax
800e82: 50 push %eax
800e83: 83 c2 04 add $0x4,%edx
800e86: 52 push %edx
800e87: e8 1f fb ff ff call 8009ab <memmove>
(*args->argc)--;
800e8c: 8b 03 mov (%ebx),%eax
800e8e: 83 28 01 subl $0x1,(%eax)
// Check for "--": end of argument list
if (args->curarg[0] == '-' && args->curarg[1] == '\0')
800e91: 8b 43 08 mov 0x8(%ebx),%eax
800e94: 83 c4 10 add $0x10,%esp
800e97: 80 38 2d cmpb $0x2d,(%eax)
800e9a: 74 11 je 800ead <argnext+0x76>
goto endofargs;
}
arg = (unsigned char) *args->curarg;
800e9c: 8b 53 08 mov 0x8(%ebx),%edx
800e9f: 0f b6 02 movzbl (%edx),%eax
args->curarg++;
800ea2: 83 c2 01 add $0x1,%edx
800ea5: 89 53 08 mov %edx,0x8(%ebx)
return arg;
endofargs:
args->curarg = 0;
return -1;
}
800ea8: 8b 5d fc mov -0x4(%ebp),%ebx
800eab: c9 leave
800eac: c3 ret
if (args->curarg[0] == '-' && args->curarg[1] == '\0')
800ead: 80 78 01 00 cmpb $0x0,0x1(%eax)
800eb1: 75 e9 jne 800e9c <argnext+0x65>
args->curarg = 0;
800eb3: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx)
return -1;
800eba: b8 ff ff ff ff mov $0xffffffff,%eax
800ebf: eb e7 jmp 800ea8 <argnext+0x71>
return -1;
800ec1: b8 ff ff ff ff mov $0xffffffff,%eax
800ec6: eb e0 jmp 800ea8 <argnext+0x71>
00800ec8 <argnextvalue>:
return (char*) (args->argvalue ? args->argvalue : argnextvalue(args));
}
char *
argnextvalue(struct Argstate *args)
{
800ec8: 55 push %ebp
800ec9: 89 e5 mov %esp,%ebp
800ecb: 53 push %ebx
800ecc: 83 ec 04 sub $0x4,%esp
800ecf: 8b 5d 08 mov 0x8(%ebp),%ebx
if (!args->curarg)
800ed2: 8b 43 08 mov 0x8(%ebx),%eax
800ed5: 85 c0 test %eax,%eax
800ed7: 74 5b je 800f34 <argnextvalue+0x6c>
return 0;
if (*args->curarg) {
800ed9: 80 38 00 cmpb $0x0,(%eax)
800edc: 74 12 je 800ef0 <argnextvalue+0x28>
args->argvalue = args->curarg;
800ede: 89 43 0c mov %eax,0xc(%ebx)
args->curarg = "";
800ee1: c7 43 08 51 21 80 00 movl $0x802151,0x8(%ebx)
(*args->argc)--;
} else {
args->argvalue = 0;
args->curarg = 0;
}
return (char*) args->argvalue;
800ee8: 8b 43 0c mov 0xc(%ebx),%eax
}
800eeb: 8b 5d fc mov -0x4(%ebp),%ebx
800eee: c9 leave
800eef: c3 ret
} else if (*args->argc > 1) {
800ef0: 8b 13 mov (%ebx),%edx
800ef2: 83 3a 01 cmpl $0x1,(%edx)
800ef5: 7f 10 jg 800f07 <argnextvalue+0x3f>
args->argvalue = 0;
800ef7: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx)
args->curarg = 0;
800efe: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx)
800f05: eb e1 jmp 800ee8 <argnextvalue+0x20>
args->argvalue = args->argv[1];
800f07: 8b 43 04 mov 0x4(%ebx),%eax
800f0a: 8b 48 04 mov 0x4(%eax),%ecx
800f0d: 89 4b 0c mov %ecx,0xc(%ebx)
memmove(args->argv + 1, args->argv + 2, sizeof(const char *) * (*args->argc - 1));
800f10: 83 ec 04 sub $0x4,%esp
800f13: 8b 12 mov (%edx),%edx
800f15: 8d 14 95 fc ff ff ff lea -0x4(,%edx,4),%edx
800f1c: 52 push %edx
800f1d: 8d 50 08 lea 0x8(%eax),%edx
800f20: 52 push %edx
800f21: 83 c0 04 add $0x4,%eax
800f24: 50 push %eax
800f25: e8 81 fa ff ff call 8009ab <memmove>
(*args->argc)--;
800f2a: 8b 03 mov (%ebx),%eax
800f2c: 83 28 01 subl $0x1,(%eax)
800f2f: 83 c4 10 add $0x10,%esp
800f32: eb b4 jmp 800ee8 <argnextvalue+0x20>
return 0;
800f34: b8 00 00 00 00 mov $0x0,%eax
800f39: eb b0 jmp 800eeb <argnextvalue+0x23>
00800f3b <argvalue>:
{
800f3b: 55 push %ebp
800f3c: 89 e5 mov %esp,%ebp
800f3e: 83 ec 08 sub $0x8,%esp
800f41: 8b 55 08 mov 0x8(%ebp),%edx
return (char*) (args->argvalue ? args->argvalue : argnextvalue(args));
800f44: 8b 42 0c mov 0xc(%edx),%eax
800f47: 85 c0 test %eax,%eax
800f49: 74 02 je 800f4d <argvalue+0x12>
}
800f4b: c9 leave
800f4c: c3 ret
return (char*) (args->argvalue ? args->argvalue : argnextvalue(args));
800f4d: 83 ec 0c sub $0xc,%esp
800f50: 52 push %edx
800f51: e8 72 ff ff ff call 800ec8 <argnextvalue>
800f56: 83 c4 10 add $0x10,%esp
800f59: eb f0 jmp 800f4b <argvalue+0x10>
00800f5b <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------
int
fd2num(struct Fd *fd)
{
800f5b: 55 push %ebp
800f5c: 89 e5 mov %esp,%ebp
return ((uintptr_t) fd - FDTABLE) / PGSIZE;
800f5e: 8b 45 08 mov 0x8(%ebp),%eax
800f61: 05 00 00 00 30 add $0x30000000,%eax
800f66: c1 e8 0c shr $0xc,%eax
}
800f69: 5d pop %ebp
800f6a: c3 ret
00800f6b <fd2data>:
char*
fd2data(struct Fd *fd)
{
800f6b: 55 push %ebp
800f6c: 89 e5 mov %esp,%ebp
return ((uintptr_t) fd - FDTABLE) / PGSIZE;
800f6e: 8b 45 08 mov 0x8(%ebp),%eax
800f71: 05 00 00 00 30 add $0x30000000,%eax
return INDEX2DATA(fd2num(fd));
800f76: 25 00 f0 ff ff and $0xfffff000,%eax
800f7b: 2d 00 00 fe 2f sub $0x2ffe0000,%eax
}
800f80: 5d pop %ebp
800f81: c3 ret
00800f82 <fd_alloc>:
// Returns 0 on success, < 0 on error. Errors are:
// -E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
800f82: 55 push %ebp
800f83: 89 e5 mov %esp,%ebp
800f85: 8b 4d 08 mov 0x8(%ebp),%ecx
800f88: b8 00 00 00 d0 mov $0xd0000000,%eax
int i;
struct Fd *fd;
for (i = 0; i < MAXFD; i++) {
fd = INDEX2FD(i);
if ((uvpd[PDX(fd)] & PTE_P) == 0 || (uvpt[PGNUM(fd)] & PTE_P) == 0) {
800f8d: 89 c2 mov %eax,%edx
800f8f: c1 ea 16 shr $0x16,%edx
800f92: 8b 14 95 00 d0 7b ef mov -0x10843000(,%edx,4),%edx
800f99: f6 c2 01 test $0x1,%dl
800f9c: 74 2a je 800fc8 <fd_alloc+0x46>
800f9e: 89 c2 mov %eax,%edx
800fa0: c1 ea 0c shr $0xc,%edx
800fa3: 8b 14 95 00 00 40 ef mov -0x10c00000(,%edx,4),%edx
800faa: f6 c2 01 test $0x1,%dl
800fad: 74 19 je 800fc8 <fd_alloc+0x46>
800faf: 05 00 10 00 00 add $0x1000,%eax
for (i = 0; i < MAXFD; i++) {
800fb4: 3d 00 00 02 d0 cmp $0xd0020000,%eax
800fb9: 75 d2 jne 800f8d <fd_alloc+0xb>
*fd_store = fd;
return 0;
}
}
*fd_store = 0;
800fbb: c7 01 00 00 00 00 movl $0x0,(%ecx)
return -E_MAX_OPEN;
800fc1: b8 f6 ff ff ff mov $0xfffffff6,%eax
800fc6: eb 07 jmp 800fcf <fd_alloc+0x4d>
*fd_store = fd;
800fc8: 89 01 mov %eax,(%ecx)
return 0;
800fca: b8 00 00 00 00 mov $0x0,%eax
}
800fcf: 5d pop %ebp
800fd0: c3 ret
00800fd1 <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
// -E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
800fd1: 55 push %ebp
800fd2: 89 e5 mov %esp,%ebp
800fd4: 8b 45 08 mov 0x8(%ebp),%eax
struct Fd *fd;
if (fdnum < 0 || fdnum >= MAXFD) {
800fd7: 83 f8 1f cmp $0x1f,%eax
800fda: 77 36 ja 801012 <fd_lookup+0x41>
if (debug)
cprintf("[%08x] bad fd %d\n", thisenv->env_id, fdnum);
return -E_INVAL;
}
fd = INDEX2FD(fdnum);
800fdc: c1 e0 0c shl $0xc,%eax
800fdf: 2d 00 00 00 30 sub $0x30000000,%eax
if (!(uvpd[PDX(fd)] & PTE_P) || !(uvpt[PGNUM(fd)] & PTE_P)) {
800fe4: 89 c2 mov %eax,%edx
800fe6: c1 ea 16 shr $0x16,%edx
800fe9: 8b 14 95 00 d0 7b ef mov -0x10843000(,%edx,4),%edx
800ff0: f6 c2 01 test $0x1,%dl
800ff3: 74 24 je 801019 <fd_lookup+0x48>
800ff5: 89 c2 mov %eax,%edx
800ff7: c1 ea 0c shr $0xc,%edx
800ffa: 8b 14 95 00 00 40 ef mov -0x10c00000(,%edx,4),%edx
801001: f6 c2 01 test $0x1,%dl
801004: 74 1a je 801020 <fd_lookup+0x4f>
if (debug)
cprintf("[%08x] closed fd %d\n", thisenv->env_id, fdnum);
return -E_INVAL;
}
*fd_store = fd;
801006: 8b 55 0c mov 0xc(%ebp),%edx
801009: 89 02 mov %eax,(%edx)
return 0;
80100b: b8 00 00 00 00 mov $0x0,%eax
}
801010: 5d pop %ebp
801011: c3 ret
return -E_INVAL;
801012: b8 fd ff ff ff mov $0xfffffffd,%eax
801017: eb f7 jmp 801010 <fd_lookup+0x3f>
return -E_INVAL;
801019: b8 fd ff ff ff mov $0xfffffffd,%eax
80101e: eb f0 jmp 801010 <fd_lookup+0x3f>
801020: b8 fd ff ff ff mov $0xfffffffd,%eax
801025: eb e9 jmp 801010 <fd_lookup+0x3f>
00801027 <dev_lookup>:
0
};
int
dev_lookup(int dev_id, struct Dev **dev)
{
801027: 55 push %ebp
801028: 89 e5 mov %esp,%ebp
80102a: 83 ec 08 sub $0x8,%esp
80102d: 8b 4d 08 mov 0x8(%ebp),%ecx
801030: ba 28 25 80 00 mov $0x802528,%edx
int i;
for (i = 0; devtab[i]; i++)
801035: b8 04 30 80 00 mov $0x803004,%eax
if (devtab[i]->dev_id == dev_id) {
80103a: 39 08 cmp %ecx,(%eax)
80103c: 74 33 je 801071 <dev_lookup+0x4a>
80103e: 83 c2 04 add $0x4,%edx
for (i = 0; devtab[i]; i++)
801041: 8b 02 mov (%edx),%eax
801043: 85 c0 test %eax,%eax
801045: 75 f3 jne 80103a <dev_lookup+0x13>
*dev = devtab[i];
return 0;
}
cprintf("[%08x] unknown device type %d\n", thisenv->env_id, dev_id);
801047: a1 04 40 80 00 mov 0x804004,%eax
80104c: 8b 40 48 mov 0x48(%eax),%eax
80104f: 83 ec 04 sub $0x4,%esp
801052: 51 push %ecx
801053: 50 push %eax
801054: 68 ac 24 80 00 push $0x8024ac
801059: e8 a0 f1 ff ff call 8001fe <cprintf>
*dev = 0;
80105e: 8b 45 0c mov 0xc(%ebp),%eax
801061: c7 00 00 00 00 00 movl $0x0,(%eax)
return -E_INVAL;
801067: 83 c4 10 add $0x10,%esp
80106a: b8 fd ff ff ff mov $0xfffffffd,%eax
}
80106f: c9 leave
801070: c3 ret
*dev = devtab[i];
801071: 8b 4d 0c mov 0xc(%ebp),%ecx
801074: 89 01 mov %eax,(%ecx)
return 0;
801076: b8 00 00 00 00 mov $0x0,%eax
80107b: eb f2 jmp 80106f <dev_lookup+0x48>
0080107d <fd_close>:
{
80107d: 55 push %ebp
80107e: 89 e5 mov %esp,%ebp
801080: 57 push %edi
801081: 56 push %esi
801082: 53 push %ebx
801083: 83 ec 1c sub $0x1c,%esp
801086: 8b 75 08 mov 0x8(%ebp),%esi
801089: 8b 7d 0c mov 0xc(%ebp),%edi
if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
80108c: 8d 45 e4 lea -0x1c(%ebp),%eax
80108f: 50 push %eax
return ((uintptr_t) fd - FDTABLE) / PGSIZE;
801090: 8d 86 00 00 00 30 lea 0x30000000(%esi),%eax
801096: c1 e8 0c shr $0xc,%eax
if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
801099: 50 push %eax
80109a: e8 32 ff ff ff call 800fd1 <fd_lookup>
80109f: 89 c3 mov %eax,%ebx
8010a1: 83 c4 08 add $0x8,%esp
8010a4: 85 c0 test %eax,%eax
8010a6: 78 05 js 8010ad <fd_close+0x30>
|| fd != fd2)
8010a8: 39 75 e4 cmp %esi,-0x1c(%ebp)
8010ab: 74 16 je 8010c3 <fd_close+0x46>
return (must_exist ? r : 0);
8010ad: 89 f8 mov %edi,%eax
8010af: 84 c0 test %al,%al
8010b1: b8 00 00 00 00 mov $0x0,%eax
8010b6: 0f 44 d8 cmove %eax,%ebx
}
8010b9: 89 d8 mov %ebx,%eax
8010bb: 8d 65 f4 lea -0xc(%ebp),%esp
8010be: 5b pop %ebx
8010bf: 5e pop %esi
8010c0: 5f pop %edi
8010c1: 5d pop %ebp
8010c2: c3 ret
if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
8010c3: 83 ec 08 sub $0x8,%esp
8010c6: 8d 45 e0 lea -0x20(%ebp),%eax
8010c9: 50 push %eax
8010ca: ff 36 pushl (%esi)
8010cc: e8 56 ff ff ff call 801027 <dev_lookup>
8010d1: 89 c3 mov %eax,%ebx
8010d3: 83 c4 10 add $0x10,%esp
8010d6: 85 c0 test %eax,%eax
8010d8: 78 15 js 8010ef <fd_close+0x72>
if (dev->dev_close)
8010da: 8b 45 e0 mov -0x20(%ebp),%eax
8010dd: 8b 40 10 mov 0x10(%eax),%eax
8010e0: 85 c0 test %eax,%eax
8010e2: 74 1b je 8010ff <fd_close+0x82>
r = (*dev->dev_close)(fd);
8010e4: 83 ec 0c sub $0xc,%esp
8010e7: 56 push %esi
8010e8: ff d0 call *%eax
8010ea: 89 c3 mov %eax,%ebx
8010ec: 83 c4 10 add $0x10,%esp
(void) sys_page_unmap(0, fd);
8010ef: 83 ec 08 sub $0x8,%esp
8010f2: 56 push %esi
8010f3: 6a 00 push $0x0
8010f5: e8 a1 fb ff ff call 800c9b <sys_page_unmap>
return r;
8010fa: 83 c4 10 add $0x10,%esp
8010fd: eb ba jmp 8010b9 <fd_close+0x3c>
r = 0;
8010ff: bb 00 00 00 00 mov $0x0,%ebx
801104: eb e9 jmp 8010ef <fd_close+0x72>
00801106 <close>:
int
close(int fdnum)
{
801106: 55 push %ebp
801107: 89 e5 mov %esp,%ebp
801109: 83 ec 18 sub $0x18,%esp
struct Fd *fd;
int r;
if ((r = fd_lookup(fdnum, &fd)) < 0)
80110c: 8d 45 f4 lea -0xc(%ebp),%eax
80110f: 50 push %eax
801110: ff 75 08 pushl 0x8(%ebp)
801113: e8 b9 fe ff ff call 800fd1 <fd_lookup>
801118: 83 c4 08 add $0x8,%esp
80111b: 85 c0 test %eax,%eax
80111d: 78 10 js 80112f <close+0x29>
return r;
else
return fd_close(fd, 1);
80111f: 83 ec 08 sub $0x8,%esp
801122: 6a 01 push $0x1
801124: ff 75 f4 pushl -0xc(%ebp)
801127: e8 51 ff ff ff call 80107d <fd_close>
80112c: 83 c4 10 add $0x10,%esp
}
80112f: c9 leave
801130: c3 ret
00801131 <close_all>:
void
close_all(void)
{
801131: 55 push %ebp
801132: 89 e5 mov %esp,%ebp
801134: 53 push %ebx
801135: 83 ec 04 sub $0x4,%esp
int i;
for (i = 0; i < MAXFD; i++)
801138: bb 00 00 00 00 mov $0x0,%ebx
close(i);
80113d: 83 ec 0c sub $0xc,%esp
801140: 53 push %ebx
801141: e8 c0 ff ff ff call 801106 <close>
for (i = 0; i < MAXFD; i++)
801146: 83 c3 01 add $0x1,%ebx
801149: 83 c4 10 add $0x10,%esp
80114c: 83 fb 20 cmp $0x20,%ebx
80114f: 75 ec jne 80113d <close_all+0xc>
}
801151: 8b 5d fc mov -0x4(%ebp),%ebx
801154: c9 leave
801155: c3 ret
00801156 <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
801156: 55 push %ebp
801157: 89 e5 mov %esp,%ebp
801159: 57 push %edi
80115a: 56 push %esi
80115b: 53 push %ebx
80115c: 83 ec 1c sub $0x1c,%esp
int r;
char *ova, *nva;
pte_t pte;
struct Fd *oldfd, *newfd;
if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
80115f: 8d 45 e4 lea -0x1c(%ebp),%eax
801162: 50 push %eax
801163: ff 75 08 pushl 0x8(%ebp)
801166: e8 66 fe ff ff call 800fd1 <fd_lookup>
80116b: 89 c3 mov %eax,%ebx
80116d: 83 c4 08 add $0x8,%esp
801170: 85 c0 test %eax,%eax
801172: 0f 88 81 00 00 00 js 8011f9 <dup+0xa3>
return r;
close(newfdnum);
801178: 83 ec 0c sub $0xc,%esp
80117b: ff 75 0c pushl 0xc(%ebp)
80117e: e8 83 ff ff ff call 801106 <close>
newfd = INDEX2FD(newfdnum);
801183: 8b 75 0c mov 0xc(%ebp),%esi
801186: c1 e6 0c shl $0xc,%esi
801189: 81 ee 00 00 00 30 sub $0x30000000,%esi
ova = fd2data(oldfd);
80118f: 83 c4 04 add $0x4,%esp
801192: ff 75 e4 pushl -0x1c(%ebp)
801195: e8 d1 fd ff ff call 800f6b <fd2data>
80119a: 89 c3 mov %eax,%ebx
nva = fd2data(newfd);
80119c: 89 34 24 mov %esi,(%esp)
80119f: e8 c7 fd ff ff call 800f6b <fd2data>
8011a4: 83 c4 10 add $0x10,%esp
8011a7: 89 c7 mov %eax,%edi
if ((uvpd[PDX(ova)] & PTE_P) && (uvpt[PGNUM(ova)] & PTE_P))
8011a9: 89 d8 mov %ebx,%eax
8011ab: c1 e8 16 shr $0x16,%eax
8011ae: 8b 04 85 00 d0 7b ef mov -0x10843000(,%eax,4),%eax
8011b5: a8 01 test $0x1,%al
8011b7: 74 11 je 8011ca <dup+0x74>
8011b9: 89 d8 mov %ebx,%eax
8011bb: c1 e8 0c shr $0xc,%eax
8011be: 8b 14 85 00 00 40 ef mov -0x10c00000(,%eax,4),%edx
8011c5: f6 c2 01 test $0x1,%dl
8011c8: 75 39 jne 801203 <dup+0xad>
if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
goto err;
if ((r = sys_page_map(0, oldfd, 0, newfd, uvpt[PGNUM(oldfd)] & PTE_SYSCALL)) < 0)
8011ca: 8b 55 e4 mov -0x1c(%ebp),%edx
8011cd: 89 d0 mov %edx,%eax
8011cf: c1 e8 0c shr $0xc,%eax
8011d2: 8b 04 85 00 00 40 ef mov -0x10c00000(,%eax,4),%eax
8011d9: 83 ec 0c sub $0xc,%esp
8011dc: 25 07 0e 00 00 and $0xe07,%eax
8011e1: 50 push %eax
8011e2: 56 push %esi
8011e3: 6a 00 push $0x0
8011e5: 52 push %edx
8011e6: 6a 00 push $0x0
8011e8: e8 6c fa ff ff call 800c59 <sys_page_map>
8011ed: 89 c3 mov %eax,%ebx
8011ef: 83 c4 20 add $0x20,%esp
8011f2: 85 c0 test %eax,%eax
8011f4: 78 31 js 801227 <dup+0xd1>
goto err;
return newfdnum;
8011f6: 8b 5d 0c mov 0xc(%ebp),%ebx
err:
sys_page_unmap(0, newfd);
sys_page_unmap(0, nva);
return r;
}
8011f9: 89 d8 mov %ebx,%eax
8011fb: 8d 65 f4 lea -0xc(%ebp),%esp
8011fe: 5b pop %ebx
8011ff: 5e pop %esi
801200: 5f pop %edi
801201: 5d pop %ebp
801202: c3 ret
if ((r = sys_page_map(0, ova, 0, nva, uvpt[PGNUM(ova)] & PTE_SYSCALL)) < 0)
801203: 8b 04 85 00 00 40 ef mov -0x10c00000(,%eax,4),%eax
80120a: 83 ec 0c sub $0xc,%esp
80120d: 25 07 0e 00 00 and $0xe07,%eax
801212: 50 push %eax
801213: 57 push %edi
801214: 6a 00 push $0x0
801216: 53 push %ebx
801217: 6a 00 push $0x0
801219: e8 3b fa ff ff call 800c59 <sys_page_map>
80121e: 89 c3 mov %eax,%ebx
801220: 83 c4 20 add $0x20,%esp
801223: 85 c0 test %eax,%eax
801225: 79 a3 jns 8011ca <dup+0x74>
sys_page_unmap(0, newfd);
801227: 83 ec 08 sub $0x8,%esp
80122a: 56 push %esi
80122b: 6a 00 push $0x0
80122d: e8 69 fa ff ff call 800c9b <sys_page_unmap>
sys_page_unmap(0, nva);
801232: 83 c4 08 add $0x8,%esp
801235: 57 push %edi
801236: 6a 00 push $0x0
801238: e8 5e fa ff ff call 800c9b <sys_page_unmap>
return r;
80123d: 83 c4 10 add $0x10,%esp
801240: eb b7 jmp 8011f9 <dup+0xa3>
00801242 <read>:
ssize_t
read(int fdnum, void *buf, size_t n)
{
801242: 55 push %ebp
801243: 89 e5 mov %esp,%ebp
801245: 53 push %ebx
801246: 83 ec 14 sub $0x14,%esp
801249: 8b 5d 08 mov 0x8(%ebp),%ebx
int r;
struct Dev *dev;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0
80124c: 8d 45 f0 lea -0x10(%ebp),%eax
80124f: 50 push %eax
801250: 53 push %ebx
801251: e8 7b fd ff ff call 800fd1 <fd_lookup>
801256: 83 c4 08 add $0x8,%esp
801259: 85 c0 test %eax,%eax
80125b: 78 3f js 80129c <read+0x5a>
|| (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
80125d: 83 ec 08 sub $0x8,%esp
801260: 8d 45 f4 lea -0xc(%ebp),%eax
801263: 50 push %eax
801264: 8b 45 f0 mov -0x10(%ebp),%eax
801267: ff 30 pushl (%eax)
801269: e8 b9 fd ff ff call 801027 <dev_lookup>
80126e: 83 c4 10 add $0x10,%esp
801271: 85 c0 test %eax,%eax
801273: 78 27 js 80129c <read+0x5a>
return r;
if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
801275: 8b 55 f0 mov -0x10(%ebp),%edx
801278: 8b 42 08 mov 0x8(%edx),%eax
80127b: 83 e0 03 and $0x3,%eax
80127e: 83 f8 01 cmp $0x1,%eax
801281: 74 1e je 8012a1 <read+0x5f>
cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
return -E_INVAL;
}
if (!dev->dev_read)
801283: 8b 45 f4 mov -0xc(%ebp),%eax
801286: 8b 40 08 mov 0x8(%eax),%eax
801289: 85 c0 test %eax,%eax
80128b: 74 35 je 8012c2 <read+0x80>
return -E_NOT_SUPP;
return (*dev->dev_read)(fd, buf, n);
80128d: 83 ec 04 sub $0x4,%esp
801290: ff 75 10 pushl 0x10(%ebp)
801293: ff 75 0c pushl 0xc(%ebp)
801296: 52 push %edx
801297: ff d0 call *%eax
801299: 83 c4 10 add $0x10,%esp
}
80129c: 8b 5d fc mov -0x4(%ebp),%ebx
80129f: c9 leave
8012a0: c3 ret
cprintf("[%08x] read %d -- bad mode\n", thisenv->env_id, fdnum);
8012a1: a1 04 40 80 00 mov 0x804004,%eax
8012a6: 8b 40 48 mov 0x48(%eax),%eax
8012a9: 83 ec 04 sub $0x4,%esp
8012ac: 53 push %ebx
8012ad: 50 push %eax
8012ae: 68 ed 24 80 00 push $0x8024ed
8012b3: e8 46 ef ff ff call 8001fe <cprintf>
return -E_INVAL;
8012b8: 83 c4 10 add $0x10,%esp
8012bb: b8 fd ff ff ff mov $0xfffffffd,%eax
8012c0: eb da jmp 80129c <read+0x5a>
return -E_NOT_SUPP;
8012c2: b8 f1 ff ff ff mov $0xfffffff1,%eax
8012c7: eb d3 jmp 80129c <read+0x5a>
008012c9 <readn>:
ssize_t
readn(int fdnum, void *buf, size_t n)
{
8012c9: 55 push %ebp
8012ca: 89 e5 mov %esp,%ebp
8012cc: 57 push %edi
8012cd: 56 push %esi
8012ce: 53 push %ebx
8012cf: 83 ec 0c sub $0xc,%esp
8012d2: 8b 7d 08 mov 0x8(%ebp),%edi
8012d5: 8b 75 10 mov 0x10(%ebp),%esi
int m, tot;
for (tot = 0; tot < n; tot += m) {
8012d8: bb 00 00 00 00 mov $0x0,%ebx
8012dd: 39 f3 cmp %esi,%ebx
8012df: 73 25 jae 801306 <readn+0x3d>
m = read(fdnum, (char*)buf + tot, n - tot);
8012e1: 83 ec 04 sub $0x4,%esp
8012e4: 89 f0 mov %esi,%eax
8012e6: 29 d8 sub %ebx,%eax
8012e8: 50 push %eax
8012e9: 89 d8 mov %ebx,%eax
8012eb: 03 45 0c add 0xc(%ebp),%eax
8012ee: 50 push %eax
8012ef: 57 push %edi
8012f0: e8 4d ff ff ff call 801242 <read>
if (m < 0)
8012f5: 83 c4 10 add $0x10,%esp
8012f8: 85 c0 test %eax,%eax
8012fa: 78 08 js 801304 <readn+0x3b>
return m;
if (m == 0)
8012fc: 85 c0 test %eax,%eax
8012fe: 74 06 je 801306 <readn+0x3d>
for (tot = 0; tot < n; tot += m) {
801300: 01 c3 add %eax,%ebx
801302: eb d9 jmp 8012dd <readn+0x14>
m = read(fdnum, (char*)buf + tot, n - tot);
801304: 89 c3 mov %eax,%ebx
break;
}
return tot;
}
801306: 89 d8 mov %ebx,%eax
801308: 8d 65 f4 lea -0xc(%ebp),%esp
80130b: 5b pop %ebx
80130c: 5e pop %esi
80130d: 5f pop %edi
80130e: 5d pop %ebp
80130f: c3 ret
00801310 <write>:
ssize_t
write(int fdnum, const void *buf, size_t n)
{
801310: 55 push %ebp
801311: 89 e5 mov %esp,%ebp
801313: 53 push %ebx
801314: 83 ec 14 sub $0x14,%esp
801317: 8b 5d 08 mov 0x8(%ebp),%ebx
int r;
struct Dev *dev;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0
80131a: 8d 45 f0 lea -0x10(%ebp),%eax
80131d: 50 push %eax
80131e: 53 push %ebx
80131f: e8 ad fc ff ff call 800fd1 <fd_lookup>
801324: 83 c4 08 add $0x8,%esp
801327: 85 c0 test %eax,%eax
801329: 78 3a js 801365 <write+0x55>
|| (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
80132b: 83 ec 08 sub $0x8,%esp
80132e: 8d 45 f4 lea -0xc(%ebp),%eax
801331: 50 push %eax
801332: 8b 45 f0 mov -0x10(%ebp),%eax
801335: ff 30 pushl (%eax)
801337: e8 eb fc ff ff call 801027 <dev_lookup>
80133c: 83 c4 10 add $0x10,%esp
80133f: 85 c0 test %eax,%eax
801341: 78 22 js 801365 <write+0x55>
return r;
if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
801343: 8b 45 f0 mov -0x10(%ebp),%eax
801346: f6 40 08 03 testb $0x3,0x8(%eax)
80134a: 74 1e je 80136a <write+0x5a>
return -E_INVAL;
}
if (debug)
cprintf("write %d %p %d via dev %s\n",
fdnum, buf, n, dev->dev_name);
if (!dev->dev_write)
80134c: 8b 55 f4 mov -0xc(%ebp),%edx
80134f: 8b 52 0c mov 0xc(%edx),%edx
801352: 85 d2 test %edx,%edx
801354: 74 35 je 80138b <write+0x7b>
return -E_NOT_SUPP;
return (*dev->dev_write)(fd, buf, n);
801356: 83 ec 04 sub $0x4,%esp
801359: ff 75 10 pushl 0x10(%ebp)
80135c: ff 75 0c pushl 0xc(%ebp)
80135f: 50 push %eax
801360: ff d2 call *%edx
801362: 83 c4 10 add $0x10,%esp
}
801365: 8b 5d fc mov -0x4(%ebp),%ebx
801368: c9 leave
801369: c3 ret
cprintf("[%08x] write %d -- bad mode\n", thisenv->env_id, fdnum);
80136a: a1 04 40 80 00 mov 0x804004,%eax
80136f: 8b 40 48 mov 0x48(%eax),%eax
801372: 83 ec 04 sub $0x4,%esp
801375: 53 push %ebx
801376: 50 push %eax
801377: 68 09 25 80 00 push $0x802509
80137c: e8 7d ee ff ff call 8001fe <cprintf>
return -E_INVAL;
801381: 83 c4 10 add $0x10,%esp
801384: b8 fd ff ff ff mov $0xfffffffd,%eax
801389: eb da jmp 801365 <write+0x55>
return -E_NOT_SUPP;
80138b: b8 f1 ff ff ff mov $0xfffffff1,%eax
801390: eb d3 jmp 801365 <write+0x55>
00801392 <seek>:
int
seek(int fdnum, off_t offset)
{
801392: 55 push %ebp
801393: 89 e5 mov %esp,%ebp
801395: 83 ec 10 sub $0x10,%esp
int r;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0)
801398: 8d 45 fc lea -0x4(%ebp),%eax
80139b: 50 push %eax
80139c: ff 75 08 pushl 0x8(%ebp)
80139f: e8 2d fc ff ff call 800fd1 <fd_lookup>
8013a4: 83 c4 08 add $0x8,%esp
8013a7: 85 c0 test %eax,%eax
8013a9: 78 0e js 8013b9 <seek+0x27>
return r;
fd->fd_offset = offset;
8013ab: 8b 55 0c mov 0xc(%ebp),%edx
8013ae: 8b 45 fc mov -0x4(%ebp),%eax
8013b1: 89 50 04 mov %edx,0x4(%eax)
return 0;
8013b4: b8 00 00 00 00 mov $0x0,%eax
}
8013b9: c9 leave
8013ba: c3 ret
008013bb <ftruncate>:
int
ftruncate(int fdnum, off_t newsize)
{
8013bb: 55 push %ebp
8013bc: 89 e5 mov %esp,%ebp
8013be: 53 push %ebx
8013bf: 83 ec 14 sub $0x14,%esp
8013c2: 8b 5d 08 mov 0x8(%ebp),%ebx
int r;
struct Dev *dev;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0
8013c5: 8d 45 f0 lea -0x10(%ebp),%eax
8013c8: 50 push %eax
8013c9: 53 push %ebx
8013ca: e8 02 fc ff ff call 800fd1 <fd_lookup>
8013cf: 83 c4 08 add $0x8,%esp
8013d2: 85 c0 test %eax,%eax
8013d4: 78 37 js 80140d <ftruncate+0x52>
|| (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
8013d6: 83 ec 08 sub $0x8,%esp
8013d9: 8d 45 f4 lea -0xc(%ebp),%eax
8013dc: 50 push %eax
8013dd: 8b 45 f0 mov -0x10(%ebp),%eax
8013e0: ff 30 pushl (%eax)
8013e2: e8 40 fc ff ff call 801027 <dev_lookup>
8013e7: 83 c4 10 add $0x10,%esp
8013ea: 85 c0 test %eax,%eax
8013ec: 78 1f js 80140d <ftruncate+0x52>
return r;
if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
8013ee: 8b 45 f0 mov -0x10(%ebp),%eax
8013f1: f6 40 08 03 testb $0x3,0x8(%eax)
8013f5: 74 1b je 801412 <ftruncate+0x57>
cprintf("[%08x] ftruncate %d -- bad mode\n",
thisenv->env_id, fdnum);
return -E_INVAL;
}
if (!dev->dev_trunc)
8013f7: 8b 55 f4 mov -0xc(%ebp),%edx
8013fa: 8b 52 18 mov 0x18(%edx),%edx
8013fd: 85 d2 test %edx,%edx
8013ff: 74 32 je 801433 <ftruncate+0x78>
return -E_NOT_SUPP;
return (*dev->dev_trunc)(fd, newsize);
801401: 83 ec 08 sub $0x8,%esp
801404: ff 75 0c pushl 0xc(%ebp)
801407: 50 push %eax
801408: ff d2 call *%edx
80140a: 83 c4 10 add $0x10,%esp
}
80140d: 8b 5d fc mov -0x4(%ebp),%ebx
801410: c9 leave
801411: c3 ret
thisenv->env_id, fdnum);
801412: a1 04 40 80 00 mov 0x804004,%eax
cprintf("[%08x] ftruncate %d -- bad mode\n",
801417: 8b 40 48 mov 0x48(%eax),%eax
80141a: 83 ec 04 sub $0x4,%esp
80141d: 53 push %ebx
80141e: 50 push %eax
80141f: 68 cc 24 80 00 push $0x8024cc
801424: e8 d5 ed ff ff call 8001fe <cprintf>
return -E_INVAL;
801429: 83 c4 10 add $0x10,%esp
80142c: b8 fd ff ff ff mov $0xfffffffd,%eax
801431: eb da jmp 80140d <ftruncate+0x52>
return -E_NOT_SUPP;
801433: b8 f1 ff ff ff mov $0xfffffff1,%eax
801438: eb d3 jmp 80140d <ftruncate+0x52>
0080143a <fstat>:
int
fstat(int fdnum, struct Stat *stat)
{
80143a: 55 push %ebp
80143b: 89 e5 mov %esp,%ebp
80143d: 53 push %ebx
80143e: 83 ec 14 sub $0x14,%esp
801441: 8b 5d 0c mov 0xc(%ebp),%ebx
int r;
struct Dev *dev;
struct Fd *fd;
if ((r = fd_lookup(fdnum, &fd)) < 0
801444: 8d 45 f0 lea -0x10(%ebp),%eax
801447: 50 push %eax
801448: ff 75 08 pushl 0x8(%ebp)
80144b: e8 81 fb ff ff call 800fd1 <fd_lookup>
801450: 83 c4 08 add $0x8,%esp
801453: 85 c0 test %eax,%eax
801455: 78 4b js 8014a2 <fstat+0x68>
|| (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
801457: 83 ec 08 sub $0x8,%esp
80145a: 8d 45 f4 lea -0xc(%ebp),%eax
80145d: 50 push %eax
80145e: 8b 45 f0 mov -0x10(%ebp),%eax
801461: ff 30 pushl (%eax)
801463: e8 bf fb ff ff call 801027 <dev_lookup>
801468: 83 c4 10 add $0x10,%esp
80146b: 85 c0 test %eax,%eax
80146d: 78 33 js 8014a2 <fstat+0x68>
return r;
if (!dev->dev_stat)
80146f: 8b 45 f4 mov -0xc(%ebp),%eax
801472: 83 78 14 00 cmpl $0x0,0x14(%eax)
801476: 74 2f je 8014a7 <fstat+0x6d>
return -E_NOT_SUPP;
stat->st_name[0] = 0;
801478: c6 03 00 movb $0x0,(%ebx)
stat->st_size = 0;
80147b: c7 83 80 00 00 00 00 movl $0x0,0x80(%ebx)
801482: 00 00 00
stat->st_isdir = 0;
801485: c7 83 84 00 00 00 00 movl $0x0,0x84(%ebx)
80148c: 00 00 00
stat->st_dev = dev;
80148f: 89 83 88 00 00 00 mov %eax,0x88(%ebx)
return (*dev->dev_stat)(fd, stat);
801495: 83 ec 08 sub $0x8,%esp
801498: 53 push %ebx
801499: ff 75 f0 pushl -0x10(%ebp)
80149c: ff 50 14 call *0x14(%eax)
80149f: 83 c4 10 add $0x10,%esp
}
8014a2: 8b 5d fc mov -0x4(%ebp),%ebx
8014a5: c9 leave
8014a6: c3 ret
return -E_NOT_SUPP;
8014a7: b8 f1 ff ff ff mov $0xfffffff1,%eax
8014ac: eb f4 jmp 8014a2 <fstat+0x68>
008014ae <stat>:
int
stat(const char *path, struct Stat *stat)
{
8014ae: 55 push %ebp
8014af: 89 e5 mov %esp,%ebp
8014b1: 56 push %esi
8014b2: 53 push %ebx
int fd, r;
if ((fd = open(path, O_RDONLY)) < 0)
8014b3: 83 ec 08 sub $0x8,%esp
8014b6: 6a 00 push $0x0
8014b8: ff 75 08 pushl 0x8(%ebp)
8014bb: e8 30 02 00 00 call 8016f0 <open>
8014c0: 89 c3 mov %eax,%ebx
8014c2: 83 c4 10 add $0x10,%esp
8014c5: 85 c0 test %eax,%eax
8014c7: 78 1b js 8014e4 <stat+0x36>
return fd;
r = fstat(fd, stat);
8014c9: 83 ec 08 sub $0x8,%esp
8014cc: ff 75 0c pushl 0xc(%ebp)
8014cf: 50 push %eax
8014d0: e8 65 ff ff ff call 80143a <fstat>
8014d5: 89 c6 mov %eax,%esi
close(fd);
8014d7: 89 1c 24 mov %ebx,(%esp)
8014da: e8 27 fc ff ff call 801106 <close>
return r;
8014df: 83 c4 10 add $0x10,%esp
8014e2: 89 f3 mov %esi,%ebx
}
8014e4: 89 d8 mov %ebx,%eax
8014e6: 8d 65 f8 lea -0x8(%ebp),%esp
8014e9: 5b pop %ebx
8014ea: 5e pop %esi
8014eb: 5d pop %ebp
8014ec: c3 ret
008014ed <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
8014ed: 55 push %ebp
8014ee: 89 e5 mov %esp,%ebp
8014f0: 56 push %esi
8014f1: 53 push %ebx
8014f2: 89 c6 mov %eax,%esi
8014f4: 89 d3 mov %edx,%ebx
static envid_t fsenv;
if (fsenv == 0)
8014f6: 83 3d 00 40 80 00 00 cmpl $0x0,0x804000
8014fd: 74 27 je 801526 <fsipc+0x39>
static_assert(sizeof(fsipcbuf) == PGSIZE);
if (debug)
cprintf("[%08x] fsipc %d %08x\n", thisenv->env_id, type, *(uint32_t *)&fsipcbuf);
ipc_send(fsenv, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
8014ff: 6a 07 push $0x7
801501: 68 00 50 80 00 push $0x805000
801506: 56 push %esi
801507: ff 35 00 40 80 00 pushl 0x804000
80150d: e8 11 09 00 00 call 801e23 <ipc_send>
return ipc_recv(NULL, dstva, NULL);
801512: 83 c4 0c add $0xc,%esp
801515: 6a 00 push $0x0
801517: 53 push %ebx
801518: 6a 00 push $0x0
80151a: e8 9b 08 00 00 call 801dba <ipc_recv>
}
80151f: 8d 65 f8 lea -0x8(%ebp),%esp
801522: 5b pop %ebx
801523: 5e pop %esi
801524: 5d pop %ebp
801525: c3 ret
fsenv = ipc_find_env(ENV_TYPE_FS);
801526: 83 ec 0c sub $0xc,%esp
801529: 6a 01 push $0x1
80152b: e8 47 09 00 00 call 801e77 <ipc_find_env>
801530: a3 00 40 80 00 mov %eax,0x804000
801535: 83 c4 10 add $0x10,%esp
801538: eb c5 jmp 8014ff <fsipc+0x12>
0080153a <devfile_trunc>:
}
// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
80153a: 55 push %ebp
80153b: 89 e5 mov %esp,%ebp
80153d: 83 ec 08 sub $0x8,%esp
fsipcbuf.set_size.req_fileid = fd->fd_file.id;
801540: 8b 45 08 mov 0x8(%ebp),%eax
801543: 8b 40 0c mov 0xc(%eax),%eax
801546: a3 00 50 80 00 mov %eax,0x805000
fsipcbuf.set_size.req_size = newsize;
80154b: 8b 45 0c mov 0xc(%ebp),%eax
80154e: a3 04 50 80 00 mov %eax,0x805004
return fsipc(FSREQ_SET_SIZE, NULL);
801553: ba 00 00 00 00 mov $0x0,%edx
801558: b8 02 00 00 00 mov $0x2,%eax
80155d: e8 8b ff ff ff call 8014ed <fsipc>
}
801562: c9 leave
801563: c3 ret
00801564 <devfile_flush>:
{
801564: 55 push %ebp
801565: 89 e5 mov %esp,%ebp
801567: 83 ec 08 sub $0x8,%esp
fsipcbuf.flush.req_fileid = fd->fd_file.id;
80156a: 8b 45 08 mov 0x8(%ebp),%eax
80156d: 8b 40 0c mov 0xc(%eax),%eax
801570: a3 00 50 80 00 mov %eax,0x805000
return fsipc(FSREQ_FLUSH, NULL);
801575: ba 00 00 00 00 mov $0x0,%edx
80157a: b8 06 00 00 00 mov $0x6,%eax
80157f: e8 69 ff ff ff call 8014ed <fsipc>
}
801584: c9 leave
801585: c3 ret
00801586 <devfile_stat>:
{
801586: 55 push %ebp
801587: 89 e5 mov %esp,%ebp
801589: 53 push %ebx
80158a: 83 ec 04 sub $0x4,%esp
80158d: 8b 5d 0c mov 0xc(%ebp),%ebx
fsipcbuf.stat.req_fileid = fd->fd_file.id;
801590: 8b 45 08 mov 0x8(%ebp),%eax
801593: 8b 40 0c mov 0xc(%eax),%eax
801596: a3 00 50 80 00 mov %eax,0x805000
if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
80159b: ba 00 00 00 00 mov $0x0,%edx
8015a0: b8 05 00 00 00 mov $0x5,%eax
8015a5: e8 43 ff ff ff call 8014ed <fsipc>
8015aa: 85 c0 test %eax,%eax
8015ac: 78 2c js 8015da <devfile_stat+0x54>
strcpy(st->st_name, fsipcbuf.statRet.ret_name);
8015ae: 83 ec 08 sub $0x8,%esp
8015b1: 68 00 50 80 00 push $0x805000
8015b6: 53 push %ebx
8015b7: e8 61 f2 ff ff call 80081d <strcpy>
st->st_size = fsipcbuf.statRet.ret_size;
8015bc: a1 80 50 80 00 mov 0x805080,%eax
8015c1: 89 83 80 00 00 00 mov %eax,0x80(%ebx)
st->st_isdir = fsipcbuf.statRet.ret_isdir;
8015c7: a1 84 50 80 00 mov 0x805084,%eax
8015cc: 89 83 84 00 00 00 mov %eax,0x84(%ebx)
return 0;
8015d2: 83 c4 10 add $0x10,%esp
8015d5: b8 00 00 00 00 mov $0x0,%eax
}
8015da: 8b 5d fc mov -0x4(%ebp),%ebx
8015dd: c9 leave
8015de: c3 ret
008015df <devfile_write>:
{
8015df: 55 push %ebp
8015e0: 89 e5 mov %esp,%ebp
8015e2: 53 push %ebx
8015e3: 83 ec 08 sub $0x8,%esp
8015e6: 8b 5d 10 mov 0x10(%ebp),%ebx
n = sizeof(fsipcbuf.write.req_buf) > n ? n : sizeof(fsipcbuf.write.req_buf);
8015e9: 81 fb f8 0f 00 00 cmp $0xff8,%ebx
8015ef: b8 f8 0f 00 00 mov $0xff8,%eax
8015f4: 0f 47 d8 cmova %eax,%ebx
fsipcbuf.write.req_fileid = fd->fd_file.id;
8015f7: 8b 45 08 mov 0x8(%ebp),%eax
8015fa: 8b 40 0c mov 0xc(%eax),%eax
8015fd: a3 00 50 80 00 mov %eax,0x805000
fsipcbuf.write.req_n = n;
801602: 89 1d 04 50 80 00 mov %ebx,0x805004
memmove(fsipcbuf.write.req_buf, buf, n);
801608: 53 push %ebx
801609: ff 75 0c pushl 0xc(%ebp)
80160c: 68 08 50 80 00 push $0x805008
801611: e8 95 f3 ff ff call 8009ab <memmove>
if ((r = fsipc(FSREQ_WRITE, NULL)) < 0)
801616: ba 00 00 00 00 mov $0x0,%edx
80161b: b8 04 00 00 00 mov $0x4,%eax
801620: e8 c8 fe ff ff call 8014ed <fsipc>
801625: 83 c4 10 add $0x10,%esp
801628: 85 c0 test %eax,%eax
80162a: 78 0b js 801637 <devfile_write+0x58>
assert(r <= n);
80162c: 39 d8 cmp %ebx,%eax
80162e: 77 0c ja 80163c <devfile_write+0x5d>
assert(r <= PGSIZE);
801630: 3d 00 10 00 00 cmp $0x1000,%eax
801635: 7f 1e jg 801655 <devfile_write+0x76>
}
801637: 8b 5d fc mov -0x4(%ebp),%ebx
80163a: c9 leave
80163b: c3 ret
assert(r <= n);
80163c: 68 38 25 80 00 push $0x802538
801641: 68 3f 25 80 00 push $0x80253f
801646: 68 98 00 00 00 push $0x98
80164b: 68 54 25 80 00 push $0x802554
801650: e8 1f 07 00 00 call 801d74 <_panic>
assert(r <= PGSIZE);
801655: 68 5f 25 80 00 push $0x80255f
80165a: 68 3f 25 80 00 push $0x80253f
80165f: 68 99 00 00 00 push $0x99
801664: 68 54 25 80 00 push $0x802554
801669: e8 06 07 00 00 call 801d74 <_panic>
0080166e <devfile_read>:
{
80166e: 55 push %ebp
80166f: 89 e5 mov %esp,%ebp
801671: 56 push %esi
801672: 53 push %ebx
801673: 8b 75 10 mov 0x10(%ebp),%esi
fsipcbuf.read.req_fileid = fd->fd_file.id;
801676: 8b 45 08 mov 0x8(%ebp),%eax
801679: 8b 40 0c mov 0xc(%eax),%eax
80167c: a3 00 50 80 00 mov %eax,0x805000
fsipcbuf.read.req_n = n;
801681: 89 35 04 50 80 00 mov %esi,0x805004
if ((r = fsipc(FSREQ_READ, NULL)) < 0)
801687: ba 00 00 00 00 mov $0x0,%edx
80168c: b8 03 00 00 00 mov $0x3,%eax
801691: e8 57 fe ff ff call 8014ed <fsipc>
801696: 89 c3 mov %eax,%ebx
801698: 85 c0 test %eax,%eax
80169a: 78 1f js 8016bb <devfile_read+0x4d>
assert(r <= n);
80169c: 39 f0 cmp %esi,%eax
80169e: 77 24 ja 8016c4 <devfile_read+0x56>
assert(r <= PGSIZE);
8016a0: 3d 00 10 00 00 cmp $0x1000,%eax
8016a5: 7f 33 jg 8016da <devfile_read+0x6c>
memmove(buf, fsipcbuf.readRet.ret_buf, r);
8016a7: 83 ec 04 sub $0x4,%esp
8016aa: 50 push %eax
8016ab: 68 00 50 80 00 push $0x805000
8016b0: ff 75 0c pushl 0xc(%ebp)
8016b3: e8 f3 f2 ff ff call 8009ab <memmove>
return r;
8016b8: 83 c4 10 add $0x10,%esp
}
8016bb: 89 d8 mov %ebx,%eax
8016bd: 8d 65 f8 lea -0x8(%ebp),%esp
8016c0: 5b pop %ebx
8016c1: 5e pop %esi
8016c2: 5d pop %ebp
8016c3: c3 ret
assert(r <= n);
8016c4: 68 38 25 80 00 push $0x802538
8016c9: 68 3f 25 80 00 push $0x80253f
8016ce: 6a 7c push $0x7c
8016d0: 68 54 25 80 00 push $0x802554
8016d5: e8 9a 06 00 00 call 801d74 <_panic>
assert(r <= PGSIZE);
8016da: 68 5f 25 80 00 push $0x80255f
8016df: 68 3f 25 80 00 push $0x80253f
8016e4: 6a 7d push $0x7d
8016e6: 68 54 25 80 00 push $0x802554
8016eb: e8 84 06 00 00 call 801d74 <_panic>
008016f0 <open>:
{
8016f0: 55 push %ebp
8016f1: 89 e5 mov %esp,%ebp
8016f3: 56 push %esi
8016f4: 53 push %ebx
8016f5: 83 ec 1c sub $0x1c,%esp
8016f8: 8b 75 08 mov 0x8(%ebp),%esi
if (strlen(path) >= MAXPATHLEN)
8016fb: 56 push %esi
8016fc: e8 e5 f0 ff ff call 8007e6 <strlen>
801701: 83 c4 10 add $0x10,%esp
801704: 3d ff 03 00 00 cmp $0x3ff,%eax
801709: 7f 6c jg 801777 <open+0x87>
if ((r = fd_alloc(&fd)) < 0)
80170b: 83 ec 0c sub $0xc,%esp
80170e: 8d 45 f4 lea -0xc(%ebp),%eax
801711: 50 push %eax
801712: e8 6b f8 ff ff call 800f82 <fd_alloc>
801717: 89 c3 mov %eax,%ebx
801719: 83 c4 10 add $0x10,%esp
80171c: 85 c0 test %eax,%eax
80171e: 78 3c js 80175c <open+0x6c>
strcpy(fsipcbuf.open.req_path, path);
801720: 83 ec 08 sub $0x8,%esp
801723: 56 push %esi
801724: 68 00 50 80 00 push $0x805000
801729: e8 ef f0 ff ff call 80081d <strcpy>
fsipcbuf.open.req_omode = mode;
80172e: 8b 45 0c mov 0xc(%ebp),%eax
801731: a3 00 54 80 00 mov %eax,0x805400
if ((r = fsipc(FSREQ_OPEN, fd)) < 0) {
801736: 8b 55 f4 mov -0xc(%ebp),%edx
801739: b8 01 00 00 00 mov $0x1,%eax
80173e: e8 aa fd ff ff call 8014ed <fsipc>
801743: 89 c3 mov %eax,%ebx
801745: 83 c4 10 add $0x10,%esp
801748: 85 c0 test %eax,%eax
80174a: 78 19 js 801765 <open+0x75>
return fd2num(fd);
80174c: 83 ec 0c sub $0xc,%esp
80174f: ff 75 f4 pushl -0xc(%ebp)
801752: e8 04 f8 ff ff call 800f5b <fd2num>
801757: 89 c3 mov %eax,%ebx
801759: 83 c4 10 add $0x10,%esp
}
80175c: 89 d8 mov %ebx,%eax
80175e: 8d 65 f8 lea -0x8(%ebp),%esp
801761: 5b pop %ebx
801762: 5e pop %esi
801763: 5d pop %ebp
801764: c3 ret
fd_close(fd, 0);
801765: 83 ec 08 sub $0x8,%esp
801768: 6a 00 push $0x0
80176a: ff 75 f4 pushl -0xc(%ebp)
80176d: e8 0b f9 ff ff call 80107d <fd_close>
return r;
801772: 83 c4 10 add $0x10,%esp
801775: eb e5 jmp 80175c <open+0x6c>
return -E_BAD_PATH;
801777: bb f4 ff ff ff mov $0xfffffff4,%ebx
80177c: eb de jmp 80175c <open+0x6c>
0080177e <sync>:
// Synchronize disk with buffer cache
int
sync(void)
{
80177e: 55 push %ebp
80177f: 89 e5 mov %esp,%ebp
801781: 83 ec 08 sub $0x8,%esp
// Ask the file server to update the disk
// by writing any dirty blocks in the buffer cache.
return fsipc(FSREQ_SYNC, NULL);
801784: ba 00 00 00 00 mov $0x0,%edx
801789: b8 08 00 00 00 mov $0x8,%eax
80178e: e8 5a fd ff ff call 8014ed <fsipc>
}
801793: c9 leave
801794: c3 ret
00801795 <writebuf>:
static void
writebuf(struct printbuf *b)
{
if (b->error > 0) {
801795: 83 78 0c 00 cmpl $0x0,0xc(%eax)
801799: 7e 38 jle 8017d3 <writebuf+0x3e>
{
80179b: 55 push %ebp
80179c: 89 e5 mov %esp,%ebp
80179e: 53 push %ebx
80179f: 83 ec 08 sub $0x8,%esp
8017a2: 89 c3 mov %eax,%ebx
ssize_t result = write(b->fd, b->buf, b->idx);
8017a4: ff 70 04 pushl 0x4(%eax)
8017a7: 8d 40 10 lea 0x10(%eax),%eax
8017aa: 50 push %eax
8017ab: ff 33 pushl (%ebx)
8017ad: e8 5e fb ff ff call 801310 <write>
if (result > 0)
8017b2: 83 c4 10 add $0x10,%esp
8017b5: 85 c0 test %eax,%eax
8017b7: 7e 03 jle 8017bc <writebuf+0x27>
b->result += result;
8017b9: 01 43 08 add %eax,0x8(%ebx)
if (result != b->idx) // error, or wrote less than supplied
8017bc: 39 43 04 cmp %eax,0x4(%ebx)
8017bf: 74 0d je 8017ce <writebuf+0x39>
b->error = (result < 0 ? result : 0);
8017c1: 85 c0 test %eax,%eax
8017c3: ba 00 00 00 00 mov $0x0,%edx
8017c8: 0f 4f c2 cmovg %edx,%eax
8017cb: 89 43 0c mov %eax,0xc(%ebx)
}
}
8017ce: 8b 5d fc mov -0x4(%ebp),%ebx
8017d1: c9 leave
8017d2: c3 ret
8017d3: f3 c3 repz ret
008017d5 <putch>:
static void
putch(int ch, void *thunk)
{
8017d5: 55 push %ebp
8017d6: 89 e5 mov %esp,%ebp
8017d8: 53 push %ebx
8017d9: 83 ec 04 sub $0x4,%esp
8017dc: 8b 5d 0c mov 0xc(%ebp),%ebx
struct printbuf *b = (struct printbuf *) thunk;
b->buf[b->idx++] = ch;
8017df: 8b 53 04 mov 0x4(%ebx),%edx
8017e2: 8d 42 01 lea 0x1(%edx),%eax
8017e5: 89 43 04 mov %eax,0x4(%ebx)
8017e8: 8b 4d 08 mov 0x8(%ebp),%ecx
8017eb: 88 4c 13 10 mov %cl,0x10(%ebx,%edx,1)
if (b->idx == 256) {
8017ef: 3d 00 01 00 00 cmp $0x100,%eax
8017f4: 74 06 je 8017fc <putch+0x27>
writebuf(b);
b->idx = 0;
}
}
8017f6: 83 c4 04 add $0x4,%esp
8017f9: 5b pop %ebx
8017fa: 5d pop %ebp
8017fb: c3 ret
writebuf(b);
8017fc: 89 d8 mov %ebx,%eax
8017fe: e8 92 ff ff ff call 801795 <writebuf>
b->idx = 0;
801803: c7 43 04 00 00 00 00 movl $0x0,0x4(%ebx)
}
80180a: eb ea jmp 8017f6 <putch+0x21>
0080180c <vfprintf>:
int
vfprintf(int fd, const char *fmt, va_list ap)
{
80180c: 55 push %ebp
80180d: 89 e5 mov %esp,%ebp
80180f: 81 ec 18 01 00 00 sub $0x118,%esp
struct printbuf b;
b.fd = fd;
801815: 8b 45 08 mov 0x8(%ebp),%eax
801818: 89 85 e8 fe ff ff mov %eax,-0x118(%ebp)
b.idx = 0;
80181e: c7 85 ec fe ff ff 00 movl $0x0,-0x114(%ebp)
801825: 00 00 00
b.result = 0;
801828: c7 85 f0 fe ff ff 00 movl $0x0,-0x110(%ebp)
80182f: 00 00 00
b.error = 1;
801832: c7 85 f4 fe ff ff 01 movl $0x1,-0x10c(%ebp)
801839: 00 00 00
vprintfmt(putch, &b, fmt, ap);
80183c: ff 75 10 pushl 0x10(%ebp)
80183f: ff 75 0c pushl 0xc(%ebp)
801842: 8d 85 e8 fe ff ff lea -0x118(%ebp),%eax
801848: 50 push %eax
801849: 68 d5 17 80 00 push $0x8017d5
80184e: e8 a8 ea ff ff call 8002fb <vprintfmt>
if (b.idx > 0)
801853: 83 c4 10 add $0x10,%esp
801856: 83 bd ec fe ff ff 00 cmpl $0x0,-0x114(%ebp)
80185d: 7f 11 jg 801870 <vfprintf+0x64>
writebuf(&b);
return (b.result ? b.result : b.error);
80185f: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax
801865: 85 c0 test %eax,%eax
801867: 0f 44 85 f4 fe ff ff cmove -0x10c(%ebp),%eax
}
80186e: c9 leave
80186f: c3 ret
writebuf(&b);
801870: 8d 85 e8 fe ff ff lea -0x118(%ebp),%eax
801876: e8 1a ff ff ff call 801795 <writebuf>
80187b: eb e2 jmp 80185f <vfprintf+0x53>
0080187d <fprintf>:
int
fprintf(int fd, const char *fmt, ...)
{
80187d: 55 push %ebp
80187e: 89 e5 mov %esp,%ebp
801880: 83 ec 0c sub $0xc,%esp
va_list ap;
int cnt;
va_start(ap, fmt);
801883: 8d 45 10 lea 0x10(%ebp),%eax
cnt = vfprintf(fd, fmt, ap);
801886: 50 push %eax
801887: ff 75 0c pushl 0xc(%ebp)
80188a: ff 75 08 pushl 0x8(%ebp)
80188d: e8 7a ff ff ff call 80180c <vfprintf>
va_end(ap);
return cnt;
}
801892: c9 leave
801893: c3 ret
00801894 <printf>:
int
printf(const char *fmt, ...)
{
801894: 55 push %ebp
801895: 89 e5 mov %esp,%ebp
801897: 83 ec 0c sub $0xc,%esp
va_list ap;
int cnt;
va_start(ap, fmt);
80189a: 8d 45 0c lea 0xc(%ebp),%eax
cnt = vfprintf(1, fmt, ap);
80189d: 50 push %eax
80189e: ff 75 08 pushl 0x8(%ebp)
8018a1: 6a 01 push $0x1
8018a3: e8 64 ff ff ff call 80180c <vfprintf>
va_end(ap);
return cnt;
}
8018a8: c9 leave
8018a9: c3 ret
008018aa <devpipe_stat>:
return i;
}
static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
8018aa: 55 push %ebp
8018ab: 89 e5 mov %esp,%ebp
8018ad: 56 push %esi
8018ae: 53 push %ebx
8018af: 8b 5d 0c mov 0xc(%ebp),%ebx
struct Pipe *p = (struct Pipe*) fd2data(fd);
8018b2: 83 ec 0c sub $0xc,%esp
8018b5: ff 75 08 pushl 0x8(%ebp)
8018b8: e8 ae f6 ff ff call 800f6b <fd2data>
8018bd: 89 c6 mov %eax,%esi
strcpy(stat->st_name, "<pipe>");
8018bf: 83 c4 08 add $0x8,%esp
8018c2: 68 6b 25 80 00 push $0x80256b
8018c7: 53 push %ebx
8018c8: e8 50 ef ff ff call 80081d <strcpy>
stat->st_size = p->p_wpos - p->p_rpos;
8018cd: 8b 46 04 mov 0x4(%esi),%eax
8018d0: 2b 06 sub (%esi),%eax
8018d2: 89 83 80 00 00 00 mov %eax,0x80(%ebx)
stat->st_isdir = 0;
8018d8: c7 83 84 00 00 00 00 movl $0x0,0x84(%ebx)
8018df: 00 00 00
stat->st_dev = &devpipe;
8018e2: c7 83 88 00 00 00 20 movl $0x803020,0x88(%ebx)
8018e9: 30 80 00
return 0;
}
8018ec: b8 00 00 00 00 mov $0x0,%eax
8018f1: 8d 65 f8 lea -0x8(%ebp),%esp
8018f4: 5b pop %ebx
8018f5: 5e pop %esi
8018f6: 5d pop %ebp
8018f7: c3 ret
008018f8 <devpipe_close>:
static int
devpipe_close(struct Fd *fd)
{
8018f8: 55 push %ebp
8018f9: 89 e5 mov %esp,%ebp
8018fb: 53 push %ebx
8018fc: 83 ec 0c sub $0xc,%esp
8018ff: 8b 5d 08 mov 0x8(%ebp),%ebx
(void) sys_page_unmap(0, fd);
801902: 53 push %ebx
801903: 6a 00 push $0x0
801905: e8 91 f3 ff ff call 800c9b <sys_page_unmap>
return sys_page_unmap(0, fd2data(fd));
80190a: 89 1c 24 mov %ebx,(%esp)
80190d: e8 59 f6 ff ff call 800f6b <fd2data>
801912: 83 c4 08 add $0x8,%esp
801915: 50 push %eax
801916: 6a 00 push $0x0
801918: e8 7e f3 ff ff call 800c9b <sys_page_unmap>
}
80191d: 8b 5d fc mov -0x4(%ebp),%ebx
801920: c9 leave
801921: c3 ret
00801922 <_pipeisclosed>:
{
801922: 55 push %ebp
801923: 89 e5 mov %esp,%ebp
801925: 57 push %edi
801926: 56 push %esi
801927: 53 push %ebx
801928: 83 ec 1c sub $0x1c,%esp
80192b: 89 c7 mov %eax,%edi
80192d: 89 d6 mov %edx,%esi
n = thisenv->env_runs;
80192f: a1 04 40 80 00 mov 0x804004,%eax
801934: 8b 58 58 mov 0x58(%eax),%ebx
ret = pageref(fd) == pageref(p);
801937: 83 ec 0c sub $0xc,%esp
80193a: 57 push %edi
80193b: e8 70 05 00 00 call 801eb0 <pageref>
801940: 89 45 e4 mov %eax,-0x1c(%ebp)
801943: 89 34 24 mov %esi,(%esp)
801946: e8 65 05 00 00 call 801eb0 <pageref>
nn = thisenv->env_runs;
80194b: 8b 15 04 40 80 00 mov 0x804004,%edx
801951: 8b 4a 58 mov 0x58(%edx),%ecx
if (n == nn)
801954: 83 c4 10 add $0x10,%esp
801957: 39 cb cmp %ecx,%ebx
801959: 74 1b je 801976 <_pipeisclosed+0x54>
if (n != nn && ret == 1)
80195b: 39 45 e4 cmp %eax,-0x1c(%ebp)
80195e: 75 cf jne 80192f <_pipeisclosed+0xd>
cprintf("pipe race avoided\n", n, thisenv->env_runs, ret);
801960: 8b 42 58 mov 0x58(%edx),%eax
801963: 6a 01 push $0x1
801965: 50 push %eax
801966: 53 push %ebx
801967: 68 72 25 80 00 push $0x802572
80196c: e8 8d e8 ff ff call 8001fe <cprintf>
801971: 83 c4 10 add $0x10,%esp
801974: eb b9 jmp 80192f <_pipeisclosed+0xd>
ret = pageref(fd) == pageref(p);
801976: 39 45 e4 cmp %eax,-0x1c(%ebp)
801979: 0f 94 c0 sete %al
80197c: 0f b6 c0 movzbl %al,%eax
}
80197f: 8d 65 f4 lea -0xc(%ebp),%esp
801982: 5b pop %ebx
801983: 5e pop %esi
801984: 5f pop %edi
801985: 5d pop %ebp
801986: c3 ret
00801987 <devpipe_write>:
{
801987: 55 push %ebp
801988: 89 e5 mov %esp,%ebp
80198a: 57 push %edi
80198b: 56 push %esi
80198c: 53 push %ebx
80198d: 83 ec 28 sub $0x28,%esp
801990: 8b 75 08 mov 0x8(%ebp),%esi
p = (struct Pipe*) fd2data(fd);
801993: 56 push %esi
801994: e8 d2 f5 ff ff call 800f6b <fd2data>
801999: 89 c3 mov %eax,%ebx
for (i = 0; i < n; i++) {
80199b: 83 c4 10 add $0x10,%esp
80199e: bf 00 00 00 00 mov $0x0,%edi
8019a3: 3b 7d 10 cmp 0x10(%ebp),%edi
8019a6: 74 4f je 8019f7 <devpipe_write+0x70>
while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
8019a8: 8b 43 04 mov 0x4(%ebx),%eax
8019ab: 8b 0b mov (%ebx),%ecx
8019ad: 8d 51 20 lea 0x20(%ecx),%edx
8019b0: 39 d0 cmp %edx,%eax
8019b2: 72 14 jb 8019c8 <devpipe_write+0x41>
if (_pipeisclosed(fd, p))
8019b4: 89 da mov %ebx,%edx
8019b6: 89 f0 mov %esi,%eax
8019b8: e8 65 ff ff ff call 801922 <_pipeisclosed>
8019bd: 85 c0 test %eax,%eax
8019bf: 75 3a jne 8019fb <devpipe_write+0x74>
sys_yield();
8019c1: e8 31 f2 ff ff call 800bf7 <sys_yield>
8019c6: eb e0 jmp 8019a8 <devpipe_write+0x21>
p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
8019c8: 8b 4d 0c mov 0xc(%ebp),%ecx
8019cb: 0f b6 0c 39 movzbl (%ecx,%edi,1),%ecx
8019cf: 88 4d e7 mov %cl,-0x19(%ebp)
8019d2: 89 c2 mov %eax,%edx
8019d4: c1 fa 1f sar $0x1f,%edx
8019d7: 89 d1 mov %edx,%ecx
8019d9: c1 e9 1b shr $0x1b,%ecx
8019dc: 8d 14 08 lea (%eax,%ecx,1),%edx
8019df: 83 e2 1f and $0x1f,%edx
8019e2: 29 ca sub %ecx,%edx
8019e4: 0f b6 4d e7 movzbl -0x19(%ebp),%ecx
8019e8: 88 4c 13 08 mov %cl,0x8(%ebx,%edx,1)
p->p_wpos++;
8019ec: 83 c0 01 add $0x1,%eax
8019ef: 89 43 04 mov %eax,0x4(%ebx)
for (i = 0; i < n; i++) {
8019f2: 83 c7 01 add $0x1,%edi
8019f5: eb ac jmp 8019a3 <devpipe_write+0x1c>
return i;
8019f7: 89 f8 mov %edi,%eax
8019f9: eb 05 jmp 801a00 <devpipe_write+0x79>
return 0;
8019fb: b8 00 00 00 00 mov $0x0,%eax
}
801a00: 8d 65 f4 lea -0xc(%ebp),%esp
801a03: 5b pop %ebx
801a04: 5e pop %esi
801a05: 5f pop %edi
801a06: 5d pop %ebp
801a07: c3 ret
00801a08 <devpipe_read>:
{
801a08: 55 push %ebp
801a09: 89 e5 mov %esp,%ebp
801a0b: 57 push %edi
801a0c: 56 push %esi
801a0d: 53 push %ebx
801a0e: 83 ec 18 sub $0x18,%esp
801a11: 8b 7d 08 mov 0x8(%ebp),%edi
p = (struct Pipe*)fd2data(fd);
801a14: 57 push %edi
801a15: e8 51 f5 ff ff call 800f6b <fd2data>
801a1a: 89 c3 mov %eax,%ebx
for (i = 0; i < n; i++) {
801a1c: 83 c4 10 add $0x10,%esp
801a1f: be 00 00 00 00 mov $0x0,%esi
801a24: 3b 75 10 cmp 0x10(%ebp),%esi
801a27: 74 47 je 801a70 <devpipe_read+0x68>
while (p->p_rpos == p->p_wpos) {
801a29: 8b 03 mov (%ebx),%eax
801a2b: 3b 43 04 cmp 0x4(%ebx),%eax
801a2e: 75 22 jne 801a52 <devpipe_read+0x4a>
if (i > 0)
801a30: 85 f6 test %esi,%esi
801a32: 75 14 jne 801a48 <devpipe_read+0x40>
if (_pipeisclosed(fd, p))
801a34: 89 da mov %ebx,%edx
801a36: 89 f8 mov %edi,%eax
801a38: e8 e5 fe ff ff call 801922 <_pipeisclosed>
801a3d: 85 c0 test %eax,%eax
801a3f: 75 33 jne 801a74 <devpipe_read+0x6c>
sys_yield();
801a41: e8 b1 f1 ff ff call 800bf7 <sys_yield>
801a46: eb e1 jmp 801a29 <devpipe_read+0x21>
return i;
801a48: 89 f0 mov %esi,%eax
}
801a4a: 8d 65 f4 lea -0xc(%ebp),%esp
801a4d: 5b pop %ebx
801a4e: 5e pop %esi
801a4f: 5f pop %edi
801a50: 5d pop %ebp
801a51: c3 ret
buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
801a52: 99 cltd
801a53: c1 ea 1b shr $0x1b,%edx
801a56: 01 d0 add %edx,%eax
801a58: 83 e0 1f and $0x1f,%eax
801a5b: 29 d0 sub %edx,%eax
801a5d: 0f b6 44 03 08 movzbl 0x8(%ebx,%eax,1),%eax
801a62: 8b 4d 0c mov 0xc(%ebp),%ecx
801a65: 88 04 31 mov %al,(%ecx,%esi,1)
p->p_rpos++;
801a68: 83 03 01 addl $0x1,(%ebx)
for (i = 0; i < n; i++) {
801a6b: 83 c6 01 add $0x1,%esi
801a6e: eb b4 jmp 801a24 <devpipe_read+0x1c>
return i;
801a70: 89 f0 mov %esi,%eax
801a72: eb d6 jmp 801a4a <devpipe_read+0x42>
return 0;
801a74: b8 00 00 00 00 mov $0x0,%eax
801a79: eb cf jmp 801a4a <devpipe_read+0x42>
00801a7b <pipe>:
{
801a7b: 55 push %ebp
801a7c: 89 e5 mov %esp,%ebp
801a7e: 56 push %esi
801a7f: 53 push %ebx
801a80: 83 ec 1c sub $0x1c,%esp
if ((r = fd_alloc(&fd0)) < 0
801a83: 8d 45 f4 lea -0xc(%ebp),%eax
801a86: 50 push %eax
801a87: e8 f6 f4 ff ff call 800f82 <fd_alloc>
801a8c: 89 c3 mov %eax,%ebx
801a8e: 83 c4 10 add $0x10,%esp
801a91: 85 c0 test %eax,%eax
801a93: 78 5b js 801af0 <pipe+0x75>
|| (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
801a95: 83 ec 04 sub $0x4,%esp
801a98: 68 07 04 00 00 push $0x407
801a9d: ff 75 f4 pushl -0xc(%ebp)
801aa0: 6a 00 push $0x0
801aa2: e8 6f f1 ff ff call 800c16 <sys_page_alloc>
801aa7: 89 c3 mov %eax,%ebx
801aa9: 83 c4 10 add $0x10,%esp
801aac: 85 c0 test %eax,%eax
801aae: 78 40 js 801af0 <pipe+0x75>
if ((r = fd_alloc(&fd1)) < 0
801ab0: 83 ec 0c sub $0xc,%esp
801ab3: 8d 45 f0 lea -0x10(%ebp),%eax
801ab6: 50 push %eax
801ab7: e8 c6 f4 ff ff call 800f82 <fd_alloc>
801abc: 89 c3 mov %eax,%ebx
801abe: 83 c4 10 add $0x10,%esp
801ac1: 85 c0 test %eax,%eax
801ac3: 78 1b js 801ae0 <pipe+0x65>
|| (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
801ac5: 83 ec 04 sub $0x4,%esp
801ac8: 68 07 04 00 00 push $0x407
801acd: ff 75 f0 pushl -0x10(%ebp)
801ad0: 6a 00 push $0x0
801ad2: e8 3f f1 ff ff call 800c16 <sys_page_alloc>
801ad7: 89 c3 mov %eax,%ebx
801ad9: 83 c4 10 add $0x10,%esp
801adc: 85 c0 test %eax,%eax
801ade: 79 19 jns 801af9 <pipe+0x7e>
sys_page_unmap(0, fd0);
801ae0: 83 ec 08 sub $0x8,%esp
801ae3: ff 75 f4 pushl -0xc(%ebp)
801ae6: 6a 00 push $0x0
801ae8: e8 ae f1 ff ff call 800c9b <sys_page_unmap>
801aed: 83 c4 10 add $0x10,%esp
}
801af0: 89 d8 mov %ebx,%eax
801af2: 8d 65 f8 lea -0x8(%ebp),%esp
801af5: 5b pop %ebx
801af6: 5e pop %esi
801af7: 5d pop %ebp
801af8: c3 ret
va = fd2data(fd0);
801af9: 83 ec 0c sub $0xc,%esp
801afc: ff 75 f4 pushl -0xc(%ebp)
801aff: e8 67 f4 ff ff call 800f6b <fd2data>
801b04: 89 c6 mov %eax,%esi
if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
801b06: 83 c4 0c add $0xc,%esp
801b09: 68 07 04 00 00 push $0x407
801b0e: 50 push %eax
801b0f: 6a 00 push $0x0
801b11: e8 00 f1 ff ff call 800c16 <sys_page_alloc>
801b16: 89 c3 mov %eax,%ebx
801b18: 83 c4 10 add $0x10,%esp
801b1b: 85 c0 test %eax,%eax
801b1d: 0f 88 8c 00 00 00 js 801baf <pipe+0x134>
if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
801b23: 83 ec 0c sub $0xc,%esp
801b26: ff 75 f0 pushl -0x10(%ebp)
801b29: e8 3d f4 ff ff call 800f6b <fd2data>
801b2e: c7 04 24 07 04 00 00 movl $0x407,(%esp)
801b35: 50 push %eax
801b36: 6a 00 push $0x0
801b38: 56 push %esi
801b39: 6a 00 push $0x0
801b3b: e8 19 f1 ff ff call 800c59 <sys_page_map>
801b40: 89 c3 mov %eax,%ebx
801b42: 83 c4 20 add $0x20,%esp
801b45: 85 c0 test %eax,%eax
801b47: 78 58 js 801ba1 <pipe+0x126>
fd0->fd_dev_id = devpipe.dev_id;
801b49: 8b 45 f4 mov -0xc(%ebp),%eax
801b4c: 8b 15 20 30 80 00 mov 0x803020,%edx
801b52: 89 10 mov %edx,(%eax)
fd0->fd_omode = O_RDONLY;
801b54: 8b 45 f4 mov -0xc(%ebp),%eax
801b57: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax)
fd1->fd_dev_id = devpipe.dev_id;
801b5e: 8b 45 f0 mov -0x10(%ebp),%eax
801b61: 8b 15 20 30 80 00 mov 0x803020,%edx
801b67: 89 10 mov %edx,(%eax)
fd1->fd_omode = O_WRONLY;
801b69: 8b 45 f0 mov -0x10(%ebp),%eax
801b6c: c7 40 08 01 00 00 00 movl $0x1,0x8(%eax)
pfd[0] = fd2num(fd0);
801b73: 83 ec 0c sub $0xc,%esp
801b76: ff 75 f4 pushl -0xc(%ebp)
801b79: e8 dd f3 ff ff call 800f5b <fd2num>
801b7e: 8b 4d 08 mov 0x8(%ebp),%ecx
801b81: 89 01 mov %eax,(%ecx)
pfd[1] = fd2num(fd1);
801b83: 83 c4 04 add $0x4,%esp
801b86: ff 75 f0 pushl -0x10(%ebp)
801b89: e8 cd f3 ff ff call 800f5b <fd2num>
801b8e: 8b 4d 08 mov 0x8(%ebp),%ecx
801b91: 89 41 04 mov %eax,0x4(%ecx)
return 0;
801b94: 83 c4 10 add $0x10,%esp
801b97: bb 00 00 00 00 mov $0x0,%ebx
801b9c: e9 4f ff ff ff jmp 801af0 <pipe+0x75>
sys_page_unmap(0, va);
801ba1: 83 ec 08 sub $0x8,%esp
801ba4: 56 push %esi
801ba5: 6a 00 push $0x0
801ba7: e8 ef f0 ff ff call 800c9b <sys_page_unmap>
801bac: 83 c4 10 add $0x10,%esp
sys_page_unmap(0, fd1);
801baf: 83 ec 08 sub $0x8,%esp
801bb2: ff 75 f0 pushl -0x10(%ebp)
801bb5: 6a 00 push $0x0
801bb7: e8 df f0 ff ff call 800c9b <sys_page_unmap>
801bbc: 83 c4 10 add $0x10,%esp
801bbf: e9 1c ff ff ff jmp 801ae0 <pipe+0x65>
00801bc4 <pipeisclosed>:
{
801bc4: 55 push %ebp
801bc5: 89 e5 mov %esp,%ebp
801bc7: 83 ec 20 sub $0x20,%esp
if ((r = fd_lookup(fdnum, &fd)) < 0)
801bca: 8d 45 f4 lea -0xc(%ebp),%eax
801bcd: 50 push %eax
801bce: ff 75 08 pushl 0x8(%ebp)
801bd1: e8 fb f3 ff ff call 800fd1 <fd_lookup>
801bd6: 83 c4 10 add $0x10,%esp
801bd9: 85 c0 test %eax,%eax
801bdb: 78 18 js 801bf5 <pipeisclosed+0x31>
p = (struct Pipe*) fd2data(fd);
801bdd: 83 ec 0c sub $0xc,%esp
801be0: ff 75 f4 pushl -0xc(%ebp)
801be3: e8 83 f3 ff ff call 800f6b <fd2data>
return _pipeisclosed(fd, p);
801be8: 89 c2 mov %eax,%edx
801bea: 8b 45 f4 mov -0xc(%ebp),%eax
801bed: e8 30 fd ff ff call 801922 <_pipeisclosed>
801bf2: 83 c4 10 add $0x10,%esp
}
801bf5: c9 leave
801bf6: c3 ret
00801bf7 <devcons_close>:
return tot;
}
static int
devcons_close(struct Fd *fd)
{
801bf7: 55 push %ebp
801bf8: 89 e5 mov %esp,%ebp
USED(fd);
return 0;
}
801bfa: b8 00 00 00 00 mov $0x0,%eax
801bff: 5d pop %ebp
801c00: c3 ret
00801c01 <devcons_stat>:
static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
801c01: 55 push %ebp
801c02: 89 e5 mov %esp,%ebp
801c04: 83 ec 10 sub $0x10,%esp
strcpy(stat->st_name, "<cons>");
801c07: 68 8a 25 80 00 push $0x80258a
801c0c: ff 75 0c pushl 0xc(%ebp)
801c0f: e8 09 ec ff ff call 80081d <strcpy>
return 0;
}
801c14: b8 00 00 00 00 mov $0x0,%eax
801c19: c9 leave
801c1a: c3 ret
00801c1b <devcons_write>:
{
801c1b: 55 push %ebp
801c1c: 89 e5 mov %esp,%ebp
801c1e: 57 push %edi
801c1f: 56 push %esi
801c20: 53 push %ebx
801c21: 81 ec 8c 00 00 00 sub $0x8c,%esp
for (tot = 0; tot < n; tot += m) {
801c27: be 00 00 00 00 mov $0x0,%esi
memmove(buf, (char*)vbuf + tot, m);
801c2c: 8d bd 68 ff ff ff lea -0x98(%ebp),%edi
for (tot = 0; tot < n; tot += m) {
801c32: eb 2f jmp 801c63 <devcons_write+0x48>
m = n - tot;
801c34: 8b 5d 10 mov 0x10(%ebp),%ebx
801c37: 29 f3 sub %esi,%ebx
801c39: 83 fb 7f cmp $0x7f,%ebx
801c3c: b8 7f 00 00 00 mov $0x7f,%eax
801c41: 0f 47 d8 cmova %eax,%ebx
memmove(buf, (char*)vbuf + tot, m);
801c44: 83 ec 04 sub $0x4,%esp
801c47: 53 push %ebx
801c48: 89 f0 mov %esi,%eax
801c4a: 03 45 0c add 0xc(%ebp),%eax
801c4d: 50 push %eax
801c4e: 57 push %edi
801c4f: e8 57 ed ff ff call 8009ab <memmove>
sys_cputs(buf, m);
801c54: 83 c4 08 add $0x8,%esp
801c57: 53 push %ebx
801c58: 57 push %edi
801c59: e8 fc ee ff ff call 800b5a <sys_cputs>
for (tot = 0; tot < n; tot += m) {
801c5e: 01 de add %ebx,%esi
801c60: 83 c4 10 add $0x10,%esp
801c63: 3b 75 10 cmp 0x10(%ebp),%esi
801c66: 72 cc jb 801c34 <devcons_write+0x19>
}
801c68: 89 f0 mov %esi,%eax
801c6a: 8d 65 f4 lea -0xc(%ebp),%esp
801c6d: 5b pop %ebx
801c6e: 5e pop %esi
801c6f: 5f pop %edi
801c70: 5d pop %ebp
801c71: c3 ret
00801c72 <devcons_read>:
{
801c72: 55 push %ebp
801c73: 89 e5 mov %esp,%ebp
801c75: 83 ec 08 sub $0x8,%esp
801c78: b8 00 00 00 00 mov $0x0,%eax
if (n == 0)
801c7d: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
801c81: 75 07 jne 801c8a <devcons_read+0x18>
}
801c83: c9 leave
801c84: c3 ret
sys_yield();
801c85: e8 6d ef ff ff call 800bf7 <sys_yield>
while ((c = sys_cgetc()) == 0)
801c8a: e8 e9 ee ff ff call 800b78 <sys_cgetc>
801c8f: 85 c0 test %eax,%eax
801c91: 74 f2 je 801c85 <devcons_read+0x13>
if (c < 0)
801c93: 85 c0 test %eax,%eax
801c95: 78 ec js 801c83 <devcons_read+0x11>
if (c == 0x04) // ctl-d is eof
801c97: 83 f8 04 cmp $0x4,%eax
801c9a: 74 0c je 801ca8 <devcons_read+0x36>
*(char*)vbuf = c;
801c9c: 8b 55 0c mov 0xc(%ebp),%edx
801c9f: 88 02 mov %al,(%edx)
return 1;
801ca1: b8 01 00 00 00 mov $0x1,%eax
801ca6: eb db jmp 801c83 <devcons_read+0x11>
return 0;
801ca8: b8 00 00 00 00 mov $0x0,%eax
801cad: eb d4 jmp 801c83 <devcons_read+0x11>
00801caf <cputchar>:
{
801caf: 55 push %ebp
801cb0: 89 e5 mov %esp,%ebp
801cb2: 83 ec 20 sub $0x20,%esp
char c = ch;
801cb5: 8b 45 08 mov 0x8(%ebp),%eax
801cb8: 88 45 f7 mov %al,-0x9(%ebp)
sys_cputs(&c, 1);
801cbb: 6a 01 push $0x1
801cbd: 8d 45 f7 lea -0x9(%ebp),%eax
801cc0: 50 push %eax
801cc1: e8 94 ee ff ff call 800b5a <sys_cputs>
}
801cc6: 83 c4 10 add $0x10,%esp
801cc9: c9 leave
801cca: c3 ret
00801ccb <getchar>:
{
801ccb: 55 push %ebp
801ccc: 89 e5 mov %esp,%ebp
801cce: 83 ec 1c sub $0x1c,%esp
r = read(0, &c, 1);
801cd1: 6a 01 push $0x1
801cd3: 8d 45 f7 lea -0x9(%ebp),%eax
801cd6: 50 push %eax
801cd7: 6a 00 push $0x0
801cd9: e8 64 f5 ff ff call 801242 <read>
if (r < 0)
801cde: 83 c4 10 add $0x10,%esp
801ce1: 85 c0 test %eax,%eax
801ce3: 78 08 js 801ced <getchar+0x22>
if (r < 1)
801ce5: 85 c0 test %eax,%eax
801ce7: 7e 06 jle 801cef <getchar+0x24>
return c;
801ce9: 0f b6 45 f7 movzbl -0x9(%ebp),%eax
}
801ced: c9 leave
801cee: c3 ret
return -E_EOF;
801cef: b8 f8 ff ff ff mov $0xfffffff8,%eax
801cf4: eb f7 jmp 801ced <getchar+0x22>
00801cf6 <iscons>:
{
801cf6: 55 push %ebp
801cf7: 89 e5 mov %esp,%ebp
801cf9: 83 ec 20 sub $0x20,%esp
if ((r = fd_lookup(fdnum, &fd)) < 0)
801cfc: 8d 45 f4 lea -0xc(%ebp),%eax
801cff: 50 push %eax
801d00: ff 75 08 pushl 0x8(%ebp)
801d03: e8 c9 f2 ff ff call 800fd1 <fd_lookup>
801d08: 83 c4 10 add $0x10,%esp
801d0b: 85 c0 test %eax,%eax
801d0d: 78 11 js 801d20 <iscons+0x2a>
return fd->fd_dev_id == devcons.dev_id;
801d0f: 8b 45 f4 mov -0xc(%ebp),%eax
801d12: 8b 15 3c 30 80 00 mov 0x80303c,%edx
801d18: 39 10 cmp %edx,(%eax)
801d1a: 0f 94 c0 sete %al
801d1d: 0f b6 c0 movzbl %al,%eax
}
801d20: c9 leave
801d21: c3 ret
00801d22 <opencons>:
{
801d22: 55 push %ebp
801d23: 89 e5 mov %esp,%ebp
801d25: 83 ec 24 sub $0x24,%esp
if ((r = fd_alloc(&fd)) < 0)
801d28: 8d 45 f4 lea -0xc(%ebp),%eax
801d2b: 50 push %eax
801d2c: e8 51 f2 ff ff call 800f82 <fd_alloc>
801d31: 83 c4 10 add $0x10,%esp
801d34: 85 c0 test %eax,%eax
801d36: 78 3a js 801d72 <opencons+0x50>
if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
801d38: 83 ec 04 sub $0x4,%esp
801d3b: 68 07 04 00 00 push $0x407
801d40: ff 75 f4 pushl -0xc(%ebp)
801d43: 6a 00 push $0x0
801d45: e8 cc ee ff ff call 800c16 <sys_page_alloc>
801d4a: 83 c4 10 add $0x10,%esp
801d4d: 85 c0 test %eax,%eax
801d4f: 78 21 js 801d72 <opencons+0x50>
fd->fd_dev_id = devcons.dev_id;
801d51: 8b 45 f4 mov -0xc(%ebp),%eax
801d54: 8b 15 3c 30 80 00 mov 0x80303c,%edx
801d5a: 89 10 mov %edx,(%eax)
fd->fd_omode = O_RDWR;
801d5c: 8b 45 f4 mov -0xc(%ebp),%eax
801d5f: c7 40 08 02 00 00 00 movl $0x2,0x8(%eax)
return fd2num(fd);
801d66: 83 ec 0c sub $0xc,%esp
801d69: 50 push %eax
801d6a: e8 ec f1 ff ff call 800f5b <fd2num>
801d6f: 83 c4 10 add $0x10,%esp
}
801d72: c9 leave
801d73: c3 ret
00801d74 <_panic>:
* It prints "panic: <message>", then causes a breakpoint exception,
* which causes JOS to enter the JOS kernel monitor.
*/
void
_panic(const char *file, int line, const char *fmt, ...)
{
801d74: 55 push %ebp
801d75: 89 e5 mov %esp,%ebp
801d77: 56 push %esi
801d78: 53 push %ebx
va_list ap;
va_start(ap, fmt);
801d79: 8d 5d 14 lea 0x14(%ebp),%ebx
// Print the panic message
cprintf("[%08x] user panic in %s at %s:%d: ",
801d7c: 8b 35 00 30 80 00 mov 0x803000,%esi
801d82: e8 51 ee ff ff call 800bd8 <sys_getenvid>
801d87: 83 ec 0c sub $0xc,%esp
801d8a: ff 75 0c pushl 0xc(%ebp)
801d8d: ff 75 08 pushl 0x8(%ebp)
801d90: 56 push %esi
801d91: 50 push %eax
801d92: 68 98 25 80 00 push $0x802598
801d97: e8 62 e4 ff ff call 8001fe <cprintf>
sys_getenvid(), binaryname, file, line);
vcprintf(fmt, ap);
801d9c: 83 c4 18 add $0x18,%esp
801d9f: 53 push %ebx
801da0: ff 75 10 pushl 0x10(%ebp)
801da3: e8 05 e4 ff ff call 8001ad <vcprintf>
cprintf("\n");
801da8: c7 04 24 50 21 80 00 movl $0x802150,(%esp)
801daf: e8 4a e4 ff ff call 8001fe <cprintf>
801db4: 83 c4 10 add $0x10,%esp
// Cause a breakpoint exception
while (1)
asm volatile("int3");
801db7: cc int3
801db8: eb fd jmp 801db7 <_panic+0x43>
00801dba <ipc_recv>:
// If 'pg' is null, pass sys_ipc_recv a value that it will understand
// as meaning "no page". (Zero is not the right value, since that's
// a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
801dba: 55 push %ebp
801dbb: 89 e5 mov %esp,%ebp
801dbd: 56 push %esi
801dbe: 53 push %ebx
801dbf: 8b 75 08 mov 0x8(%ebp),%esi
801dc2: 8b 45 0c mov 0xc(%ebp),%eax
801dc5: 8b 5d 10 mov 0x10(%ebp),%ebx
// LAB 4: Your code here.
if (pg == NULL) {
801dc8: 85 c0 test %eax,%eax
pg = (void *)-1;
801dca: ba ff ff ff ff mov $0xffffffff,%edx
801dcf: 0f 44 c2 cmove %edx,%eax
}
int r = sys_ipc_recv(pg);
801dd2: 83 ec 0c sub $0xc,%esp
801dd5: 50 push %eax
801dd6: e8 eb ef ff ff call 800dc6 <sys_ipc_recv>
if (r < 0) { //系统调用失败
801ddb: 83 c4 10 add $0x10,%esp
801dde: 85 c0 test %eax,%eax
801de0: 78 2b js 801e0d <ipc_recv+0x53>
if (from_env_store) *from_env_store = 0;
if (perm_store) *perm_store = 0;
return r;
}
if (from_env_store)
801de2: 85 f6 test %esi,%esi
801de4: 74 0a je 801df0 <ipc_recv+0x36>
*from_env_store = thisenv->env_ipc_from;
801de6: a1 04 40 80 00 mov 0x804004,%eax
801deb: 8b 40 74 mov 0x74(%eax),%eax
801dee: 89 06 mov %eax,(%esi)
if (perm_store)
801df0: 85 db test %ebx,%ebx
801df2: 74 0a je 801dfe <ipc_recv+0x44>
*perm_store = thisenv->env_ipc_perm;
801df4: a1 04 40 80 00 mov 0x804004,%eax
801df9: 8b 40 78 mov 0x78(%eax),%eax
801dfc: 89 03 mov %eax,(%ebx)
return thisenv->env_ipc_value;
801dfe: a1 04 40 80 00 mov 0x804004,%eax
801e03: 8b 40 70 mov 0x70(%eax),%eax
}
801e06: 8d 65 f8 lea -0x8(%ebp),%esp
801e09: 5b pop %ebx
801e0a: 5e pop %esi
801e0b: 5d pop %ebp
801e0c: c3 ret
if (from_env_store) *from_env_store = 0;
801e0d: 85 f6 test %esi,%esi
801e0f: 74 06 je 801e17 <ipc_recv+0x5d>
801e11: c7 06 00 00 00 00 movl $0x0,(%esi)
if (perm_store) *perm_store = 0;
801e17: 85 db test %ebx,%ebx
801e19: 74 eb je 801e06 <ipc_recv+0x4c>
801e1b: c7 03 00 00 00 00 movl $0x0,(%ebx)
801e21: eb e3 jmp 801e06 <ipc_recv+0x4c>
00801e23 <ipc_send>:
// Use sys_yield() to be CPU-friendly.
// If 'pg' is null, pass sys_ipc_try_send a value that it will understand
// as meaning "no page". (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
801e23: 55 push %ebp
801e24: 89 e5 mov %esp,%ebp
801e26: 57 push %edi
801e27: 56 push %esi
801e28: 53 push %ebx
801e29: 83 ec 0c sub $0xc,%esp
801e2c: 8b 7d 08 mov 0x8(%ebp),%edi
801e2f: 8b 75 0c mov 0xc(%ebp),%esi
801e32: 8b 5d 10 mov 0x10(%ebp),%ebx
// LAB 4: Your code here.
if (pg == NULL) {
801e35: 85 db test %ebx,%ebx
pg = (void *)-1;
801e37: b8 ff ff ff ff mov $0xffffffff,%eax
801e3c: 0f 44 d8 cmove %eax,%ebx
}
int r;
while(1) {
r = sys_ipc_try_send(to_env, val, pg, perm);
801e3f: ff 75 14 pushl 0x14(%ebp)
801e42: 53 push %ebx
801e43: 56 push %esi
801e44: 57 push %edi
801e45: e8 59 ef ff ff call 800da3 <sys_ipc_try_send>
if (r == 0) { //发送成功
801e4a: 83 c4 10 add $0x10,%esp
801e4d: 85 c0 test %eax,%eax
801e4f: 74 1e je 801e6f <ipc_send+0x4c>
return;
} else if (r == -E_IPC_NOT_RECV) { //接收进程没有准备好
801e51: 83 f8 f9 cmp $0xfffffff9,%eax
801e54: 75 07 jne 801e5d <ipc_send+0x3a>
sys_yield();
801e56: e8 9c ed ff ff call 800bf7 <sys_yield>
r = sys_ipc_try_send(to_env, val, pg, perm);
801e5b: eb e2 jmp 801e3f <ipc_send+0x1c>
} else { //其它错误
panic("ipc_send():%e", r);
801e5d: 50 push %eax
801e5e: 68 bc 25 80 00 push $0x8025bc
801e63: 6a 41 push $0x41
801e65: 68 ca 25 80 00 push $0x8025ca
801e6a: e8 05 ff ff ff call 801d74 <_panic>
}
}
}
801e6f: 8d 65 f4 lea -0xc(%ebp),%esp
801e72: 5b pop %ebx
801e73: 5e pop %esi
801e74: 5f pop %edi
801e75: 5d pop %ebp
801e76: c3 ret
00801e77 <ipc_find_env>:
// Find the first environment of the given type. We'll use this to
// find special environments.
// Returns 0 if no such environment exists.
envid_t
ipc_find_env(enum EnvType type)
{
801e77: 55 push %ebp
801e78: 89 e5 mov %esp,%ebp
801e7a: 8b 4d 08 mov 0x8(%ebp),%ecx
int i;
for (i = 0; i < NENV; i++)
801e7d: b8 00 00 00 00 mov $0x0,%eax
if (envs[i].env_type == type)
801e82: 6b d0 7c imul $0x7c,%eax,%edx
801e85: 81 c2 00 00 c0 ee add $0xeec00000,%edx
801e8b: 8b 52 50 mov 0x50(%edx),%edx
801e8e: 39 ca cmp %ecx,%edx
801e90: 74 11 je 801ea3 <ipc_find_env+0x2c>
for (i = 0; i < NENV; i++)
801e92: 83 c0 01 add $0x1,%eax
801e95: 3d 00 04 00 00 cmp $0x400,%eax
801e9a: 75 e6 jne 801e82 <ipc_find_env+0xb>
return envs[i].env_id;
return 0;
801e9c: b8 00 00 00 00 mov $0x0,%eax
801ea1: eb 0b jmp 801eae <ipc_find_env+0x37>
return envs[i].env_id;
801ea3: 6b c0 7c imul $0x7c,%eax,%eax
801ea6: 05 00 00 c0 ee add $0xeec00000,%eax
801eab: 8b 40 48 mov 0x48(%eax),%eax
}
801eae: 5d pop %ebp
801eaf: c3 ret
00801eb0 <pageref>:
#include <inc/lib.h>
int
pageref(void *v)
{
801eb0: 55 push %ebp
801eb1: 89 e5 mov %esp,%ebp
801eb3: 8b 55 08 mov 0x8(%ebp),%edx
pte_t pte;
if (!(uvpd[PDX(v)] & PTE_P))
801eb6: 89 d0 mov %edx,%eax
801eb8: c1 e8 16 shr $0x16,%eax
801ebb: 8b 0c 85 00 d0 7b ef mov -0x10843000(,%eax,4),%ecx
return 0;
801ec2: b8 00 00 00 00 mov $0x0,%eax
if (!(uvpd[PDX(v)] & PTE_P))
801ec7: f6 c1 01 test $0x1,%cl
801eca: 74 1d je 801ee9 <pageref+0x39>
pte = uvpt[PGNUM(v)];
801ecc: c1 ea 0c shr $0xc,%edx
801ecf: 8b 14 95 00 00 40 ef mov -0x10c00000(,%edx,4),%edx
if (!(pte & PTE_P))
801ed6: f6 c2 01 test $0x1,%dl
801ed9: 74 0e je 801ee9 <pageref+0x39>
return 0;
return pages[PGNUM(pte)].pp_ref;
801edb: c1 ea 0c shr $0xc,%edx
801ede: 0f b7 04 d5 04 00 00 movzwl -0x10fffffc(,%edx,8),%eax
801ee5: ef
801ee6: 0f b7 c0 movzwl %ax,%eax
}
801ee9: 5d pop %ebp
801eea: c3 ret
801eeb: 66 90 xchg %ax,%ax
801eed: 66 90 xchg %ax,%ax
801eef: 90 nop
00801ef0 <__udivdi3>:
801ef0: 55 push %ebp
801ef1: 57 push %edi
801ef2: 56 push %esi
801ef3: 53 push %ebx
801ef4: 83 ec 1c sub $0x1c,%esp
801ef7: 8b 54 24 3c mov 0x3c(%esp),%edx
801efb: 8b 6c 24 30 mov 0x30(%esp),%ebp
801eff: 8b 74 24 34 mov 0x34(%esp),%esi
801f03: 8b 5c 24 38 mov 0x38(%esp),%ebx
801f07: 85 d2 test %edx,%edx
801f09: 75 35 jne 801f40 <__udivdi3+0x50>
801f0b: 39 f3 cmp %esi,%ebx
801f0d: 0f 87 bd 00 00 00 ja 801fd0 <__udivdi3+0xe0>
801f13: 85 db test %ebx,%ebx
801f15: 89 d9 mov %ebx,%ecx
801f17: 75 0b jne 801f24 <__udivdi3+0x34>
801f19: b8 01 00 00 00 mov $0x1,%eax
801f1e: 31 d2 xor %edx,%edx
801f20: f7 f3 div %ebx
801f22: 89 c1 mov %eax,%ecx
801f24: 31 d2 xor %edx,%edx
801f26: 89 f0 mov %esi,%eax
801f28: f7 f1 div %ecx
801f2a: 89 c6 mov %eax,%esi
801f2c: 89 e8 mov %ebp,%eax
801f2e: 89 f7 mov %esi,%edi
801f30: f7 f1 div %ecx
801f32: 89 fa mov %edi,%edx
801f34: 83 c4 1c add $0x1c,%esp
801f37: 5b pop %ebx
801f38: 5e pop %esi
801f39: 5f pop %edi
801f3a: 5d pop %ebp
801f3b: c3 ret
801f3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
801f40: 39 f2 cmp %esi,%edx
801f42: 77 7c ja 801fc0 <__udivdi3+0xd0>
801f44: 0f bd fa bsr %edx,%edi
801f47: 83 f7 1f xor $0x1f,%edi
801f4a: 0f 84 98 00 00 00 je 801fe8 <__udivdi3+0xf8>
801f50: 89 f9 mov %edi,%ecx
801f52: b8 20 00 00 00 mov $0x20,%eax
801f57: 29 f8 sub %edi,%eax
801f59: d3 e2 shl %cl,%edx
801f5b: 89 54 24 08 mov %edx,0x8(%esp)
801f5f: 89 c1 mov %eax,%ecx
801f61: 89 da mov %ebx,%edx
801f63: d3 ea shr %cl,%edx
801f65: 8b 4c 24 08 mov 0x8(%esp),%ecx
801f69: 09 d1 or %edx,%ecx
801f6b: 89 f2 mov %esi,%edx
801f6d: 89 4c 24 08 mov %ecx,0x8(%esp)
801f71: 89 f9 mov %edi,%ecx
801f73: d3 e3 shl %cl,%ebx
801f75: 89 c1 mov %eax,%ecx
801f77: d3 ea shr %cl,%edx
801f79: 89 f9 mov %edi,%ecx
801f7b: 89 5c 24 0c mov %ebx,0xc(%esp)
801f7f: d3 e6 shl %cl,%esi
801f81: 89 eb mov %ebp,%ebx
801f83: 89 c1 mov %eax,%ecx
801f85: d3 eb shr %cl,%ebx
801f87: 09 de or %ebx,%esi
801f89: 89 f0 mov %esi,%eax
801f8b: f7 74 24 08 divl 0x8(%esp)
801f8f: 89 d6 mov %edx,%esi
801f91: 89 c3 mov %eax,%ebx
801f93: f7 64 24 0c mull 0xc(%esp)
801f97: 39 d6 cmp %edx,%esi
801f99: 72 0c jb 801fa7 <__udivdi3+0xb7>
801f9b: 89 f9 mov %edi,%ecx
801f9d: d3 e5 shl %cl,%ebp
801f9f: 39 c5 cmp %eax,%ebp
801fa1: 73 5d jae 802000 <__udivdi3+0x110>
801fa3: 39 d6 cmp %edx,%esi
801fa5: 75 59 jne 802000 <__udivdi3+0x110>
801fa7: 8d 43 ff lea -0x1(%ebx),%eax
801faa: 31 ff xor %edi,%edi
801fac: 89 fa mov %edi,%edx
801fae: 83 c4 1c add $0x1c,%esp
801fb1: 5b pop %ebx
801fb2: 5e pop %esi
801fb3: 5f pop %edi
801fb4: 5d pop %ebp
801fb5: c3 ret
801fb6: 8d 76 00 lea 0x0(%esi),%esi
801fb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
801fc0: 31 ff xor %edi,%edi
801fc2: 31 c0 xor %eax,%eax
801fc4: 89 fa mov %edi,%edx
801fc6: 83 c4 1c add $0x1c,%esp
801fc9: 5b pop %ebx
801fca: 5e pop %esi
801fcb: 5f pop %edi
801fcc: 5d pop %ebp
801fcd: c3 ret
801fce: 66 90 xchg %ax,%ax
801fd0: 31 ff xor %edi,%edi
801fd2: 89 e8 mov %ebp,%eax
801fd4: 89 f2 mov %esi,%edx
801fd6: f7 f3 div %ebx
801fd8: 89 fa mov %edi,%edx
801fda: 83 c4 1c add $0x1c,%esp
801fdd: 5b pop %ebx
801fde: 5e pop %esi
801fdf: 5f pop %edi
801fe0: 5d pop %ebp
801fe1: c3 ret
801fe2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
801fe8: 39 f2 cmp %esi,%edx
801fea: 72 06 jb 801ff2 <__udivdi3+0x102>
801fec: 31 c0 xor %eax,%eax
801fee: 39 eb cmp %ebp,%ebx
801ff0: 77 d2 ja 801fc4 <__udivdi3+0xd4>
801ff2: b8 01 00 00 00 mov $0x1,%eax
801ff7: eb cb jmp 801fc4 <__udivdi3+0xd4>
801ff9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
802000: 89 d8 mov %ebx,%eax
802002: 31 ff xor %edi,%edi
802004: eb be jmp 801fc4 <__udivdi3+0xd4>
802006: 66 90 xchg %ax,%ax
802008: 66 90 xchg %ax,%ax
80200a: 66 90 xchg %ax,%ax
80200c: 66 90 xchg %ax,%ax
80200e: 66 90 xchg %ax,%ax
00802010 <__umoddi3>:
802010: 55 push %ebp
802011: 57 push %edi
802012: 56 push %esi
802013: 53 push %ebx
802014: 83 ec 1c sub $0x1c,%esp
802017: 8b 6c 24 3c mov 0x3c(%esp),%ebp
80201b: 8b 74 24 30 mov 0x30(%esp),%esi
80201f: 8b 5c 24 34 mov 0x34(%esp),%ebx
802023: 8b 7c 24 38 mov 0x38(%esp),%edi
802027: 85 ed test %ebp,%ebp
802029: 89 f0 mov %esi,%eax
80202b: 89 da mov %ebx,%edx
80202d: 75 19 jne 802048 <__umoddi3+0x38>
80202f: 39 df cmp %ebx,%edi
802031: 0f 86 b1 00 00 00 jbe 8020e8 <__umoddi3+0xd8>
802037: f7 f7 div %edi
802039: 89 d0 mov %edx,%eax
80203b: 31 d2 xor %edx,%edx
80203d: 83 c4 1c add $0x1c,%esp
802040: 5b pop %ebx
802041: 5e pop %esi
802042: 5f pop %edi
802043: 5d pop %ebp
802044: c3 ret
802045: 8d 76 00 lea 0x0(%esi),%esi
802048: 39 dd cmp %ebx,%ebp
80204a: 77 f1 ja 80203d <__umoddi3+0x2d>
80204c: 0f bd cd bsr %ebp,%ecx
80204f: 83 f1 1f xor $0x1f,%ecx
802052: 89 4c 24 04 mov %ecx,0x4(%esp)
802056: 0f 84 b4 00 00 00 je 802110 <__umoddi3+0x100>
80205c: b8 20 00 00 00 mov $0x20,%eax
802061: 89 c2 mov %eax,%edx
802063: 8b 44 24 04 mov 0x4(%esp),%eax
802067: 29 c2 sub %eax,%edx
802069: 89 c1 mov %eax,%ecx
80206b: 89 f8 mov %edi,%eax
80206d: d3 e5 shl %cl,%ebp
80206f: 89 d1 mov %edx,%ecx
802071: 89 54 24 0c mov %edx,0xc(%esp)
802075: d3 e8 shr %cl,%eax
802077: 09 c5 or %eax,%ebp
802079: 8b 44 24 04 mov 0x4(%esp),%eax
80207d: 89 c1 mov %eax,%ecx
80207f: d3 e7 shl %cl,%edi
802081: 89 d1 mov %edx,%ecx
802083: 89 7c 24 08 mov %edi,0x8(%esp)
802087: 89 df mov %ebx,%edi
802089: d3 ef shr %cl,%edi
80208b: 89 c1 mov %eax,%ecx
80208d: 89 f0 mov %esi,%eax
80208f: d3 e3 shl %cl,%ebx
802091: 89 d1 mov %edx,%ecx
802093: 89 fa mov %edi,%edx
802095: d3 e8 shr %cl,%eax
802097: 0f b6 4c 24 04 movzbl 0x4(%esp),%ecx
80209c: 09 d8 or %ebx,%eax
80209e: f7 f5 div %ebp
8020a0: d3 e6 shl %cl,%esi
8020a2: 89 d1 mov %edx,%ecx
8020a4: f7 64 24 08 mull 0x8(%esp)
8020a8: 39 d1 cmp %edx,%ecx
8020aa: 89 c3 mov %eax,%ebx
8020ac: 89 d7 mov %edx,%edi
8020ae: 72 06 jb 8020b6 <__umoddi3+0xa6>
8020b0: 75 0e jne 8020c0 <__umoddi3+0xb0>
8020b2: 39 c6 cmp %eax,%esi
8020b4: 73 0a jae 8020c0 <__umoddi3+0xb0>
8020b6: 2b 44 24 08 sub 0x8(%esp),%eax
8020ba: 19 ea sbb %ebp,%edx
8020bc: 89 d7 mov %edx,%edi
8020be: 89 c3 mov %eax,%ebx
8020c0: 89 ca mov %ecx,%edx
8020c2: 0f b6 4c 24 0c movzbl 0xc(%esp),%ecx
8020c7: 29 de sub %ebx,%esi
8020c9: 19 fa sbb %edi,%edx
8020cb: 8b 5c 24 04 mov 0x4(%esp),%ebx
8020cf: 89 d0 mov %edx,%eax
8020d1: d3 e0 shl %cl,%eax
8020d3: 89 d9 mov %ebx,%ecx
8020d5: d3 ee shr %cl,%esi
8020d7: d3 ea shr %cl,%edx
8020d9: 09 f0 or %esi,%eax
8020db: 83 c4 1c add $0x1c,%esp
8020de: 5b pop %ebx
8020df: 5e pop %esi
8020e0: 5f pop %edi
8020e1: 5d pop %ebp
8020e2: c3 ret
8020e3: 90 nop
8020e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
8020e8: 85 ff test %edi,%edi
8020ea: 89 f9 mov %edi,%ecx
8020ec: 75 0b jne 8020f9 <__umoddi3+0xe9>
8020ee: b8 01 00 00 00 mov $0x1,%eax
8020f3: 31 d2 xor %edx,%edx
8020f5: f7 f7 div %edi
8020f7: 89 c1 mov %eax,%ecx
8020f9: 89 d8 mov %ebx,%eax
8020fb: 31 d2 xor %edx,%edx
8020fd: f7 f1 div %ecx
8020ff: 89 f0 mov %esi,%eax
802101: f7 f1 div %ecx
802103: e9 31 ff ff ff jmp 802039 <__umoddi3+0x29>
802108: 90 nop
802109: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
802110: 39 dd cmp %ebx,%ebp
802112: 72 08 jb 80211c <__umoddi3+0x10c>
802114: 39 f7 cmp %esi,%edi
802116: 0f 87 21 ff ff ff ja 80203d <__umoddi3+0x2d>
80211c: 89 da mov %ebx,%edx
80211e: 89 f0 mov %esi,%eax
802120: 29 f8 sub %edi,%eax
802122: 19 ea sbb %ebp,%edx
802124: e9 14 ff ff ff jmp 80203d <__umoddi3+0x2d>
| 40.248193 | 91 | 0.46611 |
801a15faca3fbb0c11e31a150e46e5f38c8cb0f3 | 935 | java | Java | vonce-sqlbean-core/src/main/java/cn/vonce/sql/annotation/SqlColumn.java | Jovilam77/vonce-sqlbean | 881ce6b45533306c2aae7a310672f4597d4dae29 | [
"MIT"
] | 15 | 2019-08-19T07:37:02.000Z | 2021-07-09T06:14:22.000Z | vonce-sqlbean-core/src/main/java/cn/vonce/sql/annotation/SqlColumn.java | Jovilam77/vonce-sqlbean | 881ce6b45533306c2aae7a310672f4597d4dae29 | [
"MIT"
] | 1 | 2021-09-01T01:33:28.000Z | 2021-09-01T01:33:28.000Z | vonce-sqlbean-core/src/main/java/cn/vonce/sql/annotation/SqlColumn.java | Jovilam77/vonce-sqlbean | 881ce6b45533306c2aae7a310672f4597d4dae29 | [
"MIT"
] | 2 | 2019-12-05T08:56:36.000Z | 2021-09-01T08:41:20.000Z | package cn.vonce.sql.annotation;
import cn.vonce.sql.enumerate.JdbcType;
import java.lang.annotation.*;
/**
* 标识Bean 实体类的字段与数据库中对应的字段名
*
* @author Jovi
* @version 1.0
* @email 766255988@qq.com
* @date 2018年2月8日下午2:55:04
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Documented
@Inherited
public @interface SqlColumn {
/**
* 列字段名称
*
* @return
*/
String value();
/**
* 不能是null
*
* @return
*/
boolean notNull() default false;
/**
* 类型
*
* @return
*/
JdbcType type() default JdbcType.NOTHING;
/**
* 长度
*
* @return
*/
int length() default 0;
/**
* 小数点
*
* @return
*/
int decimal() default 0;
/**
* 默认值
*
* @return
*/
String def() default "";
/**
* 是否忽略该字段
*
* @return
*/
boolean ignore() default false;
}
| 13.169014 | 45 | 0.512299 |
6672af695dd1f63f0a008141628e9ae30abb0da7 | 964 | swift | Swift | intro/student-4/9 Types/Types.playground/Pages/Type Inference From Assignment.xcplaygroundpage/Contents.swift | hgtlzyc/DevMountainStudy | 6496fe019a1e0df7fc7b482f1eb4f99a14809ef8 | [
"MIT"
] | 7 | 2017-03-04T00:09:40.000Z | 2017-12-08T16:21:20.000Z | intro/student-4/9 Types/Types.playground/Pages/Type Inference From Assignment.xcplaygroundpage/Contents.swift | hgtlzyc/DevMountainStudy | 6496fe019a1e0df7fc7b482f1eb4f99a14809ef8 | [
"MIT"
] | null | null | null | intro/student-4/9 Types/Types.playground/Pages/Type Inference From Assignment.xcplaygroundpage/Contents.swift | hgtlzyc/DevMountainStudy | 6496fe019a1e0df7fc7b482f1eb4f99a14809ef8 | [
"MIT"
] | 7 | 2017-10-14T10:33:05.000Z | 2021-06-24T07:29:08.000Z | /*:
## Type Inference from Assignment
Literals are not the only way to create new constants or variables.
An assignment statement has a left side (the thing being assigned to) and a right side (the value that’s being assigned):
```
let leftHandSide = rightHandSide
```
The value on the right hand side will have a type, because it already exists. `leftHandSide` will be inferred to have the same type.
*/
let string = "42"
let anotherString = string
/*:
In this example, `string` is of type `String` because it is created from a literal. And `anotherString` is also of type `String`, because it is created from a `String`.
- experiment: Change `"42"` to `42`. What type will `anotherString` have now?\
(Hint: Check the type by holding down the `Option` key while clicking the `anotherString` constant.)
Next, find out what to do when type inference doesn’t work.
[Previous](@previous) | page 7 of 13 | [Next: Type Annotation](@next)
*/
| 37.076923 | 169 | 0.71888 |
423027e6da5396bb102195badfaf8a924d0a1f2e | 669 | dart | Dart | lib/src/base/bloc/base_event.dart | himadridebnath1993/flutter_gql_centwork | b8544c3f0d7c4296cd0cf06c0e1ca36b89d1bd63 | [
"Unlicense"
] | null | null | null | lib/src/base/bloc/base_event.dart | himadridebnath1993/flutter_gql_centwork | b8544c3f0d7c4296cd0cf06c0e1ca36b89d1bd63 | [
"Unlicense"
] | null | null | null | lib/src/base/bloc/base_event.dart | himadridebnath1993/flutter_gql_centwork | b8544c3f0d7c4296cd0cf06c0e1ca36b89d1bd63 | [
"Unlicense"
] | null | null | null | part of 'base_bloc.dart';
@immutable
abstract class BaseEvent {
Stream<BaseState> applyAsync({required BaseState currentState,required BaseBloc bloc});
}
class BError extends BaseEvent {
final dynamic error;
BError(this.error);
@override
Stream<BaseState> applyAsync({required BaseState currentState,required BaseBloc bloc}) async* {
await Timer(const Duration(milliseconds: 400), () {});
yield BaseError(error);
}
}
class BRefresh extends BaseEvent {
final dynamic data;
BRefresh([this.data]);
@override
Stream<BaseState> applyAsync({required BaseState currentState,required BaseBloc bloc}) async* {
yield BaseRefresh(data);
}
}
| 24.777778 | 97 | 0.73991 |
b6d59722b6ded4e7f6955f5d30d642c69c1a397e | 26 | dart | Dart | packages/dmg-io-mobile/lib/src/utils/other/index.dart | ndc466/DMG.io | 20efba6cc88aa1de8bbefcc02da3e8d8a6cca0cf | [
"MIT"
] | 1 | 2021-05-12T13:55:15.000Z | 2021-05-12T13:55:15.000Z | packages/dmg-io-mobile/lib/src/utils/other/index.dart | ndc466/DMG.io | 20efba6cc88aa1de8bbefcc02da3e8d8a6cca0cf | [
"MIT"
] | null | null | null | packages/dmg-io-mobile/lib/src/utils/other/index.dart | ndc466/DMG.io | 20efba6cc88aa1de8bbefcc02da3e8d8a6cca0cf | [
"MIT"
] | null | null | null | export 'dark_theme.dart';
| 13 | 25 | 0.769231 |
97d1bed3d0897901c27ea1abfa342f37f99a71a9 | 147 | asm | Assembly | libsrc/_DEVELOPMENT/math/float/math32/c/sdcc/cm32_sdcc_atan.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 640 | 2017-01-14T23:33:45.000Z | 2022-03-30T11:28:42.000Z | libsrc/_DEVELOPMENT/math/float/math32/c/sdcc/cm32_sdcc_atan.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 1,600 | 2017-01-15T16:12:02.000Z | 2022-03-31T12:11:12.000Z | libsrc/_DEVELOPMENT/math/float/math32/c/sdcc/cm32_sdcc_atan.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 215 | 2017-01-17T10:43:03.000Z | 2022-03-23T17:25:02.000Z |
SECTION code_fp_math32
PUBLIC cm32_sdcc_atan
EXTERN cm32_sdcc_fsread1, _m32_atanf
cm32_sdcc_atan:
call cm32_sdcc_fsread1
jp _m32_atanf
| 13.363636 | 36 | 0.823129 |
aa8597879d2a7f2ba0af079c6e6883ccb8ed3cb9 | 52,170 | dart | Dart | generated/googleapis/lib/serviceconsumermanagement/v1.dart | dhruv-mehrotra/googleapis.dart | 5b798396fed8313a14c48791cea6b6cb271fba86 | [
"BSD-3-Clause"
] | 235 | 2015-06-18T10:11:53.000Z | 2021-04-05T04:13:09.000Z | generated/googleapis/lib/serviceconsumermanagement/v1.dart | dhruv-mehrotra/googleapis.dart | 5b798396fed8313a14c48791cea6b6cb271fba86 | [
"BSD-3-Clause"
] | 137 | 2015-01-28T21:23:34.000Z | 2021-04-04T06:16:10.000Z | generated/googleapis/lib/serviceconsumermanagement/v1.dart | dhruv-mehrotra/googleapis.dart | 5b798396fed8313a14c48791cea6b6cb271fba86 | [
"BSD-3-Clause"
] | 71 | 2015-06-18T10:11:55.000Z | 2021-03-26T03:04:23.000Z | // This is a generated file (see the discoveryapis_generator project).
// ignore_for_file: camel_case_types
// ignore_for_file: comment_references
// ignore_for_file: file_names
// ignore_for_file: library_names
// ignore_for_file: lines_longer_than_80_chars
// ignore_for_file: non_constant_identifier_names
// ignore_for_file: prefer_expression_function_bodies
// ignore_for_file: prefer_interpolation_to_compose_strings
// ignore_for_file: unnecessary_brace_in_string_interps
// ignore_for_file: unnecessary_lambdas
// ignore_for_file: unnecessary_string_interpolations
/// Service Consumer Management API - v1
///
/// Manages the service consumers of a Service Infrastructure service.
///
/// For more information, see
/// <https://cloud.google.com/service-consumer-management/docs/overview>
///
/// Create an instance of [ServiceConsumerManagementApi] to access these
/// resources:
///
/// - [OperationsResource]
/// - [ServicesResource]
/// - [ServicesTenancyUnitsResource]
library serviceconsumermanagement.v1;
import 'dart:async' as async;
import 'dart:convert' as convert;
import 'dart:core' as core;
import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons;
import 'package:http/http.dart' as http;
// ignore: deprecated_member_use_from_same_package
import '../shared.dart';
import '../src/user_agent.dart';
export 'package:_discoveryapis_commons/_discoveryapis_commons.dart'
show ApiRequestError, DetailedApiRequestError;
/// Manages the service consumers of a Service Infrastructure service.
class ServiceConsumerManagementApi {
/// See, edit, configure, and delete your Google Cloud data and see the email
/// address for your Google Account.
static const cloudPlatformScope =
'https://www.googleapis.com/auth/cloud-platform';
final commons.ApiRequester _requester;
OperationsResource get operations => OperationsResource(_requester);
ServicesResource get services => ServicesResource(_requester);
ServiceConsumerManagementApi(http.Client client,
{core.String rootUrl =
'https://serviceconsumermanagement.googleapis.com/',
core.String servicePath = ''})
: _requester =
commons.ApiRequester(client, rootUrl, servicePath, requestHeaders);
}
class OperationsResource {
final commons.ApiRequester _requester;
OperationsResource(commons.ApiRequester client) : _requester = client;
/// Starts asynchronous cancellation on a long-running operation.
///
/// The server makes a best effort to cancel the operation, but success is not
/// guaranteed. If the server doesn't support this method, it returns
/// `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation
/// or other methods to check whether the cancellation succeeded or whether
/// the operation completed despite cancellation. On successful cancellation,
/// the operation is not deleted; instead, it becomes an operation with an
/// Operation.error value with a google.rpc.Status.code of 1, corresponding to
/// `Code.CANCELLED`.
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [name] - The name of the operation resource to be cancelled.
/// Value must have pattern `^operations/.*$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Empty].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Empty> cancel(
CancelOperationRequest request,
core.String name, {
core.String? $fields,
}) async {
final _body = convert.json.encode(request);
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name') + ':cancel';
final _response = await _requester.request(
_url,
'POST',
body: _body,
queryParams: _queryParams,
);
return Empty.fromJson(_response as core.Map<core.String, core.dynamic>);
}
/// Deletes a long-running operation.
///
/// This method indicates that the client is no longer interested in the
/// operation result. It does not cancel the operation. If the server doesn't
/// support this method, it returns `google.rpc.Code.UNIMPLEMENTED`.
///
/// Request parameters:
///
/// [name] - The name of the operation resource to be deleted.
/// Value must have pattern `^operations/.*$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Empty].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Empty> delete(
core.String name, {
core.String? $fields,
}) async {
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name');
final _response = await _requester.request(
_url,
'DELETE',
queryParams: _queryParams,
);
return Empty.fromJson(_response as core.Map<core.String, core.dynamic>);
}
/// Gets the latest state of a long-running operation.
///
/// Clients can use this method to poll the operation result at intervals as
/// recommended by the API service.
///
/// Request parameters:
///
/// [name] - The name of the operation resource.
/// Value must have pattern `^operations/\[^/\]+$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> get(
core.String name, {
core.String? $fields,
}) async {
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name');
final _response = await _requester.request(
_url,
'GET',
queryParams: _queryParams,
);
return Operation.fromJson(_response as core.Map<core.String, core.dynamic>);
}
/// Lists operations that match the specified filter in the request.
///
/// If the server doesn't support this method, it returns `UNIMPLEMENTED`.
/// NOTE: the `name` binding allows API services to override the binding to
/// use different resource name schemes, such as `users / * /operations`. To
/// override the binding, API services can add a binding such as
/// `"/v1/{name=users / * }/operations"` to their service configuration. For
/// backwards compatibility, the default name includes the operations
/// collection id, however overriding users must ensure the name binding is
/// the parent resource, without the operations collection id.
///
/// Request parameters:
///
/// [name] - The name of the operation's parent resource.
/// Value must have pattern `^operations$`.
///
/// [filter] - The standard list filter.
///
/// [pageSize] - The standard list page size.
///
/// [pageToken] - The standard list page token.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [ListOperationsResponse].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<ListOperationsResponse> list(
core.String name, {
core.String? filter,
core.int? pageSize,
core.String? pageToken,
core.String? $fields,
}) async {
final _queryParams = <core.String, core.List<core.String>>{
if (filter != null) 'filter': [filter],
if (pageSize != null) 'pageSize': ['${pageSize}'],
if (pageToken != null) 'pageToken': [pageToken],
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name');
final _response = await _requester.request(
_url,
'GET',
queryParams: _queryParams,
);
return ListOperationsResponse.fromJson(
_response as core.Map<core.String, core.dynamic>);
}
}
class ServicesResource {
final commons.ApiRequester _requester;
ServicesTenancyUnitsResource get tenancyUnits =>
ServicesTenancyUnitsResource(_requester);
ServicesResource(commons.ApiRequester client) : _requester = client;
/// Search tenancy units for a managed service.
///
/// Request parameters:
///
/// [parent] - Required. Service for which search is performed.
/// services/{service} {service} the name of a service, for example
/// 'service.googleapis.com'.
/// Value must have pattern `^services/\[^/\]+$`.
///
/// [pageSize] - Optional. The maximum number of results returned by this
/// request. Currently, the default maximum is set to 1000. If `page_size`
/// isn't provided or the size provided is a number larger than 1000, it's
/// automatically set to 1000.
///
/// [pageToken] - Optional. The continuation token, which is used to page
/// through large result sets. To get the next page of results, set this
/// parameter to the value of `nextPageToken` from the previous response.
///
/// [query] - Optional. Set a query `{expression}` for querying tenancy units.
/// Your `{expression}` must be in the format: `field_name=literal_string`.
/// The `field_name` is the name of the field you want to compare. Supported
/// fields are `tenant_resources.tag` and `tenant_resources.resource`. For
/// example, to search tenancy units that contain at least one tenant resource
/// with a given tag 'xyz', use the query `tenant_resources.tag=xyz`. To
/// search tenancy units that contain at least one tenant resource with a
/// given resource name 'projects/123456', use the query
/// `tenant_resources.resource=projects/123456`. Multiple expressions can be
/// joined with `AND`s. Tenancy units must match all expressions to be
/// included in the result set. For example, `tenant_resources.tag=xyz AND
/// tenant_resources.resource=projects/123456`
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [SearchTenancyUnitsResponse].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<SearchTenancyUnitsResponse> search(
core.String parent, {
core.int? pageSize,
core.String? pageToken,
core.String? query,
core.String? $fields,
}) async {
final _queryParams = <core.String, core.List<core.String>>{
if (pageSize != null) 'pageSize': ['${pageSize}'],
if (pageToken != null) 'pageToken': [pageToken],
if (query != null) 'query': [query],
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$parent') + ':search';
final _response = await _requester.request(
_url,
'GET',
queryParams: _queryParams,
);
return SearchTenancyUnitsResponse.fromJson(
_response as core.Map<core.String, core.dynamic>);
}
}
class ServicesTenancyUnitsResource {
final commons.ApiRequester _requester;
ServicesTenancyUnitsResource(commons.ApiRequester client)
: _requester = client;
/// Add a new tenant project to the tenancy unit.
///
/// There can be a maximum of 1024 tenant projects in a tenancy unit. If there
/// are previously failed `AddTenantProject` calls, you might need to call
/// `RemoveTenantProject` first to resolve them before you can make another
/// call to `AddTenantProject` with the same tag. Operation.
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [parent] - Required. Name of the tenancy unit. Such as
/// 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
/// Value must have pattern
/// `^services/\[^/\]+/\[^/\]+/\[^/\]+/tenancyUnits/\[^/\]+$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> addProject(
AddTenantProjectRequest request,
core.String parent, {
core.String? $fields,
}) async {
final _body = convert.json.encode(request);
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$parent') + ':addProject';
final _response = await _requester.request(
_url,
'POST',
body: _body,
queryParams: _queryParams,
);
return Operation.fromJson(_response as core.Map<core.String, core.dynamic>);
}
/// Apply a configuration to an existing tenant project.
///
/// This project must exist in an active state and have the original owner
/// account. The caller must have permission to add a project to the given
/// tenancy unit. The configuration is applied, but any existing settings on
/// the project aren't modified. Specified policy bindings are applied.
/// Existing bindings aren't modified. Specified services are activated. No
/// service is deactivated. If specified, new billing configuration is
/// applied. Omit a billing configuration to keep the existing one. A service
/// account in the project is created if previously non existed. Specified
/// labels will be appended to tenant project, note that the value of existing
/// label key will be updated if the same label key is requested. The
/// specified folder is ignored, as moving a tenant project to a different
/// folder isn't supported. The operation fails if any of the steps fail, but
/// no rollback of already applied configuration changes is attempted.
/// Operation.
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [name] - Required. Name of the tenancy unit. Such as
/// 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
/// Value must have pattern
/// `^services/\[^/\]+/\[^/\]+/\[^/\]+/tenancyUnits/\[^/\]+$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> applyProjectConfig(
ApplyTenantProjectConfigRequest request,
core.String name, {
core.String? $fields,
}) async {
final _body = convert.json.encode(request);
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name') + ':applyProjectConfig';
final _response = await _requester.request(
_url,
'POST',
body: _body,
queryParams: _queryParams,
);
return Operation.fromJson(_response as core.Map<core.String, core.dynamic>);
}
/// Attach an existing project to the tenancy unit as a new tenant resource.
///
/// The project could either be the tenant project reserved by calling
/// `AddTenantProject` under a tenancy unit of a service producer's project of
/// a managed service, or from a separate project. The caller is checked
/// against a set of permissions as if calling `AddTenantProject` on the same
/// service consumer. To trigger the attachment, the targeted tenant project
/// must be in a folder. Make sure the ServiceConsumerManagement service
/// account is the owner of that project. These two requirements are already
/// met if the project is reserved by calling `AddTenantProject`. Operation.
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [name] - Required. Name of the tenancy unit that the project will be
/// attached to. Such as
/// 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
/// Value must have pattern
/// `^services/\[^/\]+/\[^/\]+/\[^/\]+/tenancyUnits/\[^/\]+$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> attachProject(
AttachTenantProjectRequest request,
core.String name, {
core.String? $fields,
}) async {
final _body = convert.json.encode(request);
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name') + ':attachProject';
final _response = await _requester.request(
_url,
'POST',
body: _body,
queryParams: _queryParams,
);
return Operation.fromJson(_response as core.Map<core.String, core.dynamic>);
}
/// Creates a tenancy unit with no tenant resources.
///
/// If tenancy unit already exists, it will be returned, however, in this
/// case, returned TenancyUnit does not have tenant_resources field set and
/// ListTenancyUnits has to be used to get a complete TenancyUnit with all
/// fields populated.
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [parent] - Required. services/{service}/{collection id}/{resource id}
/// {collection id} is the cloud resource collection type representing the
/// service consumer, for example 'projects', or 'organizations'. {resource
/// id} is the consumer numeric id, such as project number: '123456'.
/// {service} the name of a managed service, such as 'service.googleapis.com'.
/// Enables service binding using the new tenancy unit.
/// Value must have pattern `^services/\[^/\]+/\[^/\]+/\[^/\]+$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [TenancyUnit].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<TenancyUnit> create(
CreateTenancyUnitRequest request,
core.String parent, {
core.String? $fields,
}) async {
final _body = convert.json.encode(request);
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$parent') + '/tenancyUnits';
final _response = await _requester.request(
_url,
'POST',
body: _body,
queryParams: _queryParams,
);
return TenancyUnit.fromJson(
_response as core.Map<core.String, core.dynamic>);
}
/// Delete a tenancy unit.
///
/// Before you delete the tenancy unit, there should be no tenant resources in
/// it that aren't in a DELETED state. Operation.
///
/// Request parameters:
///
/// [name] - Required. Name of the tenancy unit to be deleted.
/// Value must have pattern
/// `^services/\[^/\]+/\[^/\]+/\[^/\]+/tenancyUnits/\[^/\]+$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> delete(
core.String name, {
core.String? $fields,
}) async {
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name');
final _response = await _requester.request(
_url,
'DELETE',
queryParams: _queryParams,
);
return Operation.fromJson(_response as core.Map<core.String, core.dynamic>);
}
/// Deletes the specified project resource identified by a tenant resource
/// tag.
///
/// The mothod removes a project lien with a 'TenantManager' origin if that
/// was added. It will then attempt to delete the project. If that operation
/// fails, this method also fails. After the project has been deleted, the
/// tenant resource state is set to DELETED. To permanently remove resource
/// metadata, call the `RemoveTenantProject` method. New resources with the
/// same tag can't be added if there are existing resources in a DELETED
/// state. Operation.
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [name] - Required. Name of the tenancy unit. Such as
/// 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
/// Value must have pattern
/// `^services/\[^/\]+/\[^/\]+/\[^/\]+/tenancyUnits/\[^/\]+$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> deleteProject(
DeleteTenantProjectRequest request,
core.String name, {
core.String? $fields,
}) async {
final _body = convert.json.encode(request);
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name') + ':deleteProject';
final _response = await _requester.request(
_url,
'POST',
body: _body,
queryParams: _queryParams,
);
return Operation.fromJson(_response as core.Map<core.String, core.dynamic>);
}
/// Find the tenancy unit for a managed service and service consumer.
///
/// This method shouldn't be used in a service producer's runtime path, for
/// example to find the tenant project number when creating VMs. Service
/// producers must persist the tenant project's information after the project
/// is created.
///
/// Request parameters:
///
/// [parent] - Required. Managed service and service consumer. Required.
/// services/{service}/{collection id}/{resource id} {collection id} is the
/// cloud resource collection type representing the service consumer, for
/// example 'projects', or 'organizations'. {resource id} is the consumer
/// numeric id, such as project number: '123456'. {service} the name of a
/// service, such as 'service.googleapis.com'.
/// Value must have pattern `^services/\[^/\]+/\[^/\]+/\[^/\]+$`.
///
/// [filter] - Optional. Filter expression over tenancy resources field.
/// Optional.
///
/// [pageSize] - Optional. The maximum number of results returned by this
/// request.
///
/// [pageToken] - Optional. The continuation token, which is used to page
/// through large result sets. To get the next page of results, set this
/// parameter to the value of `nextPageToken` from the previous response.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [ListTenancyUnitsResponse].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<ListTenancyUnitsResponse> list(
core.String parent, {
core.String? filter,
core.int? pageSize,
core.String? pageToken,
core.String? $fields,
}) async {
final _queryParams = <core.String, core.List<core.String>>{
if (filter != null) 'filter': [filter],
if (pageSize != null) 'pageSize': ['${pageSize}'],
if (pageToken != null) 'pageToken': [pageToken],
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$parent') + '/tenancyUnits';
final _response = await _requester.request(
_url,
'GET',
queryParams: _queryParams,
);
return ListTenancyUnitsResponse.fromJson(
_response as core.Map<core.String, core.dynamic>);
}
/// Removes the specified project resource identified by a tenant resource
/// tag.
///
/// The method removes the project lien with 'TenantManager' origin if that
/// was added. It then attempts to delete the project. If that operation
/// fails, this method also fails. Calls to remove already removed or
/// non-existent tenant project succeed. After the project has been deleted,
/// or if was already in a DELETED state, resource metadata is permanently
/// removed from the tenancy unit. Operation.
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [name] - Required. Name of the tenancy unit. Such as
/// 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
/// Value must have pattern
/// `^services/\[^/\]+/\[^/\]+/\[^/\]+/tenancyUnits/\[^/\]+$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> removeProject(
RemoveTenantProjectRequest request,
core.String name, {
core.String? $fields,
}) async {
final _body = convert.json.encode(request);
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name') + ':removeProject';
final _response = await _requester.request(
_url,
'POST',
body: _body,
queryParams: _queryParams,
);
return Operation.fromJson(_response as core.Map<core.String, core.dynamic>);
}
/// Attempts to undelete a previously deleted tenant project.
///
/// The project must be in a DELETED state. There are no guarantees that an
/// undeleted project will be in a fully restored and functional state. Call
/// the `ApplyTenantProjectConfig` method to update its configuration and then
/// validate all managed service resources. Operation.
///
/// [request] - The metadata request object.
///
/// Request parameters:
///
/// [name] - Required. Name of the tenancy unit. Such as
/// 'services/service.googleapis.com/projects/12345/tenancyUnits/abcd'.
/// Value must have pattern
/// `^services/\[^/\]+/\[^/\]+/\[^/\]+/tenancyUnits/\[^/\]+$`.
///
/// [$fields] - Selector specifying which fields to include in a partial
/// response.
///
/// Completes with a [Operation].
///
/// Completes with a [commons.ApiRequestError] if the API endpoint returned an
/// error.
///
/// If the used [http.Client] completes with an error when making a REST call,
/// this method will complete with the same error.
async.Future<Operation> undeleteProject(
UndeleteTenantProjectRequest request,
core.String name, {
core.String? $fields,
}) async {
final _body = convert.json.encode(request);
final _queryParams = <core.String, core.List<core.String>>{
if ($fields != null) 'fields': [$fields],
};
final _url = 'v1/' + core.Uri.encodeFull('$name') + ':undeleteProject';
final _response = await _requester.request(
_url,
'POST',
body: _body,
queryParams: _queryParams,
);
return Operation.fromJson(_response as core.Map<core.String, core.dynamic>);
}
}
/// Request to add a newly created and configured tenant project to a tenancy
/// unit.
class AddTenantProjectRequest {
/// Configuration of the new tenant project to be added to tenancy unit
/// resources.
TenantProjectConfig? projectConfig;
/// Tag of the added project.
///
/// Must be less than 128 characters. Required.
///
/// Required.
core.String? tag;
AddTenantProjectRequest({
this.projectConfig,
this.tag,
});
AddTenantProjectRequest.fromJson(core.Map _json)
: this(
projectConfig: _json.containsKey('projectConfig')
? TenantProjectConfig.fromJson(
_json['projectConfig'] as core.Map<core.String, core.dynamic>)
: null,
tag: _json.containsKey('tag') ? _json['tag'] as core.String : null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (projectConfig != null) 'projectConfig': projectConfig!,
if (tag != null) 'tag': tag!,
};
}
/// Request to apply configuration to an existing tenant project.
class ApplyTenantProjectConfigRequest {
/// Configuration that should be applied to the existing tenant project.
TenantProjectConfig? projectConfig;
/// Tag of the project.
///
/// Must be less than 128 characters. Required.
///
/// Required.
core.String? tag;
ApplyTenantProjectConfigRequest({
this.projectConfig,
this.tag,
});
ApplyTenantProjectConfigRequest.fromJson(core.Map _json)
: this(
projectConfig: _json.containsKey('projectConfig')
? TenantProjectConfig.fromJson(
_json['projectConfig'] as core.Map<core.String, core.dynamic>)
: null,
tag: _json.containsKey('tag') ? _json['tag'] as core.String : null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (projectConfig != null) 'projectConfig': projectConfig!,
if (tag != null) 'tag': tag!,
};
}
/// Request to attach an existing project to the tenancy unit as a new tenant
/// resource.
class AttachTenantProjectRequest {
/// When attaching an external project, this is in the format of
/// `projects/{project_number}`.
core.String? externalResource;
/// When attaching a reserved project already in tenancy units, this is the
/// tag of a tenant resource under the tenancy unit for the managed service's
/// service producer project.
///
/// The reserved tenant resource must be in an active state.
core.String? reservedResource;
/// Tag of the tenant resource after attachment.
///
/// Must be less than 128 characters. Required.
///
/// Required.
core.String? tag;
AttachTenantProjectRequest({
this.externalResource,
this.reservedResource,
this.tag,
});
AttachTenantProjectRequest.fromJson(core.Map _json)
: this(
externalResource: _json.containsKey('externalResource')
? _json['externalResource'] as core.String
: null,
reservedResource: _json.containsKey('reservedResource')
? _json['reservedResource'] as core.String
: null,
tag: _json.containsKey('tag') ? _json['tag'] as core.String : null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (externalResource != null) 'externalResource': externalResource!,
if (reservedResource != null) 'reservedResource': reservedResource!,
if (tag != null) 'tag': tag!,
};
}
/// Describes the billing configuration for a new tenant project.
class BillingConfig {
/// Name of the billing account.
///
/// For example `billingAccounts/012345-567890-ABCDEF`.
core.String? billingAccount;
BillingConfig({
this.billingAccount,
});
BillingConfig.fromJson(core.Map _json)
: this(
billingAccount: _json.containsKey('billingAccount')
? _json['billingAccount'] as core.String
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (billingAccount != null) 'billingAccount': billingAccount!,
};
}
/// The request message for Operations.CancelOperation.
typedef CancelOperationRequest = $Empty;
/// Request to create a tenancy unit for a service consumer of a managed
/// service.
class CreateTenancyUnitRequest {
/// Optional service producer-provided identifier of the tenancy unit.
///
/// Must be no longer than 40 characters and preferably URI friendly. If it
/// isn't provided, a UID for the tenancy unit is automatically generated. The
/// identifier must be unique across a managed service. If the tenancy unit
/// already exists for the managed service and service consumer pair, calling
/// `CreateTenancyUnit` returns the existing tenancy unit if the provided
/// identifier is identical or empty, otherwise the call fails.
///
/// Optional.
core.String? tenancyUnitId;
CreateTenancyUnitRequest({
this.tenancyUnitId,
});
CreateTenancyUnitRequest.fromJson(core.Map _json)
: this(
tenancyUnitId: _json.containsKey('tenancyUnitId')
? _json['tenancyUnitId'] as core.String
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (tenancyUnitId != null) 'tenancyUnitId': tenancyUnitId!,
};
}
/// Request message to delete tenant project resource from the tenancy unit.
typedef DeleteTenantProjectRequest = $TenantProjectRequest;
/// A generic empty message that you can re-use to avoid defining duplicated
/// empty messages in your APIs.
///
/// A typical example is to use it as the request or the response type of an API
/// method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns
/// (google.protobuf.Empty); } The JSON representation for `Empty` is empty JSON
/// object `{}`.
typedef Empty = $Empty;
/// The response message for Operations.ListOperations.
class ListOperationsResponse {
/// The standard List next-page token.
core.String? nextPageToken;
/// A list of operations that matches the specified filter in the request.
core.List<Operation>? operations;
ListOperationsResponse({
this.nextPageToken,
this.operations,
});
ListOperationsResponse.fromJson(core.Map _json)
: this(
nextPageToken: _json.containsKey('nextPageToken')
? _json['nextPageToken'] as core.String
: null,
operations: _json.containsKey('operations')
? (_json['operations'] as core.List)
.map((value) => Operation.fromJson(
value as core.Map<core.String, core.dynamic>))
.toList()
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (nextPageToken != null) 'nextPageToken': nextPageToken!,
if (operations != null) 'operations': operations!,
};
}
/// Response for the list request.
class ListTenancyUnitsResponse {
/// Pagination token for large results.
core.String? nextPageToken;
/// Tenancy units matching the request.
core.List<TenancyUnit>? tenancyUnits;
ListTenancyUnitsResponse({
this.nextPageToken,
this.tenancyUnits,
});
ListTenancyUnitsResponse.fromJson(core.Map _json)
: this(
nextPageToken: _json.containsKey('nextPageToken')
? _json['nextPageToken'] as core.String
: null,
tenancyUnits: _json.containsKey('tenancyUnits')
? (_json['tenancyUnits'] as core.List)
.map((value) => TenancyUnit.fromJson(
value as core.Map<core.String, core.dynamic>))
.toList()
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (nextPageToken != null) 'nextPageToken': nextPageToken!,
if (tenancyUnits != null) 'tenancyUnits': tenancyUnits!,
};
}
/// This resource represents a long-running operation that is the result of a
/// network API call.
class Operation {
/// If the value is `false`, it means the operation is still in progress.
///
/// If `true`, the operation is completed, and either `error` or `response` is
/// available.
core.bool? done;
/// The error result of the operation in case of failure or cancellation.
Status? error;
/// Service-specific metadata associated with the operation.
///
/// It typically contains progress information and common metadata such as
/// create time. Some services might not provide such metadata. Any method
/// that returns a long-running operation should document the metadata type,
/// if any.
///
/// The values for Object must be JSON objects. It can consist of `num`,
/// `String`, `bool` and `null` as well as `Map` and `List` values.
core.Map<core.String, core.Object?>? metadata;
/// The server-assigned name, which is only unique within the same service
/// that originally returns it.
///
/// If you use the default HTTP mapping, the `name` should be a resource name
/// ending with `operations/{unique_id}`.
core.String? name;
/// The normal response of the operation in case of success.
///
/// If the original method returns no data on success, such as `Delete`, the
/// response is `google.protobuf.Empty`. If the original method is standard
/// `Get`/`Create`/`Update`, the response should be the resource. For other
/// methods, the response should have the type `XxxResponse`, where `Xxx` is
/// the original method name. For example, if the original method name is
/// `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`.
///
/// The values for Object must be JSON objects. It can consist of `num`,
/// `String`, `bool` and `null` as well as `Map` and `List` values.
core.Map<core.String, core.Object?>? response;
Operation({
this.done,
this.error,
this.metadata,
this.name,
this.response,
});
Operation.fromJson(core.Map _json)
: this(
done: _json.containsKey('done') ? _json['done'] as core.bool : null,
error: _json.containsKey('error')
? Status.fromJson(
_json['error'] as core.Map<core.String, core.dynamic>)
: null,
metadata: _json.containsKey('metadata')
? _json['metadata'] as core.Map<core.String, core.dynamic>
: null,
name: _json.containsKey('name') ? _json['name'] as core.String : null,
response: _json.containsKey('response')
? _json['response'] as core.Map<core.String, core.dynamic>
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (done != null) 'done': done!,
if (error != null) 'error': error!,
if (metadata != null) 'metadata': metadata!,
if (name != null) 'name': name!,
if (response != null) 'response': response!,
};
}
/// Translates to IAM Policy bindings (without auditing at this level)
class PolicyBinding {
/// Uses the same format as in IAM policy.
///
/// `member` must include both a prefix and ID. For example, `user:{emailId}`,
/// `serviceAccount:{emailId}`, `group:{emailId}`.
core.List<core.String>? members;
/// Role.
///
/// (https://cloud.google.com/iam/docs/understanding-roles) For example,
/// `roles/viewer`, `roles/editor`, or `roles/owner`.
core.String? role;
PolicyBinding({
this.members,
this.role,
});
PolicyBinding.fromJson(core.Map _json)
: this(
members: _json.containsKey('members')
? (_json['members'] as core.List)
.map((value) => value as core.String)
.toList()
: null,
role: _json.containsKey('role') ? _json['role'] as core.String : null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (members != null) 'members': members!,
if (role != null) 'role': role!,
};
}
/// Request message to remove a tenant project resource from the tenancy unit.
typedef RemoveTenantProjectRequest = $TenantProjectRequest;
/// Response for the search query.
class SearchTenancyUnitsResponse {
/// Pagination token for large results.
core.String? nextPageToken;
/// Tenancy Units matching the request.
core.List<TenancyUnit>? tenancyUnits;
SearchTenancyUnitsResponse({
this.nextPageToken,
this.tenancyUnits,
});
SearchTenancyUnitsResponse.fromJson(core.Map _json)
: this(
nextPageToken: _json.containsKey('nextPageToken')
? _json['nextPageToken'] as core.String
: null,
tenancyUnits: _json.containsKey('tenancyUnits')
? (_json['tenancyUnits'] as core.List)
.map((value) => TenancyUnit.fromJson(
value as core.Map<core.String, core.dynamic>))
.toList()
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (nextPageToken != null) 'nextPageToken': nextPageToken!,
if (tenancyUnits != null) 'tenancyUnits': tenancyUnits!,
};
}
/// Describes the service account configuration for the tenant project.
class ServiceAccountConfig {
/// ID of the IAM service account to be created in tenant project.
///
/// The email format of the service account is "@.iam.gserviceaccount.com".
/// This account ID must be unique within tenant project and service producers
/// have to guarantee it. The ID must be 6-30 characters long, and match the
/// following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])`.
core.String? accountId;
/// Roles for the associated service account for the tenant project.
core.List<core.String>? tenantProjectRoles;
ServiceAccountConfig({
this.accountId,
this.tenantProjectRoles,
});
ServiceAccountConfig.fromJson(core.Map _json)
: this(
accountId: _json.containsKey('accountId')
? _json['accountId'] as core.String
: null,
tenantProjectRoles: _json.containsKey('tenantProjectRoles')
? (_json['tenantProjectRoles'] as core.List)
.map((value) => value as core.String)
.toList()
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (accountId != null) 'accountId': accountId!,
if (tenantProjectRoles != null)
'tenantProjectRoles': tenantProjectRoles!,
};
}
/// The `Status` type defines a logical error model that is suitable for
/// different programming environments, including REST APIs and RPC APIs.
///
/// It is used by [gRPC](https://github.com/grpc). Each `Status` message
/// contains three pieces of data: error code, error message, and error details.
/// You can find out more about this error model and how to work with it in the
/// [API Design Guide](https://cloud.google.com/apis/design/errors).
typedef Status = $Status;
/// Representation of a tenancy unit.
class TenancyUnit {
/// @OutputOnly Cloud resource name of the consumer of this service.
///
/// For example 'projects/123456'.
///
/// Output only.
core.String? consumer;
/// @OutputOnly The time this tenancy unit was created.
///
/// Output only.
core.String? createTime;
/// Globally unique identifier of this tenancy unit
/// "services/{service}/{collection id}/{resource id}/tenancyUnits/{unit}"
core.String? name;
/// Google Cloud API name of the managed service owning this tenancy unit.
///
/// For example 'serviceconsumermanagement.googleapis.com'.
///
/// Output only.
core.String? service;
/// Resources constituting the tenancy unit.
///
/// There can be at most 512 tenant resources in a tenancy unit.
core.List<TenantResource>? tenantResources;
TenancyUnit({
this.consumer,
this.createTime,
this.name,
this.service,
this.tenantResources,
});
TenancyUnit.fromJson(core.Map _json)
: this(
consumer: _json.containsKey('consumer')
? _json['consumer'] as core.String
: null,
createTime: _json.containsKey('createTime')
? _json['createTime'] as core.String
: null,
name: _json.containsKey('name') ? _json['name'] as core.String : null,
service: _json.containsKey('service')
? _json['service'] as core.String
: null,
tenantResources: _json.containsKey('tenantResources')
? (_json['tenantResources'] as core.List)
.map((value) => TenantResource.fromJson(
value as core.Map<core.String, core.dynamic>))
.toList()
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (consumer != null) 'consumer': consumer!,
if (createTime != null) 'createTime': createTime!,
if (name != null) 'name': name!,
if (service != null) 'service': service!,
if (tenantResources != null) 'tenantResources': tenantResources!,
};
}
/// This structure defines a tenant project to be added to the specified tenancy
/// unit and its initial configuration and properties.
///
/// A project lien is created for the tenant project to prevent the tenant
/// project from being deleted accidentally. The lien is deleted as part of
/// tenant project removal.
class TenantProjectConfig {
/// Billing account properties.
///
/// The billing account must be specified.
BillingConfig? billingConfig;
/// Folder where project in this tenancy unit must be located This folder must
/// have been previously created with the required permissions for the caller
/// to create and configure a project in it.
///
/// Valid folder resource names have the format `folders/{folder_number}` (for
/// example, `folders/123456`).
core.String? folder;
/// Labels that are applied to this project.
core.Map<core.String, core.String>? labels;
/// Configuration for the IAM service account on the tenant project.
ServiceAccountConfig? serviceAccountConfig;
/// Google Cloud API names of services that are activated on this project
/// during provisioning.
///
/// If any of these services can't be activated, the request fails. For
/// example: 'compute.googleapis.com','cloudfunctions.googleapis.com'
core.List<core.String>? services;
/// Describes ownership and policies for the new tenant project.
///
/// Required.
TenantProjectPolicy? tenantProjectPolicy;
TenantProjectConfig({
this.billingConfig,
this.folder,
this.labels,
this.serviceAccountConfig,
this.services,
this.tenantProjectPolicy,
});
TenantProjectConfig.fromJson(core.Map _json)
: this(
billingConfig: _json.containsKey('billingConfig')
? BillingConfig.fromJson(
_json['billingConfig'] as core.Map<core.String, core.dynamic>)
: null,
folder: _json.containsKey('folder')
? _json['folder'] as core.String
: null,
labels: _json.containsKey('labels')
? (_json['labels'] as core.Map<core.String, core.dynamic>).map(
(key, item) => core.MapEntry(
key,
item as core.String,
),
)
: null,
serviceAccountConfig: _json.containsKey('serviceAccountConfig')
? ServiceAccountConfig.fromJson(_json['serviceAccountConfig']
as core.Map<core.String, core.dynamic>)
: null,
services: _json.containsKey('services')
? (_json['services'] as core.List)
.map((value) => value as core.String)
.toList()
: null,
tenantProjectPolicy: _json.containsKey('tenantProjectPolicy')
? TenantProjectPolicy.fromJson(_json['tenantProjectPolicy']
as core.Map<core.String, core.dynamic>)
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (billingConfig != null) 'billingConfig': billingConfig!,
if (folder != null) 'folder': folder!,
if (labels != null) 'labels': labels!,
if (serviceAccountConfig != null)
'serviceAccountConfig': serviceAccountConfig!,
if (services != null) 'services': services!,
if (tenantProjectPolicy != null)
'tenantProjectPolicy': tenantProjectPolicy!,
};
}
/// Describes policy settings that need to be applied to a newly created tenant
/// project.
class TenantProjectPolicy {
/// Policy bindings to be applied to the tenant project, in addition to the
/// 'roles/owner' role granted to the Service Consumer Management service
/// account.
///
/// At least one binding must have the role `roles/owner`.
core.List<PolicyBinding>? policyBindings;
TenantProjectPolicy({
this.policyBindings,
});
TenantProjectPolicy.fromJson(core.Map _json)
: this(
policyBindings: _json.containsKey('policyBindings')
? (_json['policyBindings'] as core.List)
.map((value) => PolicyBinding.fromJson(
value as core.Map<core.String, core.dynamic>))
.toList()
: null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (policyBindings != null) 'policyBindings': policyBindings!,
};
}
/// Resource constituting the TenancyUnit.
class TenantResource {
/// @OutputOnly Identifier of the tenant resource.
///
/// For cloud projects, it is in the form 'projects/{number}'. For example
/// 'projects/123456'.
///
/// Output only.
core.String? resource;
/// Status of tenant resource.
/// Possible string values are:
/// - "STATUS_UNSPECIFIED" : Unspecified status is the default unset value.
/// - "PENDING_CREATE" : Creation of the tenant resource is ongoing.
/// - "ACTIVE" : Active resource.
/// - "PENDING_DELETE" : Deletion of the resource is ongoing.
/// - "FAILED" : Tenant resource creation or deletion has failed.
/// - "DELETED" : Tenant resource has been deleted.
core.String? status;
/// Unique per single tenancy unit.
core.String? tag;
TenantResource({
this.resource,
this.status,
this.tag,
});
TenantResource.fromJson(core.Map _json)
: this(
resource: _json.containsKey('resource')
? _json['resource'] as core.String
: null,
status: _json.containsKey('status')
? _json['status'] as core.String
: null,
tag: _json.containsKey('tag') ? _json['tag'] as core.String : null,
);
core.Map<core.String, core.dynamic> toJson() => {
if (resource != null) 'resource': resource!,
if (status != null) 'status': status!,
if (tag != null) 'tag': tag!,
};
}
/// Request message to undelete tenant project resource previously deleted from
/// the tenancy unit.
typedef UndeleteTenantProjectRequest = $TenantProjectRequest;
| 35.635246 | 80 | 0.655127 |
9bea4f81a96d40583830446876c834e7a5b800a4 | 254 | js | JavaScript | documentation/doxygen/search/pages_0.js | kmuseth/openvdb-website | 454c06278acd77e4bc294efc2c4b9565da7d992d | [
"CC-BY-4.0"
] | 10 | 2019-01-25T20:10:25.000Z | 2022-03-27T21:21:29.000Z | documentation/doxygen/search/pages_0.js | kmuseth/openvdb-website | 454c06278acd77e4bc294efc2c4b9565da7d992d | [
"CC-BY-4.0"
] | 10 | 2019-10-08T22:22:17.000Z | 2021-04-22T22:37:35.000Z | documentation/doxygen/search/pages_0.js | kmuseth/openvdb-website | 454c06278acd77e4bc294efc2c4b9565da7d992d | [
"CC-BY-4.0"
] | 13 | 2018-12-11T18:50:44.000Z | 2021-07-22T21:21:01.000Z | var searchData=
[
['ax',['AX',['../ax.html',1,'openvdbax']]],
['ax_20code_20examples',['AX Code Examples',['../axexamples.html',1,'openvdbax']]],
['ax_20supported_20functions',['AX Supported Functions',['../axfunctionlist.html',1,'openvdbax']]]
];
| 36.285714 | 100 | 0.649606 |
430461a85389d32a72aa1571b8cc9a71ca9d092b | 1,262 | sql | SQL | Hacks/06_Hacking_Aggregation/solution.sql | SinKasula/Beyond-LeetCode-SQL | a625941735e13dc0a670019e93981ee0cb8420fa | [
"MIT"
] | 677 | 2019-04-17T18:50:18.000Z | 2022-03-29T05:57:23.000Z | Hacks/06_Hacking_Aggregation/solution.sql | yixuan-feng/Beyond-LeetCode-SQL | 8ab7f0ad60b85ab9dff18da6fc760211335d0fb0 | [
"MIT"
] | 7 | 2019-10-27T16:40:33.000Z | 2021-11-17T07:04:35.000Z | Hacks/06_Hacking_Aggregation/solution.sql | yixuan-feng/Beyond-LeetCode-SQL | 8ab7f0ad60b85ab9dff18da6fc760211335d0fb0 | [
"MIT"
] | 291 | 2019-04-17T19:04:38.000Z | 2022-03-31T22:32:13.000Z | -- global aggregate
SELECT Name
FROM country
WHERE GNP >= ALL(SELECT GNP FROM country WHERE GNP IS NOT NULL);
SELECT Name
FROM country
WHERE GNP <= ALL(SELECT GNP FROM country WHERE GNP IS NOT NULL);
SELECT Name
FROM country
WHERE GNP >= (SELECT AVG(GNP) FROM country WHERE GNP IS NOT NULL);
SELECT Name
FROM country
WHERE GNP <= (SELECT AVG(GNP) FROM country WHERE GNP IS NOT NULL);
-- group aggregate
SELECT
a.Name
,a.Continent
,a.SurfaceArea
FROM country AS a
WHERE a.SurfaceArea >= ALL(
SELECT b.SurfaceArea
FROM country AS b
WHERE a.Continent = b.Continent
AND b.SurfaceArea IS NOT NULL
);
SELECT
a.Name
,a.Continent
,a.SurfaceArea
FROM country AS a
WHERE a.SurfaceArea <= ALL(
SELECT b.SurfaceArea
FROM country AS b
WHERE a.Continent = b.Continent
AND b.SurfaceArea IS NOT NULL
);
SELECT
a.Name
,a.Continent
,a.SurfaceArea
FROM country AS a
WHERE a.SurfaceArea >= ALL(
SELECT AVG(b.SurfaceArea)
FROM country AS b
WHERE a.Continent = b.Continent
AND b.SurfaceArea IS NOT NULL
);
SELECT
a.Name
,a.Continent
,a.SurfaceArea
FROM country AS a
WHERE a.SurfaceArea <= ALL(
SELECT AVG(b.SurfaceArea)
FROM country AS b
WHERE a.Continent = b.Continent
AND b.SurfaceArea IS NOT NULL
);
| 19.121212 | 66 | 0.715531 |
21a58fb51fba293dd8d4e6c67c0986b99571bb39 | 6,690 | rs | Rust | git-packetline/src/borrowed.rs | tshepang/gitoxide | aec7240036750c98796b8ef4075758f6b825d293 | [
"Apache-2.0",
"MIT"
] | null | null | null | git-packetline/src/borrowed.rs | tshepang/gitoxide | aec7240036750c98796b8ef4075758f6b825d293 | [
"Apache-2.0",
"MIT"
] | null | null | null | git-packetline/src/borrowed.rs | tshepang/gitoxide | aec7240036750c98796b8ef4075758f6b825d293 | [
"Apache-2.0",
"MIT"
] | null | null | null | use crate::{encode, Channel, ERR_PREFIX};
use bstr::BStr;
use std::io;
/// A borrowed packet line as it refers to a slice of data by reference.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum Borrowed<'a> {
/// A chunk of raw data.
Data(&'a [u8]),
/// A flush packet.
Flush,
/// A delimiter packet.
Delimiter,
/// The end of the response.
ResponseEnd,
}
impl<'a> Borrowed<'a> {
/// Serialize this instance to `out` in git `packetline` format, returning the amount of bytes written to `out`.
pub fn to_write(&self, out: impl io::Write) -> Result<usize, encode::Error> {
match self {
Borrowed::Data(d) => encode::data_to_write(d, out),
Borrowed::Flush => encode::flush_to_write(out).map_err(Into::into),
Borrowed::Delimiter => encode::delim_to_write(out).map_err(Into::into),
Borrowed::ResponseEnd => encode::response_end_to_write(out).map_err(Into::into),
}
}
/// Return this instance as slice if it's [`Data`][Borrowed::Data].
pub fn as_slice(&self) -> Option<&[u8]> {
match self {
Borrowed::Data(d) => Some(d),
Borrowed::Flush | Borrowed::Delimiter | Borrowed::ResponseEnd => None,
}
}
/// Return this instance's [`as_slice()`][Borrowed::as_slice()] as [`BStr`].
pub fn as_bstr(&self) -> Option<&BStr> {
self.as_slice().map(Into::into)
}
/// Interpret this instance's [`as_slice()`][Borrowed::as_slice()] as [`Error`].
///
/// This works for any data received in an error [channel][crate::Channel].
///
/// Note that this creates an unchecked error using the slice verbatim, which is useful to [serialize it][Error::to_write()].
/// See [`check_error()`][Borrowed::check_error()] for a version that assures the error information is in the expected format.
pub fn to_error(&self) -> Option<Error<'_>> {
self.as_slice().map(Error)
}
/// Check this instance's [`as_slice()`][Borrowed::as_slice()] is a valid [`Error`] and return it.
///
/// This works for any data received in an error [channel][crate::Channel].
pub fn check_error(&self) -> Option<Error<'_>> {
self.as_slice().and_then(|data| {
if data.len() >= ERR_PREFIX.len() && &data[..ERR_PREFIX.len()] == ERR_PREFIX {
Some(Error(&data[ERR_PREFIX.len()..]))
} else {
None
}
})
}
/// Return this instance as text, with the trailing newline truncated if present.
pub fn to_text(&self) -> Option<Text<'_>> {
self.as_slice().map(Into::into)
}
/// Interpret the data in this [`slice`][Borrowed::as_slice()] as [`Band`] according to the given `kind` of channel.
///
/// Note that this is only relevant in a side-band channel.
/// See [`decode_band()`][Borrowed::decode_band()] in case `kind` is unknown.
pub fn to_band(&self, kind: Channel) -> Option<Band<'_>> {
self.as_slice().map(|d| match kind {
Channel::Data => Band::Data(d),
Channel::Progress => Band::Progress(d),
Channel::Error => Band::Error(d),
})
}
/// Decode the band of this [`slice`][Borrowed::as_slice()], or panic if it is not actually a side-band line.
pub fn decode_band(&self) -> Result<Band<'_>, DecodeBandError> {
let d = self.as_slice().ok_or(DecodeBandError::NonDataLine)?;
Ok(match d[0] {
1 => Band::Data(&d[1..]),
2 => Band::Progress(&d[1..]),
3 => Band::Error(&d[1..]),
band => return Err(DecodeBandError::InvalidSideBand(band)),
})
}
}
use quick_error::quick_error;
quick_error! {
/// The error used in [`decode_band()`][Borrowed::decode_band()].
#[derive(Debug)]
#[allow(missing_docs)]
pub enum DecodeBandError {
InvalidSideBand(band: u8) {
display("attempt to decode a non-side channel line or input was malformed: {}", band)
}
NonDataLine {
display("attempt to decode a non-data line into a side-channel band")
}
}
}
/// A packet line representing an Error in a side-band channel.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Error<'a>(pub &'a [u8]);
impl<'a> Error<'a> {
/// Serialize this line as error to `out`.
///
/// This includes a marker to allow decoding it outside of a side-band channel, returning the amount of bytes written.
pub fn to_write(&self, out: impl io::Write) -> Result<usize, encode::Error> {
encode::error_to_write(self.0, out)
}
}
/// A packet line representing text, which may include a trailing newline.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Text<'a>(pub &'a [u8]);
impl<'a> From<&'a [u8]> for Text<'a> {
fn from(d: &'a [u8]) -> Self {
let d = if d[d.len() - 1] == b'\n' { &d[..d.len() - 1] } else { d };
Text(d)
}
}
impl<'a> Text<'a> {
/// Return this instance's data.
pub fn as_slice(&self) -> &[u8] {
self.0
}
/// Return this instance's data as [`BStr`].
pub fn as_bstr(&self) -> &BStr {
self.0.into()
}
/// Serialize this instance to `out`, appending a newline if there is none, returning the amount of bytes written.
pub fn to_write(&self, out: impl io::Write) -> Result<usize, encode::Error> {
encode::text_to_write(self.0, out)
}
}
/// A band in a side-band channel.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub enum Band<'a> {
/// A band carrying data.
Data(&'a [u8]),
/// A band carrying user readable progress information.
Progress(&'a [u8]),
/// A band carrying user readable errors.
Error(&'a [u8]),
}
impl<'a> Band<'a> {
/// Serialize this instance to `out`, returning the amount of bytes written.
///
/// The data written to `out` can be decoded with [`Borrowed::decode_band()]`.
pub fn to_write(&self, out: impl io::Write) -> Result<usize, encode::Error> {
match self {
Band::Data(d) => encode::band_to_write(Channel::Data, d, out),
Band::Progress(d) => encode::band_to_write(Channel::Progress, d, out),
Band::Error(d) => encode::band_to_write(Channel::Error, d, out),
}
}
}
| 39.122807 | 130 | 0.599103 |
e80f326fbc77af353e3f09d2600c3677be63bdd0 | 194 | dart | Dart | fit_for_food_flutter_project/lib/Modules/clasesavance/consumo_api_consultas_generales.dart | Trysac/Fit_For_Food_Flutter_App | e1f8870f09e6cc03d33d6d72ebe9b50d9ade9364 | [
"MIT"
] | null | null | null | fit_for_food_flutter_project/lib/Modules/clasesavance/consumo_api_consultas_generales.dart | Trysac/Fit_For_Food_Flutter_App | e1f8870f09e6cc03d33d6d72ebe9b50d9ade9364 | [
"MIT"
] | null | null | null | fit_for_food_flutter_project/lib/Modules/clasesavance/consumo_api_consultas_generales.dart | Trysac/Fit_For_Food_Flutter_App | e1f8870f09e6cc03d33d6d72ebe9b50d9ade9364 | [
"MIT"
] | 1 | 2021-10-21T23:18:19.000Z | 2021-10-21T23:18:19.000Z | class ConsumoApiConsultasGenerales {
ConsumoApiGenerales() {}
bool EnvioConsulta() {
return false;
}
void AtualizacionDatos() {}
void BorrarDatos() {}
void AgregarDatos() {}
}
| 16.166667 | 36 | 0.680412 |
e877e859e9a1189cb0afe6979a6926d8e6390516 | 4,261 | cc | C++ | components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data_unittest.cc | hefen1/chromium | 52f0b6830e000ca7c5e9aa19488af85be792cc88 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data_unittest.cc | hefen1/chromium | 52f0b6830e000ca7c5e9aa19488af85be792cc88 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data_unittest.cc | hefen1/chromium | 52f0b6830e000ca7c5e9aa19488af85be792cc88 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2 | 2020-04-04T13:34:56.000Z | 2020-11-04T07:17:52.000Z | // Copyright 2015 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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/prefs/testing_pref_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "net/base/net_log.h"
#include "net/url_request/url_request_interceptor.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
// Used only to verify that a wrapped network delegate gets called.
class CountingNetworkDelegate : public net::NetworkDelegateImpl {
public:
CountingNetworkDelegate() : created_requests_(0) {
}
~CountingNetworkDelegate() final {
}
int OnBeforeURLRequest(net::URLRequest* request,
const net::CompletionCallback& callback,
GURL* new_url) final {
created_requests_++;
return net::OK;
}
int created_requests() const {
return created_requests_;
}
private:
int created_requests_;
};
} // namespace
namespace data_reduction_proxy {
class DataReductionProxyIODataTest : public testing::Test {
public:
void SetUp() override {
RegisterSimpleProfilePrefs(prefs_.registry());
}
void RequestCallback(int err) {
}
scoped_refptr<base::MessageLoopProxy> message_loop_proxy() {
return loop_.message_loop_proxy();
}
net::TestDelegate* delegate() {
return &delegate_;
}
const net::TestURLRequestContext& context() const {
return context_;
}
net::NetLog* net_log() {
return &net_log_;
}
PrefService* prefs() {
return &prefs_;
}
private:
base::MessageLoopForIO loop_;
net::TestDelegate delegate_;
net::TestURLRequestContext context_;
net::NetLog net_log_;
TestingPrefServiceSimple prefs_;
};
TEST_F(DataReductionProxyIODataTest, TestConstruction) {
scoped_ptr<DataReductionProxyIOData> io_data(new DataReductionProxyIOData(
Client::UNKNOWN, DataReductionProxyParams::kAllowed, net_log(),
message_loop_proxy(), message_loop_proxy(), false /* enable_quic */));
// Check that io_data creates an interceptor. Such an interceptor is
// thoroughly tested by DataReductionProxyInterceptoTest.
scoped_ptr<net::URLRequestInterceptor> interceptor =
io_data->CreateInterceptor();
EXPECT_NE(nullptr, interceptor.get());
// When creating a network delegate, expect that it properly wraps a
// network delegate. Such a network delegate is thoroughly tested by
// DataReductionProxyNetworkDelegateTest.
scoped_ptr<net::URLRequest> fake_request =
context().CreateRequest(
GURL("http://www.foo.com/"), net::IDLE, delegate(), NULL);
CountingNetworkDelegate* wrapped_network_delegate =
new CountingNetworkDelegate();
scoped_ptr<DataReductionProxyNetworkDelegate> network_delegate =
io_data->CreateNetworkDelegate(
make_scoped_ptr(wrapped_network_delegate), false);
network_delegate->NotifyBeforeURLRequest(
fake_request.get(),
base::Bind(&DataReductionProxyIODataTest::RequestCallback,
base::Unretained(this)), nullptr);
EXPECT_EQ(1, wrapped_network_delegate->created_requests());
EXPECT_EQ(nullptr, io_data->usage_stats());
// Creating a second delegate with bypass statistics tracking should result
// in usage stats being created.
io_data->CreateNetworkDelegate(make_scoped_ptr(new CountingNetworkDelegate()),
true);
EXPECT_NE(nullptr, io_data->usage_stats());
// The Data Reduction Proxy isn't actually enabled here.
io_data->InitOnUIThread(prefs());
EXPECT_FALSE(io_data->IsEnabled());
io_data->ShutdownOnUIThread();
}
} // namespace data_reduction_proxy
| 32.280303 | 94 | 0.744896 |
0ecdb1b5b3e5d6816a7be2c99529b726d05369c5 | 417 | ts | TypeScript | lib/interfaces/INodeUpdateHandler.d.ts | Wroud/reistore | ad97f0b4a6fe403eaaa0662df38772fbc634cd16 | [
"MIT"
] | 6 | 2018-06-23T18:32:53.000Z | 2020-04-07T08:38:50.000Z | lib/interfaces/INodeUpdateHandler.d.ts | Wroud/reistore | ad97f0b4a6fe403eaaa0662df38772fbc634cd16 | [
"MIT"
] | 1 | 2020-07-21T12:35:57.000Z | 2020-07-21T12:35:57.000Z | lib/interfaces/INodeUpdateHandler.d.ts | Wroud/reistore | ad97f0b4a6fe403eaaa0662df38772fbc634cd16 | [
"MIT"
] | 1 | 2018-06-22T22:20:54.000Z | 2018-06-22T22:20:54.000Z | import { INodeAccessor, INode, IUndo } from "./INode";
import { INodeSubscriber } from "./INodeSubscriber";
export interface INodeUpdateHandler<TRoot> {
node: INodeAccessor<TRoot, INode<TRoot, any, any, any, any>>;
subscribe(subscriber: INodeSubscriber<TRoot>): any;
unSubscribe(subscriber: INodeSubscriber<TRoot>): any;
update(state: TRoot, change: IUndo<TRoot, any>, fromChildren: boolean): void;
}
| 46.333333 | 81 | 0.729017 |
a700e5908030dc765871bf6d7e4cfdfe2eec3cdd | 1,092 | psd1 | PowerShell | Modules/ModManMan.psd1 | esserafael/PowerShell | cd6f9c56a54962c1eccd6c1466dc84383055a04f | [
"MIT"
] | 1 | 2020-08-03T00:19:02.000Z | 2020-08-03T00:19:02.000Z | Modules/ModManMan.psd1 | esserafael/PowerShell | cd6f9c56a54962c1eccd6c1466dc84383055a04f | [
"MIT"
] | null | null | null | Modules/ModManMan.psd1 | esserafael/PowerShell | cd6f9c56a54962c1eccd6c1466dc84383055a04f | [
"MIT"
] | 1 | 2020-05-04T07:58:48.000Z | 2020-05-04T07:58:48.000Z | @{
RootModule = 'ModManMan.psm1'
ModuleVersion = '1.0.0'
GUID = 'faf2a84e-7593-4f79-83e6-9e0f2a285d3b'
Author = 'Rafael Alexandre Feustel Gustmann'
CompanyName = ''
Copyright = ''
Description = 'ModManMan (Module Manifest Manager) helps me a little in doing boring module manifests management.'
PowerShellVersion = '5.0'
PowerShellHostName = ''
PowerShellHostVersion = ''
DotNetFrameworkVersion = '4.5'
CLRVersion = '4.0.0'
ProcessorArchitecture = 'None'
RequiredModules = @()
RequiredAssemblies = @()
ScriptsToProcess = @()
TypesToProcess = @()
FormatsToProcess = @()
NestedModules = @()
FunctionsToExport = @(
'Update-ModuleManifestVersioning'
)
CmdletsToExport = @()
VariablesToExport = '*'
AliasesToExport = @()
ModuleList = @()
FileList = @()
PrivateData = @{
PSData = @{
# URL to the license for this module.
LicenseUri = 'https://github.com/esserafael/PowerShell/blob/master/LICENSE'
# URL to the main website for this project.
ProjectUri = 'https://github.com/esserafael/PowerShell'
}
}
}
| 28 | 116 | 0.669414 |
fb066ed451daf5cdf6169409ed1fd311685dc10d | 2,088 | h | C | geppetto/code/compiler/src/arith/arith/Curve/Fp_weierstrass.h | anthonydelgado/pinocchio | a1f1836679b8a135d85f2094bfaafc972101557a | [
"MIT"
] | null | null | null | geppetto/code/compiler/src/arith/arith/Curve/Fp_weierstrass.h | anthonydelgado/pinocchio | a1f1836679b8a135d85f2094bfaafc972101557a | [
"MIT"
] | null | null | null | geppetto/code/compiler/src/arith/arith/Curve/Fp_weierstrass.h | anthonydelgado/pinocchio | a1f1836679b8a135d85f2094bfaafc972101557a | [
"MIT"
] | null | null | null | /* curves/Fp_twistededwards.h
* by Joppe W. Bos and Michael Naehrig (mnaehrig@microsoft.com),
* Cryptography Research Group, MSR Redmond, 2014
*
* This file is part of the ARITH library version 0.01
*
* DISCLAIMER:
* This is RESEARCH code.
* Parts of the code might be incomplete.
* Please use at your own risk.
* DO NOT USE IN PRODUCTION CODE!!!
* This code is still under active development.
*/
#ifndef __FP_WEIERSTRASS
#define __FP_WEIERSTRASS
#include "../uint.h"
#include "../Fp/Fp.h"
typedef struct {
Fp_t X;
Fp_t Y;
Fp_t Z;
} point_wp_t;
typedef point_wp_t Point_wp_t[1];
typedef struct {
Fp_t X;
Fp_t Y;
} point_wpaff_t;
typedef point_wpaff_t Point_wpaff_t[1];
int Fp_initialize_weierstrass (Fp_t *b, int num);
void Fp_free_weierstrass (void);
void Fp_weierstrass_dbl (Point_wp_t c, Point_wp_t a);
void Fp_weierstrass_add (Point_wp_t c, Point_wp_t a, Point_wp_t b);
void Fp_weierstrass_mix (Point_wp_t c, Point_wp_t a, Point_wp_t b); // b is affine
void Fp_weierstrass_aff (Point_wp_t c, Point_wp_t a, Point_wp_t b);
void Fp_weierstrass_affdbl(Point_wp_t c, Point_wp_t a);
void Fp_weierstrass_affadd(Point_wp_t c, Point_wp_t a, Point_wp_t b);
int Fp_weierstrass_oncurve_jacproj (Point_wp_t x);
int Fp_weierstrass_oncurve_aff (Point_wp_t x);
int Fp_weierstrass_oncurve_jacproj_select_b (Point_wp_t x, int num);
int Fp_weierstrass_oncurve_aff_select_b (Point_wp_t x, int num);
void Fp_weierstrass_aff2proj (Point_wp_t c, Point_wp_t a);
void Fp_weierstrass_jacproj2aff (Point_wp_t c, Point_wp_t a);
int Fp_weierstrass_equal_aff(Point_wp_t a, Point_wp_t b);
int Fp_weierstrass_equal_jacproj(Point_wp_t a, Point_wp_t b);
int Fp_wp_init (Point_wp_t p);
void Fp_wp_free (Point_wp_t p);
void Fp_wp_copy (Point_wp_t c, Point_wp_t a);
void Fp_wp_neg (Point_wp_t c, Point_wp_t a);
int Fp_wpaff_init(Point_wpaff_t p);
void Fp_wpaff_free(Point_wpaff_t p);
void Fp_wpaff_copy(Point_wpaff_t c, Point_wpaff_t a);
void Fp_wpaff_neg(Point_wpaff_t c, Point_wpaff_t a);
#endif /* __FP_WEIERSTRASS */ | 32.123077 | 83 | 0.756226 |
9c9fc0c646352dbb08836946a0ca978110ce8ebf | 579 | swift | Swift | Example/MMMArrayChangesExample/AppDelegate.swift | terwanerik/MMMArrayChanges | a8165e2080ed7974c744dc971330fc7e7e679913 | [
"MIT"
] | 1 | 2020-06-25T12:05:25.000Z | 2020-06-25T12:05:25.000Z | Example/MMMArrayChangesExample/AppDelegate.swift | terwanerik/MMMArrayChanges | a8165e2080ed7974c744dc971330fc7e7e679913 | [
"MIT"
] | null | null | null | Example/MMMArrayChangesExample/AppDelegate.swift | terwanerik/MMMArrayChanges | a8165e2080ed7974c744dc971330fc7e7e679913 | [
"MIT"
] | 1 | 2020-06-25T11:03:57.000Z | 2020-06-25T11:03:57.000Z | //
// MMMArrayChanges.
// Copyright (C) 2019 MediaMonks. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
let rootViewController = CookieListViewController()
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = rootViewController
window.makeKeyAndVisible()
self.window = window
return true
}
}
| 19.965517 | 85 | 0.765112 |
81eb723794edd41ebc416e83f44c51636e2a8217 | 1,220 | go | Go | vector/internal/math/math_test.go | gomyhaha/ebiten | 6ffa52def43466b74a1b7b301f6d246c4a0c1184 | [
"Apache-2.0"
] | null | null | null | vector/internal/math/math_test.go | gomyhaha/ebiten | 6ffa52def43466b74a1b7b301f6d246c4a0c1184 | [
"Apache-2.0"
] | null | null | null | vector/internal/math/math_test.go | gomyhaha/ebiten | 6ffa52def43466b74a1b7b301f6d246c4a0c1184 | [
"Apache-2.0"
] | null | null | null | // Copyright 2019 The Ebiten Authors
//
// 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 math_test
import (
"testing"
. "github.com/hajimehoshi/ebiten/vector/internal/math"
)
func TestIntersectionAsLine(t *testing.T) {
cases := []struct {
S0 Segment
S1 Segment
Want Point
}{
{
S0: Segment{Point{0.5, 0}, Point{0.5, 0.5}},
S1: Segment{Point{1, 1}, Point{2, 1}},
Want: Point{0.5, 1},
},
{
S0: Segment{Point{0.5, 0}, Point{0.5, 1.5}},
S1: Segment{Point{1, 1}, Point{2, 1}},
Want: Point{0.5, 1},
},
}
for _, c := range cases {
got := c.S0.IntersectionAsLines(c.S1)
want := c.Want
if got != want {
t.Errorf("got: %v, want: %v", got, want)
}
}
}
| 25.416667 | 75 | 0.653279 |
a17a837698d44f0249cb06bcf1682d0cf0dcdf72 | 159 | h | C | viosock/viosocklib-test/installprov.h | LinJunming/kvm-guest-drivers-windows | d55b74bc1c0ecb71a960c5747191d4ea2098fa3c | [
"BSD-3-Clause"
] | 1 | 2020-03-01T21:05:05.000Z | 2020-03-01T21:05:05.000Z | viosock/viosocklib-test/installprov.h | LinJunming/kvm-guest-drivers-windows | d55b74bc1c0ecb71a960c5747191d4ea2098fa3c | [
"BSD-3-Clause"
] | 16 | 2020-01-08T22:24:13.000Z | 2020-05-14T02:10:20.000Z | viosock/viosocklib-test/installprov.h | LinJunming/kvm-guest-drivers-windows | d55b74bc1c0ecb71a960c5747191d4ea2098fa3c | [
"BSD-3-Clause"
] | null | null | null | #ifndef _INSTALLPROV_H
#define _INSTALLPROV_H
#pragma once
BOOL
InstallProtocol();
BOOL
DeinstallProtocol();
BOOL
EnumProtocols();
#endif //_INSTALLPROV_H | 10.6 | 23 | 0.792453 |
f9b430b07987c5445bca62d5aef4525ecafac3ac | 3,061 | go | Go | encode/type_encoder.go | dumpmemory/slim | d27f7e916f6b70fc0b065fb835a7cde5e4a40db9 | [
"MIT"
] | 1,830 | 2019-02-02T16:15:20.000Z | 2022-03-29T14:13:53.000Z | encode/type_encoder.go | dumpmemory/slim | d27f7e916f6b70fc0b065fb835a7cde5e4a40db9 | [
"MIT"
] | 86 | 2019-02-02T07:31:50.000Z | 2022-03-10T10:00:56.000Z | encode/type_encoder.go | dumpmemory/slim | d27f7e916f6b70fc0b065fb835a7cde5e4a40db9 | [
"MIT"
] | 103 | 2019-02-15T12:15:27.000Z | 2022-03-11T09:22:15.000Z | package encode
import (
"bytes"
"encoding/binary"
"reflect"
"github.com/openacid/errors"
)
// defaultEndian is default endian
var defaultEndian = binary.LittleEndian
// TypeEncoder provides encoding for fixed size types.
// Such as int32 or struct { X int32; Y int64; }
//
// "int" is not a fixed size type: int on different platform has different size,
// 4 or 8 bytes.
//
// "[]int32" is not a fixed size type: the data size is also defined by the
// number of elements.
type TypeEncoder struct {
// Endian defines the byte order to encode a value.
// By default it is binary.LittleEndian
Endian binary.ByteOrder
// Type is the data type to encode.
Type reflect.Type
// Size is the encoded size of this type.
Size int
}
// NewTypeEncoder creates a *TypeEncoder by a value.
// The value "zero" defines what type this Encoder can deal with and must be a
// fixed size type.
func NewTypeEncoder(zero interface{}) (*TypeEncoder, error) {
return NewTypeEncoderEndian(zero, nil)
}
// NewTypeEncoderEndian creates a *TypeEncoder with a specified byte order.
//
// "endian" could be binary.LittleEndian or binary.BigEndian.
func NewTypeEncoderEndian(zero interface{}, endian binary.ByteOrder) (*TypeEncoder, error) {
if endian == nil {
endian = defaultEndian
}
m := &TypeEncoder{
Endian: endian,
Type: reflect.Indirect(reflect.ValueOf(zero)).Type(),
Size: binary.Size(zero),
}
if m.Size == -1 {
return nil, errors.Wrapf(ErrNotFixedSize, "type: %v", reflect.TypeOf(zero))
}
if m.Type.Kind() == reflect.Slice {
return nil, errors.Wrapf(ErrNotFixedSize, "slice size is not fixed")
}
return m, nil
}
// NewTypeEncoderEndianByType creates a *TypeEncoder for specified type and with a specified byte order.
//
// "endian" could be binary.LittleEndian or binary.BigEndian.
func NewTypeEncoderEndianByType(t reflect.Type, endian binary.ByteOrder) (*TypeEncoder, error) {
v := reflect.New(t)
return NewTypeEncoderEndian(v.Interface(), endian)
}
// Encode converts a m.Type value to byte slice.
// If a different type value from the one used with NewTypeEncoder passed in,
// it panics.
func (m *TypeEncoder) Encode(d interface{}) []byte {
if reflect.Indirect(reflect.ValueOf(d)).Type() != m.Type {
panic("different type from TypeEncoder.Type")
}
b := bytes.NewBuffer(make([]byte, 0, m.Size))
err := binary.Write(b, m.Endian, d)
if err != nil {
// there should not be any error if type is fixed size
panic(err)
}
return b.Bytes()
}
// Decode converts byte slice to a pointer to Type value.
// It returns number bytes consumed and an Type value in interface{}.
func (m *TypeEncoder) Decode(b []byte) (int, interface{}) {
b = b[0:m.Size]
v := reflect.New(m.Type)
err := binary.Read(bytes.NewBuffer(b), m.Endian, v.Interface())
if err != nil {
panic(err)
}
return m.Size, reflect.Indirect(v).Interface()
}
// GetSize returns m.Size.
func (m *TypeEncoder) GetSize(d interface{}) int {
return m.Size
}
// GetEncodedSize returns m.Size.
func (m *TypeEncoder) GetEncodedSize(b []byte) int {
return m.Size
}
| 28.082569 | 104 | 0.712186 |
9c101cf74d6e0873b0867459e59e8c379d93d5ea | 13,825 | js | JavaScript | gm_scripts/SecurePasswords/SecurePasswords.user.js | Tiller/passwords | ba61ae617cc47b6e3bc592803629d921c36abb3f | [
"Apache-2.0"
] | null | null | null | gm_scripts/SecurePasswords/SecurePasswords.user.js | Tiller/passwords | ba61ae617cc47b6e3bc592803629d921c36abb3f | [
"Apache-2.0"
] | null | null | null | gm_scripts/SecurePasswords/SecurePasswords.user.js | Tiller/passwords | ba61ae617cc47b6e3bc592803629d921c36abb3f | [
"Apache-2.0"
] | null | null | null | // ==UserScript==
// @name SecurePasswords
// @namespace stooit
// @include *
// @version 1
// @require jquery.js
// @require typeahead.js
// @require bCrypt.js
// @grant GM_addStyle
// ==/UserScript==
var deja = false;
var $output, $user, $phrase, $domain, $length, $info, $help;
var win = ' <div class="pwdlogin" style="width: 300px;"> <div class="pwdlogin-screen" style="background-color: #FFF; padding: 20px; border-radius: 10px; border: 5px solid #3498DB;"> <div class="pwdapp-title" style="text-align: center; color: #777; font-size: 12px; text-transform: uppercase; font-family: courier;"></div> <div class="pwdlogin-form" style="text-align: center;"> <div class="pwdcontrol-group" style="margin-bottom: 10px;"> <input autocorrect="off" style="text-align: center; background-color: #ECF0F1; border: 2px solid transparent; border-radius: 3px; font-size: 16px; font-weight: 200; padding: 10px 0; width: 250px; transition: border .5s;" spellcheck="false" type="text" class="pwdlogin-field pwduserInput pwdnotstored" value="" placeholder="username" id="pwdinputUser"> <label class="pwdlogin-field-icon pwdfui-user" for="login-name"></label> </div> <div class="pwdcontrol-group" style="margin-bottom: 10px;"> <input autocorrect="off" style="text-align: center; background-color: #ECF0F1; border: 2px solid transparent; border-radius: 3px; font-size: 16px; font-weight: 200; padding: 10px 0; width: 250px; transition: border .5s;" spellcheck="false" type="text" class="pwdlogin-field pwduserInput pwdtypeahead pwdnotstored" value="" placeholder="web domain" id="pwdinputDomain"> <label class="pwdlogin-field-icon pwdfui-lock" for="login-pass"></label> </div> <div class="pwdcontrol-group" style="margin-bottom: 10px;"> <input autocorrect="off" style="text-align: center; background-color: #ECF0F1; border: 2px solid transparent; border-radius: 3px; font-size: 16px; font-weight: 200; padding: 10px 0; width: 250px; transition: border .5s;" spellcheck="false" type="text" class="pwdlogin-field pwduserInput pwdstored" value="14" placeholder="password length" id="pwdinputLength"> <label class="pwdlogin-field-icon pwdfui-lock" for="login-pass"></label> </div> <div class="pwdcontrol-group" style="margin-bottom: 10px;"> <input autocorrect="off" style="text-align: center; background-color: #ECF0F1; border: 2px solid transparent; border-radius: 3px; font-size: 16px; font-weight: 200; padding: 10px 0; width: 250px; transition: border .5s;" spellcheck="false" type="password" class="pwdlogin-field pwduserInput pwdstored" value="" placeholder="secret key" id="pwdinputPhrase"> <label class="pwdlogin-field-icon pwdfui-lock" for="login-pass"></label> </div> <div class="pwdcontrol-group" style="margin-bottom: 10px; color: red; font-family: arial; font-size: 11px;" id="pwdoutputInfo"> </div> <div class="pwdcontrol-group" style="margin-bottom: 10px;"> <a class="pwdbtn pwdbtn-primary pwdbtn-large pwdbtn-block" href="#" id="pwdshowPassword" style="border: 2px solid transparent; background: #3498DB; color: #ffffff; font-size: 16px; line-height: 25px; padding: 10px 0; text-decoration: none; text-shadow: none; border-radius: 3px; box-shadow: none; transition: 0.25s; display: block; width: 250px; margin: 0 auto;">show password</a> </div> <div class="pwdcontrol-group" style="margin-bottom: 10px;"> <input autocorrect="off" size="30" spellcheck="false" style="display:none; background-color: #ff9;text-align: center; background-color: #ECF0F1; border: 2px solid transparent; border-radius: 3px; font-size: 16px; font-weight: 200; padding: 10px 0; width: 250px; transition: border .5s;" type="text" class="pwdlogin-field" value="" placeholder="your password" id="pwdoutputPassword"> </div><a href="#" id="pwdpwdclose">close</a></div> </div> </div>';
function findPos(obj){
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
var workOn = function (elm) {
if (typeof elm.dataset.pwddeja != 'undefined') {
return;
}
elm.dataset.pwddeja = true;
var pos = findPos(elm);
elm.style.backgroundImage = "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAMHSURBVHjadNNfTFtlGMfx73s4/QOlYy2sA5yy7pBpMoXMRLdBg3phspism5kX2xxDN53eMNhoa7zQxHhBaKeijbqZaBSY8Q/NGIneTR2ic/HCZJRospal0m2Cow0ttB3nwOtFA3EZPJdPnnzy5pffK6SUCCFYnuDpUB3gcTqdLqvZsg6gsHAnk0qlpoHRgM+fWL6VUiL+DwRPh6otFsvxnY/vEJqmoaoqAIZhcC12jZ9HRyXwScDn/2ct4Lm9e7zbJpOTxOMTuqHrcQDVZNIe3b7dpOs6o7/+Mh7w+QfXAtpbnz/s7D83gJTy7EwqPQ1Q6XS4XBtcrzQ3NzF04UIq4POH1wI621qPVHw7OIhqUrvVErUSwFg0ZtbZ7a97mj189c3XswGfv3dV4INwOHDwwIHSj8+eobamFpfLBcDU1BSGoeP17iUSieRPtLcHVwW6u7vfcG9xK949XqxW68peSkmhUODiDxeZmJhY6jjR8fY9wMmuU49t2ex+xuv1UiJs9J2JcfmnaQB2PeniyKv1LMp5hoeH+Ts5+X2oJ/j7XUBHZ6f/2X37yh55uIGjrZe5WVWDqHYUX3DjNrXpaT7r38VY9Crnh4Zy7/f2hlaAk12nnOW28vYX2tq4Hr/Dm+cKqFtrMJuUYg+WJPp4krday3BrFr7o6yM7lw2/9867KSGlxP9aYJOqlhxraWnhr7Sd72J1CKuZUrWYQd6QKPoCu90JHnJkufLbFeZzuU9DPcHkMlCRyWY6GxsbEJsbGLm6iVtLpZhKisAicJ+So2lbEhJjRMeilJXZekM9wdmVDF46/nKXo9JRXq09iLPlECOXZkn8KxEC6msEO5sqSI18SebWJPF4PD/weX/wrhC7/D4teSN5WKvXsD2wlbqn9oPZWvw1CwUSP0bIXP+TWCzGRtfGyEfhD6P39ODFY0d3Z+YyOxzO9SiKgr36fgBmbybI5fPMZ+ex2+x/DPT1D69apKqqDSbPE55GRVGeRmBeOUIgBIWZ2+mR8bHouGEszqXTM0tSSv4bAHVZgvCIptfJAAAAAElFTkSuQmCC')";
elm.style.backgroundRepeat = 'no-repeat';
elm.style.backgroundPosition = 'right center';
var clk = function () {
if (!deja) {
deja = true;
}
var tmp;
if (tmp = document.getElementById('pwdHolder')) {
tmp.parentNode.removeChild(tmp);
}
var hold = document.createElement('div');
hold.id = 'pwdHolder';
hold.style.position = 'absolute';
hold.style.left = (pos[0] - (300 - elm.offsetWidth) / 2) + 'px';
hold.style.top = (pos[1] + elm.offsetHeight) + 'px';
hold.style.zIndex = 999999999;
hold.innerHTML = win;
document.body.appendChild(hold);
document.getElementById('pwdinputPhrase').focus();
document.getElementById('pwdinputPhrase').addEventListener('keydown', function (e) {
if (e.keyCode == 13) {
document.getElementById('pwdshowPassword').click();
e.stopPropagation();
e.preventDefault();
}
}, true);
document.getElementById('pwdinputDomain').value = window.location.hostname.split('.').slice(-2, -1)[0];
document.getElementById('pwdpwdclose').addEventListener('click', function (e) {
document.body.removeChild(hold);
e.preventDefault();
e.stopPropagation();
}, true);
function generate_password(User, Domain, Phrase, Len) {
// Min Length: 4; Max Length: 30
Len = (Len < 4) ? 4 : (Len > 30) ? 30 : Len;
$output.val("Computing..").show();
var salt = '$2a$10$' + hex_sha512(Domain + User + 'ed6abeb33d6191a6acdc7f55ea93e0e2').substr(0, 21) + '.';
var key = Phrase + User + ":" + Domain;
var bcrypt = new bCrypt();
bcrypt.hashpw(key, salt, function (result) {
var hashed = b85_hash(result.slice((result.length - 31), result.length)).substring(0, Len);
while (!validate_b85_password(hashed)) {
hashed = b85_hash(hashed).substring(0, Len);
}
$output.val(hashed).select();
elm.value = hashed;
document.body.removeChild(hold);
elm.focus();
}, function () {
$output.val(Math.random());
});
return undefined;
}
$user = jQueryPwd('#pwdinputUser');
$output = jQueryPwd('#pwdoutputPassword');
$phrase = jQueryPwd('#pwdinputPhrase');
$domain = jQueryPwd('#pwdinputDomain');
$length = jQueryPwd('#pwdinputLength');
$info = jQueryPwd('#pwdoutputInfo');
$help = jQueryPwd('#pwdinfo');
$phrase.val('');
setTimeout(function () {
$phrase.val('');
}, 20);
if (localStorage["inputLength"]) {
jQueryPwd('#pwdinputLength').val(localStorage["inputLength"]);
}
if (localStorage["inputPhrase"]) {
jQueryPwd('#pwdinputPhrase').val(localStorage["inputPhrase"]);
}
jQueryPwd('.stored').change(function () {
localStorage[jQueryPwd(this).attr('id')] = jQueryPwd(this).val();
});
jQueryPwd('.deletecache').on('click', function () {
localStorage.clear();
jQueryPwd('.stored').val("");
jQueryPwd('.notstored').val("");
jQueryPwd('#pwdoutputPassword').hide();
return false;
});
jQueryPwd("#pwdmodal-launcher").click(function (e) {
$help.addClass("active");
e.preventDefault();
});
jQueryPwd("#pwdmodal-footer").click(function (e) {
$help.removeClass("active");
e.preventDefault();
});
jQueryPwd('#pwdshowPassword').on('click', function (e) {
var Phrase = $phrase.val();
$phrase.val('');
var User = $user.val().replace(/\s/g, '').toLowerCase();
var Domain = $domain.val().replace(/\s/g, '').toLowerCase();
$domain.val('');
var Len = $length.val().replace(/\s/g, '');
if (!User) {
$user.css('background-color', '#ff9');
$info.html("Please enter a user name").show().delay(2000).fadeOut('slow');
} else if (!Domain) {
$domain.css('background-color', '#ff9');
$info.html("Please enter a valid domain name (e.g., google)").show().delay(2000).fadeOut('slow');
} else if ((!Len) || (isNaN(Len / 1) == true)) {
$length.css('background-color', '#ff9');
$info.html("Please enter a valid numerical length for your password").show().delay(2000).fadeOut('slow');
} else if (!Phrase) {
$phrase.css('background-color', '#ff9');
$info.html("Please enter your secret passphrase").show().delay(2000).fadeOut('slow');
} else {
var hostPattern = /^([a-zA-Z0-9-]+)$/;
if (hostPattern.test(Domain) == false) {
$domain.css('background-color', '#FF9');
$info.html("Please enter a valid domain name but without using any prefixes or suffixes. For instance, enter google and not google.com or www.google.com or accounts.google.com").show().delay(2000).fadeOut('slow');
} else {
generate_password(User, Domain, Phrase, Len);
}
}
e.preventDefault();
});
jQueryPwd('input.userInput').on('keydown change', function (e) {
var key = e.which;
if (e.type == 'change' || key == 8 || key == 32 || (key > 45 && key < 91) || (key > 95 && key < 112) || (key > 185 && key < 223)) {
$output.hide();
$phrase.css('background-color', '#ECF0F1');
$user.css('background-color', '#ECF0F1');
$domain.css('background-color', '#ECF0F1');
$length.css('background-color', '#ECF0F1');
} else if (key == 13) {
jQueryPwd(this).blur();
jQueryPwd('#pwdshowPassword').trigger('click');
e.preventDefault();
}
});
jQueryPwd("input.typeahead").typeahead({
name: "domain",
local: ["Amazon", "Apple", "Box", "Digg", "Disqus", "DreamHost", "Dribbble", "Dropbox", "eBay", "EverNote", "Facebook", "Flipboard", "FourSquare", "GetPocket", "Github", "GoDaddy", "Google", "Hulu", "IFTTT", "IMDB", "Instagram", "Instapaper", "Kickstarter", "LinkedIn", "MailChimp", "Netflix", "NYTimes", "Outlook", "Pandora", "PayPal", "Pinboard", "Pinterest", "Quora", "Readability", "Reddit", "Skype", "SlideShare", "Stack Overflow", "StumbleUpon", "TED", "Tumblr", "Tweetdeck", "Twitter", "Vimeo", "Wikipedia", "WordPress", "WSJ", "Yahoo", "Steam", "SensCritique", "Trillian", "FTP"]
});
};
elm.addEventListener('keydown', function (e) {
if (e.keyCode == 9 && this.value == '') {
clk();
e.stopPropagation();
e.preventDefault();
}
}, true);
//div.addEventListener('click', clk, true);
};
window.addEventListener("load", function () {
var passwds = document.querySelectorAll('input[type=password]');
for (var i = 0; i < passwds.length; i++) {
workOn(passwds[i]);
}
}, true);
window.addEventListener("mousedown", function () {
var passwds = document.querySelectorAll('input[type=password]');
for (var i = 0; i < passwds.length; i++) {
workOn(passwds[i]);
}
}, true);
function clean(str) {
var sentence = str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
return sentence.replace(/\s/g, '');
}
function validate_b85_password(password) {
return (
password.search(/[0-9]/) >= 0 && password.search(/[A-Z]/) >= 0 && password.search(/[a-z]/) >= 0 && password.search(/[\x21-\x2F\x3A-\x40\x5B-\x60]/) >= 0) ? true : false;
}
function b85_hash(s) {
return ascii85(jQueryPwd.map(b64_sha512(s).split(''), function (val) {
return val.charCodeAt(0);
}));
}
var c = function (input, length, result) {
var i, j, n, b = [0, 0, 0, 0, 0];
for (i = 0; i < length; i += 4) {
n = ((input[i] * 256 + input[i + 1]) * 256 + input[i + 2]) * 256 + input[i + 3];
if (!n) {
result.push("z");
} else {
for (j = 0; j < 5; b[j++] = n % 85 + 33, n = Math.floor(n / 85));
}
result.push(String.fromCharCode(b[4], b[3], b[2], b[1], b[0]));
}
};
var ascii85 = function (input) {
// summary: encodes input data in ascii85 string
// input: Array: an array of numbers (0-255) to encode
var result = [],
reminder = input.length % 4,
length = input.length - reminder;
c(input, length, result);
if (reminder) {
var t = input.slice(length);
while (t.length < 4) {
t.push(0);
}
c(t, 4, result);
var x = result.pop();
if (x == "z") {
x = "!!!!!";
}
result.push(x.substr(0, reminder + 1));
}
return result.join(""); // String
};
| 46.083333 | 3,468 | 0.654394 |
5bf444c989742bed3c0ce1618c8592dcc99b4a73 | 68,518 | c | C | sdk-6.5.20/libs/sdklt/bcmcth/tnl/bcmcth_tnl_encap_drv.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmcth/tnl/bcmcth_tnl_encap_drv.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/libs/sdklt/bcmcth/tnl/bcmcth_tnl_encap_drv.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | /*! \file bcmcth_tnl_encap_drv.c
*
* BCMCTH Tunnel Driver APIs
*/
/*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
#include <bsl/bsl.h>
#include <sal/sal_libc.h>
#include <sal/sal_alloc.h>
#include <sal/sal_types.h>
#include <shr/shr_error.h>
#include <shr/shr_debug.h>
#include <shr/shr_ha.h>
#include <shr/shr_debug.h>
#include <bcmltd/chip/bcmltd_id.h>
#include <bcmltd/bcmltd_handler.h>
#include <bcmlrd/bcmlrd_types.h>
#include <bcmlrd/bcmlrd_table.h>
#include <bcmdrd/bcmdrd_field.h>
#include <bcmdrd/bcmdrd_pt.h>
#include <bcmdrd/bcmdrd_dev.h>
#include <bcmptm/bcmptm.h>
#include <bcmbd/bcmbd.h>
#include <bcmmgmt/bcmmgmt_sysm.h>
#include <bcmcth/bcmcth_tnl_internal.h>
#include <bcmcth/bcmcth_tnl_drv.h>
#include <bcmissu/issu_api.h>
#include <bcmcth/generated/tnl_ha.h>
/*******************************************************************************
* Local definitions
*/
#define BSL_LOG_MODULE BSL_LS_BCMCTH_TNL
/*! Device specific attach function type for tunnel encap. */
typedef bcmcth_tnl_encap_drv_t *(*bcmcth_tnl_encap_drv_get_f)(int unit);
/*! Array of device specific attach functions */
#define BCMDRD_DEVLIST_ENTRY(_nm,_vn,_dv,_rv,_md,_pi,_bd,_bc,_fn,_cn,_pf,_pd,_r0,_r1) \
{ _bc##_cth_tnl_encap_drv_get },
static struct {
bcmcth_tnl_encap_drv_get_f drv_get;
} tnl_encap_drv_get[] = {
{ 0 }, /* dummy entry for type "none" */
#include <bcmdrd/bcmdrd_devlist.h>
{ 0 } /* end-of-list */
};
/*! TNL fields array handler. */
static shr_famm_hdl_t tnl_fld_array_hdl[BCMDRD_CONFIG_MAX_UNITS];
static bcmcth_tnl_encap_drv_t *tnl_encap_drv[BCMDRD_CONFIG_MAX_UNITS];
bcmcth_tnl_encap_sw_state_t bcmcth_tnl_encap_sw_state[BCMDRD_CONFIG_MAX_UNITS];
bcmcth_tnl_encap_sw_state_t bcmcth_tnl_encap_sw_state_ha[BCMDRD_CONFIG_MAX_UNITS];
/*******************************************************************************
* Private functions
*/
/*
* Retrieve a field from the input field list.
*/
static int
tnl_entry_field_get(int unit,
const bcmltd_field_t *list,
uint32_t fid,
uint32_t *data)
{
bool found = false;
const bcmltd_field_t *field;
SHR_FUNC_ENTER(unit);
field = list;
while (field) {
if (field->id == fid) {
*data = field->data;
found = true;
break;
}
field = field->next;
}
if (found == false) {
SHR_ERR_EXIT(SHR_E_NOT_FOUND);
}
exit:
SHR_FUNC_EXIT();
}
/*
* Convert an LT field into a field in the MPLS entry structure.
*/
static int
tnl_mpls_lt_fid_to_mpls_entry_data(int unit,
uint32_t fid,
uint32_t idx,
uint64_t data,
tnl_mpls_encap_entry_t *entry)
{
SHR_FUNC_ENTER(unit);
switch (fid) {
case TNL_MPLS_ENCAPt_TNL_MPLS_ENCAP_IDf:
entry->sw_encap_id = data;
break;
case TNL_MPLS_ENCAPt_ENCAP_INDEXf:
entry->encap_id = data;
break;
case TNL_MPLS_ENCAPt_MAX_LABELSf:
entry->max_labels = data;
break;
case TNL_MPLS_ENCAPt_NUM_LABELSf:
entry->num_labels = data;
break;
case TNL_MPLS_ENCAPt_LABELf:
entry->label[idx] = data;
break;
case TNL_MPLS_ENCAPt_LABEL_TTLf:
entry->ttl[idx] = data;
break;
case TNL_MPLS_ENCAPt_MPLS_TNL_EXP_MODEf:
entry->exp_mode[idx] = data;
break;
case TNL_MPLS_ENCAPt_PHB_EGR_MPLS_IDf:
entry->phb_id[idx] = data;
break;
case TNL_MPLS_ENCAPt_LABEL_EXPf:
entry->exp[idx] = data;
break;
case TNL_MPLS_ENCAPt_PRIf:
entry->pri[idx] = data;
break;
case TNL_MPLS_ENCAPt_CFIf:
entry->cfi[idx] = data;
break;
case TNL_MPLS_ENCAPt_ECN_CNG_TO_MPLS_EXP_IDf:
entry->cng_to_exp[idx] = data;
break;
case TNL_MPLS_ENCAPt_ECN_CNG_TO_MPLS_EXP_PRIORITYf:
entry->cng_to_exp_pri[idx] = data;
break;
case TNL_MPLS_ENCAPt_ECN_IP_TO_MPLS_EXP_IDf:
entry->ecn_to_exp[idx] = data;
break;
case TNL_MPLS_ENCAPt_ECN_IP_TO_MPLS_EXP_PRIORITYf:
entry->ecn_to_exp_pri[idx] = data;
break;
default:
SHR_ERR_EXIT(SHR_E_PARAM);
break;
}
exit:
SHR_FUNC_EXIT();
}
/*
* Populate the MPLS entry structure as follows.
* - initialize with default values.
* - update with IMM fields from IMM DB in case the entry is not new.
* - update based on current user input.
*/
static int
tnl_mpls_encap_entry_parse(int unit,
bool new,
bcmltd_fields_t *imm_data,
const bcmltd_field_t *list,
tnl_mpls_encap_entry_t *entry)
{
size_t num_fid = 0, count = 0;
uint32_t i = 0, fid = 0, idx = 0;
uint32_t table_sz = 0;
uint64_t data = 0;
bcmlrd_fid_t *fid_list = NULL;
bcmlrd_field_def_t field_def;
const bcmltd_field_t *field;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(bcmlrd_field_count_get(unit, TNL_MPLS_ENCAPt, &num_fid));
table_sz = (num_fid * sizeof(bcmlrd_fid_t));
SHR_ALLOC(fid_list, table_sz, "bcmcthtnlMplsEncapFldList");
SHR_NULL_CHECK(fid_list, SHR_E_MEMORY);
sal_memset(fid_list, 0, table_sz);
/* Get the list of valid fids corresponding to TNL_MPLS_ENCAP for this unit. */
SHR_IF_ERR_EXIT
(bcmlrd_field_list_get(unit,
TNL_MPLS_ENCAPt,
num_fid,
fid_list,
&count));
/* Initialize the structure with default values. */
for (i = 0; i < count; i++) {
fid = fid_list[i];
SHR_IF_ERR_VERBOSE_EXIT
(bcmlrd_table_field_def_get(unit,
TNL_MPLS_ENCAPt,
fid,
&field_def));
data = BCMCTH_TNL_FIELD_DEF(field_def);
for (idx = 0; idx < BCMCTH_TNL_MPLS_MAX_LABELS; idx++) {
SHR_IF_ERR_VERBOSE_EXIT(
tnl_mpls_lt_fid_to_mpls_entry_data(unit, fid, idx, data, entry));
}
}
/* Update with IMM fields if entry is not new (UPDATE case). */
if (!new && imm_data && imm_data->count != 0) {
for (i = 0; i < imm_data->count; i++) {
fid = imm_data->field[i]->id;
data = imm_data->field[i]->data;
idx = imm_data->field[i]->idx;
SHR_IF_ERR_VERBOSE_EXIT(
tnl_mpls_lt_fid_to_mpls_entry_data(unit, fid, idx, data, entry));
}
}
/* Update with current user input. */
field = list;
while (field) {
fid = field->id;
data = field->data;
idx = field->idx;
SHR_IF_ERR_VERBOSE_EXIT(
tnl_mpls_lt_fid_to_mpls_entry_data(unit, fid, idx, data, entry));
field = field->next;
}
exit:
SHR_FREE(fid_list);
SHR_FUNC_EXIT();
}
/*
* Get value of a field from IMM fields list.
*/
static int
tnl_imm_entry_field_get(int unit,
bcmltd_fields_t *list,
uint32_t fid,
uint32_t *data)
{
uint32_t i = 0;
SHR_FUNC_ENTER(unit);
for (i = 0; i < list->count; i++) {
if (list->field[i]->id == fid) {
*data = list->field[i]->data;
break;
}
}
if (i == list->count) {
SHR_ERR_EXIT(SHR_E_NOT_FOUND);
}
exit:
SHR_FUNC_EXIT();
}
/*
* Function to check if the current hardware index can be re-used
* for an MPLS entry that is being updated.
*/
static int
tnl_mpls_validate_curr_index(int unit,
tnl_mpls_encap_entry_t *entry,
int old_max_labels,
uint32_t mpls_tnl_id,
bool *move)
{
int count = 0;
uint32_t sub_id = 0, max_label_per_tnl = 0;
SHR_FUNC_ENTER(unit);
max_label_per_tnl = BCMCTH_TNL_MAX_MPLS_LABELS(unit);
sub_id = (mpls_tnl_id % max_label_per_tnl);
/*
* If the current hardware index cannot hold
* the new max labels specified, entry has to be moved.
*/
if ((sub_id + entry->max_labels) > max_label_per_tnl) {
*move = true;
SHR_EXIT();
}
/*
* If the current hardware index is not valid w.r.t
* the number of MPLS labels, entry has to be moved.
*/
switch (entry->max_labels) {
case 1:
case 2:
break;
case 3:
case 4:
/* Bits 0 and 1 should be 0 for a chain of 3 to 4 labels. */
if (sub_id & 0x3) {
*move = true;
SHR_EXIT();
}
break;
case 5:
case 6:
case 7:
case 8:
/* Bits 0, 1 and 2 should be 0 for a chain of 5 to 8 labels. */
if (sub_id & 0x7) {
*move = true;
SHR_EXIT();
}
break;
default:
SHR_ERR_EXIT(SHR_E_PARAM);
}
/*
* Count the number of entries used from the current index.
* If this value is more than the old max_labels value, then the following
* entries are being used by another tunnel. Entry has to be moved.
*/
SHR_BITCOUNT_RANGE(
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
count,
mpls_tnl_id,
entry->max_labels);
if (count > old_max_labels) {
*move = true;
SHR_EXIT();
}
exit:
SHR_FUNC_EXIT();
}
/*!
* \brief Allocate a free index for MPLS tunnel
*
* Allocate an entry from the base tunnel and return the
* index as MPLS tunnel ID.
*
* \param [in] unit Unit number.
* \param [in] max_labels Maximum number of labels that
* this MPLS tunnel can have.
* \param [out] mpls_tnl_id Return value of allocated MPLS tunnel ID.
*
* \retval SHR_E_NONE OK.
* \retval SHR_E_FULL Tunnel hardware table full.
*/
static int
tnl_mpls_encap_alloc_free_index(int unit,
int max_labels,
uint32_t *mpls_tnl_id)
{
int num_tnl = 0, count = 0;
int max_label_per_tnl = 0;
int start_idx, width, next_idx = 0;
int idx = 0, sub_idx = 0, base_idx = 0;
bool found = false;
SHR_FUNC_ENTER(unit);
width = BCMCTH_TNL_MPLS_WIDTH(unit);
num_tnl = BCMCTH_TNL_NUM_IPV4(unit);
start_idx = BCMCTH_TNL_MPLS_START_IDX(unit);
max_label_per_tnl = BCMCTH_TNL_MAX_MPLS_LABELS(unit);
/* Get an unused base tnl index from the base tnl bitmap. */
for (idx = start_idx; idx < num_tnl; (idx = idx + width)) {
SHR_BITCOUNT_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
count,
idx,
width);
if (count == 0) {
/* Tunnel entry is free, use for MPLS. */
*mpls_tnl_id = (((uint64_t)idx * max_label_per_tnl) / width);
break;
} else {
/*
* If this index is used, check if it is an MPLS tunnel and if there
* are free entries.
*/
if (BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type[idx] ==
TNL_TYPE_MPLS) {
/*
* Mpls tunnel, check if the sub entry is free and can hold
* max labels.
*/
base_idx = ((idx * max_label_per_tnl) / width);
SHR_BITCOUNT_RANGE(
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
count,
base_idx,
max_label_per_tnl);
if (count < max_label_per_tnl) {
/*
* There is some space here.
* Start from the first offset to look for free space.
*/
for (sub_idx = 0; sub_idx < max_label_per_tnl; sub_idx++) {
next_idx = (base_idx + sub_idx);
SHR_BITCOUNT_RANGE(
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
count,
next_idx,
max_labels);
if ((count != 0) ||
((sub_idx + max_labels) > max_label_per_tnl)) {
/* Not enough space or goes beyond one entry. */
continue;
} else {
if (max_labels > 2) {
/*
* To represent more than two labels, last two
* bits must be free. 3 and 4 label entries can
* start at offsets 0 or 4.
*/
if (sub_idx & 0x3) {
continue;
}
if (max_labels > 7) {
/*
* To accommodate more than four labels, last three
* bits must be free. 5, 6, 7 and 8 label entries can
* start only at offset 0.
*/
if (sub_idx & 0x7) {
continue;
}
}
}
/* Found a suitable index. */
found = true;
*mpls_tnl_id = next_idx;
break;
}
}
}
}
}
/* Break away from the loop if index is found. */
if (found == true) {
break;
}
}
if (idx == num_tnl) {
SHR_ERR_EXIT(SHR_E_FULL);
}
exit:
SHR_FUNC_EXIT();
}
/*!
* \brief Get a free index for MPLS tunnel.
*
* \param [in] unit Unit number.
* \param [in] max_labels Maximum number of labels that
* this MPLS tunnel can have.
* \param [out] mpls_tnl_id MPLS tunnel ID allocated by this function.
* \param [out] tnl_id Base tunnel ID corresponding to mpls_tnl_id.
* \param [out] sub_id Offset within the base tunnel for mpls_tnl_id.
*
* \retval SHR_E_NONE OK.
* \retval SHR_E_FULL Tunnel hardware table full.
*/
static int
tnl_mpls_encap_get_free_index(int unit,
int max_labels,
uint32_t *mpls_tnl_id,
uint32_t *tnl_id,
uint32_t *sub_id)
{
int max_label_per_tnl = 1;
SHR_FUNC_ENTER(unit);
max_label_per_tnl = BCMCTH_TNL_MAX_MPLS_LABELS(unit);
/*
* Get a free index from scanning the used bitmap.
*/
SHR_IF_ERR_VERBOSE_EXIT(
tnl_mpls_encap_alloc_free_index(unit,
max_labels,
mpls_tnl_id));
if (*mpls_tnl_id == 0) {
SHR_ERR_EXIT(SHR_E_FULL);
}
*tnl_id = (*mpls_tnl_id / max_label_per_tnl);
*sub_id = (*mpls_tnl_id % max_label_per_tnl);
exit:
SHR_FUNC_EXIT();
}
/*!
* \brief Get a free index for IP tunnel.
*
* \param [in] unit Unit number.
* \param [in] sid Logical table ID.
* \param [iout tnl_id Allocate tnl_id.
*
* \retval SHR_E_NONE OK.
* \retval SHR_E_FULL Tunnel hardware table full.
*/
static int
tnl_ip_encap_get_free_index(int unit,
bcmltd_sid_t sid,
uint32_t *tnl_id)
{
int num_tnl = 0, count = 0;
int start_idx, width;
int idx = 0;
SHR_FUNC_ENTER(unit);
num_tnl = BCMCTH_TNL_NUM_IPV4(unit);
switch (sid) {
case TNL_IPV4_ENCAPt:
width = BCMCTH_TNL_IPV4_WIDTH(unit);
start_idx = BCMCTH_TNL_IPV4_START_IDX(unit);
break;
case TNL_IPV6_ENCAPt:
width = BCMCTH_TNL_IPV6_WIDTH(unit);
start_idx = BCMCTH_TNL_IPV6_START_IDX(unit);
break;
default:
SHR_ERR_EXIT(SHR_E_PARAM);
}
/*
* Get a free index.
* Single-wide for IPv4 and double-wide for IPv6.
*/
for (idx = start_idx; idx < num_tnl; (idx = idx + width)) {
SHR_BITCOUNT_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
count,
idx,
width);
if (count == 0) {
*tnl_id = (idx / width);
break;
}
}
if (idx == num_tnl) {
SHR_ERR_EXIT(SHR_E_FULL);
}
exit:
SHR_FUNC_EXIT();
}
/*!
* \brief Read an entry from Tunnel hardware table.
*
* \param [in] unit Unit number.
* \param [in] op_arg The operation arguments.
* \param [in] req_ltid Logical table ID.
* \param [in] hw_sid Hardware table ID.
* \param [in] tnl_id Tunnel table hardware index to read from.
* \param [out] entry_buf Pointer to read buffer.
*
* \retval SHR_E_NONE OK.
* \retval SHR_E_NOT_FOUND Hardware table not found.
* \retval SHR_E_PARAM Index is wrong..
*/
static int
tnl_encap_hw_entry_read(int unit,
const bcmltd_op_arg_t *op_arg,
bcmltd_sid_t req_ltid,
bcmdrd_sid_t hw_sid,
uint32_t tnl_id,
uint8_t *entry_buf)
{
uint32_t rsp_flags;
bcmltd_sid_t rsp_ltid;
bcmdrd_sym_info_t sinfo;
bcmbd_pt_dyn_info_t pt_dyn_info;
uint64_t req_flags;
SHR_FUNC_ENTER(unit);
pt_dyn_info.index = tnl_id;
pt_dyn_info.tbl_inst = 0;
SHR_IF_ERR_VERBOSE_EXIT
(bcmdrd_pt_info_get(unit, hw_sid, &sinfo));
req_flags = bcmptm_lt_entry_attrib_to_ptm_req_flags(op_arg->attrib);
SHR_IF_ERR_VERBOSE_EXIT
(bcmptm_ltm_mreq_indexed_lt(unit,
req_flags,
hw_sid,
&pt_dyn_info,
NULL,
NULL,
BCMPTM_OP_READ,
0,
sinfo.entry_wsize,
req_ltid,
op_arg->trans_id,
NULL,
NULL,
(uint32_t *)entry_buf,
&rsp_ltid,
&rsp_flags));
exit:
SHR_FUNC_EXIT();
}
/*!
* \brief Write an entry into Tunnel hardware table.
*
* \param [in] unit Unit number.
* \param [in] op_arg The operation arguments.
* \param [in] req_ltid Logical table ID.
* \param [in] hw_sid Hardware table ID.
* \param [in] tnl_id Tunnel table hardware index to read from.
* \param [in] entry_buf Pointer to write buffer.
*
* \retval SHR_E_NONE OK.
* \retval SHR_E_NOT_FOUND Hardware table not found.
* \retval SHR_E_PARAM Index is wrong..
*/
static int
tnl_encap_hw_entry_write(int unit,
const bcmltd_op_arg_t *op_arg,
bcmltd_sid_t req_ltid,
bcmdrd_sid_t hw_sid,
uint32_t tnl_id,
uint8_t *entry_buf)
{
uint32_t rsp_flags;
bcmltd_sid_t rsp_ltid;
bcmdrd_sym_info_t sinfo;
bcmbd_pt_dyn_info_t pt_dyn_info;
uint64_t req_flags;
SHR_FUNC_ENTER(unit);
pt_dyn_info.index = tnl_id;
pt_dyn_info.tbl_inst = 0;
SHR_IF_ERR_VERBOSE_EXIT
(bcmdrd_pt_info_get(unit, hw_sid, &sinfo));
req_flags = bcmptm_lt_entry_attrib_to_ptm_req_flags(op_arg->attrib);
SHR_IF_ERR_VERBOSE_EXIT
(bcmptm_ltm_mreq_indexed_lt(unit,
req_flags,
hw_sid,
&pt_dyn_info,
NULL,
NULL,
BCMPTM_OP_WRITE,
(uint32_t *)entry_buf,
0,
req_ltid,
op_arg->trans_id,
NULL,
NULL,
NULL,
&rsp_ltid,
&rsp_flags));
exit:
SHR_FUNC_EXIT();
}
/*!
* \brief Clear MPLS tunnel entry.
*
* \param [in] unit Unit number.
* \param [in] hw_sid Hardware table ID.
* \param [in] mpls_tnl_id MPLS tunnel ID.
* \param [in] entry_buf Pointer to tunnel entry buffer.
*
* \retval SHR_E_NONE OK.
*/
static int
tnl_mpls_encap_hw_entry_clear(int unit,
uint32_t hw_sid,
uint64_t mpls_tnl_id,
int max_labels,
uint8_t *entry_buf)
{
uint32_t base_idx = 0, sub_id = 0;
int max_label_per_tnl = 0, count = 0;
bool entry_remove = false;
SHR_FUNC_ENTER(unit);
max_label_per_tnl = BCMCTH_TNL_MAX_MPLS_LABELS(unit);
sub_id = (mpls_tnl_id % max_label_per_tnl);
/* Get the offset into the first entry of this tunnel. */
base_idx = ((mpls_tnl_id / max_label_per_tnl) * max_label_per_tnl);
/*
* Count the number of bits in this MPLS tunnel hardware entry.
*/
SHR_BITCOUNT_RANGE(
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
count,
base_idx,
max_label_per_tnl);
/*
* Last MPLS entry being removed from this tunnel entry,
* Clear tunnel type.
*/
if (count <= max_labels) {
entry_remove = true;
}
SHR_IF_ERR_VERBOSE_EXIT(
BCMCTH_TNL_MPLS_HW_ENTRY_CLEAR(unit)(unit,
hw_sid,
sub_id,
max_labels,
entry_remove,
entry_buf));
exit:
SHR_FUNC_EXIT();
}
/*!
* \brief Prepare the Tunnel hardware entry from LT fields.
*
* \param [in] unit Unit number.
* \param [in] hw_sid Hardware table ID.
* \param [in] tnl_type Tunnel entry type.
* \param [in] sub_id Offset within the base tunnel.
* \param [in] entry MPLS entry s/w state.
* \param [in] in Input parameter list.
* \param [out] entry_buf Pointer to populated hardware entry buffer.
*
* \retval SHR_E_NONE OK.
*/
static int
tnl_encap_hw_entry_prepare(int unit,
uint32_t hw_sid,
int tnl_type,
uint32_t sub_id,
tnl_mpls_encap_entry_t *entry,
const bcmltd_field_t *data,
uint8_t *entry_buf)
{
SHR_FUNC_ENTER(unit);
/* Convert LT entry to HW entry. */
switch (tnl_type) {
case TNL_TYPE_IPV4:
SHR_IF_ERR_VERBOSE_EXIT(BCMCTH_TNL_IPV4_LT_TO_HW_ENTRY(unit)(unit,
hw_sid,
data,
entry_buf));
break;
case TNL_TYPE_IPV6:
SHR_IF_ERR_VERBOSE_EXIT(BCMCTH_TNL_IPV6_LT_TO_HW_ENTRY(unit)(unit,
hw_sid,
data,
entry_buf));
break;
case TNL_TYPE_MPLS:
SHR_IF_ERR_VERBOSE_EXIT(BCMCTH_TNL_MPLS_LT_TO_HW_ENTRY(unit)(unit,
hw_sid,
sub_id,
entry,
entry_buf));
break;
default:
break;
}
exit:
SHR_FUNC_EXIT();
}
/*!
* \brief Prepare the Tunnel hardware entry from LT fields.
*
* \param [in] unit Unit number.
* \param [in] hw_sid Hardware table ID.
* \param [in] tnl_type Tunnel entry type.
* \param [in] sub_id Offset within the base tunnel.
* \param [in] entry MPLS entry s/w state.
* \param [in] in Input parameter list.
* \param [out] entry_buf Pointer to populated hardware entry buffer.
*
* \retval SHR_E_NONE OK.
*/
static int
tnl_encap_hw_entry_parse(int unit,
uint32_t hw_sid,
int tnl_type,
uint32_t sub_id,
tnl_mpls_encap_entry_t *entry,
uint8_t *entry_buf,
bcmltd_fields_t *data)
{
SHR_FUNC_ENTER(unit);
/* Convert HW entry to LT fields. */
switch (tnl_type) {
case TNL_TYPE_IPV4:
SHR_IF_ERR_VERBOSE_EXIT(BCMCTH_TNL_IPV4_HW_TO_LT_ENTRY(unit)(unit,
hw_sid,
entry_buf,
data));
break;
case TNL_TYPE_IPV6:
SHR_IF_ERR_VERBOSE_EXIT(BCMCTH_TNL_IPV6_HW_TO_LT_ENTRY(unit)(unit,
hw_sid,
entry_buf,
data));
break;
case TNL_TYPE_MPLS:
SHR_IF_ERR_VERBOSE_EXIT(BCMCTH_TNL_MPLS_HW_TO_LT_ENTRY(unit)(unit,
hw_sid,
sub_id,
entry,
entry_buf,
data));
break;
default:
break;
}
exit:
SHR_FUNC_EXIT();
}
/*******************************************************************************
Public functions
*/
int
bcmcth_tnl_encap_entry_insert(int unit,
bcmltd_sid_t sid,
const bcmltd_op_arg_t *op_arg,
const bcmltd_field_t *key,
const bcmltd_field_t *data,
bcmltd_fields_t *out)
{
int idx = 0;
uint8_t tnl_type = 0;
uint32_t hw_sid = 0, ret_fid = 0;
uint32_t tnl_id = 0, mpls_tnl_id = 0;
uint8_t *entry_buf = NULL;
uint32_t entry_sz = 0;
uint32_t sub_id = 0;
tnl_mpls_encap_entry_t entry = {0};
SHR_FUNC_ENTER(unit);
switch (sid) {
case TNL_IPV4_ENCAPt:
ret_fid = TNL_IPV4_ENCAPt_ENCAP_INDEXf;
tnl_type = TNL_TYPE_IPV4;
hw_sid = BCMCTH_TNL_IPV4_HW_SID(unit);
break;
case TNL_IPV6_ENCAPt:
ret_fid = TNL_IPV6_ENCAPt_ENCAP_INDEXf;
tnl_type = TNL_TYPE_IPV6;
hw_sid = BCMCTH_TNL_IPV6_HW_SID(unit);
break;
case TNL_MPLS_ENCAPt:
ret_fid = TNL_MPLS_ENCAPt_ENCAP_INDEXf;
tnl_type = TNL_TYPE_MPLS;
hw_sid = BCMCTH_TNL_MPLS_HW_SID(unit);
break;
default:
SHR_ERR_EXIT(SHR_E_PARAM);
}
if ((sid == TNL_IPV4_ENCAPt) || (sid == TNL_IPV6_ENCAPt)) {
/*
* Get a free index.
*/
SHR_IF_ERR_VERBOSE_EXIT
(tnl_ip_encap_get_free_index(unit,
sid,
&tnl_id));
} else {
sal_memset(&entry, 0, sizeof(entry));
/* Parse and populate mpls_entry. */
SHR_IF_ERR_VERBOSE_EXIT(
tnl_mpls_encap_entry_parse(unit,
true,
NULL,
data,
&entry));
/* NUM_LABELS should never be greater than MAX_LABELS. */
if (entry.num_labels > entry.max_labels) {
SHR_ERR_EXIT(SHR_E_PARAM);
}
/*
* Get a free index.
*/
SHR_IF_ERR_VERBOSE_EXIT
(tnl_mpls_encap_get_free_index(unit,
entry.max_labels,
&mpls_tnl_id,
&tnl_id,
&sub_id));
}
/* Read the entry from hardware. */
entry_sz = BCMDRD_WORDS2BYTES(bcmdrd_pt_entry_wsize(unit, hw_sid));
SHR_ALLOC(entry_buf, entry_sz, "bcmcthtnlEncapHwEntry");
SHR_NULL_CHECK(entry_buf, SHR_E_MEMORY);
sal_memset(entry_buf, 0, entry_sz);
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_read(unit,
op_arg,
sid,
hw_sid,
tnl_id,
entry_buf));
/* Prepare the hw entry. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_prepare(unit,
hw_sid,
tnl_type,
sub_id,
&entry,
data,
entry_buf));
/* Write back the entry. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_write(unit,
op_arg,
sid,
hw_sid,
tnl_id,
entry_buf));
/* Mark the used tnl id in the bitmap and set tnl type. */
switch (sid) {
case TNL_IPV4_ENCAPt:
SHR_BITSET(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap, tnl_id);
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type[tnl_id] = TNL_TYPE_IPV4;
break;
case TNL_IPV6_ENCAPt:
SHR_BITSET_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
(tnl_id * BCMCTH_TNL_IPV6_WIDTH(unit)),
BCMCTH_TNL_IPV6_WIDTH(unit));
/* Save the tunnel type of this base tunnel. */
for (idx = 0; idx < BCMCTH_TNL_IPV6_WIDTH(unit); idx++) {
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type
[((tnl_id * BCMCTH_TNL_IPV6_WIDTH(unit)) + idx)] = TNL_TYPE_IPV6;
}
break;
case TNL_MPLS_ENCAPt:
/* Mark the base tnl index as used in base tnl bitmap. */
SHR_BITSET_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
(tnl_id * BCMCTH_TNL_MPLS_WIDTH(unit)),
BCMCTH_TNL_MPLS_WIDTH(unit));
/* Mark the mpls index as used in the mpls tnl bitmap. */
SHR_BITSET_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
mpls_tnl_id, entry.max_labels);
/* Save the tunnel type of this base tunnel. */
for (idx = 0; idx < BCMCTH_TNL_MPLS_WIDTH(unit); idx++) {
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type
[((tnl_id * BCMCTH_TNL_MPLS_WIDTH(unit)) + idx)] = TNL_TYPE_MPLS;
}
break;
}
/* Return the allocated hardware index in the RO field, ENCAP_ID. */
if (out) {
out->field[0]->id = ret_fid;
out->field[0]->idx = 0;
if (sid == TNL_MPLS_ENCAPt) {
out->field[0]->data = mpls_tnl_id;
} else {
out->field[0]->data = tnl_id;
}
out->count = 1;
}
exit:
SHR_FREE(entry_buf);
SHR_FUNC_EXIT();
}
int
bcmcth_tnl_encap_entry_update(int unit,
bcmltd_sid_t sid,
const bcmltd_op_arg_t *op_arg,
const bcmltd_field_t *key,
const bcmltd_field_t *data,
bcmltd_fields_t *out)
{
int rv = 0, idx = 0, max_label_per_tnl = 0, count = 0;
bool move = false, clear_excess = false;
uint32_t old_max_labels = 0, old_num_labels = 0;
uint8_t tnl_type = 0, *entry_buf = NULL;
uint32_t key_fid = 0, tnl_sw_id = 0, hw_sid = 0;
uint32_t tnl_id = 0, mpls_tnl_id = 0, ret_fid = 0;
uint32_t base_idx = 0;
uint32_t entry_sz = 0, old_tnl_id = 0, old_mpls_tnl_id = 0;
uint32_t sub_id = 0, start_id = 0, num_entries = 0;
shr_famm_hdl_t hdl = NULL;
bcmltd_fields_t in_flds = {0}, out_flds = {0};
tnl_mpls_encap_entry_t entry = {0};
SHR_FUNC_ENTER(unit);
switch (sid) {
case TNL_IPV4_ENCAPt:
key_fid = TNL_IPV4_ENCAPt_TNL_IPV4_ENCAP_IDf;
ret_fid = TNL_IPV4_ENCAPt_ENCAP_INDEXf;
tnl_type = TNL_TYPE_IPV4;
hw_sid = BCMCTH_TNL_IPV4_HW_SID(unit);
break;
case TNL_IPV6_ENCAPt:
key_fid = TNL_IPV6_ENCAPt_TNL_IPV6_ENCAP_IDf;
ret_fid = TNL_IPV6_ENCAPt_ENCAP_INDEXf;
tnl_type = TNL_TYPE_IPV6;
hw_sid = BCMCTH_TNL_IPV6_HW_SID(unit);
break;
case TNL_MPLS_ENCAPt:
key_fid = TNL_MPLS_ENCAPt_TNL_MPLS_ENCAP_IDf;
ret_fid = TNL_MPLS_ENCAPt_ENCAP_INDEXf;
tnl_type = TNL_TYPE_MPLS;
hw_sid = BCMCTH_TNL_MPLS_HW_SID(unit);
max_label_per_tnl = BCMCTH_TNL_MAX_MPLS_LABELS(unit);
break;
default:
SHR_ERR_EXIT(SHR_E_PARAM);
}
hdl = tnl_fld_array_hdl[unit];
/* Get the value of the key field. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_entry_field_get(unit, key, key_fid, &tnl_sw_id));
/*
* Do an IMM lookup to fetch the corresponding LT entry from
* IMM database.
*/
in_flds.count = BCMCTH_TNL_NUM_KEY_FIELDS(unit);
in_flds.field = shr_famm_alloc(hdl, BCMCTH_TNL_NUM_KEY_FIELDS(unit));
if (in_flds.field == NULL) {
SHR_ERR_EXIT(SHR_E_MEMORY);
}
out_flds.count = BCMCTH_TNL_NUM_DATA_FIELDS(unit);
out_flds.field = shr_famm_alloc(hdl, BCMCTH_TNL_NUM_DATA_FIELDS(unit));
if (out_flds.field == NULL) {
SHR_ERR_EXIT(SHR_E_MEMORY);
}
in_flds.field[0]->id = key_fid;
in_flds.field[0]->data = tnl_sw_id;
if (bcmimm_entry_lookup(unit, sid, &in_flds, &out_flds) == SHR_E_NOT_FOUND) {
SHR_ERR_EXIT(SHR_E_NOT_FOUND);
}
/*
* Get the previously allocated hardware index from the LT fields.
* Use the same index for IPv4 and IPv6.
* For MPLS, check if the index can be re-used. If not, allocate a new index.
*/
SHR_IF_ERR_VERBOSE_EXIT
(tnl_imm_entry_field_get(unit,
&out_flds,
ret_fid,
&tnl_id));
if (sid == TNL_MPLS_ENCAPt) {
sal_memset(&entry, 0, sizeof(entry));
mpls_tnl_id = tnl_id;
tnl_id = (mpls_tnl_id / max_label_per_tnl);
sub_id = (mpls_tnl_id % max_label_per_tnl);
/* Get the previous MAX_LABELS value. */
rv = tnl_imm_entry_field_get(unit,
&out_flds,
TNL_MPLS_ENCAPt_MAX_LABELSf,
&old_max_labels);
if (rv != SHR_E_NONE) {
old_max_labels = 1;
}
/* Get the previous NUM_LABELS value. */
rv = tnl_imm_entry_field_get(unit,
&out_flds,
TNL_MPLS_ENCAPt_NUM_LABELSf,
&old_num_labels);
if (rv != SHR_E_NONE) {
old_num_labels = 0;
}
/*
* Parse and populate MPLS entry from IMM fields and
* current user input.
*/
SHR_IF_ERR_VERBOSE_EXIT(
tnl_mpls_encap_entry_parse(unit,
false,
&out_flds,
data,
&entry));
/* NUM_LABELS should never be greater than MAX_LABELS. */
if (entry.num_labels > entry.max_labels) {
SHR_ERR_EXIT(SHR_E_PARAM);
}
/* Check if MAX_LABELS value has increased. */
if (entry.max_labels > old_max_labels) {
/* Check if current hardware index can be used. */
SHR_IF_ERR_VERBOSE_EXIT(
tnl_mpls_validate_curr_index(unit,
&entry,
old_max_labels,
mpls_tnl_id,
&move));
if (move == true) {
/* If curent index cannot be used, allocate a new index. */
old_mpls_tnl_id = mpls_tnl_id;
SHR_IF_ERR_VERBOSE_EXIT
(tnl_mpls_encap_get_free_index(unit,
entry.max_labels,
&mpls_tnl_id,
&tnl_id,
&sub_id));
}
} else {
/*
* If MAX_LABELS has decreased from previoud value,
* the surplus entries can be freed.
*/
if (entry.max_labels < old_max_labels) {
clear_excess = true;
}
}
}
/* Read the entry from hardware. */
entry_sz = BCMDRD_WORDS2BYTES(bcmdrd_pt_entry_wsize(unit, hw_sid));
SHR_ALLOC(entry_buf, entry_sz, "bcmcthtnlEncapHwEntry");
SHR_NULL_CHECK(entry_buf, SHR_E_MEMORY);
sal_memset(entry_buf, 0, entry_sz);
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_read(unit,
op_arg,
sid,
hw_sid,
tnl_id,
entry_buf));
/* Prepare the hw entry. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_prepare(unit,
hw_sid,
tnl_type,
sub_id,
&entry,
data,
entry_buf));
/* Write back the entry. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_write(unit,
op_arg,
sid,
hw_sid,
tnl_id,
entry_buf));
/* Delete entries from previous index. */
if (move == true) {
sal_memset(entry_buf, 0, entry_sz);
old_tnl_id = (old_mpls_tnl_id / max_label_per_tnl);
/* For MPLS, clear the fields specific to this entry. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_read(unit,
op_arg,
sid,
hw_sid,
old_tnl_id,
entry_buf));
/* Clear previously allocated hardware index. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_mpls_encap_hw_entry_clear(unit,
hw_sid,
old_mpls_tnl_id,
old_max_labels,
entry_buf));
/* Write back to the hardware table. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_write(unit,
op_arg,
sid,
hw_sid,
old_tnl_id,
entry_buf));
/* Mark the old mpls index as free in the mpls tnl bitmap. */
SHR_BITCLR_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
old_mpls_tnl_id, old_max_labels);
/* Check if all mpls entries in the base tnl have been deleted. */
base_idx = (old_tnl_id * max_label_per_tnl);
SHR_BITCOUNT_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
count,
base_idx,
max_label_per_tnl);
if (!count) {
/*
* No more mpls entries in this base tnl.
* Clear the bit in the base tnl bitmap.
*/
SHR_BITCLR_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
(old_tnl_id * BCMCTH_TNL_MPLS_WIDTH(unit)),
BCMCTH_TNL_MPLS_WIDTH(unit));
for (idx = 0; idx < BCMCTH_TNL_MPLS_WIDTH(unit); idx++) {
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type
[((old_tnl_id * BCMCTH_TNL_MPLS_WIDTH(unit)) + idx)] = TNL_TYPE_NONE;
}
}
}
/* Clear surplus entries from the current index. */
if (clear_excess == true) {
start_id = (mpls_tnl_id + entry.max_labels);
num_entries = (old_max_labels - entry.max_labels);
sal_memset(entry_buf, 0, entry_sz);
/* Read the entry from hardware. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_read(unit,
op_arg,
sid,
hw_sid,
tnl_id,
entry_buf));
/* Clear extra entries. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_mpls_encap_hw_entry_clear(unit,
hw_sid,
start_id,
num_entries,
entry_buf));
/* Write back the entry. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_write(unit,
op_arg,
sid,
hw_sid,
tnl_id,
entry_buf));
/* Mark the mpls index as free in the mpls tnl bitmap. */
SHR_BITCLR_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
start_id,
num_entries);
}
/* Mark the used tnl id in the bitmap and set tnl type. */
switch (sid) {
case TNL_IPV4_ENCAPt:
SHR_BITSET(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap, tnl_id);
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type[tnl_id] = TNL_TYPE_IPV4;
break;
case TNL_IPV6_ENCAPt:
SHR_BITSET_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
(tnl_id * BCMCTH_TNL_IPV6_WIDTH(unit)),
BCMCTH_TNL_IPV6_WIDTH(unit));
/* Save the tunnel type of this base tunnel. */
for (idx = 0; idx < BCMCTH_TNL_IPV6_WIDTH(unit); idx++) {
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type
[((tnl_id * BCMCTH_TNL_IPV6_WIDTH(unit)) + idx)] = TNL_TYPE_IPV6;
}
break;
case TNL_MPLS_ENCAPt:
/* Mark the base tnl index as used in base tnl bitmap. */
SHR_BITSET_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
(tnl_id * BCMCTH_TNL_MPLS_WIDTH(unit)),
BCMCTH_TNL_MPLS_WIDTH(unit));
/* Mark the mpls index as used in the mpls tnl bitmap. */
SHR_BITSET_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
mpls_tnl_id, entry.max_labels);
/* Save the tunnel type of this base tunnel. */
for (idx = 0; idx < BCMCTH_TNL_MPLS_WIDTH(unit); idx++) {
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type
[((tnl_id * BCMCTH_TNL_MPLS_WIDTH(unit)) + idx)] = TNL_TYPE_MPLS;
}
break;
}
/* Return back harwdare index. */
if (out) {
out->field[0]->id = ret_fid;
out->field[0]->idx = 0;
if (sid == TNL_MPLS_ENCAPt) {
out->field[0]->data = mpls_tnl_id;
} else {
out->field[0]->data = tnl_id;
}
out->count = 1;
}
exit:
if (in_flds.field) {
shr_famm_free(hdl, in_flds.field, BCMCTH_TNL_NUM_KEY_FIELDS(unit));
}
if (out_flds.field) {
shr_famm_free(hdl, out_flds.field, BCMCTH_TNL_NUM_DATA_FIELDS(unit));
}
SHR_FREE(entry_buf);
SHR_FUNC_EXIT();
}
int
bcmcth_tnl_encap_entry_delete(int unit,
bcmltd_sid_t sid,
const bcmltd_op_arg_t *op_arg,
const bcmltd_field_t *key,
const bcmltd_field_t *data,
bcmltd_fields_t *out)
{
int idx = 0, max_label_per_tnl = 0, count = 0, rv = 0;
uint8_t *entry_buf = NULL;
uint32_t key_fid = 0, tnl_sw_id = 0, hw_sid = 0;
uint32_t tnl_id = 0, mpls_tnl_id = 0, ret_fid = 0;
uint32_t base_idx = 0, max_labels = 0;
uint32_t entry_sz = 0;
shr_famm_hdl_t hdl = NULL;
bcmltd_fields_t in_flds = {0}, out_flds = {0};
SHR_FUNC_ENTER(unit);
switch (sid) {
case TNL_IPV4_ENCAPt:
key_fid = TNL_IPV4_ENCAPt_TNL_IPV4_ENCAP_IDf;
ret_fid = TNL_IPV4_ENCAPt_ENCAP_INDEXf;
hw_sid = BCMCTH_TNL_IPV4_HW_SID(unit);
break;
case TNL_IPV6_ENCAPt:
key_fid = TNL_IPV6_ENCAPt_TNL_IPV6_ENCAP_IDf;
ret_fid = TNL_IPV6_ENCAPt_ENCAP_INDEXf;
hw_sid = BCMCTH_TNL_IPV6_HW_SID(unit);
break;
case TNL_MPLS_ENCAPt:
key_fid = TNL_MPLS_ENCAPt_TNL_MPLS_ENCAP_IDf;
ret_fid = TNL_MPLS_ENCAPt_ENCAP_INDEXf;
hw_sid = BCMCTH_TNL_MPLS_HW_SID(unit);
max_label_per_tnl = BCMCTH_TNL_MAX_MPLS_LABELS(unit);
break;
default:
SHR_ERR_EXIT(SHR_E_PARAM);
}
hdl = tnl_fld_array_hdl[unit];
/* Get the value coresponding to the key field. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_entry_field_get(unit, key, key_fid, &tnl_sw_id));
/* Fetch the corrsponding LT entry from the IMM database. */
in_flds.count = BCMCTH_TNL_NUM_KEY_FIELDS(unit);
in_flds.field = shr_famm_alloc(hdl, BCMCTH_TNL_NUM_KEY_FIELDS(unit));
if (in_flds.field == NULL) {
SHR_ERR_EXIT(SHR_E_MEMORY);
}
out_flds.count = BCMCTH_TNL_NUM_DATA_FIELDS(unit);
out_flds.field = shr_famm_alloc(hdl, BCMCTH_TNL_NUM_DATA_FIELDS(unit));
if (out_flds.field == NULL) {
SHR_ERR_EXIT(SHR_E_MEMORY);
}
in_flds.field[0]->id = key_fid;
in_flds.field[0]->data = tnl_sw_id;
if (bcmimm_entry_lookup(unit, sid, &in_flds, &out_flds) == SHR_E_NOT_FOUND) {
SHR_ERR_EXIT(SHR_E_NOT_FOUND);
}
/* Get the hardware index allocated to this LT entry from the IMM fields. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_imm_entry_field_get(unit,
&out_flds,
ret_fid,
&tnl_id));
if (sid == TNL_MPLS_ENCAPt) {
mpls_tnl_id = tnl_id;
tnl_id = (mpls_tnl_id / max_label_per_tnl);
rv = tnl_imm_entry_field_get(unit,
&out_flds,
TNL_MPLS_ENCAPt_MAX_LABELSf,
&max_labels);
if (rv != SHR_E_NONE) {
max_labels = 1;
}
}
/* Allocate memory for writing to the hardware table. */
entry_sz = BCMDRD_WORDS2BYTES(bcmdrd_pt_entry_wsize(unit, hw_sid));
SHR_ALLOC(entry_buf, entry_sz, "bcmcthtnlEncapHwEntry");
SHR_NULL_CHECK(entry_buf, SHR_E_MEMORY);
/* Clear the entry data.*/
sal_memset(entry_buf, 0, entry_sz);
if (sid == TNL_MPLS_ENCAPt) {
/* For MPLS, clear the fields specific to this entry. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_read(unit,
op_arg,
sid,
hw_sid,
tnl_id,
entry_buf));
SHR_IF_ERR_VERBOSE_EXIT
(tnl_mpls_encap_hw_entry_clear(unit,
hw_sid,
mpls_tnl_id,
max_labels,
entry_buf));
}
/* Write back to the hardware table. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_write(unit,
op_arg,
sid,
hw_sid,
tnl_id,
entry_buf));
/* Clear the bits from the bitmap and clear tnl type. */
switch (sid) {
case TNL_IPV4_ENCAPt:
SHR_BITCLR(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap, tnl_id);
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type[tnl_id] = TNL_TYPE_NONE;
break;
case TNL_IPV6_ENCAPt:
SHR_BITCLR_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
(tnl_id * BCMCTH_TNL_IPV6_WIDTH(unit)),
BCMCTH_TNL_IPV6_WIDTH(unit));
/* Clear tunnel type of all base tunnel entries used by this tunnel. */
for (idx = 0; idx < BCMCTH_TNL_IPV6_WIDTH(unit); idx++) {
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type
[((tnl_id * BCMCTH_TNL_IPV6_WIDTH(unit)) + idx)] = TNL_TYPE_NONE;
}
break;
case TNL_MPLS_ENCAPt:
/* Mark the mpls index as free in the mpls tnl bitmap. */
SHR_BITCLR_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
mpls_tnl_id, max_labels);
/* Check if all mpls entries in the base tnl have been deleted. */
base_idx = (tnl_id * max_label_per_tnl);
SHR_BITCOUNT_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
count,
base_idx,
max_label_per_tnl);
if (!count) {
/*
* No more mpls entries in this base tnl.
* Clear the bit in the base tnl bitmap.
*/
SHR_BITCLR_RANGE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
(tnl_id * BCMCTH_TNL_MPLS_WIDTH(unit)),
BCMCTH_TNL_MPLS_WIDTH(unit));
for (idx = 0; idx < BCMCTH_TNL_MPLS_WIDTH(unit); idx++) {
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type
[((tnl_id * BCMCTH_TNL_MPLS_WIDTH(unit)) + idx)] = TNL_TYPE_NONE;
}
}
break;
}
exit:
if (in_flds.field) {
shr_famm_free(hdl, in_flds.field, BCMCTH_TNL_NUM_KEY_FIELDS(unit));
}
if (out_flds.field) {
shr_famm_free(hdl, out_flds.field, BCMCTH_TNL_NUM_DATA_FIELDS(unit));
}
SHR_FREE(entry_buf);
SHR_FUNC_EXIT();
}
int
bcmcth_tnl_encap_entry_lookup(int unit,
bcmltd_sid_t sid,
const bcmltd_op_arg_t *op_arg,
void *context,
bcmimm_lookup_type_t lkup_type,
const bcmltd_fields_t *key,
bcmltd_fields_t *out)
{
int max_label_per_tnl = 0;
uint8_t tnl_type = 0, *entry_buf = NULL;
uint32_t hw_sid = 0;
uint32_t tnl_id = 0, ret_fid = 0;
uint32_t entry_sz = 0;
uint32_t sub_id = 0;
tnl_mpls_encap_entry_t entry = {0};
SHR_FUNC_ENTER(unit);
/* Return if not getting from HW or not supported. */
if (!(op_arg->attrib & BCMLT_ENT_ATTR_GET_FROM_HW) ||
!(BCMCTH_TNL_IPV4_HW_TO_LT_ENTRY(unit))) {
SHR_EXIT();
}
switch (sid) {
case TNL_IPV4_ENCAPt:
ret_fid = TNL_IPV4_ENCAPt_ENCAP_INDEXf;
tnl_type = TNL_TYPE_IPV4;
hw_sid = BCMCTH_TNL_IPV4_HW_SID(unit);
break;
case TNL_IPV6_ENCAPt:
ret_fid = TNL_IPV6_ENCAPt_ENCAP_INDEXf;
tnl_type = TNL_TYPE_IPV6;
hw_sid = BCMCTH_TNL_IPV6_HW_SID(unit);
break;
case TNL_MPLS_ENCAPt:
ret_fid = TNL_MPLS_ENCAPt_ENCAP_INDEXf;
tnl_type = TNL_TYPE_MPLS;
hw_sid = BCMCTH_TNL_MPLS_HW_SID(unit);
max_label_per_tnl = BCMCTH_TNL_MAX_MPLS_LABELS(unit);
break;
default:
SHR_ERR_EXIT(SHR_E_PARAM);
}
/*
* Get the previously allocated hardware index from the LT fields.
*/
SHR_IF_ERR_VERBOSE_EXIT
(tnl_imm_entry_field_get(unit,
out,
ret_fid,
&tnl_id));
if (tnl_type == TNL_TYPE_MPLS) {
sub_id = tnl_id % max_label_per_tnl;
tnl_id = tnl_id / max_label_per_tnl;
/*
* Parse and populate MPLS entry from IMM fields and
* current user input.
*/
SHR_IF_ERR_VERBOSE_EXIT(
tnl_mpls_encap_entry_parse(unit,
false,
out,
NULL,
&entry));
}
/* Read the entry from hardware. */
entry_sz = BCMDRD_WORDS2BYTES(bcmdrd_pt_entry_wsize(unit, hw_sid));
SHR_ALLOC(entry_buf, entry_sz, "bcmcthtnlEncapHwEntry");
SHR_NULL_CHECK(entry_buf, SHR_E_MEMORY);
sal_memset(entry_buf, 0, entry_sz);
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_read(unit,
op_arg,
sid,
hw_sid,
tnl_id,
entry_buf));
/* Parse the hw entry. */
SHR_IF_ERR_VERBOSE_EXIT
(tnl_encap_hw_entry_parse(unit,
hw_sid,
tnl_type,
sub_id,
&entry,
entry_buf,
out));
exit:
SHR_FREE(entry_buf);
SHR_FUNC_EXIT();
}
/*!
* \fn bcmcth_tnl_sw_state_cleanup
*
* \brief Free Tunnel SW structures.
*
* \param [in] unit Unit number.
*
* \retval SHR_E_NONE OK
* \retval !SHR_E_NONE ERROR
*/
int
bcmcth_tnl_sw_state_cleanup(int unit)
{
SHR_FUNC_ENTER(unit);
if (BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap != NULL) {
SHR_FREE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap);
}
if (BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap != NULL) {
SHR_FREE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap);
}
if (BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type != NULL) {
SHR_FREE(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type);
}
if (tnl_fld_array_hdl[unit]) {
shr_famm_hdl_delete(tnl_fld_array_hdl[unit]);
tnl_fld_array_hdl[unit] = 0;
}
SHR_FUNC_EXIT();
}
/*!
* \fn bcmcth_tnl_sw_state_init
*
* \brief Initialise Tunnel SW structures.
*
* \param [in] unit Unit number.
* \param [in] warm Cold/Warm boot.
*
* \retval SHR_E_NONE OK
* \retval !SHR_E_NONE ERROR
*/
int
bcmcth_tnl_sw_state_init(int unit, bool warm)
{
int num_ip_tnl, num_mpls_tnl;
uint32_t ha_alloc_size = 0, ha_req_size = 0;
bcmcth_tnl_base_tnl_state_t *base_tnl_state = NULL;
bcmcth_tnl_mpls_tnl_state_t *mpls_tnl_state = NULL;
bcmcth_tnl_base_tnl_type_t *base_tnl_type = NULL;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(shr_famm_hdl_init(BCMCTH_TNL_NUM_DATA_FIELDS(unit),
&tnl_fld_array_hdl[unit]));
num_ip_tnl = BCMCTH_TNL_NUM_IPV4(unit);
num_mpls_tnl = BCMCTH_TNL_NUM_MPLS(unit);
/* SW state for maintaing IPv4/v6/MPLS database in the Encap Table */
ha_req_size = sizeof(bcmcth_tnl_base_tnl_state_t) +
SHR_BITALLOCSIZE(num_ip_tnl);
ha_alloc_size = ha_req_size;
/* Base IPv4/v6 tunnel bitmap */
base_tnl_state =
shr_ha_mem_alloc(unit,
BCMMGMT_TNL_COMP_ID,
BCMCTH_TNL_BASE_TNL_BMAP_SUB_COMP_ID,
"bcmcthTnlBaseTnlState",
&ha_alloc_size);
SHR_NULL_CHECK(base_tnl_state, SHR_E_MEMORY);
SHR_IF_ERR_VERBOSE_EXIT((ha_alloc_size < ha_req_size) ?
SHR_E_MEMORY : SHR_E_NONE);
if (!warm) {
sal_memset(base_tnl_state, 0, ha_alloc_size);
base_tnl_state ->array_size = SHRi_BITDCLSIZE(num_ip_tnl);
SHR_IF_ERR_EXIT
(bcmissu_struct_info_report(unit, BCMMGMT_TNL_COMP_ID,
BCMCTH_TNL_BASE_TNL_BMAP_SUB_COMP_ID, 0,
ha_req_size, 1,
BCMCTH_TNL_BASE_TNL_STATE_T_ID));
}
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_bitmap =
base_tnl_state->base_tnl_bitmap;
ha_alloc_size = ha_req_size - sizeof(bcmcth_tnl_base_tnl_state_t);
/* SW state for maintaing temp IPv4/v6/MPLS database in the Encap Table */
/* Base IPv4/v6 tunnel bitmap */
SHR_ALLOC(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap, ha_alloc_size,
"bcmcthtnlBaseTnlBmap");
SHR_NULL_CHECK(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap, SHR_E_MEMORY);
sal_memset(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap, 0,
ha_alloc_size);
/* Entry 0 is unused and reserved */
SHR_BITSET(BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_bitmap, 0);
/* Syncing the temp space to committed SW state. */
sal_memcpy(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_bitmap, ha_alloc_size);
/* MPLS tunnel bitmap */
ha_req_size = sizeof(bcmcth_tnl_mpls_tnl_state_t) +
SHR_BITALLOCSIZE(num_mpls_tnl);
ha_alloc_size = ha_req_size;
mpls_tnl_state =
shr_ha_mem_alloc(unit,
BCMMGMT_TNL_COMP_ID,
BCMCTH_TNL_MPLS_TNL_BMAP_SUB_COMP_ID,
"bcmcthTnlMplsTnlState",
&ha_alloc_size);
SHR_NULL_CHECK(mpls_tnl_state, SHR_E_MEMORY);
SHR_IF_ERR_VERBOSE_EXIT((ha_alloc_size < ha_req_size) ?
SHR_E_MEMORY : SHR_E_NONE);
if (!warm) {
sal_memset(mpls_tnl_state, 0, ha_alloc_size);
mpls_tnl_state->array_size = SHRi_BITDCLSIZE(num_mpls_tnl);
SHR_IF_ERR_EXIT
(bcmissu_struct_info_report(unit, BCMMGMT_TNL_COMP_ID,
BCMCTH_TNL_MPLS_TNL_BMAP_SUB_COMP_ID, 0,
ha_req_size, 1,
BCMCTH_TNL_MPLS_TNL_STATE_T_ID));
}
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_mpls_tnl_bitmap =
mpls_tnl_state->mpls_tnl_bitmap;
ha_alloc_size = ha_req_size - sizeof(bcmcth_tnl_mpls_tnl_state_t);
/* MPLS tunnel temp bitmap */
SHR_ALLOC(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap, ha_alloc_size,
"bcmcthtnlMplsTnlBmap");
SHR_NULL_CHECK(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap, SHR_E_MEMORY);
sal_memset(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap, 0,
ha_alloc_size);
/* Syncing the temp space to committed SW state. */
sal_memcpy(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_mpls_tnl_bitmap, ha_alloc_size);
/* SW state for maintaing IPv4/v6/MPLS tunnel types in the Encap Table */
ha_req_size = sizeof(bcmcth_tnl_base_tnl_type_t) +
(num_ip_tnl * sizeof(uint8_t));
ha_alloc_size = ha_req_size;
/* Base IPv4/v6 tunnel bitmap */
base_tnl_type =
shr_ha_mem_alloc(unit,
BCMMGMT_TNL_COMP_ID,
BCMCTH_TNL_BASE_TNL_TYPE_SUB_COMP_ID,
"bcmcthTnlBaseTnlType",
&ha_alloc_size);
SHR_NULL_CHECK(base_tnl_type, SHR_E_MEMORY);
SHR_IF_ERR_VERBOSE_EXIT((ha_alloc_size < ha_req_size) ?
SHR_E_MEMORY : SHR_E_NONE);
if (!warm) {
sal_memset(base_tnl_type, 0, ha_alloc_size);
base_tnl_type->array_size = num_ip_tnl;
SHR_IF_ERR_EXIT
(bcmissu_struct_info_report(unit, BCMMGMT_TNL_COMP_ID,
BCMCTH_TNL_BASE_TNL_TYPE_SUB_COMP_ID, 0,
ha_req_size, 1,
BCMCTH_TNL_BASE_TNL_TYPE_T_ID));
}
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_type =
base_tnl_type->base_tnl_type;
ha_alloc_size = ha_req_size - sizeof(bcmcth_tnl_base_tnl_type_t);
/* SW state for maintaing temp IPv4/v6/MPLS database in the Encap Table */
SHR_ALLOC(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type, ha_alloc_size,
"bcmcthtnlBaseTnlType");
SHR_NULL_CHECK(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type, SHR_E_MEMORY);
sal_memset(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type, 0,
ha_alloc_size);
/* Entry 0 is unused and reserved */
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_type[0] = TNL_TYPE_NONE;
/* Syncing the temp space to committed SW state. */
sal_memcpy(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type,
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_type, ha_alloc_size);
exit:
if (SHR_FUNC_ERR()) {
if (base_tnl_state != NULL) {
bcmissu_struct_info_clear(unit,
BCMCTH_TNL_BASE_TNL_STATE_T_ID,
BCMMGMT_TNL_COMP_ID,
BCMCTH_TNL_BASE_TNL_BMAP_SUB_COMP_ID);
shr_ha_mem_free(unit, base_tnl_state);
}
if (mpls_tnl_state != NULL) {
bcmissu_struct_info_clear(unit,
BCMCTH_TNL_MPLS_TNL_STATE_T_ID,
BCMMGMT_TNL_COMP_ID,
BCMCTH_TNL_MPLS_TNL_BMAP_SUB_COMP_ID);
shr_ha_mem_free(unit, mpls_tnl_state);
}
if (base_tnl_type != NULL) {
bcmissu_struct_info_clear(unit,
BCMCTH_TNL_BASE_TNL_TYPE_T_ID,
BCMMGMT_TNL_COMP_ID,
BCMCTH_TNL_BASE_TNL_TYPE_SUB_COMP_ID);
shr_ha_mem_free(unit, base_tnl_type);
}
bcmcth_tnl_sw_state_cleanup(unit);
}
SHR_FUNC_EXIT();
}
/*!
* \fn bcmcth_tnl_transaction_commit
*
* \brief Commit SW states for the tunnel Table.
*
* \param [in] unit Unit number.
* \param [in] lt_sid Logical table ID.
* \param [in] trans_id Transaction ID.
* \param [in] context Context pointer.
*
* \retval SHR_E_NONE OK
* \retval !SHR_E_NONE ERROR
*/
int
bcmcth_tnl_transaction_commit(int unit,
bcmltd_sid_t lt_sid,
uint32_t trans_id,
void *context)
{
int num_ip_tnl, num_mpls_tnl;
uint32_t alloc_sz = 0;
SHR_FUNC_ENTER(unit);
num_ip_tnl = BCMCTH_TNL_NUM_IPV4(unit);
num_mpls_tnl = BCMCTH_TNL_NUM_MPLS(unit);
alloc_sz = SHR_BITALLOCSIZE(num_mpls_tnl);
sal_memcpy(BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_mpls_tnl_bitmap,
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
alloc_sz);
alloc_sz = SHR_BITALLOCSIZE(num_ip_tnl);
sal_memcpy(BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_bitmap,
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
alloc_sz);
alloc_sz = (num_ip_tnl * sizeof(uint8_t));
sal_memcpy(BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_type,
BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type,
alloc_sz);
SHR_FUNC_EXIT();
}
/*!
* \fn bcmcth_tnl_transaction_abort
*
* \brief Abort SW states for the tunnel Table.
*
* \param [in] unit Unit number.
* \param [in] lt_sid Logical table ID.
* \param [in] trans_id Transaction ID.
* \param [in] context Context pointer.
*
* \retval SHR_E_NONE OK
*/
void
bcmcth_tnl_transaction_abort(int unit,
bcmltd_sid_t lt_sid,
uint32_t trans_id,
void *context)
{
uint32_t alloc_sz = 0;
int num_ip_tnl, num_mpls_tnl;
num_ip_tnl = BCMCTH_TNL_NUM_IPV4(unit);
num_mpls_tnl = BCMCTH_TNL_NUM_MPLS(unit);
alloc_sz = SHR_BITALLOCSIZE(num_mpls_tnl);
sal_memcpy(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_mpls_tnl_bitmap,
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_mpls_tnl_bitmap,
alloc_sz);
alloc_sz = SHR_BITALLOCSIZE(num_ip_tnl);
sal_memcpy(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_bitmap,
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_bitmap,
alloc_sz);
alloc_sz = (num_ip_tnl * sizeof(uint8_t));
sal_memcpy(BCMCTH_TNL_ENCAP_SW_STATE(unit).bcmcth_tnl_base_tnl_type,
BCMCTH_TNL_ENCAP_SW_STATE_HA(unit).bcmcth_tnl_base_tnl_type,
alloc_sz);
}
int
bcmcth_tnl_encap_drv_init(int unit)
{
bcmdrd_dev_type_t dev_type;
dev_type = bcmdrd_dev_type(unit);
if (dev_type == BCMDRD_DEV_T_NONE) {
return SHR_E_UNIT;
}
/* Perform device-specific software setup */
tnl_encap_drv[unit] = tnl_encap_drv_get[dev_type].drv_get(unit);
return SHR_E_NONE;
}
int
bcmcth_tnl_encap_drv_get(int unit, bcmcth_tnl_encap_drv_t **drv)
{
SHR_FUNC_ENTER(unit);
if (tnl_encap_drv[unit] != NULL) {
*drv = tnl_encap_drv[unit];
} else {
SHR_VERBOSE_EXIT(SHR_E_UNAVAIL);
}
exit:
SHR_FUNC_EXIT();
}
| 34.780711 | 134 | 0.528649 |
32e01173e666f3d1949fa61ba4d8eb36c59e2c09 | 3,730 | lua | Lua | ixhl2rp/plugins/charpane/sv_hooks.lua | terranova3/hl2rp | dcbd2828575ef3a17bb11142978085db6b9661dd | [
"MIT"
] | null | null | null | ixhl2rp/plugins/charpane/sv_hooks.lua | terranova3/hl2rp | dcbd2828575ef3a17bb11142978085db6b9661dd | [
"MIT"
] | null | null | null | ixhl2rp/plugins/charpane/sv_hooks.lua | terranova3/hl2rp | dcbd2828575ef3a17bb11142978085db6b9661dd | [
"MIT"
] | null | null | null | --[[
© 2020 TERRANOVA do not share, re-distribute or modify
without permission of its author.
--]]
local PLUGIN = PLUGIN;
-- Called when a player enters observer
function PLUGIN:OnPlayerObserve(client, state)
if(state) then
local curParts = client:GetParts()
-- Hide any PACs when going observer.
if (curParts) then
client:ResetParts()
end
else
-- Reload the pacs when exiting out of observer.
local charPanel = client:GetCharacter():GetCharPanel();
local inv = client:GetCharacter():GetInventory()
for _, v in pairs(charPanel:GetItems()) do
if (v.pacData) then
client:AddPart(v.uniqueID, v)
end
end
for _, v in pairs(inv:GetItems()) do
if (v:GetData("equip") == true and v.pacData) then
client:AddPart(v.uniqueID, v)
end
end
end
end
-- Called when a player tries to equip an item with items in their character panel.
function PLUGIN:CanPlayerEquipItem(client, item)
local charPanel = client:GetCharacter():GetCharPanel();
if(item.outfitCategory) then
if(charPanel:HasEquipped()) then
client:Notify("You can't equip a full outfit with items in your character panel!")
return false;
end
end;
return true;
end
-- Called during character load when the panel needs to be loaded.
function PLUGIN:CharPanelLoaded(character)
local charPanel = character:GetCharPanel();
for _, v in pairs(charPanel:GetItems()) do
if (v.pacData) then
character:GetPlayer():AddPart(v.uniqueID, v)
end
end
end
-- Called when a character is spawning.
function PLUGIN:PostPlayerLoadout(client)
local character = client:GetCharacter()
local charPanel = character:GetCharPanel();
if (charPanel) then
for _, v in pairs(charPanel:GetItems()) do
if(v.OnLoadout) then
v:Call("OnLoadout", client)
end
end
end
end
-- Called when character data is being saved.
function PLUGIN:CharacterPreSave(character)
local client = character:GetPlayer()
for _, v in pairs(character:GetCharPanel():GetItems()) do
if (v.OnSave) then
v:Call("OnSave", client)
end
end
end
-- Called when an item has been added to the character panel
function PLUGIN:CharPanelItemEquipped(client, item)
if(!item.outfitCategory) then return false end;
if(item.OnEquipped) then
item:Call("OnEquipped", client)
end
if(item.isBag and item:GetData("id")) then
local inv = ix.item.inventories[item:GetData("id")]
if(inv) then
inv:AddReceiver(client)
net.Start("ixCharPanelLoadBag")
net.WriteInt(item.id, 32)
net.Send(client)
end
end
if(item.bodyGroups) then
local bodygroup = 0
for _, v in pairs(item.bodyGroups) do
bodygroup = v;
end
PLUGIN:UpdateBodygroup(client, item.outfitCategory, bodygroup)
elseif(item.pacData) then
client:AddPart(item.uniqueID, item)
end
end;
-- Called when an item has been removed from the character panel
function PLUGIN:CharPanelItemUnequipped(client, item)
if(!item.outfitCategory) then return false end;
if(item.OnUnequipped) then
item:Call("OnUnequipped", client)
end
if(item.isBag and item:GetData("id")) then
local inv = ix.item.inventories[item:GetData("id")]
if(inv) then
inv:RemoveReceiver(client)
net.Start("ixCharPanelBagDrop")
net.WriteUInt(item:GetData("id"), 32)
net.Send(client)
end
end
if(item.bodyGroups) then
PLUGIN:UpdateBodygroup(client, item.outfitCategory, 0)
elseif(item.pacData) then
client:RemovePart(item.uniqueID)
end
end;
function PLUGIN:UpdateBodygroup(client, outfitCategory, bodygroup)
local character = client:GetCharacter()
local index = client:FindBodygroupByName(outfitCategory)
local groups = character:GetData("groups", {})
groups[index] = bodygroup
character:SetData("groups", groups)
client:SetBodygroup(index, bodygroup)
end | 24.064516 | 85 | 0.73244 |
21db9940d6757c7eacd296fb181a1d534c17246a | 6,008 | html | HTML | NEST-14.0-FPGA/doc/help/sli/testsuite::test_iaf_dc_aligned_automatic.html | OpenHEC/SNN-simulator-on-PYNQcluster | 14f86a76edf4e8763b58f84960876e95d4efc43a | [
"MIT"
] | 45 | 2019-12-09T06:45:53.000Z | 2022-01-29T12:16:41.000Z | NEST-14.0-FPGA/doc/help/sli/testsuite::test_iaf_dc_aligned_automatic.html | zlchai/SNN-simulator-on-PYNQcluster | 14f86a76edf4e8763b58f84960876e95d4efc43a | [
"MIT"
] | 2 | 2020-05-23T05:34:21.000Z | 2021-09-08T02:33:46.000Z | NEST-14.0-FPGA/doc/help/sli/testsuite::test_iaf_dc_aligned_automatic.html | OpenHEC/SNN-simulator-on-PYNQcluster | 14f86a76edf4e8763b58f84960876e95d4efc43a | [
"MIT"
] | 10 | 2019-12-09T06:45:59.000Z | 2021-03-25T09:32:56.000Z | <!DOCTYPE html>
<html>
<head>
<title>NEST Command Index: testsuite::test_iaf_dc_aligned_automatic</title>
<style type="text/css">
body {
padding: 0;
margin: 0;
}
h1 {
padding: 15px 0 0 15px;
}
p {
padding-left: 15px;
}
a {
color: #339;
text-decoration: none;
}
a:visited {
color: #339;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
h1 a {
color: #000;
text-decoration: none;
}
table.headerfooter {
margin: 20px 0 20px 0;
background-color: #eee;
width: 100%;
height: 30px;
border-top: 2px solid #ccc;
border-bottom: 2px solid #ccc;
text-align: center;
}
table.commands {
margin: 15px 0 15px 0;
background-color: #eee;
width: 90%;
border: 2px solid #ccc;
border-spacing: 0px;
border-collapse: collapse;
}
table.commands td {
border-bottom: 1px solid #ccc;
border-right: 1px dotted #ccc;
padding: 5px 0 5px 10px;
text-align: left;
}
table.letteridx {
margin: 0;
background-color: #eee;
width: 90%;
border: 2px solid #ccc;
border-spacing: 0px;
border-collapse: collapse;
}
table.letteridx td {
border-right: 1px solid #ccc;
padding: 5px;
text-align: center;
}
table.letteridx a {
display: block;
height: 100%;
width: 100%;
}
td.left{
width:30%;
}
div.wrap {
padding-left: 15px;
}
</style>
</head>
<body>
<h1>Command: testsuite::test_iaf_dc_aligned_automatic</h1>
<table class="headerfooter">
<tbody><tr>
<td width="30%" align="center"><a href="../../index.html">
NEST HelpDesk</a></td>
<td width="30%" align="center"><a href="../helpindex.html">
Command Index</a></td>
<td width="30%" align="center"><a href="../../quickref.html">
NEST Quick Reference</a></td>
</tr>
</tbody></table>
<div class="wrap">
<!-- Begin -->
<b>Name:</b><pre>testsuite::test_iaf_dc_aligned_automatic - sli script for test of iaf_neuron resolution independence</pre>
<b>Synopsis: </b>
<pre>(test_iaf_dc_aligned_automatic) run -> compare response with reference data <br/> <br/> <br/>
</pre>
<b>Description: </b>
<pre> <br/> <br/> test_iaf_dc_aligned_automatic.sli is a modified version of <br/> test_iaf_dc_aligned_delay.sli . <br/> <br/> The code of this program is now identical to <br/> test_iaf_dc_aligned_delay.sli. Previous versions used a different <br/> definition of start which was not independent of the resolution. <br/> Therefore, an additional device property /on was required. See <br/> test_iaf_dc_aligned_automatic.sli for details. <br/> <br/> The documentation below refers to the old definition of start <br/> <br/> The output generated is exactly identical to the output of the <br/> previous file. The dependence of the simulation script on the <br/> computation step size is completely removed by using the capability <br/> of the DC generator to adjust the required starting time to the <br/> computation time step. This functionality is implemented in the Device <br/> base class and, thus, available to all devices. <br/> <br/> Instead of specifying the start time of the generator as in <br/> test_iaf_dc_aligned_delay.sli, the emission time of the first current <br/> event is specified. A device can only take action in a step t-h -> t. <br/> When t-h represents the start time of the device, t is the earliest time <br/> stamp of an emitted event. In our case the time stamp is the onset of the <br/> current. Thus, both times can not simultaneously be independent of the <br/> computation time step h. It is sufficient to specify one of the two measures, <br/> the other one is computed automatically. Internally, only the start time <br/> is stored. A warning is issued when both measures are specified because <br/> a difference other than h would be meaningless and a difference of h may <br/> not be representable by the two double values. In case both properties are <br/> specified, on overrides start. The timer of the device does not rely on <br/> computing differences between doubles but uses the exact representation of <br/> time provided by the simulation kernel. <br/> <br/> An inspection of the property dictionary of the DC generator at different <br/> computation step sizes shows the relationship between DC generator <br/> on and start. <br/> <br/> h=0.1ms h=0.5ms <br/> << << <br/> /start 1.9 /start 1.5 <br/> /on 2.0 /on 2.0 <br/> >> >> <br/> <br/> No output of the spike detector is visible here because of the short simulation <br/> time of only 6 ms. Set the simulation time to larger values to verify the <br/> consistency of voltage meter and spike detector. <br/> <br/> The expected output is documented at the end of the script. <br/> <br/> July 2004, <br/> updated, Diesmann <br/> <br/> Author: February 2004, Diesmann, Gewaltig, Plesser <br/>
</pre>
<b>SeeAlso: </b>
<ul>
<li><a href="../sli/testsuite::test_iaf_dc.html">testsuite::test_iaf_dc</a></li>
<li><a href="../sli/testsuite::test_iaf_dc_aligned.html">testsuite::test_iaf_dc_aligned</a></li>
<li><a href="../sli/testsuite::test_iaf_dc_aligned_delay.html">testsuite::test_iaf_dc_aligned_delay</a></li>
</ul>
<b>Source:</b><pre>/home/xilinx/nest_fpga_compe/testsuite/unittests/test_iaf_dc_aligned_automatic.sli</pre>
</div>
<!-- End -->
</div>
<table class="headerfooter">
<tbody><tr>
<td width="30%" align="center"><a href="../../index.html">
NEST HelpDesk</a></td>
<td width="30%" align="center"><a href="../helpindex.html">
Command Index</a></td>
<td width="30%" align="center"><a href="../../quickref.html">
NEST Quick Reference</a></td>
</tr>
</tbody></table>
<p style="text-align:center">
© 2004 <a href="http://www.nest-initiative.org">The NEST Initiative</a>
</p>
</body>
</html> | 45.515152 | 2,809 | 0.658955 |
807c4b4c3f3cf950ae64905012e8507c66a9f83c | 721 | java | Java | src/main/java/io/iron/ironworker/client/builders/Params.java | rkononov/iron_worker_java | bc2b60af70f130cf8bce1e4069727044239511dc | [
"BSD-2-Clause"
] | null | null | null | src/main/java/io/iron/ironworker/client/builders/Params.java | rkononov/iron_worker_java | bc2b60af70f130cf8bce1e4069727044239511dc | [
"BSD-2-Clause"
] | null | null | null | src/main/java/io/iron/ironworker/client/builders/Params.java | rkononov/iron_worker_java | bc2b60af70f130cf8bce1e4069727044239511dc | [
"BSD-2-Clause"
] | null | null | null | package io.iron.ironworker.client.builders;
import io.iron.ironworker.client.APIException;
import java.util.HashMap;
import java.util.Map;
public class Params {
public static Map<String, Object> create(Object... os) throws APIException {
if (os.length % 2 != 0) {
throw new APIException("Odd params number", null);
}
Map<String, Object> params = new HashMap<String, Object>();
for (int i = 0; i < os.length; i += 2) {
params.put(os[i].toString(), os[i + 1]);
}
return params;
}
public static ParamsObject add(String key, Object value) {
return (new ParamsObject()).add(key, value);
}
protected Params() {
}
}
| 24.033333 | 80 | 0.601942 |
8026934d5dd00d5eb740eb6cfa3dc99c0af8019c | 9,627 | java | Java | Java Code/SlapperFishy/src/main/java/me/darklorddudealt/fishslap/FishSlap.java | ona-li-toki-e-jan-Epiphany-tawa-mi/AkashicRecord | 0a4882d2729da88c4fb7b7c8970bb00af82eb29c | [
"MIT"
] | 1 | 2021-02-24T22:07:01.000Z | 2021-02-24T22:07:01.000Z | Java Code/SlapperFishy/src/main/java/me/darklorddudealt/fishslap/FishSlap.java | ona-li-toki-e-jan-Epiphany-tawa-mi/AkashicRecord | 0a4882d2729da88c4fb7b7c8970bb00af82eb29c | [
"MIT"
] | null | null | null | Java Code/SlapperFishy/src/main/java/me/darklorddudealt/fishslap/FishSlap.java | ona-li-toki-e-jan-Epiphany-tawa-mi/AkashicRecord | 0a4882d2729da88c4fb7b7c8970bb00af82eb29c | [
"MIT"
] | null | null | null | package me.darklorddudealt.fishslap;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public final class FishSlap extends JavaPlugin implements Listener {
private static final Material[] slapper = {Material.SALMON, Material.TROPICAL_FISH, Material.COD}; // Used for testing player-held items
private static boolean stopTnt; // Used to dictate whether explosion sounds should be cancelled
@Override
public void onEnable() {
// Some nice startup messages
getLogger().info("Convincing chinese fish markets...");
getLogger().info("Oiling fish...");
getLogger().info("Making things... fishy...");
getLogger().info("blop...");
getServer().getPluginManager().registerEvents(this, this); // Registers listener to be used for onEntityDamage()
ProtocolManager pm = ProtocolLibrary.getProtocolManager();
// Runs when any sound packet is made on sever
pm.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket(); // Makes code easier to read
String soundName = packet.getSoundEffects().read(0).toString(); // Grabs the name of the intercepted sound
if (stopTnt && soundName.contains("ENTITY_GENERIC_EXPLODE")) {
event.setCancelled(true); // Stops 'ENTITY_GENERIC_EXPLODE' from being sent to player clients
}
}
});
getLogger().info("FishSlap Initialized!"); // A nice startup message
}
@EventHandler
public void onEntityDamage(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof Player) {
Player sal = null;
Entity sal2 = null;
boolean b; // Used to denote if the hit 'entity' is actually an entity or a player
Player chad = (Player) e.getDamager();
if (e.getEntity() instanceof Player) {
sal = (Player) e.getEntity();
b = true;
} else {
sal2 = e.getEntity();
b = false;
}
if (chad != null) { // Safety first!
Material held = chad.getInventory().getItemInMainHand().getType();
if (held != null) // Safety first!
for (Material material : slapper) // Compares held item with the list of raw fish
if (held == material) {
double dist; // Denotes integer distance between the attacker and the attacked
Location loc; // Helps find position for explosion and animation
// This spaghetti tastes really nice
if (b) {
sal.addPotionEffect((new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 2, 4))); // Prevents explosion from causing any damage
dist = Math.ceil(Math.sqrt(Math.pow((sal.getLocation().getX() - chad.getLocation().getX()), 2) + Math.pow((sal.getLocation().getY() - chad.getLocation().getY()), 2) + Math.pow((sal.getLocation().getZ() - chad.getLocation().getZ()), 2))); // ⌈√((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2)⌉, defines how many iterations the floor loop should run off of
loc = sal.getLocation();
for (int x = 0; x < dist; x++) { // Approximates the point near but not equal to sal's coordinates, in the direction of chad
//Midpoint madness
loc.setX((loc.getX() + sal.getLocation().getX()) / 2);
loc.setY((loc.getY() + sal.getLocation().getY()) / 2);
loc.setZ((loc.getZ() + sal.getLocation().getZ()) / 2);
}
loc.setY(loc.getY() + 1); // Corrects animation and explosion to be more accurate to the chad's hit
stopTnt = true; // Stops following sound packet
sal.getWorld().createExplosion(loc, 0.25f); // Kinda for looks, kinda not
sal.getWorld().spawnParticle(Particle.CRIT, loc, 25, 0.125, 0.125, 0.125, 0.5); // Pleasing
// Thought it would be cool if it played a sound that corresponds to the fish used
if (held == Material.SALMON)
sal.getWorld().playSound(loc, Sound.ENTITY_SALMON_HURT, SoundCategory.PLAYERS, 2, 0.1f);
else if (held == Material.COD)
sal.getWorld().playSound(loc, Sound.ENTITY_COD_HURT, SoundCategory.PLAYERS, 2, 0.1f);
else
sal.getWorld().playSound(loc, Sound.ENTITY_TROPICAL_FISH_HURT, SoundCategory.PLAYERS, 2, 0.1f);
} else {
((LivingEntity) sal2).addPotionEffect((new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 2, 4))); // Prevents explosion from causing any damage
dist = Math.ceil(Math.sqrt(Math.pow((sal2.getLocation().getX() - chad.getLocation().getX()), 2) + Math.pow((sal2.getLocation().getY() - chad.getLocation().getY()), 2) + Math.pow((sal2.getLocation().getZ() - chad.getLocation().getZ()), 2))); // ⌈√((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2)⌉, defines how many iterations the floor loop should run off of
loc = sal2.getLocation();
for (int x = 0; x < dist; x++) { // Approximates the point near but not equal to sal's coordinates, in the direction of chad
//Midpoint madness
loc.setX((loc.getX() + sal2.getLocation().getX()) / 2);
loc.setY((loc.getY() + sal2.getLocation().getY()) / 2);
loc.setZ((loc.getZ() + sal2.getLocation().getZ()) / 2);
}
loc.setY(loc.getY() + 1); // Corrects animation and explosion to be more accurate to the chad's hit
stopTnt = true; // Stops following sound packet
sal2.getWorld().createExplosion(loc, 0.25f); // Kinda for looks, kinda not
sal2.getWorld().spawnParticle(Particle.CRIT, loc, 25, 0.125, 0.125, 0.125, 0.5); // Pleasing
// Thought it would be cool if it played a sound that corresponds to the fish used
if (held == Material.SALMON)
sal2.getWorld().playSound(loc, Sound.ENTITY_SALMON_HURT, SoundCategory.PLAYERS, 2, 0.1f);
else if (held == Material.COD)
sal2.getWorld().playSound(loc, Sound.ENTITY_COD_HURT, SoundCategory.PLAYERS, 2, 0.1f);
else
sal2.getWorld().playSound(loc, Sound.ENTITY_TROPICAL_FISH_HURT, SoundCategory.PLAYERS, 2, 0.1f);
}
Player finalSal1 = sal;
Entity finalSal = sal2;
new BukkitRunnable() { // Waits a short while for the entity to get some speed
@Override
public void run() {
Vector vekky = b ? finalSal1.getVelocity() : finalSal.getVelocity(); // Grabs from correct entity variable
// Really puts that... 'UMPH' into the slap
vekky.setX(vekky.getX() * 5);
vekky.setY(vekky.getY() * 2.5);
vekky.setZ(vekky.getZ() * 5);
if (b)
finalSal1.setVelocity(vekky);
else
finalSal.setVelocity(vekky);
stopTnt = false; // stops cancelling explosion sounds
}
}.runTaskLater(this, 1);
}
}
}
}
@Override
public void onDisable () {
// Some nice shutdown messages
getLogger().info("Capin, the ship is sinking!");
getLogger().info("glugluglugluglugluglugluglug...");
getLogger().info("FishSlap is swimming with the fishies.");
}
}
| 61.318471 | 376 | 0.5335 |
22fe6a61b38d307687f66cbc242fbcc7c9591b40 | 17,711 | cc | C++ | update_engine/update_engine_client.cc | Keneral/asystem | df12381b72ef3d629c8efc61100cc8c714195320 | [
"Unlicense"
] | null | null | null | update_engine/update_engine_client.cc | Keneral/asystem | df12381b72ef3d629c8efc61100cc8c714195320 | [
"Unlicense"
] | null | null | null | update_engine/update_engine_client.cc | Keneral/asystem | df12381b72ef3d629c8efc61100cc8c714195320 | [
"Unlicense"
] | null | null | null | //
// Copyright (C) 2012 The Android Open Source Project
//
// 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.
//
#include <inttypes.h>
#include <sysexits.h>
#include <unistd.h>
#include <memory>
#include <string>
#include <vector>
#include <base/bind.h>
#include <base/command_line.h>
#include <base/logging.h>
#include <base/macros.h>
#include <brillo/daemons/daemon.h>
#include <brillo/flag_helper.h>
#include "update_engine/common/error_code.h"
#include "update_engine/common/error_code_utils.h"
#include "update_engine/client.h"
#include "update_engine/status_update_handler.h"
#include "update_engine/update_status.h"
#include "update_engine/update_status_utils.h"
using chromeos_update_engine::UpdateStatusToString;
using chromeos_update_engine::ErrorCode;
using std::string;
using std::unique_ptr;
using std::vector;
using update_engine::UpdateStatus;
namespace {
// Constant to signal that we need to continue running the daemon after
// initialization.
const int kContinueRunning = -1;
class UpdateEngineClient : public brillo::Daemon {
public:
UpdateEngineClient(int argc, char** argv) : argc_(argc), argv_(argv) {
}
~UpdateEngineClient() override = default;
protected:
int OnInit() override {
int ret = Daemon::OnInit();
if (ret != EX_OK) return ret;
client_ = update_engine::UpdateEngineClient::CreateInstance();
if (!client_) {
LOG(ERROR) << "UpdateEngineService not available.";
return 1;
}
// We can't call QuitWithExitCode from OnInit(), so we delay the execution
// of the ProcessFlags method after the Daemon initialization is done.
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&UpdateEngineClient::ProcessFlagsAndExit,
base::Unretained(this)));
return EX_OK;
}
private:
// Show the status of the update engine in stdout.
bool ShowStatus();
// Return whether we need to reboot. 0 if reboot is needed, 1 if an error
// occurred, 2 if no reboot is needed.
int GetNeedReboot();
// Main method that parses and triggers all the actions based on the passed
// flags. Returns the exit code of the program of kContinueRunning if it
// should not exit.
int ProcessFlags();
// Processes the flags and exits the program accordingly.
void ProcessFlagsAndExit();
// Copy of argc and argv passed to main().
int argc_;
char** argv_;
// Library-based client
unique_ptr<update_engine::UpdateEngineClient> client_;
// Pointers to handlers for cleanup
vector<unique_ptr<update_engine::StatusUpdateHandler>> handlers_;
// Tell whether the UpdateEngine service is available after startup.
bool service_is_available_{false};
DISALLOW_COPY_AND_ASSIGN(UpdateEngineClient);
};
class ExitingStatusUpdateHandler : public update_engine::StatusUpdateHandler {
public:
~ExitingStatusUpdateHandler() override = default;
void IPCError(const string& error) override;
};
void ExitingStatusUpdateHandler::IPCError(const string& error) {
LOG(ERROR) << error;
exit(1);
}
class WatchingStatusUpdateHandler : public ExitingStatusUpdateHandler {
public:
~WatchingStatusUpdateHandler() override = default;
void HandleStatusUpdate(int64_t last_checked_time,
double progress,
UpdateStatus current_operation,
const string& new_version,
int64_t new_size) override;
};
void WatchingStatusUpdateHandler::HandleStatusUpdate(
int64_t last_checked_time, double progress, UpdateStatus current_operation,
const string& new_version, int64_t new_size) {
LOG(INFO) << "Got status update:";
LOG(INFO) << " last_checked_time: " << last_checked_time;
LOG(INFO) << " progress: " << progress;
LOG(INFO) << " current_operation: "
<< UpdateStatusToString(current_operation);
LOG(INFO) << " new_version: " << new_version;
LOG(INFO) << " new_size: " << new_size;
}
bool UpdateEngineClient::ShowStatus() {
int64_t last_checked_time = 0;
double progress = 0.0;
UpdateStatus current_op;
string new_version;
int64_t new_size = 0;
if (!client_->GetStatus(&last_checked_time, &progress, ¤t_op,
&new_version, &new_size)) {
return false;
}
printf("LAST_CHECKED_TIME=%" PRIi64
"\nPROGRESS=%f\nCURRENT_OP=%s\n"
"NEW_VERSION=%s\nNEW_SIZE=%" PRIi64 "\n",
last_checked_time, progress, UpdateStatusToString(current_op),
new_version.c_str(), new_size);
return true;
}
int UpdateEngineClient::GetNeedReboot() {
int64_t last_checked_time = 0;
double progress = 0.0;
UpdateStatus current_op;
string new_version;
int64_t new_size = 0;
if (!client_->GetStatus(&last_checked_time, &progress, ¤t_op,
&new_version, &new_size)) {
return 1;
}
if (current_op == UpdateStatus::UPDATED_NEED_REBOOT) {
return 0;
}
return 2;
}
class UpdateWaitHandler : public ExitingStatusUpdateHandler {
public:
explicit UpdateWaitHandler(bool exit_on_error)
: exit_on_error_(exit_on_error) {}
~UpdateWaitHandler() override = default;
void HandleStatusUpdate(int64_t last_checked_time,
double progress,
UpdateStatus current_operation,
const string& new_version,
int64_t new_size) override;
private:
bool exit_on_error_;
};
void UpdateWaitHandler::HandleStatusUpdate(int64_t /* last_checked_time */,
double /* progress */,
UpdateStatus current_operation,
const string& /* new_version */,
int64_t /* new_size */) {
if (exit_on_error_ && current_operation == UpdateStatus::IDLE) {
LOG(ERROR) << "Update failed, current operations is "
<< UpdateStatusToString(current_operation);
exit(1);
}
if (current_operation == UpdateStatus::UPDATED_NEED_REBOOT) {
LOG(INFO) << "Update succeeded -- reboot needed.";
exit(0);
}
}
int UpdateEngineClient::ProcessFlags() {
DEFINE_string(app_version, "", "Force the current app version.");
DEFINE_string(channel, "",
"Set the target channel. The device will be powerwashed if the "
"target channel is more stable than the current channel unless "
"--nopowerwash is specified.");
DEFINE_bool(check_for_update, false, "Initiate check for updates.");
DEFINE_bool(follow, false,
"Wait for any update operations to complete."
"Exit status is 0 if the update succeeded, and 1 otherwise.");
DEFINE_bool(interactive, true, "Mark the update request as interactive.");
DEFINE_string(omaha_url, "", "The URL of the Omaha update server.");
DEFINE_string(p2p_update, "",
"Enables (\"yes\") or disables (\"no\") the peer-to-peer update"
" sharing.");
DEFINE_bool(powerwash, true,
"When performing rollback or channel change, "
"do a powerwash or allow it respectively.");
DEFINE_bool(reboot, false, "Initiate a reboot if needed.");
DEFINE_bool(is_reboot_needed, false,
"Exit status 0 if reboot is needed, "
"2 if reboot is not needed or 1 if an error occurred.");
DEFINE_bool(block_until_reboot_is_needed, false,
"Blocks until reboot is "
"needed. Returns non-zero exit status if an error occurred.");
DEFINE_bool(reset_status, false, "Sets the status in update_engine to idle.");
DEFINE_bool(rollback, false,
"Perform a rollback to the previous partition. The device will "
"be powerwashed unless --nopowerwash is specified.");
DEFINE_bool(can_rollback, false,
"Shows whether rollback partition "
"is available.");
DEFINE_bool(show_channel, false, "Show the current and target channels.");
DEFINE_bool(show_p2p_update, false,
"Show the current setting for peer-to-peer update sharing.");
DEFINE_bool(show_update_over_cellular, false,
"Show the current setting for updates over cellular networks.");
DEFINE_bool(status, false, "Print the status to stdout.");
DEFINE_bool(update, false,
"Forces an update and waits for it to complete. "
"Implies --follow.");
DEFINE_string(update_over_cellular, "",
"Enables (\"yes\") or disables (\"no\") the updates over "
"cellular networks.");
DEFINE_bool(watch_for_updates, false,
"Listen for status updates and print them to the screen.");
DEFINE_bool(prev_version, false,
"Show the previous OS version used before the update reboot.");
DEFINE_bool(last_attempt_error, false, "Show the last attempt error.");
// Boilerplate init commands.
base::CommandLine::Init(argc_, argv_);
brillo::FlagHelper::Init(argc_, argv_, "Chromium OS Update Engine Client");
// Ensure there are no positional arguments.
const vector<string> positional_args =
base::CommandLine::ForCurrentProcess()->GetArgs();
if (!positional_args.empty()) {
LOG(ERROR) << "Found a positional argument '" << positional_args.front()
<< "'. If you want to pass a value to a flag, pass it as "
"--flag=value.";
return 1;
}
// Update the status if requested.
if (FLAGS_reset_status) {
LOG(INFO) << "Setting Update Engine status to idle ...";
if (client_->ResetStatus()) {
LOG(INFO) << "ResetStatus succeeded; to undo partition table changes "
"run:\n"
"(D=$(rootdev -d) P=$(rootdev -s); cgpt p -i$(($(echo "
"${P#$D} | sed 's/^[^0-9]*//')-1)) $D;)";
} else {
LOG(ERROR) << "ResetStatus failed";
return 1;
}
}
// Changes the current update over cellular network setting.
if (!FLAGS_update_over_cellular.empty()) {
bool allowed = FLAGS_update_over_cellular == "yes";
if (!allowed && FLAGS_update_over_cellular != "no") {
LOG(ERROR) << "Unknown option: \"" << FLAGS_update_over_cellular
<< "\". Please specify \"yes\" or \"no\".";
} else {
if (!client_->SetUpdateOverCellularPermission(allowed)) {
LOG(ERROR) << "Error setting the update over cellular setting.";
return 1;
}
}
}
// Show the current update over cellular network setting.
if (FLAGS_show_update_over_cellular) {
bool allowed;
if (!client_->GetUpdateOverCellularPermission(&allowed)) {
LOG(ERROR) << "Error getting the update over cellular setting.";
return 1;
}
LOG(INFO) << "Current update over cellular network setting: "
<< (allowed ? "ENABLED" : "DISABLED");
}
if (!FLAGS_powerwash && !FLAGS_rollback && FLAGS_channel.empty()) {
LOG(ERROR) << "powerwash flag only makes sense rollback or channel change";
return 1;
}
// Change the P2P enabled setting.
if (!FLAGS_p2p_update.empty()) {
bool enabled = FLAGS_p2p_update == "yes";
if (!enabled && FLAGS_p2p_update != "no") {
LOG(ERROR) << "Unknown option: \"" << FLAGS_p2p_update
<< "\". Please specify \"yes\" or \"no\".";
} else {
if (!client_->SetP2PUpdatePermission(enabled)) {
LOG(ERROR) << "Error setting the peer-to-peer update setting.";
return 1;
}
}
}
// Show the rollback availability.
if (FLAGS_can_rollback) {
string rollback_partition;
if (!client_->GetRollbackPartition(&rollback_partition)) {
LOG(ERROR) << "Error while querying rollback partition availabilty.";
return 1;
}
bool can_rollback = true;
if (rollback_partition.empty()) {
rollback_partition = "UNAVAILABLE";
can_rollback = false;
} else {
rollback_partition = "AVAILABLE: " + rollback_partition;
}
LOG(INFO) << "Rollback partition: " << rollback_partition;
if (!can_rollback) {
return 1;
}
}
// Show the current P2P enabled setting.
if (FLAGS_show_p2p_update) {
bool enabled;
if (!client_->GetP2PUpdatePermission(&enabled)) {
LOG(ERROR) << "Error getting the peer-to-peer update setting.";
return 1;
}
LOG(INFO) << "Current update using P2P setting: "
<< (enabled ? "ENABLED" : "DISABLED");
}
// First, update the target channel if requested.
if (!FLAGS_channel.empty()) {
if (!client_->SetTargetChannel(FLAGS_channel, FLAGS_powerwash)) {
LOG(ERROR) << "Error setting the channel.";
return 1;
}
LOG(INFO) << "Channel permanently set to: " << FLAGS_channel;
}
// Show the current and target channels if requested.
if (FLAGS_show_channel) {
string current_channel;
string target_channel;
if (!client_->GetChannel(¤t_channel)) {
LOG(ERROR) << "Error getting the current channel.";
return 1;
}
if (!client_->GetTargetChannel(&target_channel)) {
LOG(ERROR) << "Error getting the target channel.";
return 1;
}
LOG(INFO) << "Current Channel: " << current_channel;
if (!target_channel.empty())
LOG(INFO) << "Target Channel (pending update): " << target_channel;
}
bool do_update_request = FLAGS_check_for_update | FLAGS_update |
!FLAGS_app_version.empty() |
!FLAGS_omaha_url.empty();
if (FLAGS_update) FLAGS_follow = true;
if (do_update_request && FLAGS_rollback) {
LOG(ERROR) << "Incompatible flags specified with rollback."
<< "Rollback should not include update-related flags.";
return 1;
}
if (FLAGS_rollback) {
LOG(INFO) << "Requesting rollback.";
if (!client_->Rollback(FLAGS_powerwash)) {
LOG(ERROR) << "Rollback request failed.";
return 1;
}
}
// Initiate an update check, if necessary.
if (do_update_request) {
LOG_IF(WARNING, FLAGS_reboot) << "-reboot flag ignored.";
string app_version = FLAGS_app_version;
if (FLAGS_update && app_version.empty()) {
app_version = "ForcedUpdate";
LOG(INFO) << "Forcing an update by setting app_version to ForcedUpdate.";
}
LOG(INFO) << "Initiating update check and install.";
if (!client_->AttemptUpdate(app_version, FLAGS_omaha_url,
FLAGS_interactive)) {
LOG(ERROR) << "Error checking for update.";
return 1;
}
}
// These final options are all mutually exclusive with one another.
if (FLAGS_follow + FLAGS_watch_for_updates + FLAGS_reboot + FLAGS_status +
FLAGS_is_reboot_needed + FLAGS_block_until_reboot_is_needed >
1) {
LOG(ERROR) << "Multiple exclusive options selected. "
<< "Select only one of --follow, --watch_for_updates, --reboot, "
<< "--is_reboot_needed, --block_until_reboot_is_needed, "
<< "or --status.";
return 1;
}
if (FLAGS_status) {
LOG(INFO) << "Querying Update Engine status...";
if (!ShowStatus()) {
LOG(ERROR) << "Failed to query status";
return 1;
}
return 0;
}
if (FLAGS_follow) {
LOG(INFO) << "Waiting for update to complete.";
auto handler = new UpdateWaitHandler(true);
handlers_.emplace_back(handler);
client_->RegisterStatusUpdateHandler(handler);
return kContinueRunning;
}
if (FLAGS_watch_for_updates) {
LOG(INFO) << "Watching for status updates.";
auto handler = new WatchingStatusUpdateHandler();
handlers_.emplace_back(handler);
client_->RegisterStatusUpdateHandler(handler);
return kContinueRunning;
}
if (FLAGS_reboot) {
LOG(INFO) << "Requesting a reboot...";
client_->RebootIfNeeded();
return 0;
}
if (FLAGS_prev_version) {
string prev_version;
if (!client_->GetPrevVersion(&prev_version)) {
LOG(ERROR) << "Error getting previous version.";
} else {
LOG(INFO) << "Previous version = " << prev_version;
}
}
if (FLAGS_is_reboot_needed) {
int ret = GetNeedReboot();
if (ret == 1) {
LOG(ERROR) << "Could not query the current operation.";
}
return ret;
}
if (FLAGS_block_until_reboot_is_needed) {
auto handler = new UpdateWaitHandler(false);
handlers_.emplace_back(handler);
client_->RegisterStatusUpdateHandler(handler);
return kContinueRunning;
}
if (FLAGS_last_attempt_error) {
int last_attempt_error;
if (!client_->GetLastAttemptError(&last_attempt_error)) {
LOG(ERROR) << "Error getting last attempt error.";
} else {
ErrorCode code = static_cast<ErrorCode>(last_attempt_error);
string error_msg = chromeos_update_engine::utils::ErrorCodeToString(code);
printf("ERROR_CODE=%i\n"
"ERROR_MESSAGE=%s\n",
last_attempt_error, error_msg.c_str());
}
}
return 0;
}
void UpdateEngineClient::ProcessFlagsAndExit() {
int ret = ProcessFlags();
if (ret != kContinueRunning)
QuitWithExitCode(ret);
}
} // namespace
int main(int argc, char** argv) {
UpdateEngineClient client(argc, argv);
return client.Run();
}
| 32.556985 | 80 | 0.649992 |
753477506269b94f735edcaa02bb9b75cbf99f79 | 807 | cs | C# | src/PMDEvers.Servicebus/Interfaces/IServiceBus.cs | pmdevers/Servicebus | c2c402012097af39d82134cba56bad401335d101 | [
"Apache-2.0"
] | 1 | 2020-01-04T19:03:57.000Z | 2020-01-04T19:03:57.000Z | src/PMDEvers.Servicebus/Interfaces/IServiceBus.cs | pmdevers/Servicebus | c2c402012097af39d82134cba56bad401335d101 | [
"Apache-2.0"
] | null | null | null | src/PMDEvers.Servicebus/Interfaces/IServiceBus.cs | pmdevers/Servicebus | c2c402012097af39d82134cba56bad401335d101 | [
"Apache-2.0"
] | null | null | null | using System.Threading;
using System.Threading.Tasks;
using PMDEvers.Servicebus.Interfaces;
namespace PMDEvers.Servicebus
{
public interface IServiceBus
{
Task<TResult> QueryAsync<TResult>(IQuery<TResult> query, CancellationToken cancellationToken = default);
Task<TResult> QueryAsync<TQuery, TResult>(TQuery query, CancellationToken cancellationToken = default)
where TQuery : class, IQuery<TResult>;
Task<TResponse> SendAsync<TResponse>(ICommand<TResponse> command,
CancellationToken cancellationToken = default);
Task SendAsync(ICommand command, CancellationToken cancellationToken = default);
Task PublishAsync<TEvent>(TEvent @event, CancellationToken cancellationToken = default)
where TEvent : IEvent;
}
}
| 33.625 | 112 | 0.729864 |
0b63b4e5baf389984b66bde68abf981d8599f521 | 3,109 | dart | Dart | lib/web_ui/lib/src/engine/compositor/fonts.dart | zhongchao-han/engine | 5075172fe7f7858c2e1449e53092d34f23a3338e | [
"BSD-3-Clause"
] | null | null | null | lib/web_ui/lib/src/engine/compositor/fonts.dart | zhongchao-han/engine | 5075172fe7f7858c2e1449e53092d34f23a3338e | [
"BSD-3-Clause"
] | null | null | null | lib/web_ui/lib/src/engine/compositor/fonts.dart | zhongchao-han/engine | 5075172fe7f7858c2e1449e53092d34f23a3338e | [
"BSD-3-Clause"
] | 1 | 2020-12-28T03:06:13.000Z | 2020-12-28T03:06:13.000Z | // Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
part of engine;
class SkiaFontCollection {
final Map<String, Map<Map<String, String>, js.JsObject>>
_registeredTypefaces = <String, Map<Map<String, String>, js.JsObject>>{};
final List<Future<void>> _fontLoadingFutures = <Future<void>>[];
Future<void> ensureFontsLoaded() async {
await Future.wait(_fontLoadingFutures);
}
Future<void> registerFonts(AssetManager assetManager) async {
ByteData byteData;
try {
byteData = await assetManager.load('FontManifest.json');
} on AssetManagerException catch (e) {
if (e.httpStatus == 404) {
html.window.console
.warn('Font manifest does not exist at `${e.url}` – ignoring.');
return;
} else {
rethrow;
}
}
if (byteData == null) {
throw AssertionError(
'There was a problem trying to load FontManifest.json');
}
final List<dynamic> fontManifest =
json.decode(utf8.decode(byteData.buffer.asUint8List()));
if (fontManifest == null) {
throw AssertionError(
'There was a problem trying to load FontManifest.json');
}
for (Map<String, dynamic> fontFamily in fontManifest) {
final String family = fontFamily['family'];
final List<dynamic> fontAssets = fontFamily['fonts'];
for (dynamic fontAssetItem in fontAssets) {
final Map<String, dynamic> fontAsset = fontAssetItem;
final String asset = fontAsset['asset'];
final Map<String, String> descriptors = <String, String>{};
for (String descriptor in fontAsset.keys) {
if (descriptor != 'asset') {
descriptors[descriptor] = '${fontAsset[descriptor]}';
}
}
_fontLoadingFutures.add(_registerFont(
family, assetManager.getAssetUrl(asset), descriptors));
}
}
}
Future<void> _registerFont(
String family, String url, Map<String, String> descriptors) async {
final dynamic fetchResult = await html.window.fetch(url);
final ByteBuffer resultBuffer = await fetchResult.arrayBuffer();
final js.JsObject skTypeFace = skFontMgr.callMethod(
'MakeTypefaceFromData', <Uint8List>[resultBuffer.asUint8List()]);
_registeredTypefaces.putIfAbsent(
family, () => <Map<String, String>, js.JsObject>{});
_registeredTypefaces[family][descriptors] = skTypeFace;
}
js.JsObject getFont(String family, double size) {
if (_registeredTypefaces[family] == null) {
if (family == 'sans-serif') {
// If it's the default font, return a default SkFont
return js.JsObject(canvasKit['SkFont'], <dynamic>[null, size]);
}
throw Exception('Unregistered font: $family');
}
final js.JsObject skTypeface = _registeredTypefaces[family].values.first;
return js.JsObject(canvasKit['SkFont'], <dynamic>[skTypeface, size]);
}
final js.JsObject skFontMgr =
js.JsObject(canvasKit['SkFontMgr']['RefDefault']);
}
| 34.932584 | 79 | 0.656481 |
f7e53cb35be3da4ddd40feff72c9839e8bffd567 | 758 | kt | Kotlin | app/src/androidTest/java/com/github/anastr/myscore/util/FakeDatabaseModule.kt | anastr/MyDegree | ef1b8e66a472762477b2cfe1da142521942a8a78 | [
"Apache-2.0"
] | null | null | null | app/src/androidTest/java/com/github/anastr/myscore/util/FakeDatabaseModule.kt | anastr/MyDegree | ef1b8e66a472762477b2cfe1da142521942a8a78 | [
"Apache-2.0"
] | null | null | null | app/src/androidTest/java/com/github/anastr/myscore/util/FakeDatabaseModule.kt | anastr/MyDegree | ef1b8e66a472762477b2cfe1da142521942a8a78 | [
"Apache-2.0"
] | null | null | null | package com.github.anastr.myscore.util
import android.content.Context
import androidx.room.Room
import com.github.anastr.data.hilt.DatabaseModule
import com.github.anastr.data.room.AppDatabase
import dagger.Module
import dagger.Provides
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import dagger.hilt.testing.TestInstallIn
import javax.inject.Singleton
@Module
@TestInstallIn(
components = [SingletonComponent::class],
replaces = [DatabaseModule::class],
)
class FakeDatabaseModule {
@Singleton
@Provides
fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase {
return Room.inMemoryDatabaseBuilder(context, AppDatabase::class.java).build()
}
}
| 29.153846 | 85 | 0.802111 |
698a91a3d4c801a74bfb1c2a8b235fdbc1ca8800 | 3,739 | ps1 | PowerShell | tests/reports/New-TssReport.Tests.ps1 | peetrike/thycotic.secretserver | 3c22109873e48f18036911248eac7b8a8d7a90cc | [
"Apache-2.0"
] | null | null | null | tests/reports/New-TssReport.Tests.ps1 | peetrike/thycotic.secretserver | 3c22109873e48f18036911248eac7b8a8d7a90cc | [
"Apache-2.0"
] | null | null | null | tests/reports/New-TssReport.Tests.ps1 | peetrike/thycotic.secretserver | 3c22109873e48f18036911248eac7b8a8d7a90cc | [
"Apache-2.0"
] | null | null | null | BeforeDiscovery {
$commandName = Split-Path ($PSCommandPath.Replace('.Tests.ps1','')) -Leaf
. ([IO.Path]::Combine([string]$PSScriptRoot,'..','constants.ps1'))
}
Describe "$commandName verify parameters" {
BeforeDiscovery {
[object[]]$knownParameters = 'TssSession', 'ReportName', 'CategoryId', 'ReportSql', 'Description', 'ChartType', 'Is3DReport', 'PageSize', 'Paging'
[object[]]$currentParams = ([Management.Automation.CommandMetaData]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function')).Parameters.Keys
[object[]]$commandDetails = [System.Management.Automation.CommandInfo]$ExecutionContext.SessionState.InvokeCommand.GetCommand($commandName,'Function')
$unknownParameters = Compare-Object -ReferenceObject $knownParameters -DifferenceObject $currentParams -PassThru
}
Context "Verify parameters" -Foreach @{currentParams = $currentParams} {
It "$commandName should contain <_> parameter" -TestCases $knownParameters {
$_ -in $currentParams | Should -Be $true
}
It "$commandName should not contain parameter: <_>" -TestCases $unknownParameters {
$_ | Should -BeNullOrEmpty
}
}
Context "Command specific details" {
It "$commandName should set OutputType to TssReport" -TestCases $commandDetails {
$_.OutputType.Name | Should -Be 'TssReport'
}
}
}
Describe "$commandName works" {
BeforeDiscovery {
$invokeParams = @{}
$reportName = ("TssTestReport$(Get-Random)")
if ($tssTestUsingWindowsAuth) {
$session = New-TssSession -SecretServer $ss -UseWindowsAuth
$invokeParams.UseDefaultCredentials = $true
} else {
$session = New-TssSession -SecretServer $ss -Credential $ssCred
$invokeParams.PersonalAccessToken = $session.AccessToken
}
$categoryId = (Get-TssReportCategory -TssSession $session -All).Where({$_.Name -eq 'tssModuleTest'}).CategoryId
if ($null -eq $categoryId) {
$bodData = @{
data = @{
reportCategoryDescription = 'tss Module test category'
reportCategoryName = 'tssModuleTest'
}
} | ConvertTo-Json
# bug in endpoint where it won't return the Category ID properly
$invokeParams.Uri = $($session.ApiUrl), "reports/categories" -join '/'
Invoke-TssRestApi @invokeParams -Method 'POST' -Body $bodData > $null
$categoryId = (Get-TssReportCategory -TssSession $session -All).Where({$_.Name -eq 'tssModuleTest'}).CategoryId
}
$newReport = @{
TssSession = $session
ReportName = $reportName
CategoryId = $categoryId
Description = "Tss Module Test report"
ReportSql = "SELECT 1"
}
$object = New-TssReport @newReport
$props = 'ReportId', 'Id', 'CategoryId', 'Name', 'ReportSql'
# delete report created
$invokeParams.Uri = $session.ApiUrl, "reports/$($object.Id)" -join '/'
$invokeParams.Remove('ExpandProperty') > $null
Invoke-TssRestApi @invokeParams -Method DELETE > $null
Remove-TssReportCategory -TssSession $session -ReportCategoryId $categoryId -Confirm:$false > $null
if (-not $tssTestUsingWindowsAuth) {
$session.SessionExpire()
}
}
Context "Checking" -Foreach @{object = $object} {
It "Should not be empty" {
$object | Should -Not -BeNullOrEmpty
}
It "Should output <_> property" -TestCases $props {
$object.PSObject.Properties.Name | Should -Contain $_
}
}
} | 46.7375 | 172 | 0.623696 |
04d2ed8e8e8172416dcffbf96dcfe9a7b29a9d56 | 4,538 | java | Java | maven-parent/b2c-cloud-test-learn-java/src/main/java/com/javamaster/b2c/cloud/test/learn/java/test/ReflectionTest.java | jufeng98/b2c-master | 5db75cea023c0f775a56b2a872e75e8f2fe4639f | [
"Unlicense"
] | null | null | null | maven-parent/b2c-cloud-test-learn-java/src/main/java/com/javamaster/b2c/cloud/test/learn/java/test/ReflectionTest.java | jufeng98/b2c-master | 5db75cea023c0f775a56b2a872e75e8f2fe4639f | [
"Unlicense"
] | null | null | null | maven-parent/b2c-cloud-test-learn-java/src/main/java/com/javamaster/b2c/cloud/test/learn/java/test/ReflectionTest.java | jufeng98/b2c-master | 5db75cea023c0f775a56b2a872e75e8f2fe4639f | [
"Unlicense"
] | null | null | null | package com.javamaster.b2c.cloud.test.learn.java.test;
import com.google.common.collect.Lists;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import java.lang.reflect.*;
import java.util.Arrays;
import java.util.List;
/**
* @author yudong
* @date 2019/5/9
*/
@Slf4j
public class ReflectionTest {
@Test
@SneakyThrows
public void test() {
Method method = MyClass.class.getMethod("getStringList");
Type returnType = method.getGenericReturnType();
if (returnType instanceof ParameterizedType) {
ParameterizedType type = (ParameterizedType) returnType;
Type[] typeArguments = type.getActualTypeArguments();
for (Type typeArgument : typeArguments) {
Class<?> typeArgClass = (Class<?>) typeArgument;
System.out.println("typeArgClass = " + typeArgClass);
}
}
}
@Test
@SneakyThrows
public void test1() {
Method method = MyClass.class.getMethod("setStringList", List.class);
Type[] genericParameterTypes = method.getGenericParameterTypes();
for (Type genericParameterType : genericParameterTypes) {
if (genericParameterType instanceof ParameterizedType) {
ParameterizedType aType = (ParameterizedType) genericParameterType;
Type[] parameterArgTypes = aType.getActualTypeArguments();
for (Type parameterArgType : parameterArgTypes) {
Class<?> parameterArgClass = (Class<?>) parameterArgType;
System.out.println("parameterArgClass = " + parameterArgClass);
}
}
}
}
@Test
@SneakyThrows
public void test3() {
Field field = MyClass.class.getDeclaredField("stringList");
Type genericFieldType = field.getGenericType();
if (genericFieldType instanceof ParameterizedType) {
ParameterizedType aType = (ParameterizedType) genericFieldType;
Type[] fieldArgTypes = aType.getActualTypeArguments();
for (Type fieldArgType : fieldArgTypes) {
Class<?> fieldArgClass = (Class<?>) fieldArgType;
System.out.println("fieldArgClass = " + fieldArgClass);
}
}
}
@Test
@SneakyThrows
public void test4() {
int[] intArray = (int[]) Array.newInstance(int.class, 3);
Array.set(intArray, 0, 123);
Array.set(intArray, 1, 456);
Array.set(intArray, 2, 789);
System.out.println("intArray[0] = " + Array.get(intArray, 0));
System.out.println("intArray[1] = " + Array.get(intArray, 1));
System.out.println("intArray[2] = " + Array.get(intArray, 2));
}
@Test
@SneakyThrows
@SuppressWarnings("ALL")
public void test5() {
Class<String[]> stringArrayClass = String[].class;
Class<int[]> intArray = (Class<int[]>) Class.forName("[I");
Class<String[]> stringArrayClass1 = (Class<String[]>) Class.forName("[Ljava.lang.String;");
Class<Integer> integerClass = int.class;
String[] strings = new String[3];
stringArrayClass = (Class<String[]>) strings.getClass();
Class<?> stringArrayComponentType = stringArrayClass.getComponentType();
System.out.println(stringArrayComponentType);
}
@Test
@SneakyThrows
@SuppressWarnings("ALL")
public void test6() {
InvocationHandler handler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
System.out.println(proxy.getClass());
System.out.println(method);
System.out.println(Arrays.toString(args));
return "hello";
}
};
MyInterface proxy = (MyInterface) Proxy.newProxyInstance(
MyInterface.class.getClassLoader(),
new Class[]{MyInterface.class},
handler);
System.out.println(proxy.getClass());
System.out.println(proxy.getDesc("yu", 22));
}
public static class MyClass {
protected List<String> stringList = Lists.newArrayList();
public List<String> getStringList() {
return this.stringList;
}
public void setStringList(List<String> list) {
this.stringList = list;
}
}
public interface MyInterface {
String getDesc(String name, int age);
}
}
| 34.120301 | 99 | 0.60996 |
7f5e9b28797760d288efe933e52535aa3ac47e88 | 487 | go | Go | pkg/analyze/stem_filter.go | danirod/visigoth | 33304307e9fedf4800931a31813a089d939efc02 | [
"Apache-2.0"
] | 10 | 2020-09-23T07:49:39.000Z | 2022-03-22T19:47:27.000Z | pkg/analyze/stem_filter.go | danirod/visigoth | 33304307e9fedf4800931a31813a089d939efc02 | [
"Apache-2.0"
] | 21 | 2020-09-22T09:09:25.000Z | 2021-05-22T19:27:33.000Z | pkg/analyze/stem_filter.go | danirod/visigoth | 33304307e9fedf4800931a31813a089d939efc02 | [
"Apache-2.0"
] | 2 | 2020-11-21T12:43:26.000Z | 2021-05-20T18:13:51.000Z | package analyze
import snowballSpanish "github.com/kljensen/snowball/spanish"
type SpanishStemmerFilter struct {
removeStopWords bool
}
func (s SpanishStemmerFilter) Filter(tokens []string) []string {
r := make([]string, 0, len(tokens))
for _, token := range tokens {
r = append(r, snowballSpanish.Stem(token, s.removeStopWords))
}
return r
}
func NewSpanishStemmer(removeStopWords bool) SpanishStemmerFilter {
return SpanishStemmerFilter{removeStopWords: removeStopWords}
}
| 24.35 | 67 | 0.774127 |
a077afd56bb189878a5f3fc746954e83afd79499 | 1,560 | swift | Swift | Package.swift | PureSwift/Socket | 1fea7204cf947bca112d79e41761acd59aa95fd9 | [
"MIT"
] | 2 | 2021-11-23T13:56:41.000Z | 2021-12-01T11:14:35.000Z | Package.swift | PureSwift/Socket | 1fea7204cf947bca112d79e41761acd59aa95fd9 | [
"MIT"
] | null | null | null | Package.swift | PureSwift/Socket | 1fea7204cf947bca112d79e41761acd59aa95fd9 | [
"MIT"
] | null | null | null | // swift-tools-version: 5.5
import PackageDescription
import class Foundation.ProcessInfo
// force building as dynamic library
let dynamicLibrary = ProcessInfo.processInfo.environment["SWIFT_BUILD_DYNAMIC_LIBRARY"] != nil
let libraryType: PackageDescription.Product.Library.LibraryType? = dynamicLibrary ? .dynamic : nil
var package = Package(
name: "Socket",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
],
products: [
.library(
name: "Socket",
type: libraryType,
targets: ["Socket"]
),
],
dependencies: [
.package(
url: "https://github.com/PureSwift/swift-system",
.branch("feature/dynamic-lib")
),
],
targets: [
.target(
name: "Socket",
dependencies: [
"CSocket",
.product(
name: "SystemPackage",
package: "swift-system"
),
]
),
.target(
name: "CSocket"
),
.testTarget(
name: "SocketTests",
dependencies: ["Socket"]
)
]
)
// SwiftPM command plugins are only supported by Swift version 5.6 and later.
#if swift(>=5.6)
let buildDocs = ProcessInfo.processInfo.environment["BUILDING_FOR_DOCUMENTATION_GENERATION"] != nil
if buildDocs {
package.dependencies += [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
]
}
#endif
| 26 | 99 | 0.545513 |
26ac740bafd55ae5617667c57c94e1bbc730ad8e | 4,339 | java | Java | app/src/main/java/Puzzle/Tile.java | praktikum-tiunpad-2021/oop-final-kelompok-a-02 | c0880dcb730609f7e674cbc3d73a662c10f871c5 | [
"MIT"
] | null | null | null | app/src/main/java/Puzzle/Tile.java | praktikum-tiunpad-2021/oop-final-kelompok-a-02 | c0880dcb730609f7e674cbc3d73a662c10f871c5 | [
"MIT"
] | null | null | null | app/src/main/java/Puzzle/Tile.java | praktikum-tiunpad-2021/oop-final-kelompok-a-02 | c0880dcb730609f7e674cbc3d73a662c10f871c5 | [
"MIT"
] | null | null | null | package Puzzle;
import javafx.animation.Interpolator;
import javafx.animation.TranslateTransition;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.util.Duration;
public class Tile extends StackPane{
public int pixelSizeX;
public int pixelSizeY;
public static int gap = 4;
public static Paint textColor1 = Color.GREEN;
public static Paint textColor0 = Color.CRIMSON;
public static String textFont = "Verdanna";
public static double textSize = 0.5;
public double pixelTextSize;
public static FontWeight textWeight = FontWeight.BOLD;
public static Paint color0 = Color.ORANGE;
public static Paint color1 = Color.LIGHTGRAY;
public static Duration transitionDuration = Duration.millis(200);
private TranslateTransition transition;
private int number;
private int posX;
private int posY;
public Board board; //refrence to its board instance
public void resize(){
this.pixelSizeX = this.board.pixelSizeX/this.board.size;
this.pixelSizeY = this.board.pixelSizeY/this.board.size;
this.pixelTextSize = Math.min(pixelSizeX, pixelSizeY) * textSize;
}
public void init(Board board,int posX, int posY){
this.board = board;
this.posX = posX;
this.posY = posY;
this.resize();
this.setLayoutX(this.posX*this.pixelSizeX);
this.setLayoutY(this.posY*this.pixelSizeY);
this.transition = new TranslateTransition(transitionDuration,this);
this.transition.setInterpolator(Interpolator.EASE_IN);
}
public Tile(Board board,int posX, int posY){
super();
this.init(board,posX,posY);
Rectangle rectangle = new Rectangle(this.pixelSizeX-gap,this.pixelSizeY-gap);
rectangle.setVisible(false);
this.getChildren().add(rectangle);
}
public Tile(Board board,int number,int posX, int posY){
super();
this.init(board,posX,posY);
this.number = number;
Text text = new Text("" + this.number);
text.setFont(Font.font(Tile.textFont, Tile.textWeight, this.pixelTextSize));
text.setFill(Tile.textColor1);
text.setX(text.getX()-gap);
text.setY(text.getX()-gap);
Rectangle rectangle = new Rectangle(this.pixelSizeX-gap,this.pixelSizeY-gap);
if((((this.number-1)/this.board.size)%2+((this.number-1)%this.board.size))%2 == 0){
rectangle.setFill(Tile.color0);
}
else{
rectangle.setFill(Tile.color1);
}
this.getChildren().add(rectangle);
this.getChildren().add(text);
}
public static Tile createInvisibleTile(Board board,int posX, int posY){
Tile tile = new Tile(board,posX,posY);
Text text = new Text("Press\nR");
text.setFont(Font.font(Tile.textFont, Tile.textWeight, tile.pixelTextSize*0.5));
text.setFill(textColor0);
text.setTextAlignment(TextAlignment.CENTER);
text.setX(text.getX()-gap);
text.setY(text.getX()-gap);
tile.getChildren().add(text);
return tile;
}
public boolean isMovable(){
if(this.board.movableIndexes.contains(this.getIndex())) return true;
return false;
}
public int getPosX(){
return this.posX;
}
public int getPosY(){
return this.posY;
}
public int getIndex(){
return (this.posY*this.board.size) + this.posX;
}
public int getNumber(){
return this.number;
}
public void moveTo(int x, int y){
System.out.println("from = "+(int)this.getBoundsInParent().getMinX()+", "+(int)this.getBoundsInParent().getMinY());
this.transition.stop();
double offsetX = x* this.pixelSizeX - this.getBoundsInParent().getMinX();
double offsetY = y* this.pixelSizeY - this.getBoundsInParent().getMinY();
System.out.println(" offset = "+offsetX+" ,"+offsetY);
this.transition.setByX(offsetX);
this.transition.setByY(offsetY);
this.posX = x;
this.posY = y;
this.transition.play();
}
}
| 34.712 | 123 | 0.65499 |
ae511b5374a7ec4dc106a323ba12a836d94a20b8 | 1,947 | rs | Rust | crates/cell_common/src/profiler/profiler.rs | Stupremee/cell | 2c4230dff9a22ef4238ec9674d838653d45d6e05 | [
"Zlib"
] | 8 | 2020-08-07T00:34:42.000Z | 2020-08-17T16:17:48.000Z | crates/cell_common/src/profiler/profiler.rs | Stupremee/cell | 2c4230dff9a22ef4238ec9674d838653d45d6e05 | [
"Zlib"
] | null | null | null | crates/cell_common/src/profiler/profiler.rs | Stupremee/cell | 2c4230dff9a22ef4238ec9674d838653d45d6e05 | [
"Zlib"
] | null | null | null | //! Profiler implementation using [`measureme`].
//!
//! [`measureme`]: https://docs.rs/measureme
use measureme::{EventId, TimingGuard};
use once_cell::sync::Lazy;
use std::{path::Path, thread::ThreadId};
/// MmapSerializatioSink is faster on macOS and Linux
/// but FileSerializationSink is faster on Windows
#[cfg(not(windows))]
type Sink = measureme::MmapSerializationSink;
#[cfg(windows)]
type Sink = measureme::FileSerializationSink;
/// The global profiler.
static PROFILER: Lazy<Profiler> = Lazy::new(Profiler::default);
/// Starts tracing an event which will end if the returned guard is dropped.
pub fn trace(category: &str, label: &str) -> TimingGuard<'static, Sink> {
PROFILER.trace(category.as_ref(), label.as_ref())
}
/// Wrapper around a [`measureme::Profiler`].
pub struct Profiler {
profiler: measureme::Profiler<Sink>,
}
impl Profiler {
/// Creates a new `Profiler` with the default path (`./trace/cell-<pid>`).
fn default() -> Self {
let path = format!("./trace/cell-{}", std::process::id());
let path = Path::new(&path);
Self {
profiler: measureme::Profiler::new(path).expect("failed to create profiler"),
}
}
/// Starts profiling an event with the given `category` and `label`.
fn trace(&self, category: &str, label: &str) -> TimingGuard<'_, Sink> {
let kind = self.profiler.alloc_string(category);
let label = self.profiler.alloc_string(label);
let id = EventId::from_label(label);
let thread_id = current_thread_id() as u32;
self.profiler
.start_recording_interval_event(kind, id, thread_id)
}
}
/// Gets the current thread id and transmutes it into a
/// `u64`.
fn current_thread_id() -> u64 {
// TODO: Remove unsafe if https://github.com/rust-lang/rust/issues/67939 is resolved.
let tid = std::thread::current().id();
unsafe { std::mem::transmute::<ThreadId, u64>(tid) }
}
| 33 | 89 | 0.660503 |
f754b1c23c942f7d249364b32b0c4b777beab95c | 1,298 | h | C | dtndht/utils.h | ibrdtn/dtndht | d5eb2d13cc56bc43525998f24e7d02c4dfbc1bc6 | [
"Apache-2.0",
"MIT"
] | 3 | 2019-03-31T02:54:53.000Z | 2021-06-28T20:50:46.000Z | dtndht/utils.h | ibrdtn/dtndht | d5eb2d13cc56bc43525998f24e7d02c4dfbc1bc6 | [
"Apache-2.0",
"MIT"
] | null | null | null | dtndht/utils.h | ibrdtn/dtndht | d5eb2d13cc56bc43525998f24e7d02c4dfbc1bc6 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-06-28T20:50:51.000Z | 2021-06-28T20:50:51.000Z | /*
* utils.h
*
* Created on: 08.02.2012
* Author: Till Lorentzen
*
*/
#ifndef UTILS_H_
#define UTILS_H_
#include <sys/socket.h>
/**
* This function copies the given value returned from the dht into the target sockaddr_storage
* This is very helpful, because all normal socket functions can handle the sockaddr_storage,
* but not the format, in which the dht answers
*/
int cpyvaluetosocketstorage(struct sockaddr_storage *target, const void *value,
int type);
// Creates a empty struct for dtn message results
struct dtn_dht_lookup_result * create_dtn_dht_lookup_result(void);
// Frees the dtn message result struct
void free_dtn_dht_lookup_result(struct dtn_dht_lookup_result * result);
// Creates a empty dtn_eid struct
struct dtn_eid * create_dtn_eid(void);
// Frees the dtn_eid struct and all of it's next elements
void free_dtn_eid(struct dtn_eid * eid);
// Creates a empty dtn_convergence_layer struct
struct dtn_convergence_layer * create_convergence_layer(void);
// Frees a given dtn_convergence_layer struct with all next elements and all the arguments
void free_convergence_layer(struct dtn_convergence_layer * layer);
// Creates a empty dtn_convergence_layer_arg struct
struct dtn_convergence_layer_arg * create_convergence_layer_arg(void);
#endif /* UTILS_H_ */
| 33.282051 | 94 | 0.788136 |
884f56d5d75692179601c1eb763baa8e551d58cc | 1,459 | hpp | C++ | elementary-sorts.hpp | goldsborough/algorithms | 1d76b17721eca299204c3848bf6687dc1dbf030c | [
"MIT"
] | 4 | 2017-11-17T12:02:08.000Z | 2019-06-18T23:57:34.000Z | elementary-sorts.hpp | goldsborough/Algorithms | 1d76b17721eca299204c3848bf6687dc1dbf030c | [
"MIT"
] | null | null | null | elementary-sorts.hpp | goldsborough/Algorithms | 1d76b17721eca299204c3848bf6687dc1dbf030c | [
"MIT"
] | null | null | null | #ifndef ELEMENTARY_HPP
#define ELEMENTARY_HPP
#include <cstddef>
#include <iterator>
#include <utility>
template<typename Iterator>
void insertion_sort(Iterator begin, Iterator end)
{
if (begin == end) return;
auto stop = std::prev(begin);
for (++begin; begin != end; ++begin)
{
auto value = *begin;
auto j = begin, i = std::prev(begin);
for ( ; i != stop && *i > value; --i, --j) *j = *i;
*j = value;
}
}
template<typename Iterator>
void selection_sort(Iterator begin, Iterator end)
{
if (begin == end) return;
for ( ; begin != end; ++begin)
{
auto min = begin;
for (auto i = std::next(begin); i != end; ++i)
{
if (*i < *min) min = i;
}
std::swap(*begin, *min);
}
}
template<typename Iterator>
void bubble_sort(Iterator begin, Iterator end)
{
for (auto i = begin; i != end; ++i)
{
for (auto j = begin, k = std::next(begin); k != end; ++j, ++k)
{
if (*j > *k) std::swap(*j, *k);
}
}
}
template<typename Iterator>
void shell_sort(Iterator begin, Iterator end)
{
std::size_t stride = 1;
auto stop = std::distance(begin, end)/3;
while (stride <= stop)
{
stride = 3 * stride + 1;
}
for ( ; stride > 0; stride /= 3)
{
for (auto i = begin + stride; i < end; i += stride)
{
auto value = *i;
auto k = i, j = i - stride;
for ( ; j >= begin && *j > value; j -= stride, k -= stride)
{
*k = *j;
}
*k = value;
}
}
}
#endif /* ELEMENTARY_HPP */ | 16.032967 | 64 | 0.558602 |
80b6aaeb02a56bafa55e58ba12a99b3b9ffebc1b | 378 | java | Java | kata/6-kyu/data-compression-using-run-length-encoding/main/RunLengthEncoding.java | Sophia-Okito/codewars-handbook | d896c766cf3347031dc3934ce18cd7a021ae2526 | [
"MIT"
] | 36 | 2020-04-16T17:53:05.000Z | 2022-03-15T06:59:04.000Z | kata/6-kyu/data-compression-using-run-length-encoding/main/RunLengthEncoding.java | Sophia-Okito/codewars-handbook | d896c766cf3347031dc3934ce18cd7a021ae2526 | [
"MIT"
] | 8 | 2020-07-26T05:26:40.000Z | 2022-03-01T20:03:24.000Z | kata/6-kyu/data-compression-using-run-length-encoding/main/RunLengthEncoding.java | ParanoidUser/codewars-handbook | 6e9f61b671bd379d8671f2ae1b134e3cbde62ff4 | [
"MIT"
] | 10 | 2020-04-10T12:07:02.000Z | 2022-01-21T12:29:39.000Z | import static java.util.regex.Pattern.compile;
interface RunLengthEncoding {
static String encode(String input) {
return compile("(.)\\1*").matcher(input).replaceAll(m -> m.end() - m.start() + m.group(1));
}
static String decode(String input) {
return compile("(\\d+)(\\D)").matcher(input).replaceAll(m -> m.group(2).repeat(Integer.parseInt(m.group(1))));
}
}
| 31.5 | 114 | 0.661376 |
46e6eaec20ff7f0c180ee1888b8b19952bbb623c | 5,710 | html | HTML | index.html | nazmulsakib/videoDownloader | 982ed89178b3296477be915eb1b7d60607a03753 | [
"Unlicense"
] | null | null | null | index.html | nazmulsakib/videoDownloader | 982ed89178b3296477be915eb1b7d60607a03753 | [
"Unlicense"
] | null | null | null | index.html | nazmulsakib/videoDownloader | 982ed89178b3296477be915eb1b7d60607a03753 | [
"Unlicense"
] | null | null | null | <!DOCTYPE html>
<html lang="en">
<head>
<title>video Downloader</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="images/icons/video Downloader.png"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/iconic/css/material-design-iconic-font.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animsition/css/animsition.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/daterangepicker/daterangepicker.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100">
<form class="login100-form validate-form">
<span class="login100-form-title p-b-26">
Total video Downloader
</span>
<center>
<img src="video Downloader.png" alt="Girl in a jacket" width="100px" height="100px" >
</center>
<!-- Downloader -->
<br />
<div class="wrap-input100 validate-input" data-validate = "Enter URL...">
<h3 class="Youtube">Youtube video Downloader</h3>
<br />
<iframe src="https://mp3downy.com/MP3-converter?apikey=1234567890&color=17a2b8&bg=ffffff"
style="width:100%;min-height:250px;height:auto;" ></iframe>
<!-- Downloader -->
<br />
<h3 class="Youtube">Facebook video Downloader</h3>
<iframe src="https://mp3downy.com/facebook-video-downloader?apikey=&color=17a2b8&bg=ffffff"
style="width:100%;min-height:250px;height:auto;" ></iframe>
<!-- Downloader -->
<br />
<h3 class="Youtube">Twitter video Downloader</h3>
<iframe src="https://mp3downy.com/twitter-video-downloader?apikey=&color=17a2b8&bg=ffffff"
style="width:100%;min-height:250px;height:auto;" ></iframe>
</div>
<!-- Downloader -->
</form>
</div>
</div>
</div>
<div id="dropDownSelect1"></div>
<!--===============================================================================================-->
<script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/animsition/js/animsition.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/bootstrap/js/popper.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/daterangepicker/moment.min.js"></script>
<script src="vendor/daterangepicker/daterangepicker.js"></script>
<!--===============================================================================================-->
<script src="vendor/countdowntime/countdowntime.js"></script>
<!--===============================================================================================-->
<script src="js/main.js"></script>
</body>
</html> | 65.632184 | 120 | 0.352189 |
81bdc4ba969ef6dc3794ca27a481627fb5feb499 | 243 | sql | SQL | ddl/PROCS/proc_DeleteAuthor.sql | rgorme/librarydb | 6ab6878f2ecf438d1d13ec51195a0bfc2ead801f | [
"MIT"
] | null | null | null | ddl/PROCS/proc_DeleteAuthor.sql | rgorme/librarydb | 6ab6878f2ecf438d1d13ec51195a0bfc2ead801f | [
"MIT"
] | null | null | null | ddl/PROCS/proc_DeleteAuthor.sql | rgorme/librarydb | 6ab6878f2ecf438d1d13ec51195a0bfc2ead801f | [
"MIT"
] | null | null | null | CREATE OR ALTER PROCEDURE dbo.proc_deleteAuthor
@AUTHOR_ID INT
AS
DECLARE @AUTHOR_DELETED BIT ;
DELETE dbo.AUTHOR
WHERE AUTHOR_ID = @AUTHOR_ID
SET @AUTHOR_DELETED = @@ROWCOUNT;
SELECT @AUTHOR_DELETED AS AUTHOR_DELETED | 30.375 | 47 | 0.736626 |
9a40667a70f1ba46e98cc4896a4f4387c9a8228c | 1,831 | sql | SQL | 1.2.18/unmap.sql | daamien/mantis_fdw | ffb5aed3fa1803349765eca3acd081d3ceb4d001 | [
"BSD-3-Clause"
] | null | null | null | 1.2.18/unmap.sql | daamien/mantis_fdw | ffb5aed3fa1803349765eca3acd081d3ceb4d001 | [
"BSD-3-Clause"
] | null | null | null | 1.2.18/unmap.sql | daamien/mantis_fdw | ffb5aed3fa1803349765eca3acd081d3ceb4d001 | [
"BSD-3-Clause"
] | null | null | null |
DROP FOREIGN TABLE :local_schema.mantis_bug_file_table;
DROP FOREIGN TABLE :local_schema.mantis_bug_history_table;
DROP FOREIGN TABLE :local_schema.mantis_bug_monitor_table;
DROP FOREIGN TABLE :local_schema.mantis_bug_relationship_table;
DROP FOREIGN TABLE :local_schema.mantis_bug_revision_table;
DROP FOREIGN TABLE :local_schema.mantis_bug_table;
DROP FOREIGN TABLE :local_schema.mantis_bug_tag_table;
DROP FOREIGN TABLE :local_schema.mantis_bug_text_table;
DROP FOREIGN TABLE :local_schema.mantis_bugnote_table;
DROP FOREIGN TABLE :local_schema.mantis_bugnote_text_table;
DROP FOREIGN TABLE :local_schema.mantis_category_table;
DROP FOREIGN TABLE :local_schema.mantis_config_table;
DROP FOREIGN TABLE :local_schema.mantis_custom_field_project_table;
DROP FOREIGN TABLE :local_schema.mantis_custom_field_string_table;
DROP FOREIGN TABLE :local_schema.mantis_custom_field_table;
DROP FOREIGN TABLE :local_schema.mantis_email_table;
DROP FOREIGN TABLE :local_schema.mantis_filters_table;
DROP FOREIGN TABLE :local_schema.mantis_news_table;
DROP FOREIGN TABLE :local_schema.mantis_plugin_table;
DROP FOREIGN TABLE :local_schema.mantis_project_file_table;
DROP FOREIGN TABLE :local_schema.mantis_project_hierarchy_table;
DROP FOREIGN TABLE :local_schema.mantis_project_table;
DROP FOREIGN TABLE :local_schema.mantis_project_user_list_table;
DROP FOREIGN TABLE :local_schema.mantis_project_version_table;
DROP FOREIGN TABLE :local_schema.mantis_sponsorship_table;
DROP FOREIGN TABLE :local_schema.mantis_tag_table;
DROP FOREIGN TABLE :local_schema.mantis_tokens_table;
DROP FOREIGN TABLE :local_schema.mantis_user_pref_table;
DROP FOREIGN TABLE :local_schema.mantis_user_print_pref_table;
DROP FOREIGN TABLE :local_schema.mantis_user_profile_table;
DROP FOREIGN TABLE :local_schema.mantis_user_table;
| 53.852941 | 68 | 0.863463 |
7b60e4d3b132495c0be82addf2d5cd452d8c9e63 | 271 | rb | Ruby | app/models/member_application.rb | arielspear/green_mercury | 6c1bba07c2bcd20f381feebeeb67bb46bfa21221 | [
"Apache-2.0"
] | null | null | null | app/models/member_application.rb | arielspear/green_mercury | 6c1bba07c2bcd20f381feebeeb67bb46bfa21221 | [
"Apache-2.0"
] | 1 | 2017-08-09T18:56:17.000Z | 2017-08-09T18:56:17.000Z | app/models/member_application.rb | code-scouts/green_mercury | 50a654adfea06e384f4119135b4afb9c03550f5a | [
"Apache-2.0"
] | null | null | null | class MemberApplication < ActiveRecord::Base
include UserApplication
validates :why_you_want_to_join, presence: true
validates :experience_level, presence: true
validates :comfortable_learning, presence: true
validates :time_commitment, presence: true
end
| 30.111111 | 50 | 0.804428 |
cb5b071a390beded87745c7f429cd2b5384c799a | 156 | html | HTML | openfda/openfda_res.html | acs/python-red | 6e3b9a9265edda23a930124fac61d08c944eb3f6 | [
"MIT"
] | 1 | 2018-01-21T15:57:54.000Z | 2018-01-21T15:57:54.000Z | openfda/openfda_res.html | acs/python-red | 6e3b9a9265edda23a930124fac61d08c944eb3f6 | [
"MIT"
] | null | null | null | openfda/openfda_res.html | acs/python-red | 6e3b9a9265edda23a930124fac61d08c944eb3f6 | [
"MIT"
] | null | null | null | <html>
<head>
<title>OpenFDA Client</title>
</head>
<body>
<h1>OpenFDA Client Results</h1>
<a href="/">Back</a><br>
__CONTENT__
</body>
</html>
| 14.181818 | 33 | 0.602564 |
66e400b09c796ebea87493c1cac0b461f8693984 | 392 | cpp | C++ | tests/test_utils.cpp | runfalk/batch-replace | 0b440eb71f0e68cc212e7550f272349ffb9bd571 | [
"BSD-3-Clause"
] | null | null | null | tests/test_utils.cpp | runfalk/batch-replace | 0b440eb71f0e68cc212e7550f272349ffb9bd571 | [
"BSD-3-Clause"
] | null | null | null | tests/test_utils.cpp | runfalk/batch-replace | 0b440eb71f0e68cc212e7550f272349ffb9bd571 | [
"BSD-3-Clause"
] | null | null | null | #include <doctest.h>
#include "utils.h"
TEST_CASE("Test human_join_or") {
std::vector<std::string> parts;
CHECK(human_join_or(parts) == "");
parts.push_back("foo");
CHECK(human_join_or(parts) == "foo");
parts.push_back("bar");
CHECK(human_join_or(parts) == "foo or bar");
parts.push_back("biz");
parts.push_back("baz");
CHECK(human_join_or(parts) == "foo, bar, biz or baz");
}
| 19.6 | 55 | 0.668367 |
7d6491574944dd1035044acada9378961b1e724e | 634 | dart | Dart | lib/widgets/group_picture.dart | airicbear/izone-app | deeaebd487b88300b1142d8d9c5bc5f54e942e6c | [
"MIT"
] | null | null | null | lib/widgets/group_picture.dart | airicbear/izone-app | deeaebd487b88300b1142d8d9c5bc5f54e942e6c | [
"MIT"
] | null | null | null | lib/widgets/group_picture.dart | airicbear/izone-app | deeaebd487b88300b1142d8d9c5bc5f54e942e6c | [
"MIT"
] | null | null | null | import 'package:flutter/material.dart';
import 'package:izoneapp/pages/page_view_picture.dart';
class GroupPicture extends StatelessWidget {
const GroupPicture({Key key, this.imagePath}) : super(key: key);
final String imagePath;
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return ViewPicturePage(path: imagePath);
},
),
);
},
child: Hero(
tag: imagePath,
child: Image.asset(imagePath),
),
);
}
}
| 22.642857 | 66 | 0.585174 |
0605eea8c861efd9d6bbc401487677d38c37a6e9 | 6,312 | ps1 | PowerShell | src/realtime/Rosters.ps1 | iquipsys-positron/iqs-scripts-management-ps | 5810bf5c0885f967516addd72784f4045799aff3 | [
"MIT"
] | null | null | null | src/realtime/Rosters.ps1 | iquipsys-positron/iqs-scripts-management-ps | 5810bf5c0885f967516addd72784f4045799aff3 | [
"MIT"
] | null | null | null | src/realtime/Rosters.ps1 | iquipsys-positron/iqs-scripts-management-ps | 5810bf5c0885f967516addd72784f4045799aff3 | [
"MIT"
] | null | null | null | ########################################################
##
## Rosters.ps1
## Management interface to IQuipsys Positron
## Rosters commands
##
#######################################################
function Get-IqsRosters
{
<#
.SYNOPSIS
Gets page with rosters by specified criteria
.DESCRIPTION
Gets a page with rosters that satisfy specified criteria
.PARAMETER Connection
A connection object
.PARAMETER OrgId
A organization id
.PARAMETER Filter
A filter with search criteria (default: no filter)
.PARAMETER Skip
A number of records to skip (default: 0)
.PARAMETER Take
A number of records to return (default: 100)
.PARAMETER Total
A include total count (default: false)
.EXAMPLE
Get-IqsRosters -OrgId 1 -Take 10
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
[Hashtable] $Connection,
[Parameter(Mandatory=$true, Position = 0, ValueFromPipelineByPropertyName=$true)]
[string] $OrgId,
[Parameter(Mandatory=$false, Position = 1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[Hashtable] $Filter = @{},
[Parameter(Mandatory=$false, Position = 2, ValueFromPipelineByPropertyName=$true)]
[int] $Skip = 0,
[Parameter(Mandatory=$false, Position = 3, ValueFromPipelineByPropertyName=$true)]
[int] $Take = 100,
[Parameter(Mandatory=$false, Position = 4, ValueFromPipelineByPropertyName=$true)]
[bool] $Total
)
begin {}
process
{
$route = "/api/v1/organizations/{0}/rosters" -f $OrgId
$params = $Filter +
@{
skip = $Skip;
take = $Take
total = $Total
}
$result = Invoke-PipFacade -Connection $Connection -Method "Get" -Route $route -Params $params
Write-Output $result.Data
}
end {}
}
function Get-IqsRoster
{
<#
.SYNOPSIS
Gets roster by id
.DESCRIPTION
Gets roster by its unique id
.PARAMETER Connection
A connection object
.PARAMETER OrgId
A organization id
.PARAMETER Id
A roster id
.EXAMPLE
Get-IqsRoster -OrgId 1 -Id 123
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
[Hashtable] $Connection,
[Parameter(Mandatory=$true, Position = 0, ValueFromPipelineByPropertyName=$true)]
[string] $OrgId,
[Parameter(Mandatory=$true, Position = 1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[string] $Id
)
begin {}
process
{
$route = "/api/v1/organizations/{0}/rosters/{1}" -f $OrgId, $Id
$result = Invoke-PipFacade -Connection $Connection -Method "Get" -Route $route
Write-Output $result
}
end {}
}
function New-IqsRoster
{
<#
.SYNOPSIS
Creates a new roster
.DESCRIPTION
Creates a new roster
.PARAMETER Connection
A connection object
.PARAMETER OrgId
A organization id
.PARAMETER Roster
A roster with the following structure:
- id: string
- org_id: string
- name: string
- shift_id: string
- start_date: Date
- start_time: Date
- end_time: Date
- objects: RosterObjectV1[]
- object_id: string
- assign_id: string
- planned: boolean
- actual: boolean
- start_time: Date
- end_time: Date
.EXAMPLE
New-IqsRoster -OrgId 1 -Roster @{ org_id="1"; name="Entire day"; start_date=@(Get-Date) }
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
[Hashtable] $Connection,
[Parameter(Mandatory=$true, Position = 0, ValueFromPipelineByPropertyName=$true)]
[string] $OrgId,
[Parameter(Mandatory=$true, Position = 1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[Object] $Roster
)
begin {}
process
{
$route = "/api/v1/organizations/{0}/rosters" -f $OrgId
$result = Invoke-PipFacade -Connection $Connection -Method "Post" -Route $route -Request $Roster
Write-Output $result
}
end {}
}
function Update-IqsRoster
{
<#
.SYNOPSIS
Creates a new roster
.DESCRIPTION
Creates a new roster
.PARAMETER Connection
A connection object
.PARAMETER OrgId
A organization id
.PARAMETER Roster
A roster with the following structure:
- id: string
- org_id: string
- name: string
- shift_id: string
- start_date: Date
- start_time: Date
- end_time: Date
- objects: RosterObjectV1[]
- object_id: string
- assign_id: string
- planned: boolean
- actual: boolean
- start_time: Date
- end_time: Date
.EXAMPLE
Update-IqsRoster -OrgId 1 -Roster @{ org_id="1"; name="Entire day"; start_date=@(Get-Date) }
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
[Hashtable] $Connection,
[Parameter(Mandatory=$true, Position = 0, ValueFromPipelineByPropertyName=$true)]
[string] $OrgId,
[Parameter(Mandatory=$true, Position = 1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[Object] $Roster
)
begin {}
process
{
$route = "/api/v1/organizations/{0}/rosters/{1}" -f $OrgId, $Roster.id
$result = Invoke-PipFacade -Connection $Connection -Method "Put" -Route $route -Request $Roster
Write-Output $result
}
end {}
}
function Remove-IqsRoster
{
<#
.SYNOPSIS
Removes roster by id
.DESCRIPTION
Removes roster by its unique id
.PARAMETER Connection
A connection object
.PARAMETER OrgId
A organization id
.PARAMETER Id
A roster id
.EXAMPLE
Remove-IqsRoster -OrgId 1 -Id 123
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
[Hashtable] $Connection,
[Parameter(Mandatory=$true, Position = 0, ValueFromPipelineByPropertyName=$true)]
[string] $OrgId,
[Parameter(Mandatory=$true, Position = 1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[string] $Id
)
begin {}
process
{
$route = "/api/v1/organizations/{0}/rosters/{1}" -f $OrgId, $Id
$result = Invoke-PipFacade -Connection $Connection -Method "Delete" -Route $route
Write-Output $result
}
end {}
}
| 19.974684 | 115 | 0.646229 |
49819eb3a426583be94c5cb8143ddd5bd5def0af | 1,396 | ps1 | PowerShell | PSClarifai/Public/Predict-ImageFromURL.ps1 | Claustn/Clarifai | e45d7b052c11002fd733bd096ac173233112f4a1 | [
"MIT"
] | null | null | null | PSClarifai/Public/Predict-ImageFromURL.ps1 | Claustn/Clarifai | e45d7b052c11002fd733bd096ac173233112f4a1 | [
"MIT"
] | null | null | null | PSClarifai/Public/Predict-ImageFromURL.ps1 | Claustn/Clarifai | e45d7b052c11002fd733bd096ac173233112f4a1 | [
"MIT"
] | null | null | null | <#
.SYNOPSIS
Perform image prediction by URL to Clarifai
.DESCRIPTION
A detailed description of the Predict-ImageFromFile function.
.PARAMETER ImagePath
URL to image file you want to perform analysis on
.PARAMETER Token
A description of the Token parameter.
.PARAMETER Model
Default value will search in the General Model of Clarifai
.PARAMETER ImageFile
A description of the ImageFile parameter.
.EXAMPLE
PS C:\> Predict-ImageFromFile
.NOTES
Additional information about the function.
#>
function Predict-ImageFromURL
{
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$ImageURL,
[string]$Token = (Get-ClarifaiToken),
[Parameter(Mandatory = $false)]
[string]$Model = 'aaa03c23b3724a16a56b629203edc62c'
)
$uri = "https://api.clarifai.com/v2/models/$Model/outputs" -f $Model
$headers = @{
Authorization = 'Bearer {0}' -f $Token
Accept = 'application/json'
'Content-Type' = 'application/json'
}
$jsonbody = @{
inputs = @(@{
data = @{
image = @{
url = $ImageURL
}
}
})
} | ConvertTo-Json -Depth 6
Write-Debug -Message $jsonbody
$Res = Invoke-RestMethod -Uri $uri -Body $jsonbody -Headers $headers -Method Post
$Res.outputs.data.concepts
}
| 21.8125 | 83 | 0.633954 |
0ac1e25aa161c10e6a05466f5740a62a9226e0da | 92 | go | Go | testdata/method_chain/lib/lib.go | mpppk/gollup | dde2fb46bd8e95b8adc8d9ad2e458feb8cc69e9c | [
"MIT"
] | 8 | 2020-05-31T16:09:46.000Z | 2021-08-24T16:56:25.000Z | testdata/method_chain/lib/lib.go | mpppk/gollup | dde2fb46bd8e95b8adc8d9ad2e458feb8cc69e9c | [
"MIT"
] | 9 | 2020-04-14T11:34:52.000Z | 2021-10-18T21:34:40.000Z | testdata/method_chain/lib/lib.go | mpppk/gollup | dde2fb46bd8e95b8adc8d9ad2e458feb8cc69e9c | [
"MIT"
] | null | null | null | package lib
type Int int
func (i Int) Get() int {
return 1
}
func F() Int {
return 1
}
| 7.666667 | 24 | 0.608696 |
1af5956338afe68db601f07deec617e304402727 | 426 | swift | Swift | CoinbasePro/CoinbaseProError.swift | cocojoe/CoinbasePro | d3f98c28a634a7438ffab54afe2102993519a8a3 | [
"MIT"
] | 3 | 2018-07-01T18:19:22.000Z | 2021-07-08T21:22:34.000Z | CoinbasePro/CoinbaseProError.swift | cocojoe/CoinbasePro | d3f98c28a634a7438ffab54afe2102993519a8a3 | [
"MIT"
] | 2 | 2019-11-15T22:21:15.000Z | 2019-11-18T13:37:53.000Z | CoinbasePro/CoinbaseProError.swift | cocojoe/CoinbasePro | d3f98c28a634a7438ffab54afe2102993519a8a3 | [
"MIT"
] | 1 | 2021-01-18T10:21:39.000Z | 2021-01-18T10:21:39.000Z | //
// CoinbaseProError.swift
// CoinbasePro
//
// Created by Martin Walsh on 06/06/2018.
// Copyright © 2018 Martin Walsh. All rights reserved.
//
import Foundation
/// CoinbaseProErrors
///
/// - networkError: Something went wrong during the network request
/// - dataError: Something went wrong during data decoding
public enum CoinbaseProError: Error {
case networkError
case dataError
case decodeError
}
| 21.3 | 67 | 0.725352 |
add9d4954b6aae68264c6abe1b3abd8a98abe7dc | 5,791 | rs | Rust | pkcs8/tests/public_key.rs | msrd0/formats | 5c58533557e52f45db9ec4335248ce1b5e094801 | [
"Apache-2.0",
"MIT"
] | 4 | 2022-02-08T05:32:15.000Z | 2022-03-29T22:35:33.000Z | pkcs8/tests/public_key.rs | msrd0/formats | 5c58533557e52f45db9ec4335248ce1b5e094801 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-09-03T03:35:15.000Z | 2021-09-03T03:35:15.000Z | pkcs8/tests/public_key.rs | msrd0/formats | 5c58533557e52f45db9ec4335248ce1b5e094801 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-09-03T02:56:57.000Z | 2021-09-03T02:56:57.000Z | //! Public key (`SubjectPublicKeyInfo`) tests
use core::convert::TryFrom;
use hex_literal::hex;
use pkcs8::SubjectPublicKeyInfo;
#[cfg(feature = "alloc")]
use der::Encodable;
#[cfg(any(feature = "pem", feature = "std"))]
use pkcs8::PublicKeyDocument;
/// Elliptic Curve (P-256) `SubjectPublicKeyInfo` encoded as ASN.1 DER
const EC_P256_DER_EXAMPLE: &[u8] = include_bytes!("examples/p256-pub.der");
/// Ed25519 `SubjectPublicKeyInfo` encoded as ASN.1 DER
const ED25519_DER_EXAMPLE: &[u8] = include_bytes!("examples/ed25519-pub.der");
/// RSA-2048 `SubjectPublicKeyInfo` encoded as ASN.1 DER
const RSA_2048_DER_EXAMPLE: &[u8] = include_bytes!("examples/rsa2048-pub.der");
/// Elliptic Curve (P-256) public key encoded as PEM
#[cfg(feature = "pem")]
const EC_P256_PEM_EXAMPLE: &str = include_str!("examples/p256-pub.pem");
/// Ed25519 public key encoded as PEM
#[cfg(feature = "pem")]
const ED25519_PEM_EXAMPLE: &str = include_str!("examples/ed25519-pub.pem");
/// RSA-2048 PKCS#8 public key encoded as PEM
#[cfg(feature = "pem")]
const RSA_2048_PEM_EXAMPLE: &str = include_str!("examples/rsa2048-pub.pem");
#[test]
fn decode_ec_p256_der() {
let spki = SubjectPublicKeyInfo::try_from(EC_P256_DER_EXAMPLE).unwrap();
assert_eq!(spki.algorithm.oid, "1.2.840.10045.2.1".parse().unwrap());
assert_eq!(
spki.algorithm.parameters.unwrap().oid().unwrap(),
"1.2.840.10045.3.1.7".parse().unwrap()
);
assert_eq!(spki.subject_public_key, &hex!("041CACFFB55F2F2CEFD89D89EB374B2681152452802DEEA09916068137D839CF7FC481A44492304D7EF66AC117BEFE83A8D08F155F2B52F9F618DD447029048E0F")[..]);
}
#[test]
fn decode_ed25519_der() {
let spki = SubjectPublicKeyInfo::try_from(ED25519_DER_EXAMPLE).unwrap();
assert_eq!(spki.algorithm.oid, "1.3.101.112".parse().unwrap());
assert_eq!(spki.algorithm.parameters, None);
assert_eq!(
spki.subject_public_key,
&hex!("4D29167F3F1912A6F7ADFA293A051A15C05EC67B8F17267B1C5550DCE853BD0D")[..]
);
}
#[test]
fn decode_rsa_2048_der() {
let spki = SubjectPublicKeyInfo::try_from(RSA_2048_DER_EXAMPLE).unwrap();
assert_eq!(spki.algorithm.oid, "1.2.840.113549.1.1.1".parse().unwrap());
assert!(spki.algorithm.parameters.unwrap().is_null());
assert_eq!(spki.subject_public_key, &hex!("3082010A0282010100B6C42C515F10A6AAF282C63EDBE24243A170F3FA2633BD4833637F47CA4F6F36E03A5D29EFC3191AC80F390D874B39E30F414FCEC1FCA0ED81E547EDC2CD382C76F61C9018973DB9FA537972A7C701F6B77E0982DFC15FC01927EE5E7CD94B4F599FF07013A7C8281BDF22DCBC9AD7CABB7C4311C982F58EDB7213AD4558B332266D743AED8192D1884CADB8B14739A8DADA66DC970806D9C7AC450CB13D0D7C575FB198534FC61BC41BC0F0574E0E0130C7BBBFBDFDC9F6A6E2E3E2AFF1CBEAC89BA57884528D55CFB08327A1E8C89F4E003CF2888E933241D9D695BCBBACDC90B44E3E095FA37058EA25B13F5E295CBEAC6DE838AB8C50AF61E298975B872F0203010001")[..]);
}
#[test]
#[cfg(feature = "pem")]
fn decode_ec_p256_pem() {
let doc: PublicKeyDocument = EC_P256_PEM_EXAMPLE.parse().unwrap();
assert_eq!(doc.as_ref(), EC_P256_DER_EXAMPLE);
// Ensure `PublicKeyDocument` parses successfully
let spki = SubjectPublicKeyInfo::try_from(EC_P256_DER_EXAMPLE).unwrap();
assert_eq!(doc.spki(), spki);
}
#[test]
#[cfg(feature = "pem")]
fn decode_ed25519_pem() {
let doc: PublicKeyDocument = ED25519_PEM_EXAMPLE.parse().unwrap();
assert_eq!(doc.as_ref(), ED25519_DER_EXAMPLE);
// Ensure `PublicKeyDocument` parses successfully
let spki = SubjectPublicKeyInfo::try_from(ED25519_DER_EXAMPLE).unwrap();
assert_eq!(doc.spki(), spki);
}
#[test]
#[cfg(feature = "pem")]
fn decode_rsa_2048_pem() {
let doc: PublicKeyDocument = RSA_2048_PEM_EXAMPLE.parse().unwrap();
assert_eq!(doc.as_ref(), RSA_2048_DER_EXAMPLE);
// Ensure `PublicKeyDocument` parses successfully
let spki = SubjectPublicKeyInfo::try_from(RSA_2048_DER_EXAMPLE).unwrap();
assert_eq!(doc.spki(), spki);
}
#[test]
#[cfg(feature = "alloc")]
fn encode_ec_p256_der() {
let pk = SubjectPublicKeyInfo::try_from(EC_P256_DER_EXAMPLE).unwrap();
let pk_encoded = pk.to_vec().unwrap();
assert_eq!(EC_P256_DER_EXAMPLE, pk_encoded.as_slice());
}
#[test]
#[cfg(feature = "alloc")]
fn encode_ed25519_der() {
let pk = SubjectPublicKeyInfo::try_from(ED25519_DER_EXAMPLE).unwrap();
let pk_encoded = pk.to_vec().unwrap();
assert_eq!(ED25519_DER_EXAMPLE, pk_encoded.as_slice());
}
#[test]
#[cfg(feature = "alloc")]
fn encode_rsa_2048_der() {
let pk = SubjectPublicKeyInfo::try_from(RSA_2048_DER_EXAMPLE).unwrap();
let pk_encoded = pk.to_vec().unwrap();
assert_eq!(RSA_2048_DER_EXAMPLE, pk_encoded.as_slice());
}
#[test]
#[cfg(feature = "pem")]
fn encode_ec_p256_pem() {
let pk = SubjectPublicKeyInfo::try_from(EC_P256_DER_EXAMPLE).unwrap();
let pk_encoded = PublicKeyDocument::from(pk).to_pem();
assert_eq!(EC_P256_PEM_EXAMPLE, pk_encoded);
}
#[test]
#[cfg(feature = "pem")]
fn encode_ed25519_pem() {
let pk = SubjectPublicKeyInfo::try_from(ED25519_DER_EXAMPLE).unwrap();
let pk_encoded = PublicKeyDocument::from(pk).to_pem();
assert_eq!(ED25519_PEM_EXAMPLE, pk_encoded);
}
#[test]
#[cfg(feature = "pem")]
fn encode_rsa_2048_pem() {
let pk = SubjectPublicKeyInfo::try_from(RSA_2048_DER_EXAMPLE).unwrap();
let pk_encoded = PublicKeyDocument::from(pk).to_pem();
assert_eq!(RSA_2048_PEM_EXAMPLE, pk_encoded);
}
#[test]
#[cfg(feature = "std")]
fn read_der_file() {
let pkcs8_doc = PublicKeyDocument::read_der_file("tests/examples/p256-pub.der").unwrap();
assert_eq!(pkcs8_doc.as_ref(), EC_P256_DER_EXAMPLE);
}
#[test]
#[cfg(all(feature = "pem", feature = "std"))]
fn read_pem_file() {
let pkcs8_doc = PublicKeyDocument::read_pem_file("tests/examples/p256-pub.pem").unwrap();
assert_eq!(pkcs8_doc.as_ref(), EC_P256_DER_EXAMPLE);
}
| 35.527607 | 595 | 0.740114 |
373896ccd16740a2a4f814f858aadae0dcb4e209 | 6,359 | sql | SQL | sql/core/src/test/resources/sql-tests/inputs/udf/pgSQL/udf-select_implicit.sql | zzy1120716/spark | ca711778683a16999560cbdd7c61d98ad6bde6db | [
"Apache-2.0"
] | 6 | 2020-06-28T08:23:22.000Z | 2021-12-25T07:25:32.000Z | sql/core/src/test/resources/sql-tests/inputs/udf/pgSQL/udf-select_implicit.sql | zzy1120716/spark | ca711778683a16999560cbdd7c61d98ad6bde6db | [
"Apache-2.0"
] | 2 | 2016-11-21T11:03:26.000Z | 2018-08-23T04:33:23.000Z | sql/core/src/test/resources/sql-tests/inputs/udf/pgSQL/udf-select_implicit.sql | zzy1120716/spark | ca711778683a16999560cbdd7c61d98ad6bde6db | [
"Apache-2.0"
] | 4 | 2020-06-28T08:23:33.000Z | 2021-08-04T07:24:45.000Z | --
-- Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
--
--
-- SELECT_IMPLICIT
-- Test cases for queries with ordering terms missing from the target list.
-- This used to be called "junkfilter.sql".
-- The parser uses the term "resjunk" to handle these cases.
-- - thomas 1998-07-09
-- https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/sql/select_implicit.sql
--
-- This test file was converted from pgSQL/select_implicit.sql
-- load test data
CREATE TABLE test_missing_target (a int, b int, c string, d string) using parquet;
INSERT INTO test_missing_target VALUES (0, 1, 'XXXX', 'A');
INSERT INTO test_missing_target VALUES (1, 2, 'ABAB', 'b');
INSERT INTO test_missing_target VALUES (2, 2, 'ABAB', 'c');
INSERT INTO test_missing_target VALUES (3, 3, 'BBBB', 'D');
INSERT INTO test_missing_target VALUES (4, 3, 'BBBB', 'e');
INSERT INTO test_missing_target VALUES (5, 3, 'bbbb', 'F');
INSERT INTO test_missing_target VALUES (6, 4, 'cccc', 'g');
INSERT INTO test_missing_target VALUES (7, 4, 'cccc', 'h');
INSERT INTO test_missing_target VALUES (8, 4, 'CCCC', 'I');
INSERT INTO test_missing_target VALUES (9, 4, 'CCCC', 'j');
-- w/ existing GROUP BY target
SELECT udf(c), udf(count(*)) FROM test_missing_target GROUP BY
udf(test_missing_target.c)
ORDER BY udf(c);
-- w/o existing GROUP BY target using a relation name in GROUP BY clause
SELECT udf(count(*)) FROM test_missing_target GROUP BY udf(test_missing_target.c)
ORDER BY udf(c);
-- w/o existing GROUP BY target and w/o existing a different ORDER BY target
-- failure expected
SELECT udf(count(*)) FROM test_missing_target GROUP BY udf(a) ORDER BY udf(b);
-- w/o existing GROUP BY target and w/o existing same ORDER BY target
SELECT udf(count(*)) FROM test_missing_target GROUP BY udf(b) ORDER BY udf(b);
-- w/ existing GROUP BY target using a relation name in target
SELECT udf(test_missing_target.b), udf(count(*))
FROM test_missing_target GROUP BY udf(b) ORDER BY udf(b);
-- w/o existing GROUP BY target
SELECT udf(c) FROM test_missing_target ORDER BY udf(a);
-- w/o existing ORDER BY target
SELECT udf(count(*)) FROM test_missing_target GROUP BY udf(b) ORDER BY udf(b) desc;
-- group using reference number
SELECT udf(count(*)) FROM test_missing_target ORDER BY udf(1) desc;
-- order using reference number
SELECT udf(c), udf(count(*)) FROM test_missing_target GROUP BY 1 ORDER BY 1;
-- group using reference number out of range
-- failure expected
SELECT udf(c), udf(count(*)) FROM test_missing_target GROUP BY 3;
-- group w/o existing GROUP BY and ORDER BY target under ambiguous condition
-- failure expected
SELECT udf(count(*)) FROM test_missing_target x, test_missing_target y
WHERE udf(x.a) = udf(y.a)
GROUP BY udf(b) ORDER BY udf(b);
-- order w/ target under ambiguous condition
-- failure NOT expected
SELECT udf(a), udf(a) FROM test_missing_target
ORDER BY udf(a);
-- order expression w/ target under ambiguous condition
-- failure NOT expected
SELECT udf(udf(a)/2), udf(udf(a)/2) FROM test_missing_target
ORDER BY udf(udf(a)/2);
-- group expression w/ target under ambiguous condition
-- failure NOT expected
SELECT udf(a/2), udf(a/2) FROM test_missing_target
GROUP BY udf(a/2) ORDER BY udf(a/2);
-- group w/ existing GROUP BY target under ambiguous condition
SELECT udf(x.b), udf(count(*)) FROM test_missing_target x, test_missing_target y
WHERE udf(x.a) = udf(y.a)
GROUP BY udf(x.b) ORDER BY udf(x.b);
-- group w/o existing GROUP BY target under ambiguous condition
SELECT udf(count(*)) FROM test_missing_target x, test_missing_target y
WHERE udf(x.a) = udf(y.a)
GROUP BY udf(x.b) ORDER BY udf(x.b);
-- [SPARK-28329] SELECT INTO syntax
-- group w/o existing GROUP BY target under ambiguous condition
-- into a table
-- SELECT count(*) INTO TABLE test_missing_target2
-- FROM test_missing_target x, test_missing_target y
-- WHERE x.a = y.a
-- GROUP BY x.b ORDER BY x.b;
-- SELECT * FROM test_missing_target2;
-- Functions and expressions
-- w/ existing GROUP BY target
SELECT udf(a%2), udf(count(udf(b))) FROM test_missing_target
GROUP BY udf(test_missing_target.a%2)
ORDER BY udf(test_missing_target.a%2);
-- w/o existing GROUP BY target using a relation name in GROUP BY clause
SELECT udf(count(c)) FROM test_missing_target
GROUP BY udf(lower(test_missing_target.c))
ORDER BY udf(lower(test_missing_target.c));
-- w/o existing GROUP BY target and w/o existing a different ORDER BY target
-- failure expected
SELECT udf(count(udf(a))) FROM test_missing_target GROUP BY udf(a) ORDER BY udf(b);
-- w/o existing GROUP BY target and w/o existing same ORDER BY target
SELECT udf(count(b)) FROM test_missing_target GROUP BY udf(b/2) ORDER BY udf(b/2);
-- w/ existing GROUP BY target using a relation name in target
SELECT udf(lower(test_missing_target.c)), udf(count(udf(c)))
FROM test_missing_target GROUP BY udf(lower(c)) ORDER BY udf(lower(c));
-- w/o existing GROUP BY target
SELECT udf(a) FROM test_missing_target ORDER BY udf(upper(udf(d)));
-- w/o existing ORDER BY target
SELECT udf(count(b)) FROM test_missing_target
GROUP BY udf((b + 1) / 2) ORDER BY udf((b + 1) / 2) desc;
-- group w/o existing GROUP BY and ORDER BY target under ambiguous condition
-- failure expected
SELECT udf(count(udf(x.a))) FROM test_missing_target x, test_missing_target y
WHERE udf(x.a) = udf(y.a)
GROUP BY udf(b/2) ORDER BY udf(b/2);
-- group w/ existing GROUP BY target under ambiguous condition
SELECT udf(x.b/2), udf(count(udf(x.b))) FROM test_missing_target x,
test_missing_target y
WHERE udf(x.a) = udf(y.a)
GROUP BY udf(x.b/2) ORDER BY udf(x.b/2);
-- group w/o existing GROUP BY target under ambiguous condition
-- failure expected due to ambiguous b in count(b)
SELECT udf(count(udf(b))) FROM test_missing_target x, test_missing_target y
WHERE udf(x.a) = udf(y.a)
GROUP BY udf(x.b/2);
-- [SPARK-28329] SELECT INTO syntax
-- group w/o existing GROUP BY target under ambiguous condition
-- into a table
-- SELECT count(x.b) INTO TABLE test_missing_target3
-- FROM test_missing_target x, test_missing_target y
-- WHERE x.a = y.a
-- GROUP BY x.b/2 ORDER BY x.b/2;
-- SELECT * FROM test_missing_target3;
-- Cleanup
DROP TABLE test_missing_target;
-- DROP TABLE test_missing_target2;
-- DROP TABLE test_missing_target3;
| 38.307229 | 98 | 0.731247 |
6600caa8791631a5f6f787e176977ef24a418279 | 708 | cpp | C++ | CPP/FileExample.cpp | 6299481145/Neha-bharti | 4f80498695a5ae8a16eda64fb73854c156a1d66a | [
"MIT"
] | null | null | null | CPP/FileExample.cpp | 6299481145/Neha-bharti | 4f80498695a5ae8a16eda64fb73854c156a1d66a | [
"MIT"
] | null | null | null | CPP/FileExample.cpp | 6299481145/Neha-bharti | 4f80498695a5ae8a16eda64fb73854c156a1d66a | [
"MIT"
] | null | null | null | #include<iostream>
#include<cstdio>
#include<fstream>
using namespace std;
int main()
{
string str;
ofstream fout; //fout is an object of ofstream class
//.........WARITING CONTENT TO A FILE
fout.open("FirstFile.txt");
cout<<"Please type some text below:"<<endl;
getline(cin,str);
fout<<str;
cout<<"Entered information successfully saved in the file:FirstFile"<<endl;
fout.close();
//.........READING CONTENT FROM A FILE
cout<<"To view the content of FirstFile press enter key...."<<endl;
fflush(stdin);
getchar();
ifstream fin;
fin.open("FirstFile.txt");
cout<<"FirstFile contains the following text:"<<endl;
getline(fin,str);
cout<<str<<endl;
fin.close();
return 0;
}
| 19.666667 | 76 | 0.675141 |
5bc1ffecef897a4154394bba44263cfb9fd14b71 | 1,001 | cs | C# | Proyecto_Vikingos/Assets/EscenasAlvaro/Alejandro/Evento2.cs | MarisaSF/Proyecto_Vikingos | 952aaddb0301937296d213e73d719affefab33a0 | [
"Unlicense"
] | null | null | null | Proyecto_Vikingos/Assets/EscenasAlvaro/Alejandro/Evento2.cs | MarisaSF/Proyecto_Vikingos | 952aaddb0301937296d213e73d719affefab33a0 | [
"Unlicense"
] | null | null | null | Proyecto_Vikingos/Assets/EscenasAlvaro/Alejandro/Evento2.cs | MarisaSF/Proyecto_Vikingos | 952aaddb0301937296d213e73d719affefab33a0 | [
"Unlicense"
] | null | null | null | using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Evento2 : MonoBehaviour {
public Rigidbody[] explosion;
bool una = false;
public GameObject cam1;
public GameObject cam2;
EnemyManager manager;
// Use this for initialization
void Start () {
manager = this.GetComponent<EnemyManager>();
}
// Update is called once per frame
void Update () {
if (manager.vida <= 0) { una = true; manager = null; }
if (una == true)
{
foreach (Rigidbody ri in explosion)
{
ri.isKinematic = false;
ri.AddForce(transform.right * 4, ForceMode.Impulse);
}
una = false;
StartCoroutine("camaras");
}
}
IEnumerator camaras()
{
cam1.SetActive(false);
cam2.SetActive(true);
yield return new WaitForSeconds(2f);
cam1.SetActive(true);
cam2.SetActive(false);
}
}
| 24.414634 | 68 | 0.572428 |
7abce4fd307ad73bbc03bc212b7701e64cc8151f | 1,283 | rb | Ruby | spec/lib/pact_broker/domain/version_spec.rb | evman182/pact_broker | b7d01c3f04a83c9a77bd7a364edc86d4659d6d0e | [
"MIT"
] | null | null | null | spec/lib/pact_broker/domain/version_spec.rb | evman182/pact_broker | b7d01c3f04a83c9a77bd7a364edc86d4659d6d0e | [
"MIT"
] | 1 | 2020-06-25T08:32:30.000Z | 2020-06-25T08:32:30.000Z | spec/lib/pact_broker/domain/version_spec.rb | ang3lkar/pact-broker | 9dc62f5ca5d6b4e1ee0554b6ebc4795508f8d30e | [
"MIT"
] | 1 | 2022-03-23T07:39:48.000Z | 2022-03-23T07:39:48.000Z | require 'pact_broker/domain/version'
module PactBroker
module Domain
describe Version do
describe "#latest_pact_publication" do
let!(:pact) do
TestDataBuilder.new
.create_consumer
.create_provider
.create_consumer_version
.create_pact
.revise_pact
.and_return(:pact)
end
let(:version) { Version.order(:id).last }
it "returns the latest pact revision for the consumer version" do
expect(version.latest_pact_publication.id).to eq pact.id
end
end
describe "uq_ver_ppt_ord" do
let(:consumer) do
TestDataBuilder.new
.create_consumer
.and_return(:consumer)
end
it "does not allow two versions with the same pacticipant and order" do
Sequel::Model.db[:versions].insert(number: '1', order: 0, pacticipant_id: consumer.id, created_at: DateTime.new(2017), updated_at: DateTime.new(2017))
expect { Sequel::Model.db[:versions].insert(number: '2', order: 0, pacticipant_id: consumer.id, created_at: DateTime.new(2017), updated_at: DateTime.new(2017)) }
.to raise_error(Sequel::UniqueConstraintViolation)
end
end
end
end
end
| 31.292683 | 171 | 0.626656 |
5dff5776134df7078558cf68a3f78aa9daf93ecb | 860 | go | Go | login/src/DB/init.go | zh851122/LollipopGo_example | b2849fce4045a200c03c321eb23504e915fb575f | [
"BSD-3-Clause"
] | null | null | null | login/src/DB/init.go | zh851122/LollipopGo_example | b2849fce4045a200c03c321eb23504e915fb575f | [
"BSD-3-Clause"
] | null | null | null | login/src/DB/init.go | zh851122/LollipopGo_example | b2849fce4045a200c03c321eb23504e915fb575f | [
"BSD-3-Clause"
] | 3 | 2021-03-28T09:13:05.000Z | 2022-03-01T06:48:38.000Z | package DB
import (
"github.com/golang/glog"
"login/conf"
"net/rpc"
"net/rpc/jsonrpc"
)
var ConnRPC *rpc.Client
func DBInit() {
client, err := jsonrpc.Dial("tcp", conf.GetConfig().Server.DBAddr)
if err != nil {
glog.Info("dial error:", err)
return
}
ConnRPC = client
}
// 获取链接信息
func GetConnRPC()*rpc.Client {
if ConnRPC != nil{
return ConnRPC
}else {
client, err := jsonrpc.Dial("tcp", conf.GetConfig().Server.DBAddr)
if err != nil {
glog.Info("dial error:", err)
return nil
}
return client
}
}
// 实际操作信息
func DB_rpc_SysRole(RoleName, RoleDesc, Operator, authority string) interface{} {
args := 1
var reply bool
// rpc固定的操作 操作!
divCall := ConnRPC.Go("Arith.BinGeSysRole", args, &reply, nil)
replyCall := <-divCall.Done
glog.Info(replyCall.Reply)
glog.Info("the arith.BinGeSysRole is :", reply)
return reply
} | 19.111111 | 81 | 0.666279 |
8173ef996e2f42889c6c703c1a3705c6ce00df75 | 1,109 | go | Go | cmd/start.go | Zenika/zenscaler | 9a8b4224be210630a5fc6f250a9629967e0e0889 | [
"MIT"
] | 15 | 2016-08-26T12:25:13.000Z | 2020-04-16T11:11:55.000Z | cmd/start.go | Zenika/zenscaler | 9a8b4224be210630a5fc6f250a9629967e0e0889 | [
"MIT"
] | 1 | 2017-07-23T20:47:09.000Z | 2017-07-24T08:15:06.000Z | cmd/start.go | Zenika/zenscaler | 9a8b4224be210630a5fc6f250a9629967e0e0889 | [
"MIT"
] | 3 | 2016-08-26T08:06:03.000Z | 2019-05-13T00:31:13.000Z | package cmd
import (
"github.com/Zenika/zenscaler/api"
"github.com/Zenika/zenscaler/core"
"github.com/Zenika/zenscaler/core/rule"
"github.com/gin-gonic/gin"
log "github.com/Sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// StartCmd parse configuration file and launch the scaler
var startCmd = &cobra.Command{
Use: "start",
Short: "Start autoscaler",
Run: func(cmd *cobra.Command, args []string) {
if viper.GetBool("debug") {
log.SetLevel(log.DebugLevel)
} else {
gin.SetMode(gin.ReleaseMode)
}
setConfigPath()
var err error
core.Config, err = parseConfig()
if err != nil {
log.Fatalf("Fatal error reading config file: %s \n", err)
}
go api.Start()
initialize()
},
}
// Initialize core module
func initialize() {
c := core.Config
c.Errchan = make(chan error, 5)
loop()
}
func loop() {
c := core.Config
log.Debug("Enter control loop...")
// lanch a watcher on each rule
for _, r := range c.Rules {
go rule.Watcher(c.Errchan, r)
}
// watch for errors
for {
err := <-c.Errchan
if err != nil {
log.Errorf("%s", err)
}
}
}
| 19.45614 | 60 | 0.658251 |
4ae6dea3e34e813795626068499f880a72955a83 | 1,142 | cs | C# | samples/Myo-Surgeon-Assistant-App/src/Unity3D/Myo_SFDC_v3/Assets/CoherentUI/Samples/Scenes/Sample03_MenuAndHUD/Main Menu/MenuScript.cs | brijensen101/WearablePack-Myo | b23c576d1917ebc8d68f12d399359f9e7db9392a | [
"BSD-3-Clause"
] | 1 | 2015-05-03T18:46:41.000Z | 2015-05-03T18:46:41.000Z | samples/Myo-Surgeon-Assistant-App/src/Unity3D/Myo_SFDC_v3/Assets/CoherentUI/Samples/Scenes/Sample03_MenuAndHUD/Main Menu/MenuScript.cs | brijensen101/WearablePack-Myo | b23c576d1917ebc8d68f12d399359f9e7db9392a | [
"BSD-3-Clause"
] | null | null | null | samples/Myo-Surgeon-Assistant-App/src/Unity3D/Myo_SFDC_v3/Assets/CoherentUI/Samples/Scenes/Sample03_MenuAndHUD/Main Menu/MenuScript.cs | brijensen101/WearablePack-Myo | b23c576d1917ebc8d68f12d399359f9e7db9392a | [
"BSD-3-Clause"
] | null | null | null | using UnityEngine;
using System.Collections;
using Coherent.UI;
public class MenuScript : MonoBehaviour {
private CoherentUIView ViewComponent;
// Use this for initialization
void Start ()
{
ViewComponent = GetComponent<CoherentUIView>();
if (ViewComponent)
{
ViewComponent.OnReadyForBindings += this.RegisterBindings;
}
ViewComponent.ReceivesInput = true;
}
void Update ()
{
}
private void RegisterBindings(int frame, string url, bool isMain)
{
if (isMain)
{
var view = ViewComponent.View;
if (view != null)
{
view.BindCall("NewGame", (System.Action)this.NewGame);
}
}
}
private void NewGame()
{
this.StartCoroutine(LoadGameScene());
}
IEnumerator LoadGameScene()
{
// Display a loading screen
var viewComponent = GetComponent<CoherentUIView>();
viewComponent.View.Load("coui://UIResources/MenuAndHUD/loading/loading.html");
// The game level is very simple and loads instantly;
// Add some artificial delay so we can display the loading screen.
yield return new WaitForSeconds(2.5f);
// Load the game level
Application.LoadLevelAsync("game");
}
}
| 20.035088 | 80 | 0.705779 |
42edffb5d82c8a50a540d9eee142b95b80266ef4 | 63 | lua | Lua | scaffold.lua | CppScaffolding/glfw-scaffold | 7bbb22287301e9f0f4b9cbd91779b4494b72a036 | [
"BSD-3-Clause"
] | null | null | null | scaffold.lua | CppScaffolding/glfw-scaffold | 7bbb22287301e9f0f4b9cbd91779b4494b72a036 | [
"BSD-3-Clause"
] | null | null | null | scaffold.lua | CppScaffolding/glfw-scaffold | 7bbb22287301e9f0f4b9cbd91779b4494b72a036 | [
"BSD-3-Clause"
] | null | null | null | -- scaffolding entry point for glfw
return dofile("glfw.lua")
| 15.75 | 35 | 0.746032 |
0e3a84317691e08d95a14cd2d793800d847980c2 | 1,356 | swift | Swift | App/Sources/Repositories/PACECloudAuthenticationRepository.swift | pace/connectedfueling-app-ios | e44eb336e9cd7e11a252bd94ee334fdb55c43adb | [
"MIT"
] | 2 | 2021-07-06T16:00:49.000Z | 2021-07-07T09:41:38.000Z | App/Sources/Repositories/PACECloudAuthenticationRepository.swift | pace/connectedfueling-app-ios | e44eb336e9cd7e11a252bd94ee334fdb55c43adb | [
"MIT"
] | 5 | 2021-09-13T06:46:47.000Z | 2022-03-16T11:32:42.000Z | App/Sources/Repositories/PACECloudAuthenticationRepository.swift | pace/connectedfueling-app-ios | e44eb336e9cd7e11a252bd94ee334fdb55c43adb | [
"MIT"
] | 1 | 2021-12-22T13:34:40.000Z | 2021-12-22T13:34:40.000Z | import Domain
import PACECloudSDK
import UIKit
public enum PACECloudAuthenticationRepositoryError: Error {
case authenticationFailed
}
struct PACECloudAuthenticationRepository: AuthenticationRepository {
private var presentingViewController: UIViewController?
init(presentingViewController: UIViewController?) {
self.presentingViewController = presentingViewController
IDKit.presentingViewController = presentingViewController
}
func isAuthenticated(_ completion: @escaping (Result<Bool, Error>) -> Void) {
completion(.success(IDKit.isAuthorizationValid()))
}
func authenticate(_ completion: @escaping (Result<AccessToken, Error>) -> Void) {
IDKit.authorize { result in
switch result {
case let .success(accessToken):
guard let accessToken = accessToken else {
return completion(.failure(PACECloudAuthenticationRepositoryError.authenticationFailed))
}
completion(.success(AccessToken(rawValue: accessToken)))
case let .failure(error):
completion(.failure(error))
}
}
}
func invalidateAuthentication(_ completion: @escaping (Result<Void, Error>) -> Void) {
IDKit.resetSession {
completion(.success(()))
}
}
}
| 31.534884 | 108 | 0.665192 |
2291f7e7ee34519d8d5bd2c26ef27fbd5c7c06a4 | 343 | dart | Dart | lib/utils/DevFestTabTextTheme.dart | corouteam/2019-app-devfestlevante | 13052dc2db0fecec65def4171f293bbd5709159e | [
"Apache-2.0"
] | 3 | 2019-08-18T14:43:29.000Z | 2019-08-31T03:19:08.000Z | lib/utils/DevFestTabTextTheme.dart | gdgpescara/2019-app-devfest | 13052dc2db0fecec65def4171f293bbd5709159e | [
"Apache-2.0"
] | 2 | 2021-05-10T08:12:18.000Z | 2022-01-22T08:41:40.000Z | lib/utils/DevFestTabTextTheme.dart | gdgpescara/2019-app-devfest | 13052dc2db0fecec65def4171f293bbd5709159e | [
"Apache-2.0"
] | null | null | null | import 'package:devfest_levante_2019/utils/ColorUtils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
class DevFestTabTextTheme extends StatelessWidget {
final String text;
const DevFestTabTextTheme(this.text);
@override
Widget build(BuildContext context) {
return Text(
text);
}
}
| 21.4375 | 60 | 0.758017 |
c15d034a99811c4afb8e96d591d77cbb94e1dfff | 30,246 | rs | Rust | src/lib.rs | buidoi8x/pallet-octopus-appchain | cf3c493c0191c1039a9d4355237f767b5aa6887b | [
"Apache-2.0"
] | null | null | null | src/lib.rs | buidoi8x/pallet-octopus-appchain | cf3c493c0191c1039a9d4355237f767b5aa6887b | [
"Apache-2.0"
] | null | null | null | src/lib.rs | buidoi8x/pallet-octopus-appchain | cf3c493c0191c1039a9d4355237f767b5aa6887b | [
"Apache-2.0"
] | null | null | null | #![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
use alloc::string::{String, ToString};
use frame_support::{
decl_error, decl_event, decl_module, decl_storage, dispatch::DispatchResult, ensure,
traits::{Get, OneSessionHandler},
};
use frame_system::{
self as system, ensure_none,
offchain::{
CreateSignedTransaction, SendUnsignedTransaction, SignedPayload, Signer,
SigningTypes,
},
};
use sp_core::crypto::KeyTypeId;
use sp_runtime::{
offchain::{http, storage::StorageValueRef, Duration},
traits::{Convert, IdentifyAccount},
transaction_validity::{
InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity,
ValidTransaction,
},
RuntimeDebug,
};
use sp_std::{prelude::*, vec::Vec};
use codec::{Decode, Encode};
use lite_json::json::JsonValue;
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
/// Defines application identifier for crypto keys of this module.
///
/// Every module that deals with signatures needs to declare its unique identifier for
/// its crypto keys.
/// When offchain worker is signing transactions it's going to request keys of type
/// `KeyTypeId` from the keystore and use the ones it finds to sign the transaction.
/// The keys can be inserted manually via RPC (see `author_insertKey`).
pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"octo");
/// Based on the above `KeyTypeId` we need to generate a pallet-specific crypto type wrappers.
/// We can use from supported crypto kinds (`sr25519`, `ed25519` and `ecdsa`) and augment
/// the types with this pallet-specific identifier.
pub mod crypto {
use super::KEY_TYPE;
use sp_runtime::{
app_crypto::{app_crypto, sr25519},
};
app_crypto!(sr25519, KEY_TYPE);
pub type AuthorityId = Public;
}
/// Index of an appchain on the motherchain.
pub type ChainId = u32;
/// Motherchain type, currently only NEAR is supported.
pub enum MotherchainType {
NEAR,
}
/// This pallet's configuration trait
pub trait Config: CreateSignedTransaction<Call<Self>> + pallet_session::Config {
/// The identifier type for an offchain worker.
type AppCrypto: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>;
/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
/// The overarching dispatch call type.
type Call: From<Call<Self>>;
// Configuration parameters
/// The id assigned by motherchain to this appchain.
type AppchainId: Get<ChainId>;
/// The type of the motherchain, not in use.
type Motherchain: Get<MotherchainType>;
/// The name/address of the relay contract on the motherchain.
const RELAY_CONTRACT_NAME: &'static [u8];
/// A grace period after we send transaction.
///
/// To avoid sending too many transactions, we only attempt to send one
/// every `GRACE_PERIOD` blocks. We use Local Storage to coordinate
/// sending between distinct runs of this offchain worker.
type GracePeriod: Get<Self::BlockNumber>;
/// A configuration for base priority of unsigned transactions.
///
/// This is exposed so that it can be tuned for particular runtime, when
/// multiple pallets send unsigned transactions.
type UnsignedPriority: Get<TransactionPriority>;
}
/// Validator of appchain.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
pub struct Validator<AccountId> {
/// The validator's id.
id: AccountId,
/// The weight of this validator in motherchain's staking system.
weight: u64,
}
/// The validator set of appchain.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
pub struct ValidatorSet<AccountId> {
/// The sequence number of this set on the motherchain.
sequence_number: u32,
/// Validators in this set.
validators: Vec<Validator<AccountId>>,
}
/// Payload used by this crate to hold validator set
/// data required to submit a transaction.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
pub struct ValidatorSetPayload<Public, BlockNumber, AccountId> {
public: Public,
block_number: BlockNumber,
val_set: ValidatorSet<AccountId>,
}
impl<T: SigningTypes> SignedPayload<T>
for ValidatorSetPayload<T::Public, T::BlockNumber, <T as frame_system::Config>::AccountId>
{
fn public(&self) -> T::Public {
self.public.clone()
}
}
decl_storage! {
trait Store for Module<T: Config> as OctopusAppchain {
/// The current set of validators of this appchain.
CurrentValidatorSet get(fn current_validator_set): Option<ValidatorSet<<T as frame_system::Config>::AccountId>>;
/// A list of candidate validator sets.
CandidateValidatorSets get(fn candidate_validator_sets): Vec<ValidatorSet<<T as frame_system::Config>::AccountId>>;
/// A voting record for the index of CandidateValidatorSets.
Voters get(fn voters):
map hasher(twox_64_concat) u32
=> Vec<Validator<<T as frame_system::Config>::AccountId>>;
}
add_extra_genesis {
config(validators): Vec<(<T as frame_system::Config>::AccountId, u64)>;
build(|config| Module::<T>::initialize_validator_set(&config.validators))
}
}
decl_event!(
/// Events generated by the module.
pub enum Event<T>
where
AccountId = <T as frame_system::Config>::AccountId,
{
/// Event generated when a new voter votes on a validator set.
/// \[validator_set, voter\]
NewVoterFor(ValidatorSet<AccountId>, AccountId),
}
);
decl_error! {
/// Error for the octopus appchain module.
pub enum Error for Module<T: Config> {
/// No CurrentValidatorSet.
NoCurrentValidatorSet,
/// The sequence number of new validator set was wrong.
WrongSequenceNumber,
/// Must be a validator.
NotValidator,
}
}
decl_module! {
/// A public part of the pallet.
pub struct Module<T: Config> for enum Call where origin: T::Origin {
fn deposit_event() = default;
/// Submit a new set of validators and vote on this set.
///
/// If the set already exists in the CandidateValidatorSets, then the only thing
/// to do is vote for this set.
#[weight = 0]
pub fn submit_validator_set(
origin,
payload: ValidatorSetPayload<T::Public, T::BlockNumber, <T as frame_system::Config>::AccountId>,
_signature: T::Signature,
) -> DispatchResult {
// This ensures that the function can only be called via unsigned transaction.
ensure_none(origin)?;
let cur_val_set = <CurrentValidatorSet<T>>::get().ok_or(Error::<T>::NoCurrentValidatorSet)?;
let who = payload.public.clone().into_account();
//
log::info!(
"️️️🐙 current_validator_set: {:#?},\nnext_validator_set: {:#?},\nwho: {:?}",
cur_val_set, payload.val_set, who
);
let candidates = <CandidateValidatorSets<T>>::get();
for i in 0..candidates.len() {
log::info!(
"🐙 Candidate_index: {:#?},\ncandidate: {:#?},\nvoters: {:#?}",
i, candidates.get(i), <Voters<T>>::get(i as u32)
);
}
//
ensure!(payload.val_set.sequence_number == cur_val_set.sequence_number + 1, Error::<T>::WrongSequenceNumber);
let val = cur_val_set.validators
.iter()
.find(|v| {
let id = <pallet_session::Module<T>>::key_owner(KEY_TYPE, &payload.public.clone().into_account().encode());
log::info!("🐙 check {:#?} == {:#?}", v.id, id);
<T as pallet_session::Config>::ValidatorIdOf::convert(v.id.clone()) == id
});
if val.is_none() {
log::info!("🐙 Not a validator in current validator set: {:?}", payload.public.clone().into_account());
return Err(Error::<T>::NotValidator.into());
}
let val = val.expect("Validator is valid; qed").clone();
Self::add_validator_set(who, val, payload.val_set);
//
log::info!("🐙 after submit_validator_set");
let candidates = <CandidateValidatorSets<T>>::get();
for i in 0..candidates.len() {
log::info!(
"🐙 candidate_index: {:#?},\ncandidate: {:#?},\nvoters: {:#?}",
i, candidates.get(i), <Voters<T>>::get(i as u32)
);
}
//
Ok(())
}
/// Offchain Worker entry point.
///
/// By implementing `fn offchain_worker` within `decl_module!` you declare a new offchain
/// worker.
/// This function will be called when the node is fully synced and a new best block is
/// succesfuly imported.
/// Note that it's not guaranteed for offchain workers to run on EVERY block, there might
/// be cases where some blocks are skipped, or for some the worker runs twice (re-orgs),
/// so the code should be able to handle that.
/// You can use `Local Storage` API to coordinate runs of the worker.
fn offchain_worker(block_number: T::BlockNumber) {
let appchain_id = T::AppchainId::get();
if appchain_id == 0 {
// detach appchain from motherchain when appchain_id == 0
return;
}
let parent_hash = <system::Pallet<T>>::block_hash(block_number - 1u32.into());
log::info!("🐙 Current block: {:?} (parent hash: {:?})", block_number, parent_hash);
if !Self::should_send(block_number) {
return;
}
let next_seq_num;
if let Some(cur_val_set) = <CurrentValidatorSet<T>>::get() {
next_seq_num = cur_val_set.sequence_number + 1;
} else {
log::info!("🐙 CurrentValidatorSet must be initialized.");
return;
}
log::info!("🐙 Next validator set sequenc number: {}", next_seq_num);
if let Err(e) = Self::fetch_and_update_validator_set(block_number, next_seq_num) {
log::info!("🐙 Error: {}", e);
}
}
}
}
parameter_types! {
pub const AppchainId: pallet_octopus_appchain::ChainId = 3;
pub const Motherchain: pallet_octopus_appchain::MotherchainType = pallet_octopus_appchain::MotherchainType::NEAR;
pub const GracePeriod: u32 = 5;
pub const UnsignedPriority: u64 = 1 << 20;
}
impl pallet_octopus_appchain::Config for Runtime {
type Event = Event;
type AuthorityId = pallet_octopus_appchain::crypto::OctopusAuthId;
type Call = Call;
type AppchainId = AppchainId;
type Motherchain = Motherchain;
const RELAY_CONTRACT_NAME: &'static [u8] = b"oct-relay.testnet";
type GracePeriod = GracePeriod;
type UnsignedPriority = UnsignedPriority;
}
// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime where
Block = Block,
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Authorship: pallet_authorship::{Pallet, Call, Storage, Inherent},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
Staking: pallet_staking::{Pallet, Call, Config<T>, Storage, Event<T>},
Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned},
Beefy: pallet_beefy::{Pallet, Storage, Config<T>},
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
Historical: pallet_session_historical::{Pallet},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Call, Storage},
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
Mmr: pallet_mmr::{Pallet, Storage},
OctopusAppchain: pallet_octopus_appchain::{Pallet, Call, Storage, Config<T>, Event<T>, ValidateUnsigned},
// Include the custom logic from the pallet-template in the runtime.
TemplateModule: pallet_template::{Pallet, Call, Storage, Event<T>},
}
);
/// Most of the functions are moved outside of the `decl_module!` macro.
///
/// This greatly helps with error messages, as the ones inside the macro
/// can sometimes be hard to debug.
impl<T: Config> Module<T> {
fn initialize_validator_set(
vals: &Vec<(
<T as frame_system::Config>::AccountId,
u64,
)>,
) {
if vals.len() != 0 {
assert!(
<CurrentValidatorSet<T>>::get().is_none(),
"CurrentValidatorSet is already initialized!"
);
<CurrentValidatorSet<T>>::put(ValidatorSet {
sequence_number: 0,
validators: vals
.iter()
.map(|x| Validator {
id: x.0.clone(),
weight: x.1,
})
.collect::<Vec<_>>(),
});
}
}
fn should_send(block_number: T::BlockNumber) -> bool {
/// A friendlier name for the error that is going to be returned in case we are in the grace
/// period.
const RECENTLY_SENT: () = ();
// Start off by creating a reference to Local Storage value.
// Since the local storage is common for all offchain workers, it's a good practice
// to prepend your entry with the module name.
let val = StorageValueRef::persistent(b"octopus_appchain::last_send");
// The Local Storage is persisted and shared between runs of the offchain workers,
// and offchain workers may run concurrently. We can use the `mutate` function, to
// write a storage entry in an atomic fashion. Under the hood it uses `compare_and_set`
// low-level method of local storage API, which means that only one worker
// will be able to "acquire a lock" and send a transaction if multiple workers
// happen to be executed concurrently.
let res = val.mutate(|last_send: Option<Option<T::BlockNumber>>| {
// We match on the value decoded from the storage. The first `Option`
// indicates if the value was present in the storage at all,
// the second (inner) `Option` indicates if the value was succesfuly
// decoded to expected type (`T::BlockNumber` in our case).
match last_send {
// If we already have a value in storage and the block number is recent enough
// we avoid sending another transaction at this time.
Some(Some(block)) if block_number < block + T::GracePeriod::get() => {
Err(RECENTLY_SENT)
}
// In every other case we attempt to acquire the lock and send a transaction.
_ => Ok(block_number),
}
});
// The result of `mutate` call will give us a nested `Result` type.
// The first one matches the return of the closure passed to `mutate`, i.e.
// if we return `Err` from the closure, we get an `Err` here.
// In case we return `Ok`, here we will have another (inner) `Result` that indicates
// if the value has been set to the storage correctly - i.e. if it wasn't
// written to in the meantime.
match res {
// The value has been set correctly, which means we can safely send a transaction now.
Ok(Ok(_block_number)) => true,
// We are in the grace period, we should not send a transaction this time.
Err(RECENTLY_SENT) => false,
// We wanted to send a transaction, but failed to write the block number (acquire a
// lock). This indicates that another offchain worker that was running concurrently
// most likely executed the same logic and succeeded at writing to storage.
// Thus we don't really want to send the transaction, knowing that the other run
// already did.
Ok(Err(_)) => false,
}
}
fn fetch_and_update_validator_set(
block_number: T::BlockNumber,
next_seq_num: u32,
) -> Result<(), &'static str> {
log::info!("🐙 in fetch_and_update_validator_set");
// Make an external HTTP request to fetch the current validator set.
// Note this call will block until response is received.
let next_val_set = Self::fetch_validator_set(
T::RELAY_CONTRACT_NAME.to_vec(),
T::AppchainId::get(),
next_seq_num,
)
.map_err(|_| "Failed to fetch validator set")?;
log::info!("🐙 new validator set: {:#?}", next_val_set);
// -- Sign using any account
let (_, result) = Signer::<T, T::AppCrypto>::any_account()
.send_unsigned_transaction(
|account| ValidatorSetPayload {
public: account.public.clone(),
block_number,
val_set: next_val_set.clone(),
},
|payload, signature| Call::submit_validator_set(payload, signature),
)
.ok_or("🐙 No local accounts accounts available.")?;
result.map_err(|()| "🐙 Unable to submit transaction")?;
Ok(())
}
/// Fetch the validator set of a specified appchain with seq_num from relay contract.
fn fetch_validator_set(
relay_contract: Vec<u8>,
appchain_id: u32,
seq_num: u32,
) -> Result<ValidatorSet<<T as frame_system::Config>::AccountId>, http::Error> {
// We want to keep the offchain worker execution time reasonable, so we set a hard-coded
// deadline to 2s to complete the external call.
// You can also wait idefinitely for the response, however you may still get a timeout
// coming from the host machine.
let deadline = sp_io::offchain::timestamp().add(Duration::from_millis(2_000));
// Initiate an external HTTP GET request.
// This is using high-level wrappers from `sp_runtime`, for the low-level calls that
// you can find in `sp_io`. The API is trying to be similar to `reqwest`, but
// since we are running in a custom WASM execution environment we can't simply
// import the library here.
let args = Self::encode_args(appchain_id, seq_num).ok_or_else(|| {
log::info!("🐙 Encode args error");
http::Error::Unknown
})?;
let mut body = br#"
{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "query",
"params": {
"request_type": "call_function",
"finality": "final",
"account_id": ""#
.to_vec();
body.extend(&relay_contract);
body.extend(
br#"",
"method_name": "get_validator_set",
"args_base64": ""#,
);
body.extend(&args);
body.extend(
br#""
}
}"#,
);
let request = http::Request::default()
.method(http::Method::Post)
.url("https://rpc.testnet.near.org")
.body(vec![body])
.add_header("Content-Type", "application/json");
// We set the deadline for sending of the request, note that awaiting response can
// have a separate deadline. Next we send the request, before that it's also possible
// to alter request headers or stream body content in case of non-GET requests.
let pending = request
.deadline(deadline)
.send()
.map_err(|_| http::Error::IoError)?;
// The request is already being processed by the host, we are free to do anything
// else in the worker (we can send multiple concurrent requests too).
// At some point however we probably want to check the response though,
// so we can block current thread and wait for it to finish.
// Note that since the request is being driven by the host, we don't have to wait
// for the request to have it complete, we will just not read the response.
let response = pending
.try_wait(deadline)
.map_err(|_| http::Error::DeadlineReached)??;
// Let's check the status code before we proceed to reading the response.
if response.code != 200 {
log::info!("🐙 Unexpected status code: {}", response.code);
return Err(http::Error::Unknown);
}
// Next we want to fully read the response body and collect it to a vector of bytes.
// Note that the return object allows you to read the body in chunks as well
// with a way to control the deadline.
let body = response.body().collect::<Vec<u8>>();
// Create a str slice from the body.
let body_str = sp_std::str::from_utf8(&body).map_err(|_| {
log::info!("🐙 No UTF8 body");
http::Error::Unknown
})?;
log::info!("🐙 Got response: {:?}", body_str);
let val_set = match Self::parse_validator_set(body_str) {
Some(val_set) => Ok(val_set),
None => {
log::info!(
"🐙 Unable to extract validator set from the response: {:?}",
body_str
);
Err(http::Error::Unknown)
}
}?;
log::info!("🐙 Got validator set: {:?}", val_set);
Ok(val_set)
}
fn encode_args(appchain_id: u32, seq_num: u32) -> Option<Vec<u8>> {
let a = String::from("{\"appchain_id\":");
let appchain_id = appchain_id.to_string();
let b = String::from(",\"seq_num\":");
let seq_num = seq_num.to_string();
let c = String::from("}");
let json = a + &appchain_id + &b + &seq_num + &c;
let res = base64::encode(json).into_bytes();
Some(res)
}
fn parse_validator_set(
body_str: &str,
) -> Option<ValidatorSet<<T as frame_system::Config>::AccountId>> {
// TODO
let result = Self::extract_result(body_str).ok_or_else(|| {
log::info!("🐙 Can't extract result from body");
Option::<ValidatorSet<<T as frame_system::Config>::AccountId>>::None
}).ok()?;
let result_str = sp_std::str::from_utf8(&result).map_err(|_| {
log::info!("🐙 No UTF8 result");
Option::<ValidatorSet<<T as frame_system::Config>::AccountId>>::None
}).ok()?;
log::info!("🐙 Got result: {:?}", result_str);
let mut val_set: ValidatorSet<<T as frame_system::Config>::AccountId> = ValidatorSet {
sequence_number: 0,
validators: vec![],
};
let val = lite_json::parse_json(result_str);
val.ok().and_then(|v| match v {
JsonValue::Object(obj) => {
val_set.sequence_number = obj
.clone()
.into_iter()
.find(|(k, _)| {
let mut sequence_number = "seq_num".chars();
k.iter().all(|k| Some(*k) == sequence_number.next())
})
.and_then(|v| match v.1 {
JsonValue::Number(number) => Some(number),
_ => None,
})?
.integer as u32;
obj.into_iter()
.find(|(k, _)| {
let mut validators = "validators".chars();
k.iter().all(|k| Some(*k) == validators.next())
})
.and_then(|(_, v)| match v {
JsonValue::Array(vs) => {
vs.iter().for_each(|v| match v {
JsonValue::Object(obj) => {
let id = obj
.clone()
.into_iter()
.find(|(k, _)| {
let mut id = "id".chars();
k.iter().all(|k| Some(*k) == id.next())
})
.and_then(|v| match v.1 {
JsonValue::String(s) => {
let data: Vec<u8> = s
.iter()
.skip(2)
.map(|c| *c as u8)
.collect::<Vec<_>>();
let b = hex::decode(data).map_err(|_| {
log::info!("🐙 Not a valid hex string");
Option::<ValidatorSet<<T as frame_system::Config>::AccountId>>::None
}).ok()?;
<T as frame_system::Config>::AccountId::decode(
&mut &b[..],
)
.ok()
}
_ => None,
});
let weight = obj
.clone()
.into_iter()
.find(|(k, _)| {
let mut weight = "weight".chars();
k.iter().all(|k| Some(*k) == weight.next())
})
.and_then(|v| match v.1 {
JsonValue::Number(number) => Some(number),
_ => None,
});
if id.is_some() && weight.is_some() {
let id = id.expect("id is valid; qed");
let weight = weight.expect("weight is valid; qed").integer as u64;
val_set.validators.push(Validator {
id: id,
weight: weight,
});
}
}
_ => (),
});
Some(0)
}
_ => None,
});
Some(val_set)
}
_ => None,
})
}
fn extract_result(body_str: &str) -> Option<Vec<u8>> {
let val = lite_json::parse_json(body_str);
val.ok().and_then(|v| match v {
JsonValue::Object(obj) => {
let version = obj
.clone()
.into_iter()
.find(|(k, _)| {
let mut jsonrpc = "jsonrpc".chars();
k.iter().all(|k| Some(*k) == jsonrpc.next())
})
.and_then(|v| match v.1 {
JsonValue::String(s) => Some(s),
_ => None,
})?;
log::info!("🐙 version: {:?}", version);
let id = obj
.clone()
.into_iter()
.find(|(k, _)| {
let mut id = "id".chars();
k.iter().all(|k| Some(*k) == id.next())
})
.and_then(|v| match v.1 {
JsonValue::String(s) => Some(s),
_ => None,
})?;
log::info!("🐙 id: {:?}", id);
obj.into_iter()
.find(|(k, _)| {
let mut result = "result".chars();
k.iter().all(|k| Some(*k) == result.next())
})
.and_then(|(_, v)| match v {
JsonValue::Object(obj) => {
obj.into_iter()
.find(|(k, _)| {
let mut values = "result".chars();
k.iter().all(|k| Some(*k) == values.next())
})
.and_then(|(_, v)| match v {
JsonValue::Array(vs) => {
// TODO
let res: Vec<u8> = vs
.iter()
.map(|jv| match jv {
JsonValue::Number(n) => n.integer as u8,
_ => 0,
})
.collect();
Some(res)
}
_ => None,
})
}
_ => None,
})
}
_ => None,
})
}
/// Add new validator set to the CandidateValidatorSets.
fn add_validator_set(
who: T::AccountId,
val: Validator<<T as frame_system::Config>::AccountId>,
new_val_set: ValidatorSet<<T as frame_system::Config>::AccountId>,
) {
log::info!("🐙 Adding to the voters: {:#?}", new_val_set);
let index = 0;
<CandidateValidatorSets<T>>::mutate(|val_sets| {
// TODO
if val_sets.len() == 0 {
val_sets.push(new_val_set.clone());
}
});
<Voters<T>>::mutate(index, |vals| {
let exist = vals.iter().find(|v| v.id == val.id);
match exist {
Some(id) => {
log::info!("🐙 duplicated ocw tx: {:?}", id);
}
None => vals.push(val),
}
});
Self::deposit_event(RawEvent::NewVoterFor(new_val_set, who));
}
fn validate_transaction_parameters(
block_number: &T::BlockNumber,
val_set: &ValidatorSet<<T as frame_system::Config>::AccountId>,
account_id: <T as frame_system::Config>::AccountId,
) -> TransactionValidity {
// Let's make sure to reject transactions from the future.
let current_block = <system::Pallet<T>>::block_number();
if ¤t_block < block_number {
log::info!(
"🐙 InvalidTransaction => current_block: {:?}, block_number: {:?}",
current_block,
block_number
);
return InvalidTransaction::Future.into();
}
ValidTransaction::with_tag_prefix("OctopusAppchain")
// We set base priority to 2**20 and hope it's included before any other
// transactions in the pool. Next we tweak the priority depending on the
// sequence number of the validator set.
.priority(T::UnsignedPriority::get().saturating_add(val_set.sequence_number as _))
// This transaction does not require anything else to go before into the pool.
//.and_requires()
// One can only vote on the validator set with the same seq_num once.
.and_provides((val_set.sequence_number, account_id))
// The transaction is only valid for next 5 blocks. After that it's
// going to be revalidated by the pool.
.longevity(5)
// It's fine to propagate that transaction to other peers, which means it can be
// created even by nodes that don't produce blocks.
// Note that sometimes it's better to keep it for yourself (if you are the block
// producer), since for instance in some schemes others may copy your solution and
// claim a reward.
.propagate(true)
.build()
}
}
#[allow(deprecated)] // ValidateUnsigned
impl<T: Config> frame_support::unsigned::ValidateUnsigned for Module<T> {
type Call = Call<T>;
/// Validate unsigned call to this module.
///
/// By default unsigned transactions are disallowed, but implementing the validator
/// here we make sure that some particular calls (the ones produced by offchain worker)
/// are being whitelisted and marked as valid.
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
// Firstly let's check that we call the right function.
if let Call::submit_validator_set(ref payload, ref signature) = call {
let signature_valid =
SignedPayload::<T>::verify::<T::AppCrypto>(payload, signature.clone());
if !signature_valid {
return InvalidTransaction::BadProof.into();
}
Self::validate_transaction_parameters(
&payload.block_number,
&payload.val_set,
payload.public.clone().into_account(),
)
} else {
InvalidTransaction::Call.into()
}
}
}
pub type SessionIndex = u32;
impl<T: Config> pallet_session::SessionManager<T::AccountId> for Module<T> {
fn new_session(new_index: SessionIndex) -> Option<Vec<T::AccountId>> {
log::info!(
"🐙 [{:?}] planning new_session({})",
<frame_system::Pallet<T>>::block_number(),
new_index
);
if let Some(cur_val_set) = <CurrentValidatorSet<T>>::get() {
//
log::info!(
"🐙 current_validator_set: {:#?}",
cur_val_set
);
let candidates = <CandidateValidatorSets<T>>::get();
for i in 0..candidates.len() {
log::info!(
"🐙 candidate_index: {:?},\ncandidate: {:#?},\nvoters: {:#?}",
i,
candidates.get(i),
<Voters<T>>::get(i as u32)
);
}
//
let total_weight: u64 = cur_val_set.validators.iter().map(|v| v.weight).sum();
// TODO
let next_val_set = <Voters<T>>::iter()
.find(|(_k, v)| v.iter().map(|x| x.weight).sum::<u64>() == total_weight)
.map(|(index, _v)| {
log::info!("🐙 total_weight: {}, index: {}", total_weight, index);
<CandidateValidatorSets<T>>::get()[index as usize].clone()
});
match next_val_set {
Some(new_val_set) => {
// TODO: transaction
<CurrentValidatorSet<T>>::put(new_val_set.clone());
let candidates = <CandidateValidatorSets<T>>::get();
for i in 0..candidates.len() {
<Voters<T>>::remove(i as u32);
}
<CandidateValidatorSets<T>>::kill();
log::info!("🐙 validator set changed to: {:#?}", new_val_set.clone());
Some(
new_val_set
.validators
.into_iter()
.map(|vals| vals.id)
.collect(),
)
}
None => {
log::info!("🐙 validator set has't changed");
None
}
}
} else {
None
}
}
fn start_session(start_index: SessionIndex) {
log::info!(
"🐙 [{:?}] starting start_session({})",
<frame_system::Pallet<T>>::block_number(),
start_index
);
}
fn end_session(end_index: SessionIndex) {
log::info!(
"🐙 [{:?}] ending end_session({})",
<frame_system::Pallet<T>>::block_number(),
end_index
);
}
}
impl<T: Config> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
type Public = crypto::AuthorityId;
}
impl<T: Config> OneSessionHandler<T::AccountId> for Module<T> {
type Key = crypto::AuthorityId;
fn on_genesis_session<'a, I: 'a>(_authorities: I)
where
I: Iterator<Item = (&'a T::AccountId, Self::Key)>,
{
// ignore
}
fn on_new_session<'a, I: 'a>(_changed: bool, _validators: I, _queued_validators: I)
where
I: Iterator<Item = (&'a T::AccountId, Self::Key)>,
{
// ignore
}
fn on_disabled(_i: usize) {
// ignore
}
}
| 33.273927 | 117 | 0.65202 |
2d78180d4f49a9a933e9177b4d6ccb524bc0e6f2 | 92 | sql | SQL | src/test/resources/sql/insert/bcf65252.sql | Shuttl-Tech/antlr_psql | fcf83192300abe723f3fd3709aff5b0c8118ad12 | [
"MIT"
] | 66 | 2018-06-15T11:34:03.000Z | 2022-03-16T09:24:49.000Z | src/test/resources/sql/insert/bcf65252.sql | Shuttl-Tech/antlr_psql | fcf83192300abe723f3fd3709aff5b0c8118ad12 | [
"MIT"
] | 13 | 2019-03-19T11:56:28.000Z | 2020-08-05T04:20:50.000Z | src/test/resources/sql/insert/bcf65252.sql | Shuttl-Tech/antlr_psql | fcf83192300abe723f3fd3709aff5b0c8118ad12 | [
"MIT"
] | 28 | 2019-01-05T19:59:02.000Z | 2022-03-24T11:55:50.000Z | -- file:plpgsql.sql ln:1414 expect:true
insert into HSlot values ('HS', 'base.hub1', 1, '')
| 30.666667 | 51 | 0.673913 |
83dd8bafee175b204cb83bc5ef9c5b3e962e05d5 | 815 | java | Java | src/main/java/gov/cdc/epiinfo/LineListFragment.java | Epi-Info/Epi-Info-Android | 59312cfdea84cdacab65cb03066bd75b56bace5f | [
"Apache-2.0"
] | 1 | 2020-04-29T02:36:52.000Z | 2020-04-29T02:36:52.000Z | src/main/java/gov/cdc/epiinfo/LineListFragment.java | Epi-Info/Epi-Info-Android | 59312cfdea84cdacab65cb03066bd75b56bace5f | [
"Apache-2.0"
] | 1 | 2019-03-31T18:43:34.000Z | 2020-02-26T02:05:21.000Z | src/main/java/gov/cdc/epiinfo/LineListFragment.java | Epi-Info/Epi-Info-Android | 59312cfdea84cdacab65cb03066bd75b56bace5f | [
"Apache-2.0"
] | 2 | 2019-08-24T20:40:47.000Z | 2020-11-13T14:21:07.000Z | package gov.cdc.epiinfo;
import android.app.ListFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
public class LineListFragment extends ListFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.line_list, container);
}
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
registerForContextMenu(this.getListView());
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
((RecordList) getActivity()).onListItemClick(l, v, position, id);
}
}
| 23.970588 | 98 | 0.785276 |
afbc467f2282bcea666893a823d7c23ab99e776f | 550 | html | HTML | site/layouts/index.html | IreneLou/victor-hugo | 2a26f796d01f12562c9efa7d9ab2dabcb6b6e40b | [
"MIT"
] | null | null | null | site/layouts/index.html | IreneLou/victor-hugo | 2a26f796d01f12562c9efa7d9ab2dabcb6b6e40b | [
"MIT"
] | 3 | 2021-10-06T16:12:11.000Z | 2022-02-27T03:49:03.000Z | site/layouts/index.html | IreneLou/victor-hugo | 2a26f796d01f12562c9efa7d9ab2dabcb6b6e40b | [
"MIT"
] | null | null | null | {{ define "main" }}
<div class="about animated fadeInDown">
{{ range first 10 .Site.RegularPages }}
{{ if eq .Type "post"}}
<div>
<h3><a href="{{ .RelPermalink }}">{{ .Title }}</a></h3>
{{ .Summary }}
</div>
{{ if .Truncated }}
<!-- This <div> includes a read more link, but only if the summary is truncated... -->
<div>
<a href="{{ .RelPermalink }}">Read More…</a>
</div>
{{ end }}
{{ end }}
{{ end }}
</div>
{{ end }}
| 26.190476 | 96 | 0.430909 |
047dac903c2402ab368078619b6ca65a240a4248 | 2,276 | java | Java | aeron-system-tests/src/test/java/io/aeron/FlowControlTests.java | raghav-deepsource/aeron | caa1e9cd7d6afa239806c742edb750b7cccf97de | [
"Apache-2.0"
] | 2 | 2017-05-19T08:02:25.000Z | 2018-01-01T18:26:31.000Z | aeron-system-tests/src/test/java/io/aeron/FlowControlTests.java | QIvan/aeron | 134635044b9bd0cf0eed963b73672bda740c18ba | [
"Apache-2.0"
] | null | null | null | aeron-system-tests/src/test/java/io/aeron/FlowControlTests.java | QIvan/aeron | 134635044b9bd0cf0eed963b73672bda740c18ba | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2014-2020 Real Logic Ltd.
*
* 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 io.aeron;
import io.aeron.test.Tests;
import org.agrona.DirectBuffer;
import org.agrona.concurrent.status.CountersReader;
import static io.aeron.driver.status.SystemCounterDescriptor.STATUS_MESSAGES_RECEIVED;
import static org.agrona.concurrent.status.CountersReader.*;
public class FlowControlTests
{
public static void awaitConnectionAndStatusMessages(
final CountersReader countersReader,
final Subscription subscription,
final Subscription... subscriptions)
{
while (!subscription.isConnected())
{
Tests.sleep(1);
}
for (final Subscription sub : subscriptions)
{
while (!sub.isConnected())
{
Tests.sleep(1);
}
}
final long delta = 1 + subscriptions.length;
Tests.awaitCounterDelta(countersReader, STATUS_MESSAGES_RECEIVED.id(), delta);
}
public static int findCounterIdByRegistrationId(
final CountersReader countersReader, final int counterTypeId, final long registrationId)
{
final DirectBuffer buffer = countersReader.metaDataBuffer();
for (int i = 0, size = countersReader.maxCounterId(); i < size; i++)
{
if (countersReader.getCounterState(i) == RECORD_ALLOCATED &&
countersReader.getCounterTypeId(i) == counterTypeId)
{
final int recordOffset = CountersReader.metaDataOffset(i);
if (buffer.getLong(recordOffset + KEY_OFFSET) == registrationId)
{
return i;
}
}
}
return NULL_COUNTER_ID;
}
}
| 32.514286 | 96 | 0.655097 |
66fb8c8c9ffd5a3f7177baba88f6546dfa8dd18d | 15,918 | cpp | C++ | src/dale/Form/Function/Function.cpp | ChengCat/dale | 4a764895611679cd1670d9a43ffdbee136661759 | [
"BSD-3-Clause"
] | null | null | null | src/dale/Form/Function/Function.cpp | ChengCat/dale | 4a764895611679cd1670d9a43ffdbee136661759 | [
"BSD-3-Clause"
] | null | null | null | src/dale/Form/Function/Function.cpp | ChengCat/dale | 4a764895611679cd1670d9a43ffdbee136661759 | [
"BSD-3-Clause"
] | null | null | null | #include "Function.h"
#include <cstdio>
#include <string>
#include <vector>
#include "../../CoreForms/CoreForms.h"
#include "../../Function/Function.h"
#include "../../Node/Node.h"
#include "../../ParseResult/ParseResult.h"
#include "../../Units/Units.h"
#include "../../llvmUtils/llvmUtils.h"
#include "../../llvm_Function.h"
#include "../Function/Function.h"
#include "../Linkage/Linkage.h"
#include "../Parameter/Parameter.h"
#include "../ProcBody/ProcBody.h"
#include "../Type/Type.h"
#include "../Utils/Utils.h"
#include "Config.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace dale::ErrorInst;
namespace dale {
bool parseFunctionAttributes(Context *ctx,
std::vector<Node *> *attr_list,
bool *always_inline, bool *cto) {
for (std::vector<Node *>::iterator b = (attr_list->begin() + 1),
e = attr_list->end();
b != e; ++b) {
if ((*b)->is_list) {
Error *e = new Error(InvalidAttribute, (*b));
ctx->er->addError(e);
return false;
}
if (!((*b)->token->str_value.compare("inline"))) {
*always_inline = true;
} else if (!((*b)->token->str_value.compare("cto"))) {
*cto = true;
} else {
Error *e = new Error(InvalidAttribute, (*b));
ctx->er->addError(e);
return false;
}
}
return true;
}
bool parseParameters(Units *units, Node *args_node,
std::vector<Variable *> *fn_args_internal) {
Context *ctx = units->top()->ctx;
std::vector<Node *> *args = args_node->list;
if (args->size() == 0) {
Error *e = new Error(NoEmptyLists, args_node);
ctx->er->addError(e);
return false;
}
for (std::vector<Node *>::iterator b = args->begin(),
e = args->end();
b != e; ++b) {
Variable *var = new Variable();
var->type = NULL;
FormParameterParse(units, var, (*b), false, false, true, false);
if (var->type == NULL) {
delete var;
return false;
}
if (!var->type->is_reference && var->type->is_array) {
delete var;
Error *e =
new Error(ArraysCannotBeFunctionParameters, (*b));
ctx->er->addError(e);
return false;
}
if (var->type->base_type == BaseType::Void) {
delete var;
if (args->size() != 1) {
Error *e =
new Error(VoidMustBeTheOnlyParameter, args_node);
ctx->er->addError(e);
return false;
}
break;
}
if (var->type->base_type == BaseType::VarArgs) {
if ((args->end() - b) != 1) {
delete var;
Error *e =
new Error(VarArgsMustBeLastParameter, args_node);
ctx->er->addError(e);
return false;
}
fn_args_internal->push_back(var);
break;
}
if (var->type->is_function) {
delete var;
Error *e = new Error(NonPointerFunctionParameter, (*b));
ctx->er->addError(e);
return false;
}
fn_args_internal->push_back(var);
}
return true;
}
void addInitChannelsCall(Context *ctx, llvm::Function *llvm_fn) {
std::vector<llvm::Value *> call_args;
std::vector<Type *> params;
Function *ic = ctx->getFunction("init-channels", ¶ms, NULL, 0);
assert(ic && ic->llvm_function &&
"cannot find init-channels function");
llvm::Function::iterator i = llvm_fn->begin();
llvm::BasicBlock *b = &*i;
if (b->empty()) {
llvm::CallInst::Create(ic->llvm_function,
llvm::ArrayRef<llvm::Value *>(call_args),
"", b);
} else {
llvm::Instruction *fnp = b->getFirstNonPHI();
if (fnp) {
llvm::CallInst::Create(
ic->llvm_function,
llvm::ArrayRef<llvm::Value *>(call_args), "", fnp);
} else {
llvm::CallInst::Create(
ic->llvm_function,
llvm::ArrayRef<llvm::Value *>(call_args), "", b);
}
}
}
void parametersToTypes(std::vector<Variable *> *parameters,
std::vector<Type *> *types) {
for (std::vector<Variable *>::iterator b = parameters->begin(),
e = parameters->end();
b != e; ++b) {
Type *type = (*b)->type;
types->push_back(type);
}
}
bool parametersToLLVMTypes(Context *ctx,
std::vector<Variable *> *parameters,
std::vector<llvm::Type *> *types) {
for (std::vector<Variable *>::iterator b = parameters->begin(),
e = parameters->end();
b != e; ++b) {
Type *type = (*b)->type;
if (type->is_reference || type->is_rvalue_reference) {
type = ctx->tr->getPointerType(type);
}
if (type->base_type == BaseType::VarArgs) {
break;
}
llvm::Type *llvm_type = ctx->toLLVMType(type, NULL, false);
if (!llvm_type) {
return false;
}
types->push_back(llvm_type);
}
return true;
}
Type *parseReturnType(Units *units, Context *ctx,
std::vector<Variable *> *parameters, Node *node) {
/* For return type parsing, activate an anonymous namespace and
* add all of the function parameters to it. This is so that if
* the return type uses a macro that depends on one of those
* parameters, it will work properly. */
ctx->activateAnonymousNamespace();
std::string anon_name = ctx->ns()->name;
for (std::vector<Variable *>::iterator b = parameters->begin(),
e = parameters->end();
b != e; ++b) {
ctx->ns()->addVariable((*b)->name.c_str(), (*b));
}
Type *ret_type =
FormTypeParse(units, node, false, false, false, true);
ctx->deactivateNamespace(anon_name.c_str());
if (!ret_type) {
return NULL;
}
if (ret_type->is_array) {
Error *e = new Error(ReturnTypesCannotBeArrays, node);
ctx->er->addError(e);
return NULL;
}
return ret_type;
}
bool isValidDeclaration(Context *ctx, Node *node, const char *name,
int linkage, Function *fn) {
Namespace *current_ns = (*(ctx->used_ns_nodes.rbegin()))->ns;
std::vector<Type *> types;
parametersToTypes(&fn->parameters, &types);
Function *closest_fn = NULL;
std::vector<bool> lvalues;
for (std::vector<Type *>::iterator b = types.begin(),
e = types.end();
b != e; ++b) {
lvalues.push_back((*b)->is_reference);
}
Function *matching_fn =
(linkage == Linkage::Extern_C)
? current_ns->getFunction(name, NULL, NULL, false)
: current_ns->getFunction(name, &types, &closest_fn, false,
true, &lvalues);
if (matching_fn && !matching_fn->is_macro &&
!matching_fn->isVarArgs()) {
if (!matching_fn->isEqualTo(fn)) {
Error *e =
new Error(RedeclarationOfFunctionOrMacro, node, name);
ctx->er->addError(e);
return false;
}
if (matching_fn->llvm_function &&
matching_fn->llvm_function->size()) {
Error *e =
new Error(RedeclarationOfFunctionOrMacro, node, name);
ctx->er->addError(e);
return false;
}
if (!matching_fn->attrsAreEqual(fn)) {
Error *e = new Error(AttributesOfDeclAndDefAreDifferent,
node, name);
ctx->er->addError(e);
return false;
}
}
Variable *matching_var = current_ns->getVariable(name);
if (matching_var) {
Error *e = new Error(RedeclarationOfDifferentKind, node, name);
ctx->er->addError(e);
return false;
}
return true;
}
bool FormFunctionParse(Units *units, Node *node, const char *name,
Function **new_fn, int override_linkage,
bool is_anonymous) {
Context *ctx = units->top()->ctx;
if (!is_anonymous) {
units->prefunction_ns = ctx->ns();
}
if (CoreForms::existsNoOverride(name)) {
Error *e = new Error(ThisCoreFormCannotBeOverridden, node);
ctx->er->addError(e);
return false;
}
std::vector<Node *> *lst = node->list;
if (lst->size() < 4) {
Error *e = new Error(IncorrectMinimumNumberOfArgs, node, "fn",
"3", (lst->size() - 1));
ctx->er->addError(e);
return false;
}
int next_index = 1;
bool always_inline = false;
bool cto = units->cto;
/* Whole modules, as well as specific functions, can be declared
* compile-time-only. If global CTO is enabled, that overrides
* the absence of a CTO attribute here. However, if a function
* explicitly declares that it is CTO, that will override the
* global setting. */
Node *test = ((*lst)[next_index]);
if (test->is_list && (*test->list)[0]->is_token &&
!((*test->list)[0]->token->str_value.compare("attr"))) {
bool res = parseFunctionAttributes(ctx, test->list,
&always_inline, &cto);
if (!res) {
return false;
}
++next_index;
}
int linkage = (override_linkage)
? override_linkage
: FormLinkageParse(ctx, (*lst)[next_index]);
if (!linkage) {
return false;
}
if (!override_linkage) {
++next_index;
}
/* The return type is not parsed yet, because it may depend on the
* types of the function parameters. */
int return_type_index = next_index;
Node *args_node = (*lst)[next_index + 1];
if (!args_node->is_list) {
Error *e = new Error(UnexpectedElement, args_node, "list",
"parameters", "symbol");
ctx->er->addError(e);
return false;
}
std::vector<Variable *> fn_args_internal;
bool res = parseParameters(units, args_node, &fn_args_internal);
if (!res) {
return false;
}
if (linkage == Linkage::Extern_C) {
for (std::vector<Variable *>::iterator
b = fn_args_internal.begin(),
e = fn_args_internal.end();
b != e; ++b) {
Type *type = (*b)->type;
if (type->is_reference || type->is_rvalue_reference) {
Error *e = new Error(NoRefsInExternC, args_node);
ctx->er->addError(e);
return false;
}
}
}
bool varargs = false;
if (fn_args_internal.size() &&
(fn_args_internal.back()->type->base_type ==
BaseType::VarArgs)) {
varargs = true;
}
std::vector<llvm::Type *> fn_args;
res = parametersToLLVMTypes(ctx, &fn_args_internal, &fn_args);
if (!res) {
return false;
}
Type *ret_type = parseReturnType(units, ctx, &fn_args_internal,
(*lst)[return_type_index]);
if (ret_type == NULL) {
return false;
}
llvm::Type *llvm_ret_type = ctx->toLLVMType(ret_type, NULL, true);
if (!llvm_ret_type) {
return false;
}
/* Create the LLVM function type. If the retval attribute is
* present, then the LLVM function type will have a return type of
* void, and a pointer to a value of the return type will be the
* final parameter. */
if (ret_type->is_retval) {
fn_args.push_back(ctx->toLLVMType(
ctx->tr->getPointerType(ret_type), NULL, true));
llvm_ret_type = ctx->toLLVMType(
ctx->tr->getBasicType(BaseType::Void), NULL, true);
}
llvm::FunctionType *ft =
getFunctionType(llvm_ret_type, fn_args, varargs);
std::string symbol;
ctx->ns()->functionNameToSymbol(name, &symbol, linkage,
&fn_args_internal);
Function *fn = new Function(ret_type, &fn_args_internal, NULL, 0,
&symbol, always_inline);
fn->linkage = linkage;
fn->cto = cto;
if (units->top()->once_tag.length() > 0) {
fn->once_tag = units->top()->once_tag;
}
if (!strcmp(name, "setf-copy-init") ||
!strcmp(name, "setf-copy-assign") ||
!strcmp(name, "setf-move-init") ||
!strcmp(name, "setf-move-assign")) {
fn->is_setf_fn = true;
} else if (!strcmp(name, "destroy")) {
fn->is_destructor = true;
}
if (fn->is_setf_fn) {
if (!ret_type->isEqualTo(ctx->tr->type_bool)) {
Error *e = new Error(SetfOverridesMustReturnBool,
(*lst)[return_type_index]);
ctx->er->addError(e);
return false;
}
}
res = isValidDeclaration(ctx, node, name, linkage, fn);
if (!res) {
return false;
}
llvm::Constant *fnc =
units->top()->module->getOrInsertFunction(symbol.c_str(), ft);
llvm::Function *llvm_fn = llvm::dyn_cast<llvm::Function>(fnc);
/* If llvm_fn is null, then the function already exists and the
* extant function has a different prototype, so it's an invalid
* redeclaration. If llvm_fn is not null, but has content, then
* it's an invalid redefinition. These error conditions should be
* caught by isValidDeclaration, but there's no harm in leaving
* this check here as a stopgap. */
if (!llvm_fn || llvm_fn->size()) {
fprintf(stderr, "%s\n", symbol.c_str());
assert(false && "uncaught invalid redeclaration");
abort();
}
if (always_inline) {
addInlineAttribute(llvm_fn);
}
llvm_fn->setCallingConv(llvm::CallingConv::C);
llvm_fn->setLinkage((lst->size() == (unsigned)(next_index + 2))
? ctx->toLLVMLinkage(override_linkage)
: ctx->toLLVMLinkage(linkage));
linkVariablesToFunction(&fn_args_internal, llvm_fn);
llvm::Value *llvm_return_value = NULL;
if (ret_type->is_retval) {
llvm::Function::arg_iterator llvm_arg_iter =
llvm_fn->arg_begin();
std::advance(llvm_arg_iter, fn->parameters.size());
llvm_return_value = &*llvm_arg_iter;
llvm_return_value->setName("retval");
}
fn->llvm_function = llvm_fn;
if (!ctx->ns()->addFunction(name, fn, node)) {
return false;
}
if (new_fn) {
*new_fn = fn;
}
/* If the list has only four arguments, function is a
* declaration and you can return straightaway. */
if (lst->size() == (unsigned)(next_index + 2)) {
return true;
}
ctx->activateAnonymousNamespace();
std::string anon_name = ctx->ns()->name;
units->top()->pushGlobalFunction(fn);
FormProcBodyParse(units, node, fn, llvm_fn, (next_index + 2),
is_anonymous, llvm_return_value);
units->top()->popGlobalFunction();
if (!strcmp(name, "main") && (!strcmp(SYSTEM_NAME, "Darwin") ||
!strcmp(SYSTEM_NAME, "FreeBSD")) &&
ctx->getVariable("stdin") && ctx->getVariable("stdout") &&
ctx->getVariable("stderr")) {
addInitChannelsCall(ctx, llvm_fn);
}
ctx->deactivateNamespace(anon_name.c_str());
if (units->debug) {
moduleDebugPass(units->top()->module);
}
return true;
}
}
| 31.836 | 72 | 0.536814 |
85a2566d29f5b6bd5ab7a80abf325c9b07b8dc6f | 2,089 | h | C | Frameworks/SpriteKit.framework/SKPhysicsWorld.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 36 | 2016-04-20T04:19:04.000Z | 2018-10-08T04:12:25.000Z | Frameworks/SpriteKit.framework/SKPhysicsWorld.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | null | null | null | Frameworks/SpriteKit.framework/SKPhysicsWorld.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 10 | 2016-06-16T02:40:44.000Z | 2019-01-15T03:31:45.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/Frameworks/SpriteKit.framework/SpriteKit
*/
@interface SKPhysicsWorld : NSObject <NSCoding> {
<SKPhysicsContactDelegate> * _contactDelegate;
struct CGVector {
double dx;
double dy;
} _gravity;
double speed;
}
@property (nonatomic) <SKPhysicsContactDelegate> *contactDelegate;
@property (nonatomic) struct CGVector { double x1; double x2; } gravity;
@property (nonatomic) double speed;
+ (id)allocWithZone:(struct _NSZone { }*)arg1;
+ (id)copyWithZone:(struct _NSZone { }*)arg1;
- (void)addBody:(id)arg1;
- (void)addJoint:(id)arg1;
- (id)bodies;
- (id)bodyAlongRayStart:(struct CGPoint { double x1; double x2; })arg1 end:(struct CGPoint { double x1; double x2; })arg2;
- (id)bodyAtPoint:(struct CGPoint { double x1; double x2; })arg1;
- (id)bodyInRect:(struct CGRect { struct CGPoint { double x_1_1_1; double x_1_1_2; } x1; struct CGSize { double x_2_1_1; double x_2_1_2; } x2; })arg1;
- (id)contactDelegate;
- (void)encodeWithCoder:(id)arg1;
- (void)enumerateBodiesAlongRayStart:(struct CGPoint { double x1; double x2; })arg1 end:(struct CGPoint { double x1; double x2; })arg2 usingBlock:(id /* block */)arg3;
- (void)enumerateBodiesAtPoint:(struct CGPoint { double x1; double x2; })arg1 usingBlock:(id /* block */)arg2;
- (void)enumerateBodiesInRect:(struct CGRect { struct CGPoint { double x_1_1_1; double x_1_1_2; } x1; struct CGSize { double x_2_1_1; double x_2_1_2; } x2; })arg1 usingBlock:(id /* block */)arg2;
- (id)fields;
- (struct CGVector { double x1; double x2; })gravity;
- (bool)hasBodies;
- (bool)hasFields;
- (id)initWithCoder:(id)arg1;
- (void)removeAllBodies;
- (void)removeAllJoints;
- (void)removeBody:(id)arg1;
- (void)removeJoint:(id)arg1;
- (void)sampleFields;
- (void)sampleFieldsAt;
- (void)setContactDelegate:(id)arg1;
- (void)setGravity:(struct CGVector { double x1; double x2; })arg1;
- (void)setSpeed:(double)arg1;
- (double)speed;
- (bool)stepWithTime:(double)arg1 velocityIterations:(unsigned long long)arg2 positionIterations:(unsigned long long)arg3;
@end
| 41.78 | 195 | 0.718526 |
4b10d2c4d93b190a640fb0338652f399be95bf14 | 3,783 | html | HTML | demos/Water_UV.html | maldicion069/monkeybrush.js | 9b5db2dd0d662aca78374429a2998290bcad8a37 | [
"MIT"
] | 3 | 2016-08-30T01:05:35.000Z | 2017-09-25T18:18:45.000Z | demos/Water_UV.html | maldicion069/webgl2template | 9b5db2dd0d662aca78374429a2998290bcad8a37 | [
"MIT"
] | 4 | 2016-09-20T11:47:25.000Z | 2016-09-21T00:01:12.000Z | demos/Water_UV.html | maldicion069/webgl2template | 9b5db2dd0d662aca78374429a2998290bcad8a37 | [
"MIT"
] | 1 | 2018-09-06T07:44:49.000Z | 2018-09-06T07:44:49.000Z | <!DOCTYPE html>
<html>
<head>
<title>Convolution matrix</title>
<link rel="stylesheet" type="text/css" href="./libs/style.css" />
</head>
<body>
<div class="spinner" id="spinner">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div id="stats"></div>
<div id="samplesPassed"></div>
<script type="text/javascript" src="./libs/libraries.js"></script>
<script type="text/javascript" src="../dist/output.js"></script>
<script type="x-shader/x-fragment" id="shader-fs">#version 300 es
precision highp float;
out vec4 fragColor;
in vec2 uv;
precision mediump float;
uniform float iGlobalTime;
uniform sampler2D tex;
uniform vec2 uvspeed;
uniform vec3 color;
void main() {
fragColor = texture(tex, uv + (uvspeed * iGlobalTime));
fragColor.rgb *= color;
}
</script>
<script type="text/javascript">
var MyConfig = function () {
return {
USpeed: 0.5,
VSpeed: 0.5,
RChannel: 1.0,
GChannel: 1.0,
BChannel: 1.0
};
};
var MyScene = (function (_super) {
__extends(MyScene, _super);
function MyScene() {
_super.call(this, "App", new MB.GLContextW2(), MyConfig());
};
MyScene.prototype.loadAssets = function () {
MB.Loaders.loadImage("../assets/images/water.png", "myTex");
};
MyScene.prototype.initialize = function () {
this.tex2d = new MB.Texture2D(this.context, "myTex", {
flipY: 1,
minFilter: MB.ctes.TextureFilter.Nearest,
magFilter: MB.ctes.TextureFilter.Nearest,
wrapS: MB.ctes.WrapMode.Repeat,
wrapT: MB.ctes.WrapMode.Repeat
});
this.myProg = new MB.PostProcessMaterial(this.context, {
name: "waterUV",
vertexShader: MB.Utils.readScriptShader("shader-vs"),
fragmentShader: MB.Utils.readScriptShader("shader-fs"),
uniforms: {
tex: {
type: MB.UniformType.Integer,
value: 0
},
uvspeed: { type: MB.UniformType.Vector2 },
color: { type: MB.UniformType.Vector3 },
iGlobalTime: { type: MB.UniformType.Float }
}
});
this.tex2d.bind(0);
};
MyScene.prototype.update = function (dt) {
this.myProg.uniforms.iGlobalTime.value = dt;
this.__resize__();
};
MyScene.prototype.draw = function () {
this.myProg.uniforms.color.value = new MB.Vect3(this.text.RChannel, this.text.GChannel, this.text.BChannel);
this.myProg.uniforms.uvspeed.value = new MB.Vect2(this.text.USpeed, this.text.VSpeed);
this.myProg.renderPP();
};
MyScene.prototype.textCB = function (gui) {
gui.add(this.text, "USpeed", -6, 6);
gui.add(this.text, "VSpeed", -6, 6);
gui.add(this.text, "RChannel", 0.0, 1.0);
gui.add(this.text, "GChannel", 0.0, 1.0);
gui.add(this.text, "BChannel", 0.0, 1.0);
};
return MyScene;
}(MB.App));
var myScene;
window.onload = function () {
myScene = new MyScene();
myScene.start();
};
</script>
</body>
</html>
| 35.027778 | 124 | 0.48295 |
cc176ab097065103e939e43236505ee548821f10 | 9,698 | lua | Lua | Interface/AddOns/ElvUI/Settings/filters/reminders.lua | ChinarG/Game-Wow-Plugins-Setting | e3fd3ddec1387c1f971dc195fec4fd9045d3105d | [
"Apache-2.0"
] | null | null | null | Interface/AddOns/ElvUI/Settings/filters/reminders.lua | ChinarG/Game-Wow-Plugins-Setting | e3fd3ddec1387c1f971dc195fec4fd9045d3105d | [
"Apache-2.0"
] | null | null | null | Interface/AddOns/ElvUI/Settings/filters/reminders.lua | ChinarG/Game-Wow-Plugins-Setting | e3fd3ddec1387c1f971dc195fec4fd9045d3105d | [
"Apache-2.0"
] | null | null | null | local E, L, V, P, G, _ = unpack(select(2, ...)); --Engine
--[[
Spell Reminder Arguments
General:
enable - turn the reminder off and on.
strictFilter - allow the use of spells that are not actually in your spellbook (Spell Procs)
disableSound - Don't play the warning sound.
Type of Check:
spellGroup - List of spells in a group, if you have anyone of these spells the icon will hide.
weaponCheck - Run a weapon enchant check instead of a spell check
CDSpell - Run checks to see if a spell is on cooldown or not.
Spells only Requirements:
negateGroup - List of spells in a group, if you have anyone of these spells the icon will immediately hide and stop running the spell check (these should be other peoples spells)
reverseCheck - only works if you provide a role or a tree, instead of hiding the frame when you have the buff, it shows the frame when you have the buff, doesn't work with weapons
talentTreeException - if reverseCheck is set you can set a talent tree to follow the reverse check if not set then all trees follow the reverse check, doesn't work with weapons
Cooldown only Requirements:
OnCooldown - Set to "SHOW or "HIDE".
Requirements: (These work for both spell and weapon checks)
role - you must be a certain role for it to display (Tank, Melee, Caster)
tree - you must be active in a specific talent tree for it to display ([1] = true, [2] = true, [3] = true, [4] = true) note: tree order can be viewed from top to bottom when you open your talent pane
minLevel - the minimum level you must be (most of the time we don't need to use this because it will register the spell learned event if you don't know the spell, but in the case of weapon enchants this is useful)
personal - aura must come from the player
Additional Checks: (Note we always run a check when gaining/losing an aura)
instance - check when entering a party/raid instance
pvp - check when entering a bg/arena
combat - check when entering combat
For every group created a new frame is created, it's a lot easier this way.
]]
G['reminder']['filters'] = {
DEATHKNIGHT = {
["Horn of Winter"] = { -- Horn of Winter group
["spellGroup"] = {
[57330] = true, -- Horn of Winter
},
["negateGroup"] = {
[6673] = true, -- Battle Shout
[19506] = true, -- Trueshot Aura
},
["combat"] = true,
["enable"] = true,
["strictFilter"] = true,
},
["Blood Presence"] = { -- Blood Presence group
["spellGroup"] = {
[48263] = true, -- Blood Presence
},
["role"] = "Tank",
["instance"] = true,
["reversecheck"] = true,
["enable"] = true,
["strictFilter"] = true,
},
},
DRUID = {
["Mark of the Wild"] = { -- Mark of the Wild group
["spellGroup"] = {
[1126] = true, -- Mark of the Wild
},
["negateGroup"] = {
[159988] = true, -- Bark of the Wild (Dog)
[160017] = true, -- Blessing of Kongs (Gorilla)
[90363] = true, -- Embrace of the Shale Spider
[160077] = true, -- Strength of the Earth (Worm)
[115921] = true, -- Legacy of the Emperor
[116781] = true, -- Legacy of the White Tiger
[20217] = true, -- Blessing of Kings
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
},
},
--[[ HUNTER = {
["Aspects"] = { -- Aspects group
["spellGroup"] = {
[109260] = true, -- Aspect of the Iron Hawk
},
["instance"] = true,
["personal"] = true,
["enable"] = true,
["strictFilter"] = true,
},
},]]
MAGE = {
--[[ ["Armors"] = { -- Armors group
["spellGroup"] = {
[30482] = true, -- Molten Armor
[7302] = true, -- Frost Armor
[6117] = true, -- Mage Armor
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
},]]
["Brilliance"] = { -- Brilliance group
["spellGroup"] = {
[1459] = true, -- Arcane Brilliance
[61316] = true, -- Dalaran Brilliance
},
["negateGroup"] = {
[126309] = true, -- Still Water (Water Strider)
[128433] = true, -- Serpent's Cunning (Serpent)
[90364] = true, -- Qiraji Fortitude (Silithid)
[109773] = true, -- Dark Intent
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
},
},
MONK = {
["Legacy of the Emperor"] = { -- Legacy of the Emperor group
["spellGroup"] = {
[115921] = true, -- Legacy of the Emperor
},
["negateGroup"] = {
[1126] = true, -- Mark of the Wild
[159988] = true, -- Bark of the Wild (Dog)
[160017] = true, -- Blessing of Kongs (Gorilla)
[90363] = true, -- Embrace of the Shale Spider
[160077] = true, -- Strength of the Earth (Worm)
[116781] = true, -- Legacy of the White Tiger
[20217] = true, -- Blessing of Kings
},
["role"] = "Healer",
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
},
["Legacy of the White Tiger"] = { -- Legacy of the White Tiger group
["spellGroup"] = {
[116781] = true, -- Legacy of the White Tiger
},
["negateGroup"] = {
[91126] = true, -- Mark of the Wild
[159988] = true, -- Bark of the Wild (Dog)
[160017] = true, -- Blessing of Kongs (Gorilla)
[90363] = true, -- Embrace of the Shale Spider
[160077] = true, -- Strength of the Earth (Worm)
[115921] = true, -- Legacy of the Emperor
[20217] = true, -- Blessing of Kings
[160200] = true,
[1459] = true, -- Arcane Brilliance
[61316] = true, -- Dalaran Brilliance
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
},
},
PALADIN = {
["Righteous Fury"] = { -- Righteous Fury group
["spellGroup"] = {
[25780] = true, -- Righteous Fury
},
["role"] = "Tank",
["instance"] = true,
["reversecheck"] = true,
["negate_reversecheck"] = 1, -- Holy paladins use RF sometimes
["enable"] = true,
["strictFilter"] = true,
},
["Blessing of Kings"] = { -- Blessing of Kings group
["spellGroup"] = {
[20217] = true, -- Blessing of Kings
},
["negateGroup"] = {
[1126] = true, -- Mark of the Wild
[160017] = true, -- Blessing of Kongs (Gorilla)
[90363] = true, -- Embrace of the Shale Spider
[160077] = true, -- Strength of the Earth (Worm)
[115921] = true, -- Legacy of the Emperor
[116781] = true, -- Legacy of the White
[19740] = true,
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
},
["Blessing of Might"] = { -- Blessing of Might group
["spellGroup"] = {
[19740] = true, -- Blessing of Might
},
["negateGroup"] = {
[155522] = true, -- Power of the Grave
[24907] = true, -- Moonkin Aura
[93435] = true, -- Roar of Courage (Cat)
[160039] = true, -- Keen Senses (Hydra)
[160073] = true, -- Plainswalking (Tallstrider)
[128997] = true, -- Spirit Beast Blessing
[116956] = true, -- Grace of Air
[20217] = true,
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
},
},
PRIEST = {
},
ROGUE = {
["Lethal Poisons"] = { -- Lethal Poisons group
["spellGroup"] = {
[2823] = true, -- 致命毒藥
[157584] = true, -- 速效毒藥
[8679] = true, -- 致傷毒藥
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
["level"] = 100,
},
["Non-Lethal Poisons"] = { -- Non-Lethal Poisons group
["spellGroup"] = {
[3408] = true, -- 减速
[108211] = true,-- 吸血
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
["level"] = 100,
},
},
SHAMAN = {
["Shields"] = { -- Shields group
["spellGroup"] = {
[52127] = true, -- Water Shield
[324] = true, -- Lightning Shield
[974] = true, -- Earth Shield
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
},
["Weapons Enchant"] = { -- Weapons enchants group
["weapon"] = true,
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["level"] = 10,
["enable"] = true,
["strictFilter"] = true,
},
},
WARLOCK = {
["Dark Intent"] = { -- Dark Intent group
["spellGroup"] = {
[109773] = true, -- Dark Intent
},
["negateGroup"] = {
[1459] = true, -- Arcane Brilliance
[61316] = true, -- Dalaran Brilliance
[126309] = true, -- Still Water (Water Strider)
[128433] = true, -- Serpent's Cunning (Serpent)
[90364] = true, -- Qiraji Fortitude (Silithid)
},
["combat"] = true,
["instance"] = true,
["pvp"] = true,
["enable"] = true,
["strictFilter"] = true,
},
},
WARRIOR = {
["Commanding Shout"] = { -- Commanding Shout group
["spellGroup"] = {
[469] = true, -- Commanding Shout
},
["negateGroup"] = {
[90364] = true, -- Qiraji Fortitude (Silithid)
[160003] = true, -- Savage Vigor (Rylak)
[160014] = true, -- Sturdiness (Goat)
[21562] = true, -- Power Word: Fortitude
[166928] = true, -- Blood Pact
[6673] = true,
},
["combat"] = true,
["role"] = "Tank",
["enable"] = true,
["strictFilter"] = true,
},
["Battle Shout"] = { -- Battle Shout group
["spellGroup"] = {
[6673] = true, -- Battle Shout
},
["negateGroup"] = {
[57330] = true, -- Horn of Winter
[19506] = true, -- Trueshot Aura
[469] = true, -- Commanding Shout
},
["combat"] = true,
["role"] = "Melee",
["enable"] = true,
["strictFilter"] = true,
},
},
} | 29.748466 | 215 | 0.570324 |
aad261e2585b76d34f6f91ed86ff95b5744aef04 | 711 | dart | Dart | packages/agility_redux_bloc/example/lib/counter_bloc/counter_page/counter_page.dart | songfei/agility_redux | d537fd32a434d5fb3205d6c1f9cb7b2ac2ddc5f2 | [
"MIT"
] | null | null | null | packages/agility_redux_bloc/example/lib/counter_bloc/counter_page/counter_page.dart | songfei/agility_redux | d537fd32a434d5fb3205d6c1f9cb7b2ac2ddc5f2 | [
"MIT"
] | null | null | null | packages/agility_redux_bloc/example/lib/counter_bloc/counter_page/counter_page.dart | songfei/agility_redux | d537fd32a434d5fb3205d6c1f9cb7b2ac2ddc5f2 | [
"MIT"
] | null | null | null | import 'package:agility_redux_bloc/agility_redux_bloc.dart';
import 'package:flutter/material.dart';
import 'counter_widget.dart';
class CounterPage extends BlocPageRoute {
CounterPage({
BlocRouteSettings settings,
}) : super(settings: settings);
@override
void init() {
super.init();
}
@override
void appear() {
super.appear();
}
@override
void disappear() {
super.disappear();
}
@override
Widget build(BuildContext context) {
return AppNavigatorContainer(
child: CounterWidget(),
background: Column(
children: [
Container(
height: 56.0,
color: Colors.blue,
),
],
),
);
}
}
| 17.341463 | 60 | 0.606188 |
4bf98131145a6091f48e8664b453b60cdc047e4c | 241 | asm | Assembly | libsrc/_DEVELOPMENT/adt/b_vector/c/sdcc_iy/b_vector_max_size.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 640 | 2017-01-14T23:33:45.000Z | 2022-03-30T11:28:42.000Z | libsrc/_DEVELOPMENT/adt/b_vector/c/sdcc_iy/b_vector_max_size.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 1,600 | 2017-01-15T16:12:02.000Z | 2022-03-31T12:11:12.000Z | libsrc/_DEVELOPMENT/adt/b_vector/c/sdcc_iy/b_vector_max_size.asm | jpoikela/z88dk | 7108b2d7e3a98a77de99b30c9a7c9199da9c75cb | [
"ClArtistic"
] | 215 | 2017-01-17T10:43:03.000Z | 2022-03-23T17:25:02.000Z |
; void *b_vector_max_size(b_vector_t *v)
SECTION code_clib
SECTION code_adt_b_vector
PUBLIC _b_vector_max_size
EXTERN asm_b_vector_max_size
_b_vector_max_size:
pop af
pop hl
push hl
push af
jp asm_b_vector_max_size
| 12.05 | 40 | 0.771784 |
809469e507cdfbf4184e54c01807f03cfb42c0c8 | 608 | java | Java | Etc/11945_뜨거운 붕어빵/11945_뜨거운 붕어빵.java | 7dudtj/BOJ_myCode | 37d105590a7963e2232102b3098fea3c3504b96f | [
"MIT"
] | 1 | 2022-03-30T15:50:47.000Z | 2022-03-30T15:50:47.000Z | Etc/11945_뜨거운 붕어빵/11945_뜨거운 붕어빵.java | 7dudtj/BOJ_myCode | 37d105590a7963e2232102b3098fea3c3504b96f | [
"MIT"
] | null | null | null | Etc/11945_뜨거운 붕어빵/11945_뜨거운 붕어빵.java | 7dudtj/BOJ_myCode | 37d105590a7963e2232102b3098fea3c3504b96f | [
"MIT"
] | 1 | 2021-07-20T07:11:06.000Z | 2021-07-20T07:11:06.000Z | #include <iostream>
using namespace std;
int main() {
// set needed variables
int N, M, i, j, count = 0;
char *bung;
// get N and M
cin >> N >> M;
// do process for N times
while (true) {
// set count
count++;
// check
if (count > N) {
break;
}
// make input list
bung = new char[M + 1];
// set default bung
for (i = 0; i < M + 1; i++) {
bung[i] = '*';
}
// get input
cin >> bung;
// display result
for (j = M - 1; j >= 0; j--) {
cout << bung[j];
}
cout << endl;
// delete input list
delete[] bung;
bung = NULL;
}
// end program
return 0;
}
| 12.93617 | 32 | 0.504934 |
e3ae074db28916471890b5eadd392d1ff89c2a7c | 841 | lua | Lua | Mods ChoGGi/Fix Project Morpheus Particle Fell Down/Code/Script.lua | tjbigliu/tjbigliu | b8228d8ae48312b64fc5d7232b50cb92b0499e15 | [
"MIT"
] | 1 | 2021-05-01T07:35:08.000Z | 2021-05-01T07:35:08.000Z | Mods ChoGGi/Fix Project Morpheus Particle Fell Down/Code/Script.lua | tjbigliu/tjbigliu | b8228d8ae48312b64fc5d7232b50cb92b0499e15 | [
"MIT"
] | null | null | null | Mods ChoGGi/Fix Project Morpheus Particle Fell Down/Code/Script.lua | tjbigliu/tjbigliu | b8228d8ae48312b64fc5d7232b50cb92b0499e15 | [
"MIT"
] | 1 | 2021-04-08T15:23:48.000Z | 2021-04-08T15:23:48.000Z | -- See LICENSE for terms
local IsValid = IsValid
local WaitMsg = WaitMsg
local function CheckMorph()
local morphs = UICity.labels.ProjectMorpheus or ""
for i = 1, #morphs do
local obj = morphs[i]
-- if it's turned off then pretty sure it won't fall off
if obj.ui_working and IsValid(obj) then
obj:ForEachAttach("ParSystem", function(a)
-- if there's not spot name then it's fallen down
if a:GetParticlesName() == "ProjectMorpheus_Projector" and a:GetAttachSpotName() == "" then
CreateGameTimeThread(function()
local working = obj.ui_working
obj:SetUIWorking(not working)
-- wait for it...
while obj:GetStateText() ~= "end" do
WaitMsg("OnRender")
end
obj:SetUIWorking(working)
end)
end
end)
end
end
end
OnMsg.NewDay = CheckMorph
OnMsg.LoadGame = CheckMorph
| 26.28125 | 95 | 0.681332 |
e41b2da259ab72031eec81cc589ae26cd38032e3 | 19,529 | go | Go | trafficserver_exporter.go | woopi12/trafficserver_exporter | 494558d152413514ccf68843578f136144e0d5ba | [
"MIT"
] | 5 | 2019-02-28T01:56:14.000Z | 2019-05-12T23:53:33.000Z | trafficserver_exporter.go | woopi12/trafficserver_exporter | 494558d152413514ccf68843578f136144e0d5ba | [
"MIT"
] | 1 | 2019-10-23T20:01:47.000Z | 2019-10-23T20:01:47.000Z | trafficserver_exporter.go | woopi12/trafficserver_exporter | 494558d152413514ccf68843578f136144e0d5ba | [
"MIT"
] | 1 | 2019-01-04T02:32:52.000Z | 2019-01-04T02:32:52.000Z | package main
import (
//"bytes"
"crypto/tls"
"encoding/json"
"fmt"
"io"
//"io/ioutil"
"net/http"
"net/url"
//"os"
"reflect"
"regexp"
"strings"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"github.com/prometheus/common/version"
"gopkg.in/alecthomas/kingpin.v2"
)
var (
up = prometheus.NewDesc(
"trafficserver_up",
"Was talking to Trafficserver successfully",
nil, nil,
)
invalidChars = regexp.MustCompile("[^a-zA-Z0-9:_]")
)
type TrafficServerCollector struct {
}
type Metrics struct {
Counters Counters `json:"global"`
}
// Very incomplete list of counters, but these are the ones we know we care
// about right now. As we categorize and sort the metrics more, we'll bring
// more Counters and Gauges over from the structs folder.
type Counters struct {
Proxy_process_http_completed_requests float64 `json:"proxy.process.http.completed_requests"`
Proxy_process_http_total_incoming_connections float64 `json:"proxy.process.http.total_incoming_connections"`
Proxy_process_http_total_client_connections float64 `json:"proxy.process.http.total_client_connections"`
Proxy_process_http_total_server_connections float64 `json:"proxy.process.http.total_server_connections"`
Proxy_process_http_total_parent_proxy_connections float64 `json:"proxy.process.http.total_parent_proxy_connections"`
Proxy_process_http_total_parent_retries float64 `json:"proxy.process.http.total_parent_retries"`
Proxy_process_http_total_parent_switches float64 `json:"proxy.process.http.total_parent_switches"`
Proxy_process_http_total_parent_retries_exhausted float64 `json:"proxy.process.http.total_parent_retries_exhausted"`
Proxy_process_http_total_parent_marked_down_count float64 `json:"proxy.process.http.total_parent_marked_down_count"`
Proxy_process_http_incoming_requests float64 `json:"proxy.process.http.incoming_requests"`
Proxy_process_http_outgoing_requests float64 `json:"proxy.process.http.outgoing_requests"`
Proxy_process_http_incoming_responses float64 `json:"proxy.process.http.incoming_responses"`
Proxy_process_http_invalid_client_requests float64 `json:"proxy.process.http.invalid_client_requests"`
Proxy_process_http_missing_host_hdr float64 `json:"proxy.process.http.missing_host_hdr"`
Proxy_process_http_get_requests float64 `json:"proxy.process.http.get_requests"`
Proxy_process_http_head_requests float64 `json:"proxy.process.http.head_requests"`
Proxy_process_http_trace_requests float64 `json:"proxy.process.http.trace_requests"`
Proxy_process_http_options_requests float64 `json:"proxy.process.http.options_requests"`
Proxy_process_http_post_requests float64 `json:"proxy.process.http.post_requests"`
Proxy_process_http_put_requests float64 `json:"proxy.process.http.put_requests"`
Proxy_process_http_push_requests float64 `json:"proxy.process.http.push_requests"`
Proxy_process_http_delete_requests float64 `json:"proxy.process.http.delete_requests"`
Proxy_process_http_purge_requests float64 `json:"proxy.process.http.purge_requests"`
Proxy_process_http_connect_requests float64 `json:"proxy.process.http.connect_requests"`
Proxy_process_http_extension_method_requests float64 `json:"proxy.process.http.extension_method_requests"`
Proxy_process_http_broken_server_connections float64 `json:"proxy.process.http.broken_server_connections"`
Proxy_process_http_cache_lookups float64 `json:"proxy.process.http.cache_lookups"`
Proxy_process_http_cache_writes float64 `json:"proxy.process.http.cache_writes"`
Proxy_process_http_cache_updates float64 `json:"proxy.process.http.cache_updates"`
Proxy_process_http_cache_deletes float64 `json:"proxy.process.http.cache_deletes"`
Proxy_process_http_tunnels float64 `json:"proxy.process.http.tunnels"`
Proxy_process_http_throttled_proxy_only float64 `json:"proxy.process.http.throttled_proxy_only"`
Proxy_process_http_parent_proxy_transaction_time float64 `json:"proxy.process.http.parent_proxy_transaction_time"`
Proxy_process_http_user_agent_request_header_total_size float64 `json:"proxy.process.http.user_agent_request_header_total_size"`
Proxy_process_http_user_agent_response_header_total_size float64 `json:"proxy.process.http.user_agent_response_header_total_size"`
Proxy_process_http_user_agent_request_document_total_size float64 `json:"proxy.process.http.user_agent_request_document_total_size"`
Proxy_process_http_user_agent_response_document_total_size float64 `json:"proxy.process.http.user_agent_response_document_total_size"`
Proxy_process_http_origin_server_request_header_total_size float64 `json:"proxy.process.http.origin_server_request_header_total_size"`
Proxy_process_http_origin_server_response_header_total_size float64 `json:"proxy.process.http.origin_server_response_header_total_size"`
Proxy_process_http_origin_server_request_document_total_size float64 `json:"proxy.process.http.origin_server_request_document_total_size"`
Proxy_process_http_origin_server_response_document_total_size float64 `json:"proxy.process.http.origin_server_response_document_total_size"`
Proxy_process_http_parent_proxy_request_total_bytes float64 `json:"proxy.process.http.parent_proxy_request_total_bytes"`
Proxy_process_http_parent_proxy_response_total_bytes float64 `json:"proxy.process.http.parent_proxy_response_total_bytes"`
Proxy_process_http_pushed_response_header_total_size float64 `json:"proxy.process.http.pushed_response_header_total_size"`
Proxy_process_http_pushed_document_total_size float64 `json:"proxy.process.http.pushed_document_total_size"`
Proxy_process_http_total_transactions_time float64 `json:"proxy.process.http.total_transactions_time"`
Proxy_process_http_cache_hit_fresh float64 `json:"proxy.process.http.cache_hit_fresh"`
Proxy_process_http_cache_hit_mem_fresh float64 `json:"proxy.process.http.cache_hit_mem_fresh"`
Proxy_process_http_cache_hit_revalidated float64 `json:"proxy.process.http.cache_hit_revalidated"`
Proxy_process_http_cache_hit_ims float64 `json:"proxy.process.http.cache_hit_ims"`
Proxy_process_http_cache_hit_stale_served float64 `json:"proxy.process.http.cache_hit_stale_served"`
Proxy_process_http_cache_miss_cold float64 `json:"proxy.process.http.cache_miss_cold"`
Proxy_process_http_cache_miss_changed float64 `json:"proxy.process.http.cache_miss_changed"`
Proxy_process_http_cache_miss_client_no_cache float64 `json:"proxy.process.http.cache_miss_client_no_cache"`
Proxy_process_http_cache_miss_client_not_cacheable float64 `json:"proxy.process.http.cache_miss_client_not_cacheable"`
Proxy_process_http_cache_miss_ims float64 `json:"proxy.process.http.cache_miss_ims"`
Proxy_process_http_cache_read_error float64 `json:"proxy.process.http.cache_read_error"`
Proxy_process_http_err_client_abort_count_stat float64 `json:"proxy.process.http.err_client_abort_count_stat"`
Proxy_process_http_err_client_abort_user_agent_bytes_stat float64 `json:"proxy.process.http.err_client_abort_user_agent_bytes_stat"`
Proxy_process_http_err_client_abort_origin_server_bytes_stat float64 `json:"proxy.process.http.err_client_abort_origin_server_bytes_stat"`
Proxy_process_http_err_connect_fail_count_stat float64 `json:"proxy.process.http.err_connect_fail_count_stat"`
Proxy_process_http_err_connect_fail_user_agent_bytes_stat float64 `json:"proxy.process.http.err_connect_fail_user_agent_bytes_stat"`
Proxy_process_http_err_connect_fail_origin_server_bytes_stat float64 `json:"proxy.process.http.err_connect_fail_origin_server_bytes_stat"`
Proxy_process_http_misc_count_stat float64 `json:"proxy.process.http.misc_count_stat"`
Proxy_process_http_misc_user_agent_bytes_stat float64 `json:"proxy.process.http.misc_user_agent_bytes_stat"`
Proxy_process_http_http_misc_origin_server_bytes_stat float64 `json:"proxy.process.http.http_misc_origin_server_bytes_stat"`
Proxy_process_http_background_fill_bytes_aborted_stat float64 `json:"proxy.process.http.background_fill_bytes_aborted_stat"`
Proxy_process_http_background_fill_bytes_completed_stat float64 `json:"proxy.process.http.background_fill_bytes_completed_stat"`
Proxy_process_http_cache_write_errors float64 `json:"proxy.process.http.cache_write_errors"`
Proxy_process_http_cache_read_errors float64 `json:"proxy.process.http.cache_read_errors"`
Proxy_process_http_100_responses float64 `json:"proxy.process.http.100_responses"`
Proxy_process_http_101_responses float64 `json:"proxy.process.http.101_responses"`
Proxy_process_http_1xx_responses float64 `json:"proxy.process.http.1xx_responses"`
Proxy_process_http_200_responses float64 `json:"proxy.process.http.200_responses"`
Proxy_process_http_201_responses float64 `json:"proxy.process.http.201_responses"`
Proxy_process_http_202_responses float64 `json:"proxy.process.http.202_responses"`
Proxy_process_http_203_responses float64 `json:"proxy.process.http.203_responses"`
Proxy_process_http_204_responses float64 `json:"proxy.process.http.204_responses"`
Proxy_process_http_205_responses float64 `json:"proxy.process.http.205_responses"`
Proxy_process_http_206_responses float64 `json:"proxy.process.http.206_responses"`
Proxy_process_http_2xx_responses float64 `json:"proxy.process.http.2xx_responses"`
Proxy_process_http_300_responses float64 `json:"proxy.process.http.300_responses"`
Proxy_process_http_301_responses float64 `json:"proxy.process.http.301_responses"`
Proxy_process_http_302_responses float64 `json:"proxy.process.http.302_responses"`
Proxy_process_http_303_responses float64 `json:"proxy.process.http.303_responses"`
Proxy_process_http_304_responses float64 `json:"proxy.process.http.304_responses"`
Proxy_process_http_305_responses float64 `json:"proxy.process.http.305_responses"`
Proxy_process_http_307_responses float64 `json:"proxy.process.http.307_responses"`
Proxy_process_http_3xx_responses float64 `json:"proxy.process.http.3xx_responses"`
Proxy_process_http_400_responses float64 `json:"proxy.process.http.400_responses"`
Proxy_process_http_401_responses float64 `json:"proxy.process.http.401_responses"`
Proxy_process_http_402_responses float64 `json:"proxy.process.http.402_responses"`
Proxy_process_http_403_responses float64 `json:"proxy.process.http.403_responses"`
Proxy_process_http_404_responses float64 `json:"proxy.process.http.404_responses"`
Proxy_process_http_405_responses float64 `json:"proxy.process.http.405_responses"`
Proxy_process_http_406_responses float64 `json:"proxy.process.http.406_responses"`
Proxy_process_http_407_responses float64 `json:"proxy.process.http.407_responses"`
Proxy_process_http_408_responses float64 `json:"proxy.process.http.408_responses"`
Proxy_process_http_409_responses float64 `json:"proxy.process.http.409_responses"`
Proxy_process_http_410_responses float64 `json:"proxy.process.http.410_responses"`
Proxy_process_http_411_responses float64 `json:"proxy.process.http.411_responses"`
Proxy_process_http_412_responses float64 `json:"proxy.process.http.412_responses"`
Proxy_process_http_413_responses float64 `json:"proxy.process.http.413_responses"`
Proxy_process_http_414_responses float64 `json:"proxy.process.http.414_responses"`
Proxy_process_http_415_responses float64 `json:"proxy.process.http.415_responses"`
Proxy_process_http_416_responses float64 `json:"proxy.process.http.416_responses"`
Proxy_process_http_4xx_responses float64 `json:"proxy.process.http.4xx_responses"`
Proxy_process_http_500_responses float64 `json:"proxy.process.http.500_responses"`
Proxy_process_http_501_responses float64 `json:"proxy.process.http.501_responses"`
Proxy_process_http_502_responses float64 `json:"proxy.process.http.502_responses"`
Proxy_process_http_503_responses float64 `json:"proxy.process.http.503_responses"`
Proxy_process_http_504_responses float64 `json:"proxy.process.http.504_responses"`
Proxy_process_http_505_responses float64 `json:"proxy.process.http.505_responses"`
Proxy_process_http_5xx_responses float64 `json:"proxy.process.http.5xx_responses"`
Proxy_process_https_incoming_requests float64 `json:"proxy.process.https.incoming_requests"`
Proxy_process_https_total_client_connections float64 `json:"proxy.process.https.total_client_connections"`
Proxy_process_http_origin_connections_throttled_out float64 `json:"proxy.process.http.origin_connections_throttled_out"`
Proxy_process_http_post_body_too_large float64 `json:"proxy.process.http.post_body_too_large"`
Proxy_process_net_read_bytes float64 `json:"proxy.process.net.read_bytes"`
Proxy_process_net_write_bytes float64 `json:"proxy.process.net.write_bytes"`
Proxy_node_http_user_agents_total_documents_served float64 `json:"proxy.node.http.user_agents_total_documents_served"`
Proxy_node_http_user_agents_total_transactions_count float64 `json:"proxy.node.http.user_agents_total_transactions_count"`
Proxy_node_http_origin_server_total_transactions_count float64 `json:"proxy.node.http.origin_server_total_transactions_count"`
Proxy_node_cache_bytes_total float64 `json:"proxy.node.cache.bytes_total"`
}
func (c TrafficServerCollector) Describe(ch chan<- *prometheus.Desc) {
ch <- up
}
func (c TrafficServerCollector) Collect(ch chan<- prometheus.Metric) {
// FIXME: need to make these arguments
var uri string = "http://localhost:8080/d6128c003f0179ad40d38cfc5a75b1e69b17145daaccfa02bf946983d2b6b9ea"
var sslVerify bool = true
var timeout = 5 * time.Second
_, err := url.Parse(uri)
if err != nil {
ch <- prometheus.MustNewConstMetric(up, prometheus.GaugeValue, 0)
return
}
body, err := fetchHTTP(uri, sslVerify, timeout)
// print out the body for debug purposes
//buf, _ := ioutil.ReadAll(body)
//rdr1 := ioutil.NopCloser(bytes.NewBuffer(buf))
//log.Info(rdr1)
if err != nil {
ch <- prometheus.MustNewConstMetric(up, prometheus.GaugeValue, 0)
return
}
decoder := json.NewDecoder(body)
var metrics Metrics
decode_err := decoder.Decode(&metrics)
if decode_err != nil {
ch <- prometheus.MustNewConstMetric(up, prometheus.GaugeValue, 0)
return
}
// This means things are healthy, so we can return an up
ch <- prometheus.MustNewConstMetric(up, prometheus.GaugeValue, 1)
// deal with all of our counters
fields := reflect.TypeOf(metrics.Counters)
values := reflect.ValueOf(metrics.Counters)
num := fields.NumField()
for i := 0; i < num; i++ {
field := fields.Field(i)
name := strings.ToLower("trafficserver_" + invalidChars.ReplaceAllLiteralString(field.Name, "_"))
desc := prometheus.NewDesc(name, "Trafficserver metric "+field.Name, nil, nil)
value := values.Field(i)
ch <- prometheus.MustNewConstMetric(desc, prometheus.CounterValue, float64(value.Float()))
}
// do the same with the gauges, histograms, and summarys
// TODO - figure out what metrics are gauges and which are counters
}
func fetchHTTP(uri string, sslVerify bool, timeout time.Duration) (io.Reader, error) {
tr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: !sslVerify}}
client := http.Client{
Timeout: timeout,
Transport: tr,
}
resp, err := client.Get(uri)
if err != nil {
return nil, err
}
if !(resp.StatusCode >= 200 && resp.StatusCode < 300) {
resp.Body.Close()
return nil, fmt.Errorf("HTTP status %d", resp.StatusCode)
}
return resp.Body, nil
}
func main() {
var (
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9548").String()
metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String()
//trafficServerScrapeURI = kingpin.Flag("trafficserver.scrape-uri", "URI on which to scrape TrafficServer.").Default("http://localhost/stats").String()
//trafficServerSSLVerify = kingpin.Flag("trafficserver.ssl-verify", "Flag that enables SSL certificate verification for the scrape URI").Default("true").Bool()
//trafficServerTimeout = kingpin.Flag("trafficserver.timeout", "Timeout for trying to get stats from TrafficServer.").Default("5s").Duration()
)
log.AddFlags(kingpin.CommandLine)
kingpin.Version(version.Print("trafficserver_exporter"))
kingpin.HelpFlag.Short('h')
kingpin.Parse()
log.Infoln("Starting trafficserver_exporter", version.Info())
log.Infoln("Build context", version.BuildContext())
log.Infoln("Listening on", *listenAddress)
http.Handle(*metricsPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
<head><title>Trafficserver Exporter</title></head>
<body>
<h1>Trafficserver Exporter</h1>
<p><a href='` + *metricsPath + `'>Metrics</a></p>
</body>
</html>`))
})
c := TrafficServerCollector{}
prometheus.MustRegister(c)
log.Fatal(http.ListenAndServe(*listenAddress, nil))
}
| 69.746429 | 164 | 0.713298 |
8622640f79d452468bf78b81c8ce7e5e9d82f7c4 | 5,578 | java | Java | src/main/java/com/github/theLongLab/PRESM/fasta.java | theLongLab/PRESM | dd5ff54839acd42d0f6336aa9536079154455072 | [
"MIT"
] | null | null | null | src/main/java/com/github/theLongLab/PRESM/fasta.java | theLongLab/PRESM | dd5ff54839acd42d0f6336aa9536079154455072 | [
"MIT"
] | null | null | null | src/main/java/com/github/theLongLab/PRESM/fasta.java | theLongLab/PRESM | dd5ff54839acd42d0f6336aa9536079154455072 | [
"MIT"
] | null | null | null | package com.github.theLongLab.PRESM;
import java.util.Random;
import java.util.Vector;
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
public class fasta {
public Vector <String> ChrVec = new Vector<String>();
public Vector <String> ChrSeqVec = new Vector<String>();
public Vector <String> HomoeChrVec = new Vector<String>();
public Vector <String> HomoChrSeqVec = new Vector<String>();
public String [] description;
public String [] sequence;
public Vector <chrFasta> chrFastaVec = new Vector<chrFasta>();
public fasta(String faFile) throws IOException{
List desc= new ArrayList();
List seq = new ArrayList();
String temps="";
try{
BufferedReader in = new BufferedReader( new FileReader( faFile ) );
StringBuffer buffer = new StringBuffer();
String line = in.readLine();
if( line == null )
throw new IOException( faFile + " is an empty file" );
if( line.charAt( 0 ) != '>' )
throw new IOException( "First line of " + faFile + " should start with '>'" );
else
desc.add(line);
for( line = in.readLine().trim(); line != null; line = in.readLine() )
{
if( line.length()>0 && line.charAt( 0 ) == '>' )
{
seq.add(buffer.toString());
buffer = new StringBuffer();
String chr=line;
String[] chrv = chr.split(" ");
desc.add(chrv[0]);
} else {
buffer.append( line.trim() );
}
}
if( buffer.length() != 0 ){
seq.add(buffer.toString());
}
}catch(IOException e)
{
System.out.println("Error when reading "+faFile);
e.printStackTrace();
}
description = new String[desc.size()];
sequence = new String[seq.size()];
for (int i=0; i< seq.size(); i++)
{
description[i]=(String) desc.get(i);
sequence[i]=(String) seq.get(i);
}
for (int i=0; i< seq.size() ;i++){
String[] splitedInfor = description[i].split(" ");
String temp= splitedInfor[0];
if (temp.length()!=0){
if (temp.substring(0, 1).equals(">")) temp=temp.substring(1, temp.length());
}
ChrVec.add(temp );
ChrSeqVec.add(sequence[i]);
}
for (int i=0;i<ChrVec.size();i++ ){
chrFasta vc= new chrFasta();
vc.assignment(ChrVec.get(i),ChrSeqVec.get(i));
chrFastaVec.add(vc);
}
}
public void ViewChr(String chr, int start, int end ) throws IOException{
for (int i=0;i< ChrVec.size();i++){
if (ChrVec.get(i).equals(chr) ){
if (end > ChrSeqVec.get(i).length()) end = ChrSeqVec.get(i).length();
System.out.println( "chromsome: "+chr+" From: "+start+" to: "+end );
System.out.println( ChrSeqVec.get(i).substring(start-1, end) );
return;
}
}
System.out.println("Can not find chromsome: "+chr+" in the reference genome!");
}
//MakeNewFastq
public void MakeNewFastq( Vector <VcfChr> vec ) throws IOException{
int index =0;
String qual= "888888888888888888888888888888888888888888888888888888888888888888888888888";
for (int i=0; i< vec.size();i++){
String chr = vec.get(i).ChrName;
for (int j=0;j< ChrVec.size();j++){
if (ChrVec.get(j).equals(chr) ){
for (int k=0;k< vec.get(i).StartPositionVec.size();k++){
for (int s=0;s< 70;s++){
String seq= ChrSeqVec.get(j).substring( (vec.get(i).StartPositionVec.get(k)-70+s),
(vec.get(i).StartPositionVec.get(k)+5+s) );
index++;
String name= "@"+chr+"_"+ String.valueOf( vec.get(i).StartPositionVec.get(k) )+"_"+
String.valueOf(vec.get(i).StartPositionVec.get(k)-69+s) +"_" + String.valueOf(index);
System.out.println( name);
System.out.println( seq);
System.out.println( "+");
System.out.println( qual);
}
}
}
}
}
}
public void RandomGenerateMuation(int NumberOfMut, String type, int len, String OutputFile ) throws IOException{
long totalnumberofbase = 0;
for (int i=0 ;i<chrFastaVec.size();i++ ){
totalnumberofbase+= chrFastaVec.get(i).chrSeq.length();
// System.out.println( totalnumberofbase );
}
long min = 0;
long max = totalnumberofbase-1;
Vector <Long> SedVec = new Vector<Long>();
while (SedVec.size() < NumberOfMut) {
Random random= new Random();
int temp = (int)((max-200) /100);
boolean flag = true;
int hundred = random.nextInt(temp);
int unit = random.nextInt(99);
long longhundred =(long)hundred;
long longunit =(long)unit;
long num = 100*longhundred + longunit;
for (int j=0; j< SedVec.size();j++){
if (((SedVec.get(j) - num)<3) && ((SedVec.get(j) - num)>-3)) {
flag=false;
}
}
if (flag ){
SedVec.add(num);
}
}
for (int i=0;i< SedVec.size();i++){
for (int j=i;j< SedVec.size();j++){
if (SedVec.get(i)> SedVec.get(j)){
long temp = SedVec.get(i);
SedVec.set(i, SedVec.get(j));
SedVec.set(j, temp);
}
}
}
for (int i=0;i< SedVec.size();i++){
System.out.println( SedVec.get(i) );
}
if (type=="snp"){
for (int i=0;i<SedVec.size();i++ ){
long num = SedVec.get(i);
long start =0;
long end =0;
for (int j=0;j< chrFastaVec.size();j++){
end += chrFastaVec.get(i).chrSeq.length();
if (( num >=start) && (num<= end)){
}
}
}
}
// while (SedVec.size() < NumberOfMut ) {
// Random random= new Random();
// boolean flag = false;
// long s = random.nextInt(max)%(max-min+1)+min;
// s= random.
// }
}
private int abs(long l) {
// TODO Auto-generated method stub
return 0;
}
} | 27.477833 | 113 | 0.587128 |
7ddf49b82f1ed06d2372310531d65a0acd5fced7 | 268 | swift | Swift | Sources/GitHubClient/Models/Response/PageResult.swift | eduarenas/GithubClient | e8ff508ab8323d25cbeec0757ca23c3d6c1c4ce7 | [
"MIT"
] | null | null | null | Sources/GitHubClient/Models/Response/PageResult.swift | eduarenas/GithubClient | e8ff508ab8323d25cbeec0757ca23c3d6c1c4ce7 | [
"MIT"
] | null | null | null | Sources/GitHubClient/Models/Response/PageResult.swift | eduarenas/GithubClient | e8ff508ab8323d25cbeec0757ca23c3d6c1c4ce7 | [
"MIT"
] | 1 | 2018-05-27T15:06:23.000Z | 2018-05-27T15:06:23.000Z | //
// PageResult.swift
// GithubClient
//
// Created by Eduardo Arenas on 2/24/18.
// Copyright © 2018 GameChanger. All rights reserved.
//
import RxSwift
public struct PageResult<T> {
public let items: [T]
public let nextPage: Observable<PageResult<T>>?
}
| 16.75 | 54 | 0.69403 |
1a453e97ef513378b6498d3c990e9b4e0751ecf4 | 1,101 | swift | Swift | EmbeddedSocial/Sources/Model/Cache/Commands/UpdateRelatedHandleCommand.swift | LDaneliukas/EmbeddedSocial-iOS-SDK | c1de4c64b9d744020d10bde8411db03968f24965 | [
"MIT"
] | 10 | 2017-10-20T05:39:40.000Z | 2019-04-28T16:06:12.000Z | EmbeddedSocial/Sources/Model/Cache/Commands/UpdateRelatedHandleCommand.swift | LDaneliukas/EmbeddedSocial-iOS-SDK | c1de4c64b9d744020d10bde8411db03968f24965 | [
"MIT"
] | 365 | 2017-09-29T07:31:05.000Z | 2018-10-18T16:27:48.000Z | EmbeddedSocial/Sources/Model/Cache/Commands/UpdateRelatedHandleCommand.swift | LDaneliukas/EmbeddedSocial-iOS-SDK | c1de4c64b9d744020d10bde8411db03968f24965 | [
"MIT"
] | 8 | 2019-08-07T07:13:30.000Z | 2021-11-10T10:11:30.000Z | //
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
//
import Foundation
class UpdateRelatedHandleCommand: OutgoingCommand {
let oldHandle: String
let newHandle: String
required init?(json: [String: Any]) {
guard let oldHandle = json["oldHandle"] as? String,
let newHandle = json["newHandle"] as? String else {
return nil
}
self.oldHandle = oldHandle
self.newHandle = newHandle
super.init(json: json)
}
required init(oldHandle: String, newHandle: String) {
self.oldHandle = oldHandle
self.newHandle = newHandle
super.init(json: [:])!
}
override func encodeToJSON() -> Any {
let json: [String: Any?] = [
"type": typeIdentifier,
"oldHandle": oldHandle,
"newHandle": newHandle
]
return json.flatMap { $0 }
}
override func getHandle() -> String? {
return oldHandle + "-" + newHandle
}
}
| 26.853659 | 91 | 0.593097 |
05e16ce71628353dc62a5d13d6e368c12d250b99 | 329 | rb | Ruby | test/kill_test.rb | pvande/pghero | ee2d70bb4eb5c87154b95397ac8eea074755f4bf | [
"MIT"
] | 5,190 | 2015-01-02T10:31:38.000Z | 2022-03-31T18:16:26.000Z | test/kill_test.rb | pvande/pghero | ee2d70bb4eb5c87154b95397ac8eea074755f4bf | [
"MIT"
] | 398 | 2015-01-10T17:52:56.000Z | 2022-03-29T18:41:59.000Z | test/kill_test.rb | pvande/pghero | ee2d70bb4eb5c87154b95397ac8eea074755f4bf | [
"MIT"
] | 428 | 2015-01-14T00:01:56.000Z | 2022-03-16T09:13:24.000Z | require_relative "test_helper"
class KillTest < Minitest::Test
def test_kill
# prevent warning for now
# refute database.kill(1_000_000_000)
end
def test_kill_long_running_queries
assert database.kill_long_running_queries
end
def test_kill_all
# skip for now
# assert database.kill_all
end
end
| 18.277778 | 45 | 0.75076 |