// eventFromBuffer parser bytes into InputEvent struct
13152
func (k *KeyLogger) eventFromBuffer(buffer []byte) (*InputEvent, error) {
	event := &InputEvent{}
	err := binary.Read(bytes.NewBuffer(buffer), binary.LittleEndian, event)
	return event, err
}
73523
func (c *Client) SimpleEvent(title, text string) error {
	e := NewEvent(title, text)
	return c.Event(e)
}
228586
func (l *Linearizer) dispatchEvent(e *event) {
	defer l.md.Unlock()
	l.me.Lock()
	defer l.me.Unlock()
	if e.n+l.eventsSize > l.bufferSize {
		return
	}
	l.events = append(l.events, e)
	l.eventsSize += e.n
}
719508
func (self *FSock) readEvent() (header string, body string, err error) {
	var cl int

	if header, err = self.readHeaders(); err != nil {
		return "", "", err
	}
	if !strings.Contains(header, "Content-Length") { //No body
		return header, "", nil
	}
	if cl, err = strconv.Atoi(headerVal(header, "Content-Length")); err != nil {
		return "", "", errors.New("Cannot extract content length")
	}
	if body, err = self.readBody(cl); err != nil {
		return "", "", err
	}
	return
}
322351
func (g *EventGenerator) Event() *Event {
	active, alive := g.r.Intn(2) > 0, g.r.Intn(2) > 0
	return &Event{
		ID:              fmt.Sprintf("%d", g.r.Uint64()),
		Station:         g.g.String(6, 2000),
		UserID:          int(g.g.Uint64(100000000)) + 1,
		Timestamp:       g.g.Time(time.Date(2017, time.January, 1, 0, 0, 0, 0, time.UTC), time.Second*3).Format(time.RFC3339),
		Favorites:       g.genFavorites(),
		Items:           g.genItems(),
		Ranking:         g.genItems(),
		IfaceThing:      String(g.g.String(5, 5)),
		Velocity:        g.r.Intn(1000) + 2500,
		Active:          active,
		Alive:           alive,
		DeceasedBoolean: alive,

		Geo: g.genGeo(),
	}

}
328674
func (e *EventServer) processEvent(ctx context.Context, eventInfo *common.EventInfo) (err error) {

	if e.registerer == nil {
		return fmt.Errorf("No registered handlers")
	}

	f, err := e.registerer.GetHandler(eventInfo.PUType, eventInfo.EventType)
	if err != nil {
		return fmt.Errorf("Handler not found: %s", err)
	}

	return f(ctx, eventInfo)
}
1225178
func (m *rekeyFSM) Event(event RekeyEvent) {
	select {
	case m.reqs <- event:
	case <-m.shutdownCh:
	}
}
984015
func EventFromPayload(eventId int, data interface{}) *swf.HistoryEvent {
	event := &swf.HistoryEvent{}
	event.EventId = I(eventId)
	switch t := data.(type) {
	case *swf.ActivityTaskCancelRequestedEventAttributes:
		event.ActivityTaskCancelRequestedEventAttributes = t
		event.EventType = S(swf.EventTypeActivityTaskCancelRequested)
	case *swf.ActivityTaskCanceledEventAttributes:
		event.ActivityTaskCanceledEventAttributes = t
		event.EventType = S(swf.EventTypeActivityTaskCanceled)
	case *swf.ActivityTaskCompletedEventAttributes:
		event.ActivityTaskCompletedEventAttributes = t
		event.EventType = S(swf.EventTypeActivityTaskCompleted)
	case *swf.ActivityTaskFailedEventAttributes:
		event.ActivityTaskFailedEventAttributes = t
		event.EventType = S(swf.EventTypeActivityTaskFailed)
	case *swf.ActivityTaskScheduledEventAttributes:
		event.ActivityTaskScheduledEventAttributes = t
		event.EventType = S(swf.EventTypeActivityTaskScheduled)
	case *swf.ActivityTaskStartedEventAttributes:
		event.ActivityTaskStartedEventAttributes = t
		event.EventType = S(swf.EventTypeActivityTaskStarted)
	case *swf.ActivityTaskTimedOutEventAttributes:
		event.ActivityTaskTimedOutEventAttributes = t
		event.EventType = S(swf.EventTypeActivityTaskTimedOut)
	case *swf.CancelTimerFailedEventAttributes:
		event.CancelTimerFailedEventAttributes = t
		event.EventType = S(swf.EventTypeCancelTimerFailed)
	case *swf.CancelWorkflowExecutionFailedEventAttributes:
		event.CancelWorkflowExecutionFailedEventAttributes = t
		event.EventType = S(swf.EventTypeCancelWorkflowExecutionFailed)
	case *swf.ChildWorkflowExecutionCanceledEventAttributes:
		event.ChildWorkflowExecutionCanceledEventAttributes = t
		event.EventType = S(swf.EventTypeChildWorkflowExecutionCanceled)
	case *swf.ChildWorkflowExecutionCompletedEventAttributes:
		event.ChildWorkflowExecutionCompletedEventAttributes = t
		event.EventType = S(swf.EventTypeChildWorkflowExecutionCompleted)
	case *swf.ChildWorkflowExecutionFailedEventAttributes:
		event.ChildWorkflowExecutionFailedEventAttributes = t
		event.EventType = S(swf.EventTypeChildWorkflowExecutionFailed)
	case *swf.ChildWorkflowExecutionStartedEventAttributes:
		event.ChildWorkflowExecutionStartedEventAttributes = t
		event.EventType = S(swf.EventTypeChildWorkflowExecutionStarted)
	case *swf.ChildWorkflowExecutionTerminatedEventAttributes:
		event.ChildWorkflowExecutionTerminatedEventAttributes = t
		event.EventType = S(swf.EventTypeChildWorkflowExecutionTerminated)
	case *swf.ChildWorkflowExecutionTimedOutEventAttributes:
		event.ChildWorkflowExecutionTimedOutEventAttributes = t
		event.EventType = S(swf.EventTypeChildWorkflowExecutionTimedOut)
	case *swf.CompleteWorkflowExecutionFailedEventAttributes:
		event.CompleteWorkflowExecutionFailedEventAttributes = t
		event.EventType = S(swf.EventTypeCompleteWorkflowExecutionFailed)
	case *swf.ContinueAsNewWorkflowExecutionFailedEventAttributes:
		event.ContinueAsNewWorkflowExecutionFailedEventAttributes = t
		event.EventType = S(swf.EventTypeContinueAsNewWorkflowExecutionFailed)
	case *swf.DecisionTaskCompletedEventAttributes:
		event.DecisionTaskCompletedEventAttributes = t
		event.EventType = S(swf.EventTypeDecisionTaskCompleted)
	case *swf.DecisionTaskScheduledEventAttributes:
		event.DecisionTaskScheduledEventAttributes = t
		event.EventType = S(swf.EventTypeDecisionTaskScheduled)
	case *swf.DecisionTaskStartedEventAttributes:
		event.DecisionTaskStartedEventAttributes = t
		event.EventType = S(swf.EventTypeDecisionTaskStarted)
	case *swf.DecisionTaskTimedOutEventAttributes:
		event.DecisionTaskTimedOutEventAttributes = t
		event.EventType = S(swf.EventTypeDecisionTaskTimedOut)
	case *swf.ExternalWorkflowExecutionCancelRequestedEventAttributes:
		event.ExternalWorkflowExecutionCancelRequestedEventAttributes = t
		event.EventType = S(swf.EventTypeExternalWorkflowExecutionCancelRequested)
	case *swf.ExternalWorkflowExecutionSignaledEventAttributes:
		event.ExternalWorkflowExecutionSignaledEventAttributes = t
		event.EventType = S(swf.EventTypeExternalWorkflowExecutionSignaled)
	case *swf.FailWorkflowExecutionFailedEventAttributes:
		event.FailWorkflowExecutionFailedEventAttributes = t
		event.EventType = S(swf.EventTypeFailWorkflowExecutionFailed)
	case *swf.MarkerRecordedEventAttributes:
		event.MarkerRecordedEventAttributes = t
		event.EventType = S(swf.EventTypeMarkerRecorded)
	case *swf.RecordMarkerFailedEventAttributes:
		event.RecordMarkerFailedEventAttributes = t
		event.EventType = S(swf.EventTypeRecordMarkerFailed)
	case *swf.RequestCancelActivityTaskFailedEventAttributes:
		event.RequestCancelActivityTaskFailedEventAttributes = t
		event.EventType = S(swf.EventTypeRequestCancelActivityTaskFailed)
	case *swf.RequestCancelExternalWorkflowExecutionFailedEventAttributes:
		event.RequestCancelExternalWorkflowExecutionFailedEventAttributes = t
		event.EventType = S(swf.EventTypeRequestCancelExternalWorkflowExecutionFailed)
	case *swf.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes:
		event.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes = t
		event.EventType = S(swf.EventTypeRequestCancelExternalWorkflowExecutionInitiated)
	case *swf.ScheduleActivityTaskFailedEventAttributes:
		event.ScheduleActivityTaskFailedEventAttributes = t
		event.EventType = S(swf.EventTypeScheduleActivityTaskFailed)
	case *swf.SignalExternalWorkflowExecutionFailedEventAttributes:
		event.SignalExternalWorkflowExecutionFailedEventAttributes = t
		event.EventType = S(swf.EventTypeSignalExternalWorkflowExecutionFailed)
	case *swf.SignalExternalWorkflowExecutionInitiatedEventAttributes:
		event.SignalExternalWorkflowExecutionInitiatedEventAttributes = t
		event.EventType = S(swf.EventTypeSignalExternalWorkflowExecutionInitiated)
	case *swf.StartChildWorkflowExecutionFailedEventAttributes:
		event.StartChildWorkflowExecutionFailedEventAttributes = t
		event.EventType = S(swf.EventTypeStartChildWorkflowExecutionFailed)
	case *swf.StartChildWorkflowExecutionInitiatedEventAttributes:
		event.StartChildWorkflowExecutionInitiatedEventAttributes = t
		event.EventType = S(swf.EventTypeStartChildWorkflowExecutionInitiated)
	case *swf.StartTimerFailedEventAttributes:
		event.StartTimerFailedEventAttributes = t
		event.EventType = S(swf.EventTypeStartTimerFailed)
	case *swf.TimerCanceledEventAttributes:
		event.TimerCanceledEventAttributes = t
		event.EventType = S(swf.EventTypeTimerCanceled)
	case *swf.TimerFiredEventAttributes:
		event.TimerFiredEventAttributes = t
		event.EventType = S(swf.EventTypeTimerFired)
	case *swf.TimerStartedEventAttributes:
		event.TimerStartedEventAttributes = t
		event.EventType = S(swf.EventTypeTimerStarted)
	case *swf.WorkflowExecutionCancelRequestedEventAttributes:
		event.WorkflowExecutionCancelRequestedEventAttributes = t
		event.EventType = S(swf.EventTypeWorkflowExecutionCancelRequested)
	case *swf.WorkflowExecutionCanceledEventAttributes:
		event.WorkflowExecutionCanceledEventAttributes = t
		event.EventType = S(swf.EventTypeWorkflowExecutionCanceled)
	case *swf.WorkflowExecutionCompletedEventAttributes:
		event.WorkflowExecutionCompletedEventAttributes = t
		event.EventType = S(swf.EventTypeWorkflowExecutionCompleted)
	case *swf.WorkflowExecutionContinuedAsNewEventAttributes:
		event.WorkflowExecutionContinuedAsNewEventAttributes = t
		event.EventType = S(swf.EventTypeWorkflowExecutionContinuedAsNew)
	case *swf.WorkflowExecutionFailedEventAttributes:
		event.WorkflowExecutionFailedEventAttributes = t
		event.EventType = S(swf.EventTypeWorkflowExecutionFailed)
	case *swf.WorkflowExecutionSignaledEventAttributes:
		event.WorkflowExecutionSignaledEventAttributes = t
		event.EventType = S(swf.EventTypeWorkflowExecutionSignaled)
	case *swf.WorkflowExecutionStartedEventAttributes:
		event.WorkflowExecutionStartedEventAttributes = t
		event.EventType = S(swf.EventTypeWorkflowExecutionStarted)
	case *swf.WorkflowExecutionTerminatedEventAttributes:
		event.WorkflowExecutionTerminatedEventAttributes = t
		event.EventType = S(swf.EventTypeWorkflowExecutionTerminated)
	case *swf.WorkflowExecutionTimedOutEventAttributes:
		event.WorkflowExecutionTimedOutEventAttributes = t
		event.EventType = S(swf.EventTypeWorkflowExecutionTimedOut)
	}
	return event
}
293101
func event(out io.Writer) {
	event_h := readHeader("event")

	// Event is implemented by hand in wrappers.go

	// Get all the pn_event_type_t enum values
	var etypes []eventType
	enums := findEnums(event_h)
	for _, e := range enums[0].Values {
		if skipEventRe.FindStringSubmatch(e) == nil {
			etypes = append(etypes, newEventType(e))
		}
	}

	doTemplate(out, etypes, `
type EventType int
const ({{range .}}
	 E{{.Name}} EventType = C.{{.Cname}}{{end}}
)
`)

	doTemplate(out, etypes, `
func (e EventType) String() string {
	switch e {
{{range .}}
	case C.{{.Cname}}: return "{{.Name}}"{{end}}
	}
	return "Unknown"
}
`)
}
1085733
func ProtocolBuffersToEvents(pbEvents []*proto.Event) []Event {
	var events []Event
	for _, event := range pbEvents {
		e := Event{
			State:       event.GetState(),
			Service:     event.GetService(),
			Host:        event.GetHost(),
			Description: event.GetDescription(),
			TTL:         time.Duration(event.GetTtl()) * time.Second,
			Tags:        event.GetTags(),
		}
		if event.TimeMicros != nil {
			e.Time = time.Unix(0, event.GetTimeMicros()*int64(time.Microsecond))
		} else if event.Time != nil {
			e.Time = time.Unix(event.GetTime(), 0)
		}
		if event.MetricF != nil {
			e.Metric = event.GetMetricF()
		} else if event.MetricD != nil {
			e.Metric = event.GetMetricD()
		} else {
			e.Metric = event.GetMetricSint64()
		}
		if event.Attributes != nil {
			e.Attributes = make(map[string]string, len(event.GetAttributes()))
			for _, attr := range event.GetAttributes() {
				e.Attributes[attr.GetKey()] = attr.GetValue()
			}
		}
		events = append(events, e)
	}
	return events
}
80953
func (c *InputField) HandleEvent(event termbox.Event) bool {
	if event.Key == termbox.KeyBackspace || event.Key == termbox.KeyBackspace2 {
		if c.cursor+len(c.value) > 0 {
			crs := len(c.value)
			if c.cursor < 0 {
				crs = c.cursor + len(c.value)
			}
			c.value = c.value[:crs-1] + c.value[crs:]
			//c.value = c.value[:len(c.value)-1]
		}
	} else if event.Key == termbox.KeyArrowLeft {
		if c.cursor+len(c.value) > 0 {
			c.cursor--
		}
	} else if event.Key == termbox.KeyArrowRight {
		if c.cursor < 0 {
			c.cursor++
		}
	} else if event.Key == termbox.KeyCtrlU {
		// Ctrl+U Clears the Input (before the cursor)
		c.value = c.value[c.cursor+len(c.value):]
	} else {
		// Get the rune to add to our value. Space and Tab are special cases where
		// we can't use the event's rune directly
		var ch string
		switch event.Key {
		case termbox.KeySpace:
			ch = " "
		case termbox.KeyTab:
			ch = "\t"
		case termbox.KeyEnter:
			if c.multiline {
				ch = "\n"
			}
		default:
			if KeyIsAlphaNumeric(event) || KeyIsSymbol(event) {
				ch = string(event.Ch)
			}
		}

		// TODO: Handle newlines
		if c.cursor+len(c.value) == 0 {
			c.value = string(ch) + c.value
		} else if c.cursor == 0 {
			c.value = c.value + string(ch)
		} else {
			strPt1 := c.value[:(len(c.value) + c.cursor)]
			strPt2 := c.value[(len(c.value) + c.cursor):]
			c.value = strPt1 + string(ch) + strPt2
		}
	}
	return true
}
1159605
func (handler *Handler) Event(logEvent *event.Event) error {
	handler.channel <- logEvent
	return nil
}
852594
func (sw *SplunkHandler) Event(logEvent *event.Event) error {
	splunkURL, _ := url.Parse(sw.url.String())
	values := splunkURL.Query()
	values.Set("host", sw.Hostname)
	values.Set("source", sw.Source)
	values.Set("sourcetype", sw.SourceType)
	values.Set("index", sw.Index)
	splunkURL.RawQuery = values.Encode()
	splunkURL.Path = splunkURL.Path + "services/receivers/simple"

	sessionKey, err := sw.getSessionKey()
	if err != nil {
		return err
	}

	var templateBuffer bytes.Buffer
	sw.Template.Execute(&templateBuffer, formatter.EventFormatter(logEvent))
	eventBytes := templateBuffer.Bytes()
	eventBytes = bytes.Replace(eventBytes, []byte{'\n'}, []byte{'\r'}, -1)

	req, _ := http.NewRequest("POST", splunkURL.String(), bytes.NewReader(eventBytes))
	req.Header.Set("Authorization", "Splunk "+sessionKey)
	//req.Write(os.Stderr)
	//return nil

	resp, err := sw.client.Do(req)
	if err != nil {
		return err
	}
	resp.Body.Close()

	return nil
}
674827
func (c *Chunk) ParseEvent(offset int64) (e Event) {
	if int64(c.Header.OffsetLastRec) < offset {
		return
	}
	reader := bytes.NewReader(c.Data)
	GoToSeeker(reader, offset)
	e.Offset = offset
	err := encoding.Unmarshal(reader, &e.Header, Endianness)
	if err != nil {
		panic(err)
	}
	/*err := encoding.Unmarshal(reader, &e.Magic, Endianness)
	if err != nil {
		panic(err)
	}
	err = encoding.Unmarshal(reader, &e.Size, Endianness)
	if err != nil {
		panic(err)
	}
	err = encoding.Unmarshal(reader, &e.ID, Endianness)
	if err != nil {
		panic(err)
	}
	err = encoding.Unmarshal(reader, &e.Timestamp, Endianness)
	if err != nil {
		panic(err)
	}*/
	return e
}
645670
func (b *bufferedBackend) processEvents(events []*auditinternal.Event) {
	if len(events) == 0 {
		return
	}

	// TODO(audit): Should control the number of active goroutines
	// if one goroutine takes 5 seconds to finish, the number of goroutines can be 5 * defaultBatchThrottleQPS
	if b.throttle != nil {
		b.throttle.Accept()
	}

	if b.asyncDelegate {
		b.wg.Add(1)
		go func() {
			defer b.wg.Done()
			defer runtime.HandleCrash()

			// Execute the real processing in a goroutine to keep it from blocking.
			// This lets the batching routine continue draining the queue immediately.
			b.delegateBackend.ProcessEvents(events...)
		}()
	} else {
		func() {
			defer runtime.HandleCrash()

			// Execute the real processing in a goroutine to keep it from blocking.
			// This lets the batching routine continue draining the queue immediately.
			b.delegateBackend.ProcessEvents(events...)
		}()
	}
}
19276
func (ac *AppClient) Event(event *omaha.EventRequest) <-chan error {
	errc := make(chan error, 1)
	url := ac.apiEndpoint
	req := ac.NewAppRequest()
	app := req.Apps[0]
	app.Events = append(app.Events, event)

	go func() {
		appResp, err := ac.doReq(url, req)
		if err != nil {
			errc <- err
			return
		}

		// BUG: CoreUpdate does not send event status in response.
		_ = appResp
		/*if len(appResp.Events) == 0 {
			errc <- fmt.Errorf("omaha: event status missing from response")
			return
		}

		if appResp.Events[0].Status != "ok" {
			errc <- fmt.Errorf("omaha: event status %s", appResp.Events[0].Status)
			return
		}*/

		errc <- nil
		return
	}()

	return errc
}
43277
func (g *GitHttp) event(e Event) {
	if g.EventHandler != nil {
		g.EventHandler(e)
	} else {
		fmt.Printf("EVENT: %q\n", e)
	}
}