hexsha stringlengths 40 40 | size int64 5 2.72M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 976 | max_stars_repo_name stringlengths 5 113 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:01:43 2022-03-31 23:59:48 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 00:06:24 2022-03-31 23:59:53 ⌀ | max_issues_repo_path stringlengths 3 976 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 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 976 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:19 2022-03-31 23:59:49 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 12:00:57 2022-03-31 23:59:49 ⌀ | content stringlengths 5 2.72M | avg_line_length float64 1.38 573k | max_line_length int64 2 1.01M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
94aed8bca20d50fbc3a7b932386243e6adc03fcb | 1,052 | h | C | src/profileflow.h | mozilla-releng/staging-mozilla-vpn-client | f31d3762a607ccf2d7c6a016f7b800305fbf0113 | [
"Apache-2.0"
] | null | null | null | src/profileflow.h | mozilla-releng/staging-mozilla-vpn-client | f31d3762a607ccf2d7c6a016f7b800305fbf0113 | [
"Apache-2.0"
] | null | null | null | src/profileflow.h | mozilla-releng/staging-mozilla-vpn-client | f31d3762a607ccf2d7c6a016f7b800305fbf0113 | [
"Apache-2.0"
] | null | null | null | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef PROFILEFLOW_H
#define PROFILEFLOW_H
#include "subscriptiondata.h"
#include <QObject>
class ProfileFlow final : public QObject {
Q_OBJECT
Q_DISABLE_COPY_MOVE(ProfileFlow)
Q_PROPERTY(State state READ state NOTIFY stateChanged);
public:
ProfileFlow();
~ProfileFlow();
Q_INVOKABLE void start();
Q_INVOKABLE void reset();
enum State {
StateInitial,
StateLoading,
StateAuthenticationNeeded,
StateReady,
StateError,
};
Q_ENUM(State);
State state() const { return m_state; }
void setForceReauthFlow(const bool forceReauthFlow);
signals:
void stateChanged(State state);
private:
void setState(State state);
void subscriptionDetailsFetched(const QByteArray& subscriptionData);
private:
State m_state = StateInitial;
bool m_forceReauthFlow = false;
};
#endif // PROFILEFLOW_H
| 20.230769 | 70 | 0.730989 |
94b0767b7316cf32dee1793e07bba07ca4e7035c | 2,555 | h | C | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/GIFTPRODGiftMessageInfo.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-03-29T12:08:37.000Z | 2021-05-26T05:20:11.000Z | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/GIFTPRODGiftMessageInfo.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | null | null | null | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/GIFTPRODGiftMessageInfo.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-04-17T03:24:04.000Z | 2022-03-30T05:42:17.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import "GIFTPRODToString.h"
@class NSDictionary, NSString;
@interface GIFTPRODGiftMessageInfo : GIFTPRODToString
{
_Bool _checked;
_Bool _redDot;
_Bool _flashShow;
_Bool _showRedDot;
_Bool _visible;
_Bool _mock;
int _sortLevel;
NSString *_id;
NSString *_iconUrl;
NSString *_linkUrl;
NSString *_couponId;
NSString *_userId;
NSString *_resourceType;
NSString *_state;
NSString *_bizType;
long long _gmtModified;
long long _gmtClientShow;
NSString *_templateJson;
NSString *_templateCode;
NSDictionary *_extInfo;
NSString *_extInfoString;
}
+ (Class)extInfoElementClass;
@property(nonatomic) _Bool mock; // @synthesize mock=_mock;
@property(nonatomic) _Bool visible; // @synthesize visible=_visible;
@property(retain, nonatomic) NSString *extInfoString; // @synthesize extInfoString=_extInfoString;
@property(retain, nonatomic) NSDictionary *extInfo; // @synthesize extInfo=_extInfo;
@property(nonatomic) _Bool showRedDot; // @synthesize showRedDot=_showRedDot;
@property(retain, nonatomic) NSString *templateCode; // @synthesize templateCode=_templateCode;
@property(retain, nonatomic) NSString *templateJson; // @synthesize templateJson=_templateJson;
@property(nonatomic) long long gmtClientShow; // @synthesize gmtClientShow=_gmtClientShow;
@property(nonatomic) long long gmtModified; // @synthesize gmtModified=_gmtModified;
@property(nonatomic) _Bool flashShow; // @synthesize flashShow=_flashShow;
@property(nonatomic) _Bool redDot; // @synthesize redDot=_redDot;
@property(nonatomic) int sortLevel; // @synthesize sortLevel=_sortLevel;
@property(retain, nonatomic) NSString *bizType; // @synthesize bizType=_bizType;
@property(retain, nonatomic) NSString *state; // @synthesize state=_state;
@property(retain, nonatomic) NSString *resourceType; // @synthesize resourceType=_resourceType;
@property(retain, nonatomic) NSString *userId; // @synthesize userId=_userId;
@property(retain, nonatomic) NSString *couponId; // @synthesize couponId=_couponId;
@property(retain, nonatomic) NSString *linkUrl; // @synthesize linkUrl=_linkUrl;
@property(retain, nonatomic) NSString *iconUrl; // @synthesize iconUrl=_iconUrl;
@property(retain, nonatomic) NSString *id; // @synthesize id=_id;
@property(nonatomic) _Bool checked; // @synthesize checked=_checked;
- (void).cxx_destruct;
@end
| 41.209677 | 98 | 0.756947 |
94b29b78129a182fa80383d802ee5b10b72fd36b | 5,544 | h | C | STMicroelectronics/STM32L4_L4+/app/az_ulib_dm/inc/az_ulib_dm_blob_ustream_interface.h | smcd253/dcf-baseimage-test | 8f27af84f86f8e58744092689a4c22efb0e73f10 | [
"MIT"
] | 1 | 2021-07-12T18:02:11.000Z | 2021-07-12T18:02:11.000Z | STMicroelectronics/STM32L4_L4+/app/az_ulib_dm/inc/az_ulib_dm_blob_ustream_interface.h | smcd253/dcf-baseimage-test | 8f27af84f86f8e58744092689a4c22efb0e73f10 | [
"MIT"
] | 2 | 2021-04-02T16:15:19.000Z | 2021-08-20T20:14:43.000Z | STMicroelectronics/STM32L4_L4+/app/az_ulib_dm/inc/az_ulib_dm_blob_ustream_interface.h | smcd253/dcf-baseimage-test | 8f27af84f86f8e58744092689a4c22efb0e73f10 | [
"MIT"
] | null | null | null | // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.
// See LICENSE file in the project root for full license information.
#ifndef AZ_ULIB_DM_BLOB_USTREAM_INTERFACE_H
#define AZ_ULIB_DM_BLOB_USTREAM_INTERFACE_H
#include "az_ulib_result.h"
#include "az_ulib_ustream.h"
#include "nx_api.h"
#include "nx_web_http_client.h"
#ifndef __cplusplus
#include <stdbool.h>
#endif
#include "azure/core/_az_cfg_prefix.h"
/**
* @brief Structure for the blob http control block.
*
* For any given ustream created using `az_blob_create_ustream_from_blob`, an associated
* #az_blob_http_cb is created and initialized, owning the http connection to the blob located
* at `ip`, `host`, and `resource`.
*
* @note This structure should be viewed and used as internal to the implementation of the
* ustream. Users should therefore not act on it directly and only allocate the memory
* necessary for it to be passed to the ustream.
*
*/
typedef struct az_blob_http_cb_tag
{
struct
{
/** The #NX_WEB_HTTP_CLIENT that owns the http connection to the targeted blob.*/
NX_WEB_HTTP_CLIENT http_client;
/** The #NX_PACKET* pointing to the data associated with the http response.*/
NX_PACKET* packet_ptr;
} _internal;
} az_blob_http_cb;
/**
* @brief Create a ustream with an associated blob http control block.
*
* This API initializes `ustream_instance`, allowing the caller to gain access to the data inside
* a blob located at the provided blob storage `ip`, `host`, and `resource`. The http connection
* to the blob storage server shall be established in this API and owned by the `blob_http_cb`.
* The first chunk of data will also be retrieved and the total size of the blob assessed using
* the associated http response header. In addition, this `ustream_instance` takes ownership of
* the memory associated with `blob_http_cb` and will release this memory when the ref count of
* the `ustream_data_cb` goes to zero.
*
* @param[in] ustream_instance The #az_ulib_ustream* with the interface of the
* ustream.
* @param[in] ustream_data_cb The #az_ulib_ustream_data_cb* to point to the
* ustream data.
* @param[in] blob_http_cb_release_callback The #az_ulib_release_callback function signature
* to release the ustream data buffer.
* @param[in] blob_http_cb The #az_blob_http_cb* to perform the blob http
* actions.
* @param[in] ustream_data_cb_release_callback The #az_ulib_release_callback function signature
* to release the ustream control block.
* @param[in] ip The #NXD_ADDRESS* server ip address.
* @param[in] resource The `int8_t*` blob resource /0 terminated string.
* @param[in] host The `int8_t*` blob storage host /0 terminated
* string.
*
* @pre \p ustream_instance shall not be `NULL`.
* @pre \p ustream_data_cb shall not be `NULL`.
* @pre \p blob_http_cb shall not be `NULL`.
* @pre \p ip shall not be `NULL`.
* @pre \p sizeof(resource) shall greater than zero.
* @pre \p sizeof(host) shall greater than zero.
*
* @return The #az_result with the result of the contained NX operations.
* @retval #AZ_OK If the ustream and associated blob http actions were
* completed successfully.
* @retval #AZ_ERROR_ULIB_BUSY If the resources necessary for the
* `create_ustream_from_blob` operation is busy.
* @retval #AZ_ERROR_NOT_ENOUGH_SPACE If there is not enough memory to execute the
* `create_ustream_from_blob` operation.
* @retval #AZ_ERROR_ULIB_SYSTEM If the `create_ustream_from_blob` operation failed on
* the system level.
* @retval #AZ_ERROR_NOT_SUPPORTED If the parameters passed into
* `create_ustream_from_blob` do not satisfy
* the requirements put forth by the NX functions called
* within this function.
* @retval #AZ_ERROR_ARG If the parameters passed into
* `create_ustream_from_blob` violate the option,
* pointer, or caller requirements put for in the NX
* functions called within this function.
*/
AZ_NODISCARD az_result az_blob_create_ustream_from_blob(
az_ulib_ustream* ustream_instance,
az_ulib_ustream_data_cb* ustream_data_cb,
az_ulib_release_callback ustream_data_cb_release_callback,
az_blob_http_cb* blob_http_cb,
az_ulib_release_callback blob_http_cb_release_callback,
NXD_ADDRESS* ip,
int8_t* resource,
int8_t* host);
#include "azure/core/_az_cfg_suffix.h"
#endif /* AZ_ULIB_DM_BLOB_USTREAM_INTERFACE_H */
| 51.813084 | 99 | 0.603716 |
94b5ebdd53c9f7f59f662acf3823e9f482aa709e | 421 | h | C | OutPutHeaders/BrandContactItem.h | cocos543/WeChatTimeLineRobot | 1e93480e502e36ca9a21a506f481aa1fcb70ac4b | [
"MIT"
] | 106 | 2016-04-09T01:16:14.000Z | 2021-06-04T00:20:24.000Z | OutPutHeaders/BrandContactItem.h | cocos543/WeChatTimeLineRobot | 1e93480e502e36ca9a21a506f481aa1fcb70ac4b | [
"MIT"
] | 2 | 2017-06-13T09:41:29.000Z | 2018-03-26T03:32:07.000Z | OutPutHeaders/BrandContactItem.h | cocos543/WeChatTimeLineRobot | 1e93480e502e36ca9a21a506f481aa1fcb70ac4b | [
"MIT"
] | 58 | 2016-04-28T09:52:08.000Z | 2021-12-25T06:42:14.000Z | /**
* This header is generated by class-dump-z 0.2a.
* class-dump-z is Copyright (C) 2009 by KennyTM~, licensed under GPLv3.
*
* Source: (null)
*/
#import <XXUnknownSuperclass.h> // Unknown library
@class CContact, NSString;
@interface BrandContactItem : XXUnknownSuperclass {
CContact* m_contact;
NSString* username;
}
@property(retain, nonatomic) NSString* username;
-(void).cxx_destruct;
-(id)Contact;
@end
| 20.047619 | 72 | 0.72209 |
94b6a96b3eba551587c4b4417655e78721d6dc5d | 258 | h | C | MixKit/Classes/Kernel/Socket/MKSocketEngine.h | PipeDog/MixKit | 1546f628425345da6f6c7d77099921565f95e0ae | [
"MIT"
] | null | null | null | MixKit/Classes/Kernel/Socket/MKSocketEngine.h | PipeDog/MixKit | 1546f628425345da6f6c7d77099921565f95e0ae | [
"MIT"
] | null | null | null | MixKit/Classes/Kernel/Socket/MKSocketEngine.h | PipeDog/MixKit | 1546f628425345da6f6c7d77099921565f95e0ae | [
"MIT"
] | null | null | null | //
// MKSocketEngine.h
// MoonBridge
//
// Created by liang on 2021/6/24.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol MKSocketEngine <NSObject>
- (BOOL)sendData:(id)data error:(NSError **)error;
@end
NS_ASSUME_NONNULL_END
| 13.578947 | 50 | 0.724806 |
94b77e9fe0e2fd5bdc81fee0d2b6e266254f2728 | 1,161 | h | C | FLEX/IMLEXMetadataSection.h | iMokhles/JBFlexManager | 3195bc6b88a937790ab5b4b228cb5d3ebe460f16 | [
"MIT"
] | 2 | 2022-03-06T19:22:19.000Z | 2022-03-07T12:20:37.000Z | FLEX/IMLEXMetadataSection.h | iMokhles/JBFlexManager | 3195bc6b88a937790ab5b4b228cb5d3ebe460f16 | [
"MIT"
] | null | null | null | FLEX/IMLEXMetadataSection.h | iMokhles/JBFlexManager | 3195bc6b88a937790ab5b4b228cb5d3ebe460f16 | [
"MIT"
] | null | null | null | //
// IMLEXMetadataSection.h
// IMLEX
//
// Created by Tanner Bennett on 9/19/19.
// Copyright © 2019 Flipboard. All rights reserved.
//
#import "IMLEXTableViewSection.h"
#import "IMLEXObjectExplorer.h"
typedef NS_ENUM(NSUInteger, IMLEXMetadataKind) {
IMLEXMetadataKindProperties = 1,
IMLEXMetadataKindClassProperties,
IMLEXMetadataKindIvars,
IMLEXMetadataKindMethods,
IMLEXMetadataKindClassMethods,
IMLEXMetadataKindClassHierarchy,
IMLEXMetadataKindProtocols,
IMLEXMetadataKindOther
};
/// This section is used for displaying ObjC runtime metadata
/// about a class or object, such as listing methods, properties, etc.
@interface IMLEXMetadataSection : IMLEXTableViewSection
+ (instancetype)explorer:(IMLEXObjectExplorer *)explorer kind:(IMLEXMetadataKind)metadataKind;
@property (nonatomic, readonly) IMLEXMetadataKind metadataKind;
/// The names of metadata to exclude. Useful if you wish to group specific
/// properties or methods together in their own section outside of this one.
///
/// Setting this property calls \c reloadData on this section.
@property (nonatomic) NSSet<NSString *> *excludedMetadata;
@end
| 30.552632 | 94 | 0.776916 |
94b837a3f84f90b99810f8a3e8d966edf136b612 | 270 | h | C | TestOC/Page/Mine/PBMasonry/Controllers/PBMasonryTwoController.h | shanbozhu/TestBundle | aef557c9a438302ca123825afeeb915f9443547e | [
"MIT"
] | null | null | null | TestOC/Page/Mine/PBMasonry/Controllers/PBMasonryTwoController.h | shanbozhu/TestBundle | aef557c9a438302ca123825afeeb915f9443547e | [
"MIT"
] | null | null | null | TestOC/Page/Mine/PBMasonry/Controllers/PBMasonryTwoController.h | shanbozhu/TestBundle | aef557c9a438302ca123825afeeb915f9443547e | [
"MIT"
] | null | null | null | //
// PBMasonryTwoController.h
// TestOC
//
// Created by shanbo on 2022/5/17.
// Copyright © 2022 DaMaiIOS. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface PBMasonryTwoController : UIViewController
@end
NS_ASSUME_NONNULL_END
| 15 | 52 | 0.748148 |
94ba8f4672c734ed755ce1ea02c99ac7492be3c2 | 1,973 | h | C | base/pmr/arena.h | romange/helio | 445ebf76b96b7360982f2b3c4558ec347ba3adb5 | [
"Apache-2.0"
] | 13 | 2021-12-09T19:04:01.000Z | 2022-02-20T08:49:06.000Z | base/pmr/arena.h | romange/async | 30d387fa0f2b5eee32eec570781be00157b2d07d | [
"Apache-2.0"
] | 1 | 2022-01-15T20:09:37.000Z | 2022-01-15T20:09:37.000Z | base/pmr/arena.h | romange/async | 30d387fa0f2b5eee32eec570781be00157b2d07d | [
"Apache-2.0"
] | null | null | null | // Copyright 2021, Roman Gershman. All rights reserved.
// See LICENSE for licensing terms.
//
#pragma once
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <memory_resource>
#include <vector>
namespace base {
// Used to allocate small blobs with size upto 4GB.
class PmrArena {
public:
PmrArena(std::pmr::memory_resource* mr = std::pmr::get_default_resource());
~PmrArena();
// Return a pointer to a newly allocated memory block of "bytes" bytes.
char* Allocate(size_t bytes);
// Allocate memory with the normal alignment guarantees provided by malloc
char* AllocateAligned(size_t bytes);
// Returns an estimate of the total memory usage of data allocated
// by the arena (including space allocated but not yet used for user
// allocations).
size_t MemoryUsage() const {
return blocks_memory_ + blocks_.capacity() * sizeof(char*);
}
void Swap(PmrArena& other);
private:
char* AllocateFallback(size_t bytes);
char* AllocateNewBlock(uint32_t block_bytes);
std::pmr::memory_resource* mr_;
// Allocation state
char* alloc_ptr_ = nullptr;
size_t alloc_bytes_remaining_ = 0;
// Bytes of memory in blocks allocated so far
size_t blocks_memory_ = 0;
struct Block {
char* ptr;
uint32_t sz;
} __attribute__((packed));
static_assert(sizeof(Block) == 12);
// Array of the allocated memory blocks
std::pmr::vector<Block> blocks_;
// No copying allowed
PmrArena(const PmrArena&) = delete;
void operator=(const PmrArena&) = delete;
};
inline char* PmrArena::Allocate(size_t bytes) {
// The semantics of what to return are a bit messy if we allow
// 0-byte allocations, so we disallow them here (we don't need
// them for our internal use).
assert(bytes > 0);
if (bytes <= alloc_bytes_remaining_) {
char* result = alloc_ptr_;
alloc_ptr_ += bytes;
alloc_bytes_remaining_ -= bytes;
return result;
}
return AllocateFallback(bytes);
}
} // namespace base
| 24.974684 | 77 | 0.708059 |
94bb540bfbbbab648923f484471cff6080a9463b | 20,864 | c | C | public/freetds-1.00.23/src/tds/packet.c | thepriyakadam/hrms | af7f44ac10691850487e2c412a666694680a0672 | [
"Unlicense"
] | null | null | null | public/freetds-1.00.23/src/tds/packet.c | thepriyakadam/hrms | af7f44ac10691850487e2c412a666694680a0672 | [
"Unlicense"
] | null | null | null | public/freetds-1.00.23/src/tds/packet.c | thepriyakadam/hrms | af7f44ac10691850487e2c412a666694680a0672 | [
"Unlicense"
] | null | null | null | /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
* Copyright (C) 2012 Frediano Ziglio
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#if HAVE_ERRNO_H
#include <errno.h>
#endif /* HAVE_ERRNO_H */
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif /* HAVE_STDLIB_H */
#if HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#if HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if HAVE_POLL_H
#include <poll.h>
#endif /* HAVE_POLL_H */
#include <freetds/tds.h>
#include <freetds/bytes.h>
#include <freetds/iconv.h>
#include "replacements.h"
#include <freetds/checks.h>
#undef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
/**
* \addtogroup network
* @{
*/
#if ENABLE_ODBC_MARS
static TDSRET tds_update_recv_wnd(TDSSOCKET *tds, TDS_UINT new_recv_wnd);
static short tds_packet_write(TDSCONNECTION *conn);
/* get packet from the cache */
static TDSPACKET *
tds_get_packet(TDSCONNECTION *conn, unsigned len)
{
TDSPACKET *packet, *to_free = NULL;
tds_mutex_lock(&conn->list_mtx);
while ((packet = conn->packet_cache) != NULL) {
--conn->num_cached_packets;
conn->packet_cache = packet->next;
/* return it */
if (packet->capacity >= len) {
TDS_MARK_UNDEFINED(packet->buf, packet->capacity);
packet->next = NULL;
packet->len = 0;
packet->sid = 0;
break;
}
/* discard packet if too small */
packet->next = to_free;
to_free = packet;
}
tds_mutex_unlock(&conn->list_mtx);
if (to_free)
tds_free_packets(to_free);
if (!packet)
packet = tds_alloc_packet(NULL, len);
return packet;
}
/* append packets in cached list. must have the lock! */
static void
tds_packet_cache_add(TDSCONNECTION *conn, TDSPACKET *packet)
{
TDSPACKET *last;
unsigned count = 1;
assert(conn && packet);
tds_mutex_check_owned(&conn->list_mtx);
if (conn->num_cached_packets >= 8) {
tds_free_packets(packet);
return;
}
for (last = packet; last->next; last = last->next)
++count;
last->next = conn->packet_cache;
conn->packet_cache = packet;
conn->num_cached_packets += count;
#if ENABLE_EXTRA_CHECKS
count = 0;
for (packet = conn->packet_cache; packet; packet = packet->next)
++count;
assert(count == conn->num_cached_packets);
#endif
}
/* read partial packet */
static void
tds_packet_read(TDSCONNECTION *conn, TDSSOCKET *tds)
{
TDSPACKET *packet = conn->recv_packet;
int len;
/* allocate some space to read data */
if (!packet) {
conn->recv_packet = packet = tds_get_packet(conn, MAX(conn->env.block_size + sizeof(TDS72_SMP_HEADER), 512));
if (!packet) goto Memory_Error;
TDS_MARK_UNDEFINED(packet->buf, packet->capacity);
conn->recv_pos = 0;
packet->len = 8;
}
assert(conn->recv_pos < packet->len && packet->len <= packet->capacity);
len = tds_connection_read(tds, packet->buf + conn->recv_pos, packet->len - conn->recv_pos);
if (len < 0)
goto Severe_Error;
conn->recv_pos += len;
assert(conn->recv_pos <= packet->len && packet->len <= packet->capacity);
/* handle SMP */
if (conn->recv_pos > 0 && packet->buf[0] == TDS72_SMP) {
TDS72_SMP_HEADER mars_header;
short sid;
TDSSOCKET *tds;
TDS_UINT size;
if (conn->recv_pos < 16) {
packet->len = 16;
return;
}
memcpy(&mars_header, packet->buf, sizeof(mars_header));
tdsdump_dump_buf(TDS_DBG_HEADER, "Received MARS header", &mars_header, sizeof(mars_header));
sid = TDS_GET_A2LE(&mars_header.sid);
/* FIXME this is done even by caller !! */
tds = NULL;
tds_mutex_lock(&conn->list_mtx);
if (sid >= 0 && sid < conn->num_sessions)
tds = conn->sessions[sid];
tds_mutex_unlock(&conn->list_mtx);
packet->sid = sid;
if (tds == BUSY_SOCKET) {
if (mars_header.type != TDS_SMP_FIN) {
tdsdump_log(TDS_DBG_ERROR, "Received MARS with no session (%d)\n", sid);
goto Severe_Error;
}
/* check if was just a "zombie" socket */
tds_mutex_lock(&conn->list_mtx);
conn->sessions[sid] = NULL;
tds_mutex_unlock(&conn->list_mtx);
/* reset packet to initial state to reuse it */
packet->len = 8;
conn->recv_pos = 0;
return;
}
if (!tds) {
/* server sent a unknown packet, close connection */
goto Severe_Error;
}
tds->send_wnd = TDS_GET_A4LE(&mars_header.wnd);
size = TDS_GET_A4LE(&mars_header.size);
if (mars_header.type == TDS_SMP_ACK) {
if (size != sizeof(mars_header))
goto Severe_Error;
} else if (mars_header.type == TDS_SMP_DATA) {
if (size < 0x18 || size > 0xffffu + sizeof(mars_header))
goto Severe_Error;
/* avoid recursive SMP */
if (conn->recv_pos > 16 && packet->buf[16] == TDS72_SMP)
goto Severe_Error;
/* TODO is possible to put 2 TDS packet inside a single DATA ?? */
if (conn->recv_pos >= 20 && TDS_GET_A2BE(&packet->buf[18]) != size - 16)
goto Severe_Error;
tds->recv_seq = TDS_GET_A4LE(&mars_header.seq);
/*
* does not sent ACK here cause this would lead to memory waste
* if session is not able to handle all that packets
*/
} else if (mars_header.type == TDS_SMP_FIN) {
if (size != sizeof(mars_header))
goto Severe_Error;
/* this socket shold now not start another session */
// tds_set_state(tds, TDS_DEAD);
// tds->sid = -1;
} else
goto Severe_Error;
if (mars_header.type != TDS_SMP_DATA)
return;
if (packet->len < size) {
packet = tds_realloc_packet(packet, size);
if (!packet) goto Memory_Error;
conn->recv_packet = packet;
}
packet->len = size;
return;
}
assert(conn->recv_pos <= packet->len && packet->len <= packet->capacity);
/* normal packet */
if (conn->recv_pos >= 8) {
len = TDS_GET_A2BE(&packet->buf[2]);
if (len < 8)
goto Severe_Error;
if (packet->len < len) {
packet = tds_realloc_packet(packet, len);
if (!packet) goto Memory_Error;
conn->recv_packet = packet;
}
packet->len = len;
}
return;
Memory_Error:
Severe_Error:
tds_connection_close(conn);
tds_free_packets(packet);
conn->recv_packet = NULL;
}
static void
tds_alloc_new_sid(TDSSOCKET *tds)
{
int sid = -1;
TDSCONNECTION *conn = tds->conn;
TDSSOCKET **s;
tds_mutex_lock(&conn->list_mtx);
tds->sid = -1;
for (sid = 0; sid < conn->num_sessions; ++sid)
if (!conn->sessions[sid])
break;
if (sid == conn->num_sessions) {
/* extend array */
s = (TDSSOCKET **) TDS_RESIZE(conn->sessions, sid+64);
if (!s)
goto error;
memset(s + conn->num_sessions, 0, sizeof(*s) * 64);
conn->num_sessions += 64;
}
conn->sessions[sid] = tds;
tds->sid = sid;
error:
tds_mutex_unlock(&conn->list_mtx);
}
static TDSPACKET*
tds_build_packet(TDSSOCKET *tds, unsigned char *buf, unsigned len)
{
unsigned start;
TDS72_SMP_HEADER mars[2], *p;
TDSPACKET *packet;
p = mars;
if (buf[0] != TDS72_SMP && tds->conn->mars) {
/* allocate a new sid */
if (tds->sid == -1) {
p->signature = TDS72_SMP;
p->type = TDS_SMP_SYN; /* start session */
/* FIXME check !!! */
tds_alloc_new_sid(tds);
tds->recv_seq = 0;
tds->send_seq = 0;
tds->recv_wnd = 4;
tds->send_wnd = 4;
TDS_PUT_A2LE(&p->sid, tds->sid);
p->size = TDS_HOST4LE(0x10);
p->seq = TDS_HOST4LE(0);
TDS_PUT_A4LE(&p->wnd, tds->recv_wnd);
p++;
}
if (tds->sid >= 0) {
p->signature = TDS72_SMP;
p->type = TDS_SMP_DATA;
TDS_PUT_A2LE(&p->sid, tds->sid);
TDS_PUT_A4LE(&p->size, len+16);
TDS_PUT_A4LE(&p->seq, ++tds->send_seq);
/* this is the acknowledge we give to server to stop sending !!! */
tds->recv_wnd = tds->recv_seq + 4;
TDS_PUT_A4LE(&p->wnd, tds->recv_wnd);
p++;
}
}
start = (p - mars) * sizeof(mars[0]);
packet = tds_get_packet(tds->conn, len + start);
if (TDS_LIKELY(packet)) {
packet->sid = tds->sid;
memcpy(packet->buf, mars, start);
memcpy(packet->buf + start, buf, len);
packet->len = len + start;
}
return packet;
}
static void
tds_append_packet(TDSPACKET **p_packet, TDSPACKET *packet)
{
while (*p_packet)
p_packet = &((*p_packet)->next);
*p_packet = packet;
}
int
tds_append_cancel(TDSSOCKET *tds)
{
unsigned char buf[8];
TDSPACKET *packet;
buf[0] = TDS_CANCEL;
buf[1] = 1;
TDS_PUT_A2BE(buf+2, 8);
TDS_PUT_A4(buf+4, 0);
if (IS_TDS7_PLUS(tds->conn) && !tds->login)
buf[6] = 0x01;
packet = tds_build_packet(tds, buf, 8);
if (!packet)
return TDS_FAIL;
tds_mutex_lock(&tds->conn->list_mtx);
tds_append_packet(&tds->conn->send_packets, packet);
tds_mutex_unlock(&tds->conn->list_mtx);
return TDS_SUCCESS;
}
static void
tds_connection_network(TDSCONNECTION *conn, TDSSOCKET *tds, int send)
{
assert(!conn->in_net_tds);
conn->in_net_tds = tds;
tds_mutex_unlock(&conn->list_mtx);
for (;;) {
/* wait packets or update */
int rc = tds_select(tds, conn->send_packets ? TDSSELREAD|TDSSELWRITE : TDSSELREAD, tds->query_timeout);
if (rc < 0) {
/* FIXME better error report */
tds_connection_close(conn);
break;
}
/* change notify */
/* TODO async */
if (!rc) { /* timeout */
tdsdump_log(TDS_DBG_INFO1, "timeout\n");
switch (rc = tdserror(tds_get_ctx(tds), tds, TDSETIME, sock_errno)) {
case TDS_INT_CONTINUE:
continue;
default:
case TDS_INT_CANCEL:
tds_close_socket(tds);
}
break;
}
/*
* we must write first to catch write errors as
* write errors, not as read
*/
/* something to send */
if (conn->send_packets && (rc & POLLOUT) != 0) {
TDSSOCKET *s;
short sid = tds_packet_write(conn);
if (sid == tds->sid) break; /* return to caller */
tds_mutex_lock(&conn->list_mtx);
if (sid >= 0 && sid < conn->num_sessions) {
s = conn->sessions[sid];
if (TDSSOCKET_VALID(s))
tds_cond_signal(&s->packet_cond);
}
tds_mutex_unlock(&conn->list_mtx);
/* avoid using a possible closed connection */
continue;
}
/* received */
if (rc & POLLIN) {
TDSPACKET *packet;
TDSSOCKET *s;
/* try to read a packet */
tds_packet_read(conn, tds);
packet = conn->recv_packet;
if (!packet || conn->recv_pos < packet->len) continue;
conn->recv_packet = NULL;
conn->recv_pos = 0;
tdsdump_dump_buf(TDS_DBG_NETWORK, "Received packet", packet->buf, packet->len);
tds_mutex_lock(&conn->list_mtx);
if (packet->sid >= 0 && packet->sid < conn->num_sessions) {
s = conn->sessions[packet->sid];
if (TDSSOCKET_VALID(s)) {
/* append to correct session */
if (packet->buf[0] == TDS72_SMP && packet->buf[1] != TDS_SMP_DATA)
tds_packet_cache_add(conn, packet);
else
tds_append_packet(&conn->packets, packet);
packet = NULL;
/* notify */
tds_cond_signal(&s->packet_cond);
}
}
tds_mutex_unlock(&conn->list_mtx);
tds_free_packets(packet);
/* if we are receiving return the packet */
if (!send) break;
}
}
tds_mutex_lock(&conn->list_mtx);
conn->in_net_tds = NULL;
}
static int
tds_connection_put_packet(TDSSOCKET *tds, TDSPACKET *packet)
{
TDSCONNECTION *conn = tds->conn;
if (TDS_UNLIKELY(!packet)) {
tds_close_socket(tds);
return TDS_FAIL;
}
tds->out_pos = 0;
tds_mutex_lock(&conn->list_mtx);
for (;;) {
int wait_res;
if (IS_TDSDEAD(tds)) {
tdsdump_log(TDS_DBG_NETWORK, "Write attempt when state is TDS_DEAD");
break;
}
/* limit packet sending looking at sequence/window */
if (tds->send_seq <= tds->send_wnd) {
/* append packet */
tds_append_packet(&conn->send_packets, packet);
packet = NULL;
}
/* network ok ? process network */
if (!conn->in_net_tds) {
tds_connection_network(conn, tds, packet ? 0 : 1);
if (packet) continue;
/* FIXME we are not sure we sent the packet !!! */
break;
}
/* signal thread processing network to handle our packet */
/* TODO check result */
tds_wakeup_send(&conn->wakeup, 0);
/* wait local condition */
wait_res = tds_cond_timedwait(&tds->packet_cond, &conn->list_mtx, tds->query_timeout);
if (wait_res == ETIMEDOUT
&& tdserror(tds_get_ctx(tds), tds, TDSETIME, ETIMEDOUT) != TDS_INT_CONTINUE) {
tds_mutex_unlock(&conn->list_mtx);
tds_close_socket(tds);
tds_free_packets(packet);
return TDS_FAIL;
}
}
tds_mutex_unlock(&conn->list_mtx);
if (TDS_UNLIKELY(packet)) {
tds_free_packets(packet);
return TDS_FAIL;
}
if (IS_TDSDEAD(tds))
return TDS_FAIL;
return TDS_SUCCESS;
}
#endif /* ENABLE_ODBC_MARS */
/**
* Read in one 'packet' from the server. This is a wrapped outer packet of
* the protocol (they bundle result packets into chunks and wrap them at
* what appears to be 512 bytes regardless of how that breaks internal packet
* up. (tetherow\@nol.org)
* @return bytes read or -1 on failure
*/
int
tds_read_packet(TDSSOCKET * tds)
{
#if ENABLE_ODBC_MARS
TDSCONNECTION *conn = tds->conn;
tds_mutex_lock(&conn->list_mtx);
for (;;) {
int wait_res;
TDSPACKET **p_packet;
if (IS_TDSDEAD(tds)) {
tdsdump_log(TDS_DBG_NETWORK, "Read attempt when state is TDS_DEAD\n");
break;
}
/* if there is a packet for me return it */
for (p_packet = &conn->packets; *p_packet; p_packet = &(*p_packet)->next)
if ((*p_packet)->sid == tds->sid)
break;
if (*p_packet) {
size_t hdr_size;
/* remove our packet from list */
TDSPACKET *packet = *p_packet;
*p_packet = packet->next;
tds_packet_cache_add(conn, tds->recv_packet);
tds_mutex_unlock(&conn->list_mtx);
packet->next = NULL;
tds->recv_packet = packet;
hdr_size = packet->buf[0] == TDS72_SMP ? sizeof(TDS72_SMP_HEADER) : 0;
tds->in_buf = packet->buf + hdr_size;
tds->in_len = packet->len - hdr_size;
tds->in_pos = 8;
tds->in_flag = tds->in_buf[0];
/* send acknowledge if needed */
if (tds->recv_seq + 2 >= tds->recv_wnd)
tds_update_recv_wnd(tds, tds->recv_seq + 4);
return tds->in_len;
}
/* network ok ? process network */
if (!conn->in_net_tds) {
tds_connection_network(conn, tds, 0);
continue;
}
/* wait local condition */
wait_res = tds_cond_timedwait(&tds->packet_cond, &conn->list_mtx, tds->query_timeout);
if (wait_res == ETIMEDOUT
&& tdserror(tds_get_ctx(tds), tds, TDSETIME, ETIMEDOUT) != TDS_INT_CONTINUE) {
tds_mutex_unlock(&conn->list_mtx);
tds_close_socket(tds);
return -1;
}
}
tds_mutex_unlock(&conn->list_mtx);
return -1;
#else /* !ENABLE_ODBC_MARS */
unsigned char *pkt = tds->in_buf, *p, *end;
if (IS_TDSDEAD(tds)) {
tdsdump_log(TDS_DBG_NETWORK, "Read attempt when state is TDS_DEAD");
return -1;
}
tds->in_len = 0;
tds->in_pos = 0;
for (p = pkt, end = p+8; p < end;) {
int len = tds_connection_read(tds, p, end - p);
if (len <= 0) {
tds_close_socket(tds);
return -1;
}
p += len;
if (p - pkt >= 4) {
unsigned pktlen = TDS_GET_A2BE(pkt+2);
/* packet must at least contains header */
if (TDS_UNLIKELY(pktlen < 8)) {
tds_close_socket(tds);
return -1;
}
if (TDS_UNLIKELY(pktlen > tds->recv_packet->capacity)) {
TDSPACKET *packet = tds_realloc_packet(tds->recv_packet, pktlen);
if (TDS_UNLIKELY(!packet)) {
tds_close_socket(tds);
return -1;
}
tds->recv_packet = packet;
pkt = packet->buf;
p = pkt + (p-tds->in_buf);
tds->in_buf = pkt;
}
end = pkt + pktlen;
}
}
/* set the received packet type flag */
tds->in_flag = pkt[0];
/* Set the length and pos (not sure what pos is used for now */
tds->in_len = p - pkt;
tds->in_pos = 8;
tdsdump_dump_buf(TDS_DBG_NETWORK, "Received packet", tds->in_buf, tds->in_len);
return tds->in_len;
#endif /* !ENABLE_ODBC_MARS */
}
#if ENABLE_ODBC_MARS
static TDSRET
tds_update_recv_wnd(TDSSOCKET *tds, TDS_UINT new_recv_wnd)
{
TDS72_SMP_HEADER *mars;
TDSPACKET *packet;
if (!tds->conn->mars || tds->sid < 0)
return TDS_SUCCESS;
packet = tds_get_packet(tds->conn, sizeof(*mars));
if (!packet)
return TDS_FAIL; /* TODO check result */
packet->len = sizeof(*mars);
packet->sid = tds->sid;
mars = (TDS72_SMP_HEADER *) packet->buf;
mars->signature = TDS72_SMP;
mars->type = TDS_SMP_ACK;
TDS_PUT_A2LE(&mars->sid, tds->sid);
mars->size = TDS_HOST4LE(16);
TDS_PUT_A4LE(&mars->seq, tds->send_seq);
tds->recv_wnd = new_recv_wnd;
TDS_PUT_A4LE(&mars->wnd, tds->recv_wnd);
tds_mutex_lock(&tds->conn->list_mtx);
tds_append_packet(&tds->conn->send_packets, packet);
tds_mutex_unlock(&tds->conn->list_mtx);
return TDS_SUCCESS;
}
TDSRET
tds_append_fin(TDSSOCKET *tds)
{
TDS72_SMP_HEADER mars;
TDSPACKET *packet;
if (!tds->conn->mars || tds->sid < 0)
return TDS_SUCCESS;
mars.signature = TDS72_SMP;
mars.type = TDS_SMP_FIN;
TDS_PUT_A2LE(&mars.sid, tds->sid);
mars.size = TDS_HOST4LE(16);
TDS_PUT_A4LE(&mars.seq, tds->send_seq);
tds->recv_wnd = tds->recv_seq + 4;
TDS_PUT_A4LE(&mars.wnd, tds->recv_wnd);
/* do not use tds_get_packet as it require no lock ! */
packet = tds_alloc_packet(&mars, sizeof(mars));
if (!packet)
return TDS_FAIL; /* TODO check result */
packet->sid = tds->sid;
/* we already hold lock so do not lock */
tds_append_packet(&tds->conn->send_packets, packet);
/* now is no more an active session */
tds->conn->sessions[tds->sid] = BUSY_SOCKET;
tds_set_state(tds, TDS_DEAD);
tds->sid = -1;
return TDS_SUCCESS;
}
#endif /* ENABLE_ODBC_MARS */
TDSRET
tds_write_packet(TDSSOCKET * tds, unsigned char final)
{
int res;
unsigned int left = 0;
#if TDS_ADDITIONAL_SPACE != 0
if (tds->out_pos > tds->out_buf_max) {
left = tds->out_pos - tds->out_buf_max;
tds->out_pos = tds->out_buf_max;
}
#endif
/* we must assure server can accept our packet looking at
* send_wnd and waiting for proper send_wnd if send_seq > send_wnd
*/
tds->out_buf[0] = tds->out_flag;
tds->out_buf[1] = final;
TDS_PUT_A2BE(tds->out_buf+2, tds->out_pos);
TDS_PUT_A2BE(tds->out_buf+4, tds->conn->client_spid);
TDS_PUT_A2(tds->out_buf+6, 0);
if (IS_TDS7_PLUS(tds->conn) && !tds->login)
tds->out_buf[6] = 0x01;
#if ENABLE_ODBC_MARS
res = tds_connection_put_packet(tds, tds_build_packet(tds, tds->out_buf, tds->out_pos));
#else /* !ENABLE_ODBC_MARS */
tdsdump_dump_buf(TDS_DBG_NETWORK, "Sending packet", tds->out_buf, tds->out_pos);
/* GW added in check for write() returning <0 and SIGPIPE checking */
res = tds_connection_write(tds, tds->out_buf, tds->out_pos, final) <= 0 ?
TDS_FAIL : TDS_SUCCESS;
#endif /* !ENABLE_ODBC_MARS */
#if TDS_ADDITIONAL_SPACE != 0
memcpy(tds->out_buf + 8, tds->out_buf + tds->out_buf_max, left);
#endif
tds->out_pos = left + 8;
return res;
}
#if !ENABLE_ODBC_MARS
int
tds_put_cancel(TDSSOCKET * tds)
{
unsigned char out_buf[8];
int sent;
out_buf[0] = TDS_CANCEL; /* out_flag */
out_buf[1] = 1; /* final */
out_buf[2] = 0;
out_buf[3] = 8;
TDS_PUT_A4(out_buf+4, 0);
if (IS_TDS7_PLUS(tds->conn) && !tds->login)
out_buf[6] = 0x01;
tdsdump_dump_buf(TDS_DBG_NETWORK, "Sending packet", out_buf, 8);
sent = tds_connection_write(tds, out_buf, 8, 1);
if (sent > 0)
tds->in_cancel = 2;
/* GW added in check for write() returning <0 and SIGPIPE checking */
return sent <= 0 ? TDS_FAIL : TDS_SUCCESS;
}
#endif /* !ENABLE_ODBC_MARS */
#if ENABLE_ODBC_MARS
static short
tds_packet_write(TDSCONNECTION *conn)
{
int sent;
int final;
TDSPACKET *packet = conn->send_packets;
assert(packet);
if (conn->send_pos == 0)
tdsdump_dump_buf(TDS_DBG_NETWORK, "Sending packet", packet->buf, packet->len);
/* take into account other session packets */
if (packet->next != NULL)
final = 0;
/* take into account other packets for this session */
else if (packet->buf[0] != TDS72_SMP)
final = packet->buf[1] & 1;
else if (packet->len >= sizeof(TDS72_SMP_HEADER) + 2)
final = packet->buf[sizeof(TDS72_SMP_HEADER) + 1] & 1;
else
final = 1;
sent = tds_connection_write(conn->in_net_tds, packet->buf + conn->send_pos,
packet->len - conn->send_pos, final);
if (TDS_UNLIKELY(sent < 0)) {
/* TODO tdserror called ?? */
tds_connection_close(conn);
return -1;
}
/* update sent data */
conn->send_pos += sent;
/* remove packet if sent all data */
if (conn->send_pos >= packet->len) {
short sid = packet->sid;
tds_mutex_lock(&conn->list_mtx);
conn->send_packets = packet->next;
packet->next = NULL;
tds_packet_cache_add(conn, packet);
tds_mutex_unlock(&conn->list_mtx);
conn->send_pos = 0;
return sid;
}
return -1;
}
#endif /* ENABLE_ODBC_MARS */
/** @} */
| 24.956938 | 111 | 0.667609 |
94bb63fbf2368d5e1148a1a6ccf0127ca8a13e1e | 32,577 | c | C | tests/unit/bugfix/misc-D78459-absolute-jump-correct-offset.c | dylanmckay/avr-test-suite | 1f6459c1da3480876912ec0dbed5d86e327910a4 | [
"MIT"
] | 4 | 2019-03-26T13:32:48.000Z | 2020-10-12T00:45:54.000Z | tests/unit/bugfix/misc-D78459-absolute-jump-correct-offset.c | dylanmckay/avr-test-suite | 1f6459c1da3480876912ec0dbed5d86e327910a4 | [
"MIT"
] | 2 | 2017-11-16T13:12:02.000Z | 2018-10-12T13:04:47.000Z | tests/unit/bugfix/misc-D78459-absolute-jump-correct-offset.c | dylanmckay/avr-compiler-integration-tests | 1f6459c1da3480876912ec0dbed5d86e327910a4 | [
"MIT"
] | null | null | null | // RUN: @cxx @cxxflags -mmcu=atmega328p @file -o @tempfile -O0 && avr-sim @tempfile -w TEST_STATE=u8
//
// An integration test for https://reviews.llvm.org/D78459
//
// Before D78459, this test case results in a miscompilation (invalid pointer) and the simulator
// crashes when jumping ahead of the intended symbol.
// With D78459, this test case succeeds.
#include <avrlit/boilerplate/unit_test.h>
#define STATE_READY (1<<0)
#define STATE_SEEN_BAR (1<<1)
uint8_t TEST_STATE = STATE_READY;
// Expect the test state to be initialized to 'ready'.
// CHECK: changed(TEST_STATE) = 1
void bar(void) {
// Expect the test state to later include to 'STATE_SEEN_BAR'.
// CHECK: changed(TEST_STATE) = 3
TEST_STATE |= STATE_SEEN_BAR;
}
void unit_test(void) {
for (int i=0; i<2; ++i) {
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
__asm__ __volatile__("nop");
bar();
}
}
| 30.90797 | 100 | 0.709611 |
94bb9901179e80c53104ac0702cc239df4ed760b | 472 | h | C | CalibCalorimetry/CastorCalib/interface/CastorAlgoUtils.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 1 | 2019-08-09T08:42:11.000Z | 2019-08-09T08:42:11.000Z | CalibCalorimetry/CastorCalib/interface/CastorAlgoUtils.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | null | null | null | CalibCalorimetry/CastorCalib/interface/CastorAlgoUtils.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 1 | 2019-04-03T19:23:27.000Z | 2019-04-03T19:23:27.000Z | #ifndef DQM_CASTORALGOUTILS_H
#define DQM_CASTORALGOUTILS_H
#include "CalibFormats/CastorObjects/interface/CastorDbService.h"
#include "CondFormats/CastorObjects/interface/CastorQIECoder.h"
namespace reco {
namespace castor {
void getLinearizedADC(const CastorQIEShape& shape,
const CastorQIECoder* coder,
int bins,int capid,
float& lo,
float& hi);
float maxDiff(float one, float two, float three, float four);
}
}
#endif
| 21.454545 | 65 | 0.726695 |
94be64340f25ef61433742186e4caef60674b477 | 1,612 | h | C | mainwindow.h | larsnaesbye/astrotime | 90309ad5e4a4d5b3a01318b7204597409ab1eb7b | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 2 | 2015-07-21T20:10:04.000Z | 2017-02-21T01:10:48.000Z | mainwindow.h | larsnaesbye/astrotime | 90309ad5e4a4d5b3a01318b7204597409ab1eb7b | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 12 | 2015-07-21T18:03:29.000Z | 2022-03-02T21:20:24.000Z | mainwindow.h | larsnaesbye/astrotime | 90309ad5e4a4d5b3a01318b7204597409ab1eb7b | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | /*
Copyright 2015 - Lars Næsbye Christensen
This is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
The software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QStatusBar>
#include <QDateTime>
#include "settings.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
Settings tempussettings;
protected:
void resizeEvent(QResizeEvent* event) override;
private:
Ui::MainWindow *ui;
public slots:
void about();
void setlocation();
void UpdateTimeSystemLabel();
QString GetTimeString();
QDateTime GMST();
QDateTime LST();
double JulianDay();
double JulianDayModified();
void PrintFormattedTime();
void setutc();
void setlocal();
void setgmst();
void setlst();
void setjd();
void setjdm();
void setlatitude(double inputlat);
void setlongitude(double inputlong);
};
#endif // MAINWINDOW_H
| 23.028571 | 73 | 0.707196 |
94bfbc55c7f476ce550cae1d5413100bc05cfb25 | 2,552 | c | C | src/ltc_generator.c | bathtaters/wavbuild | ed835e5c2d645b8d58107761434767ae14b9ea17 | [
"MIT"
] | 3 | 2019-11-04T13:43:12.000Z | 2022-02-09T09:01:46.000Z | src/ltc_generator.c | bathtaters/wavbuild | ed835e5c2d645b8d58107761434767ae14b9ea17 | [
"MIT"
] | 5 | 2018-05-08T19:55:08.000Z | 2019-07-23T18:39:27.000Z | src/ltc_generator.c | bathtaters/wavbuild | ed835e5c2d645b8d58107761434767ae14b9ea17 | [
"MIT"
] | null | null | null | /*
LTC AUDIO GENERATOR
(Use with 'BUILD WAVE FILE')
*/
#include "ltc_generator.h"
// HELPER FUNCITONS
// BIT FUNCTIONS
uint8_t getBit(uint8_t * bytes, int offset) {
return (bytes[offset/8] >> (offset%8)) & 1;
}
void setBit(uint8_t * bytes, int offset, uint8_t value) {
if(value) { bytes[offset/8] = bytes[offset/8] | (1 << (offset%8)); }
else { bytes[offset/8] = bytes[offset/8] & ~(1 << (offset%8)); }
}
uint8_t onesEParity(LtcFrame data, int bitCount) {
uint8_t isOdd = 0;
for(int b = 0; b < bitCount / 8; b++) {
if(bitCount < (b+1) * 8)
{ data.bytes[b] &= (0xFF >> (8 - (bitCount % 8))); }
while(data.bytes[b] != 0) {
data.bytes[b] &= data.bytes[b] - 1;
isOdd = !isOdd;
}
}
return isOdd;
}
// LTC FUNCTIONS
LtcFrame getLtc(Timecode * inTC) {
uint8_t * tcArr = getTCarr(inTC);
LtcFrame data;
// TC & User bits
for(int b = 0; b < 4; b++) {
data.bytes[b*2] = ((tcArr[3-b]%10) & 0xF) | ((inTC->userBits[3-b] << 4) & 0xF0);
data.bytes[b*2+1] = ((tcArr[3-b]/10) & 0xF) | (inTC->userBits[3-b] & 0xF0);
}
free(tcArr);
// Sync-word
data.bytes[8] = (uint8_t)( SYNCWORD & 0xFF);
data.bytes[9] = (uint8_t)((SYNCWORD >> 8) & 0xFF);
// Standard bits
setBit(data.bytes, 10, inTC->isDropFrame); // DropFrame
setBit(data.bytes, 11, 0); // Color-framing bit
setBit(data.bytes, 58, inTC->tcClockFmt); // BGF1
// FPS-specific bits (Includes even-parity bit)
setBit(data.bytes, inTC->frameRate == 25 ? 27 : 43, inTC->userBitsFmt & 1); // BGF0
setBit(data.bytes, inTC->frameRate == 25 ? 43 : 59, inTC->userBitsFmt & 2); // BGF2
setBit(data.bytes, inTC->frameRate == 25 ? 59 : 27, onesEParity(data, 64)); // Even-parity
return data;
}
// MAIN FUNCTION
float ltcGenerator(double second, GenSetting in) {
static int fps;
static double bps;
static LtcFrame currentFrame;
static double frameBound, bitBound, flipBound;
static float value = -LTC_START_VAL;
if(second == 0.0) {
// Initialize statics
fps = in.tc->frameRate;
if(fps > 30) { fps /= 2; }
bps = 80.0 * fps;
flipBound = 0.5 / bps;
}
if(second >= frameBound) {
currentFrame = getLtc(in.tc);
in.tc->frames++;
while(frameBound <= second)
{ frameBound += 1.0 / fps; }
}
if(second >= bitBound) {
value = -value;
while(bitBound <= second)
{ bitBound += 1.0 / bps; }
}
if(second >= flipBound) {
if(getBit(currentFrame.bytes, floor((second - floor(second * fps) / fps) * bps)))
{ value = -value; }
while(flipBound <= second)
{ flipBound += 1.0 / bps; }
}
return value;
} | 24.304762 | 91 | 0.605408 |
94c2155e63423059b7cdd0178a949ba65ebc35ad | 111,693 | c | C | src/scenes/level.c | DroidSparks/opensurge | 7ffb82c5c8e135337c097bbf58a258cc93324d89 | [
"CC-BY-3.0"
] | 1 | 2021-12-11T21:45:56.000Z | 2021-12-11T21:45:56.000Z | src/scenes/level.c | DroidSparks/opensurge | 7ffb82c5c8e135337c097bbf58a258cc93324d89 | [
"CC-BY-3.0"
] | null | null | null | src/scenes/level.c | DroidSparks/opensurge | 7ffb82c5c8e135337c097bbf58a258cc93324d89 | [
"CC-BY-3.0"
] | null | null | null | /*
* Open Surge Engine
* level.c - code for the game levels
* Copyright (C) 2008-2012 Alexandre Martins <alemartf(at)gmail(dot)com>
* http://opensnc.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include "level.h"
#include "confirmbox.h"
#include "gameover.h"
#include "pause.h"
#include "quest.h"
#include "../core/scene.h"
#include "../core/storyboard.h"
#include "../core/global.h"
#include "../core/input.h"
#include "../core/fadefx.h"
#include "../core/video.h"
#include "../core/audio.h"
#include "../core/timer.h"
#include "../core/sprite.h"
#include "../core/osspec.h"
#include "../core/stringutil.h"
#include "../core/logfile.h"
#include "../core/lang.h"
#include "../core/soundfactory.h"
#include "../core/nanoparser/nanoparser.h"
#include "../core/font.h"
#include "../entities/actor.h"
#include "../entities/brick.h"
#include "../entities/player.h"
#include "../entities/item.h"
#include "../entities/enemy.h"
#include "../entities/camera.h"
#include "../entities/background.h"
#include "../entities/particle.h"
#include "../entities/renderqueue.h"
#include "../entities/items/flyingtext.h"
#include "../entities/entitymanager.h"
#include "util/editorgrp.h"
/* ------------------------
* Dialog Regions
*
* If the player gets inside
* these regions, a dialog
* box appears
* ------------------------ */
/* constants */
#define DIALOGREGION_MAX 100
/* structure */
typedef struct {
int rect_x, rect_y, rect_w, rect_h; /* region data */
char title[128], message[1024]; /* dialog box data */
int disabled; /* TRUE if this region is disabled */
} dialogregion_t;
/* internal data */
static int dialogregion_size; /* size of the vector */
static dialogregion_t dialogregion[DIALOGREGION_MAX];
/* internal methods */
static void update_dialogregions();
/* ------------------------
* Startup objects
* ------------------------ */
#define DEFAULT_STARTUP_OBJECT ".default_startup"
typedef struct startupobject_list_t startupobject_list_t;
struct startupobject_list_t {
char *object_name;
startupobject_list_t *next;
};
static startupobject_list_t *startupobject_list;
static void init_startup_object_list();
static void release_startup_object_list();
static void add_to_startup_object_list(const char *object_name);
static void spawn_startup_objects();
/* ------------------------
* Level
* ------------------------ */
/* constants */
#define DEFAULT_MARGIN (VIDEO_SCREEN_W/2)
#define MAX_POWERUPS 10
#define DLGBOX_MAXTIME 7000
#define TEAM_MAX 16
#define DEFAULT_WATERLEVEL INFINITY
#define DEFAULT_WATERCOLOR image_rgb(0,32,192)
/* level attributes */
static char file[1024];
static char name[1024];
static char musicfile[1024];
static char theme[1024];
static char bgtheme[1024];
static char grouptheme[1024];
static char author[1024];
static char version[1024];
static int act;
static int requires[3]; /* this level requires engine version x.y.z */
static int readonly; /* we can't activate the level editor */
/* internal data */
static float gravity;
static int level_width;/* width of this level (in pixels) */
static int level_height; /* height of this level (in pixels) */
static float level_timer;
static v2d_t spawn_point;
static music_t *music;
static sound_t *override_music;
static int block_music;
static int quit_level;
static image_t *quit_level_img;
static bgtheme_t *backgroundtheme;
static int must_load_another_level;
static int must_restart_this_level;
static int must_push_a_quest;
static char quest_to_be_pushed[1024];
static float dead_player_timeout;
static int waterlevel; /* in pixels */
static uint32 watercolor;
/* player data */
static player_t *team[TEAM_MAX]; /* players */
static int team_size; /* size of team[] */
static player_t *player; /* reference to the current player */
/* camera */
static actor_t *camera_focus;
/* scripting controlled variables */
static int level_cleared; /* display the level cleared animation */
static int jump_to_next_stage; /* jumps to the next stage in the quest */
static int wants_to_leave; /* wants to abort the level */
static int wants_to_pause; /* wants to pause the level */
/* dialog box */
static int dlgbox_active;
static uint32 dlgbox_starttime;
static actor_t *dlgbox;
static font_t *dlgbox_title, *dlgbox_message;
/* level management */
static void level_load(const char *filepath);
static void level_unload();
static int level_save(const char *filepath);
static void level_interpret_line(const char *filename, int fileline, const char *line);
static void level_interpret_parsed_line(const char *filename, int fileline, const char *identifier, int param_count, const char **param);
/* internal methods */
static int inside_screen(int x, int y, int w, int h, int margin);
static int get_brick_id(brick_t *b);
static void update_level_size();
static void restart(int preserve_current_spawnpoint);
static void render_players(int bring_to_back);
static void update_music();
static void spawn_players();
static void render_entities(brick_list_t *major_bricks, item_list_t *major_items, enemy_list_t *major_enemies); /* render bricks, items, enemies, players, etc. */
static void render_hud(enemy_list_t *major_enemies); /* gui / hud related */
static void render_powerups(); /* gui / hud related */
static void render_dlgbox(); /* dialog boxes */
static void update_dlgbox(); /* dialog boxes */
static void reconfigure_players_input_devices();
static void render_water();
/* ------------------------
* Level Editor
* ------------------------ */
/*
IMPORTANT:
1. an object is a custom object made by the user
2. an entity may be: a brick, a built-in item or an object made by the user
Object categories are defined by the user
Entity classes are: bricks, items and objects
*/
/* constants */
#define EDITOR_BGFILE "images/editorbg.png"
/* methods */
static void editor_init();
static void editor_release();
static void editor_enable();
static void editor_disable();
static void editor_update();
static void editor_render();
static int editor_is_enabled();
static int editor_want_to_activate();
static void editor_render_background();
static void editor_moveable_platforms_path_render(brick_list_t *major_bricks);
static void editor_waterline_render(int ycoord, uint32 color);
static void editor_save();
static void editor_scroll();
static int editor_is_eraser_enabled();
/* object type */
enum editor_entity_type {
EDT_BRICK,
EDT_ITEM,
EDT_ENEMY,
EDT_GROUP
};
#define EDITORGRP_ENTITY_TO_EDT(t) \
( ((t) == EDITORGRP_ENTITY_BRICK) ? EDT_BRICK : \
((t) == EDITORGRP_ENTITY_ITEM) ? EDT_ITEM : \
EDT_ENEMY );
/* internal stuff */
static int editor_enabled; /* is the level editor enabled? */
static int editor_previous_video_resolution;
static int editor_previous_video_smooth;
static image_t *editor_bgimage;
static input_t *editor_mouse;
static input_t *editor_keyboard, *editor_keyboard2, *editor_keyboard3;
static v2d_t editor_camera, editor_cursor;
static enum editor_entity_type editor_cursor_entity_type;
static int editor_cursor_entity_id, editor_cursor_itemid;
static font_t *editor_cursor_font;
static font_t *editor_properties_font;
static font_t *editor_help_font;
static const char* editor_entity_class(enum editor_entity_type objtype);
static const char* editor_entity_info(enum editor_entity_type objtype, int objid);
static const char* editor_enemy_annotation(const char *name);
static void editor_next_class();
static void editor_previous_class();
static void editor_next_entity();
static void editor_previous_entity();
static int editor_item_list[] = {
IT_RING, IT_LIFEBOX, IT_RINGBOX, IT_STARBOX, IT_SPEEDBOX, IT_GLASSESBOX, IT_TRAPBOX,
IT_SHIELDBOX, IT_FIRESHIELDBOX, IT_THUNDERSHIELDBOX, IT_WATERSHIELDBOX,
IT_ACIDSHIELDBOX, IT_WINDSHIELDBOX,
IT_LOOPGREEN, IT_LOOPYELLOW,
IT_YELLOWSPRING, IT_BYELLOWSPRING, IT_RYELLOWSPRING, IT_LYELLOWSPRING,
IT_TRYELLOWSPRING, IT_TLYELLOWSPRING, IT_BRYELLOWSPRING, IT_BLYELLOWSPRING,
IT_REDSPRING, IT_BREDSPRING, IT_RREDSPRING, IT_LREDSPRING,
IT_TRREDSPRING, IT_TLREDSPRING, IT_BRREDSPRING, IT_BLREDSPRING,
IT_BLUESPRING, IT_BBLUESPRING, IT_RBLUESPRING, IT_LBLUESPRING,
IT_TRBLUESPRING, IT_TLBLUESPRING, IT_BRBLUESPRING, IT_BLBLUESPRING,
IT_BLUERING, IT_SWITCH, IT_DOOR, IT_TELEPORTER, IT_BIGRING, IT_CHECKPOINT, IT_GOAL,
IT_ENDSIGN, IT_ENDLEVEL, IT_BUMPER,
IT_DANGER, IT_VDANGER, IT_FIREDANGER, IT_VFIREDANGER,
IT_SPIKES, IT_CEILSPIKES, IT_LWSPIKES, IT_RWSPIKES, IT_PERSPIKES,
IT_PERCEILSPIKES, IT_PERLWSPIKES, IT_PERRWSPIKES, IT_DNADOOR, IT_DNADOORNEON,
IT_DNADOORCHARGE, IT_HDNADOOR, IT_HDNADOORNEON, IT_HDNADOORCHARGE,
-1 /* -1 represents the end of this list */
};
static int editor_item_list_size; /* counted automatically */
static int editor_item_list_get_index(int item_id);
int editor_is_valid_item(int item_id); /* this is used by editorgrp */
static void editor_draw_object(enum editor_entity_type obj_type, int obj_id, v2d_t position);
/* editor: enemy name list */
static const char** editor_enemy_name;
static int editor_enemy_name_length;
int editor_enemy_name2key(const char *name);
const char* editor_enemy_key2name(int key);
/* editor: enemy category list */
static const char** editor_enemy_category;
static int editor_enemy_category_length;
static int editor_enemy_selected_category_id; /* a value between 0 and editor_enemy_category_length - 1, inclusive */
static const char* editor_enemy_selected_category();
static void editor_next_object_category();
static void editor_previous_object_category();
/* editor: brick layer */
static bricklayer_t editor_layer;
/* editor: grid */
#define EDITOR_GRID_W (int)(editor_grid_size().x)
#define EDITOR_GRID_H (int)(editor_grid_size().y)
static int editor_grid_enabled; /* is the grid enabled? */
static void editor_grid_init();
static void editor_grid_release();
static void editor_grid_update();
static void editor_grid_render();
static v2d_t editor_grid_size(); /* returns the size of the grid */
static v2d_t editor_grid_snap(v2d_t position); /* aligns position to a cell in the grid */
/* implementing UNDO and REDO */
/* in order to implement UNDO and REDO,
* we must register the actions of the
* user */
/* action type */
enum editor_action_type {
EDA_NEWOBJECT,
EDA_DELETEOBJECT,
EDA_CHANGESPAWN,
EDA_RESTORESPAWN
};
/* action = action type + action properties */
typedef struct editor_action_t {
enum editor_action_type type;
enum editor_entity_type obj_type;
int obj_id;
v2d_t obj_position;
v2d_t obj_old_position;
bricklayer_t layer;
} editor_action_t;
/* action: constructors */
static editor_action_t editor_action_entity_new(int is_new_object, enum editor_entity_type obj_type, int obj_id, v2d_t obj_position);
static editor_action_t editor_action_spawnpoint_new(int is_changing, v2d_t obj_position, v2d_t obj_old_position);
/* linked list */
typedef struct editor_action_list_t {
editor_action_t action; /* node data */
int in_group; /* is this element part of a group? */
uint32 group_key; /* internal use (used only if in_group is true) */
struct editor_action_list_t *prev, *next; /* linked list: pointers */
} editor_action_list_t;
/* data */
editor_action_list_t *editor_action_buffer;
editor_action_list_t *editor_action_buffer_head; /* sentinel */
editor_action_list_t *editor_action_buffer_cursor;
/* methods */
static void editor_action_init();
static void editor_action_release();
static void editor_action_undo();
static void editor_action_redo();
static void editor_action_commit(editor_action_t action);
static void editor_action_register(editor_action_t action); /* internal */
static editor_action_list_t* editor_action_delete_list(editor_action_list_t *list); /* internal */
/* level-specific functions */
/*
* level_load()
* Loads a level from a file
*/
void level_load(const char *filepath)
{
char abs_path[1024], line[1024];
FILE* fp;
setlocale(LC_NUMERIC, "C"); /* bugfix */
logfile_message("level_load(\"%s\")", filepath);
resource_filepath(abs_path, filepath, sizeof(abs_path), RESFP_READ);
/* default values */
strcpy(name, "Untitled");
strcpy(musicfile, "");
strcpy(theme, "");
strcpy(bgtheme, "");
strcpy(author, "");
strcpy(version, "");
strcpy(grouptheme, "");
str_cpy(file, filepath, sizeof(file)); /* it's the relative filepath we want */
spawn_point = v2d_new(0,0);
dialogregion_size = 0;
act = 0;
requires[0] = GAME_VERSION;
requires[1] = GAME_SUB_VERSION;
requires[2] = GAME_WIP_VERSION;
readonly = FALSE;
waterlevel = DEFAULT_WATERLEVEL;
watercolor = DEFAULT_WATERCOLOR;
/* entity manager */
entitymanager_init();
/* startup objects (1) */
init_startup_object_list();
/* traversing the level file */
fp = fopen(abs_path, "r");
if(fp != NULL) {
int ln = 0;
while(fgets(line, sizeof(line) / sizeof(char), fp)) {
line[strlen(line)-1] = 0; /* no newlines, please! */
level_interpret_line(abs_path, ++ln, line);
}
fclose(fp);
}
else
fatal_error("Can\'t open level file \"%s\".", abs_path);
/* players */
if(team_size == 0) {
/* default players */
logfile_message("loading the default players...");
team[team_size++] = player_create("Surge");
team[team_size++] = player_create("Neon");
team[team_size++] = player_create("Charge");
}
level_change_player(team[0]);
spawn_players();
camera_init();
camera_set_position(player->actor->position);
player_set_collectibles(0);
/* startup objects (2) */
spawn_startup_objects();
/* load the music */
block_music = FALSE;
music = music_load(musicfile);
/* misc */
update_level_size();
backgroundtheme = background_load(bgtheme);
/* success! */
logfile_message("level_load() ok");
}
/*
* level_unload()
* Call manually after level_load() whenever
* this level has to be released or changed
*/
void level_unload()
{
int i;
logfile_message("level_unload()");
music_stop();
music_unref(musicfile);
music_unref("musics/invincible.ogg");
music_unref("musics/speed.ogg");
/* releases the startup object list */
release_startup_object_list();
/* entity manager */
entitymanager_release();
/* unloading the brickset */
logfile_message("unloading the brickset...");
brickdata_unload();
/* unloading the background */
logfile_message("unloading the background...");
backgroundtheme = background_unload(backgroundtheme);
/* destroying the players */
logfile_message("unloading the players...");
for(i=0; i<team_size; i++)
player_destroy(team[i]);
team_size = 0;
player = NULL;
/* success! */
logfile_message("level_unload() ok");
}
/*
* level_save()
* Saves the current level to a file
* Returns TRUE on success
*/
int level_save(const char *filepath)
{
int i;
FILE *fp;
char abs_path[1024];
brick_list_t *itb, *brick_list;
item_list_t *iti, *item_list;
enemy_list_t *ite, *object_list;
startupobject_list_t *its;
brick_list = entitymanager_retrieve_all_bricks();
item_list = entitymanager_retrieve_all_items();
object_list = entitymanager_retrieve_all_objects();
resource_filepath(abs_path, filepath, sizeof(abs_path), RESFP_WRITE);
/* open for writing */
logfile_message("level_save(\"%s\")", abs_path);
if(NULL == (fp=fopen(abs_path, "w"))) {
logfile_message("Warning: could not open \"%s\" for writing.", abs_path);
video_showmessage("Could not open \"%s\" for writing.", abs_path);
return FALSE;
}
/* meta information */
fprintf(fp,
"// ------------------------------------------------------------\n"
"// %s %d.%d.%d level\n"
"// This file was generated by the built-in level editor.\n"
"// ------------------------------------------------------------\n"
"\n"
"// header\n"
"name \"%s\"\n"
"author \"%s\"\n"
"version \"%s\"\n"
"requires %d.%d.%d\n"
"act %d\n"
"theme \"%s\"\n"
"bgtheme \"%s\"\n"
"spawn_point %d %d\n",
GAME_TITLE, GAME_VERSION, GAME_SUB_VERSION, GAME_WIP_VERSION,
str_addslashes(name), author, version, GAME_VERSION, GAME_SUB_VERSION, GAME_WIP_VERSION, act, theme, bgtheme,
(int)spawn_point.x, (int)spawn_point.y);
/* music? */
if(strcmp(musicfile, "") != 0)
fprintf(fp, "music \"%s\"\n", musicfile);
/* grouptheme? */
if(strcmp(grouptheme, "") != 0)
fprintf(fp, "grouptheme \"%s\"\n", grouptheme);
/* startup objects? */
fprintf(fp, "startup");
for(its=startupobject_list; its; its=its->next)
fprintf(fp, " \"%s\"", str_addslashes(its->object_name));
fprintf(fp, "\n");
/* players */
fprintf(fp, "players");
for(i=0; i<team_size; i++)
fprintf(fp, " \"%s\"", str_addslashes(team[i]->name));
fprintf(fp, "\n");
/* read only? */
if(readonly)
fprintf(fp, "readonly\n");
/* water */
if(waterlevel != DEFAULT_WATERLEVEL)
fprintf(fp, "waterlevel %d\n", waterlevel);
if(watercolor != DEFAULT_WATERCOLOR) {
uint8 r, g, b;
image_color2rgb(watercolor, &r, &g, &b);
fprintf(fp, "watercolor %d %d %d\n", r, g, b);
}
/* dialog regions */
fprintf(fp, "\n// dialog regions (xpos ypos width height title message)\n");
for(i=0; i<dialogregion_size; i++) {
char title[1024], message[1024];
str_cpy(title, str_addslashes(dialogregion[i].title), sizeof(title));
str_cpy(message, str_addslashes(dialogregion[i].message), sizeof(message));
fprintf(fp, "dialogbox %d %d %d %d \"%s\" \"%s\"\n", dialogregion[i].rect_x, dialogregion[i].rect_y, dialogregion[i].rect_w, dialogregion[i].rect_h, title, message);
}
/* brick list */
fprintf(fp, "\n// brick list\n");
for(itb=brick_list; itb; itb=itb->next) {
if(itb->data->state != BRS_DEAD)
fprintf(fp, "brick %d %d %d%s%s\n", get_brick_id(itb->data), (int)itb->data->sx, (int)itb->data->sy, itb->data->layer != BRL_DEFAULT ? " " : "", itb->data->layer != BRL_DEFAULT ? bricklayer2colorname(itb->data->layer) : "");
}
/* item list */
fprintf(fp, "\n// item list\n");
for(iti=item_list; iti; iti=iti->next) {
if(iti->data->state != IS_DEAD)
fprintf(fp, "item %d %d %d\n", iti->data->type, (int)iti->data->actor->spawn_point.x, (int)iti->data->actor->spawn_point.y);
}
/* object list */
fprintf(fp, "\n// object list\n");
for(ite=object_list; ite; ite=ite->next) {
if(ite->data->created_from_editor && ite->data->state != ES_DEAD)
fprintf(fp, "object \"%s\" %d %d\n", str_addslashes(ite->data->name), (int)ite->data->actor->spawn_point.x, (int)ite->data->actor->spawn_point.y);
}
/* done! */
fprintf(fp, "\n// EOF");
fclose(fp);
logfile_message("level_save() ok");
brick_list = entitymanager_release_retrieved_brick_list(brick_list);
item_list = entitymanager_release_retrieved_item_list(item_list);
object_list = entitymanager_release_retrieved_object_list(object_list);
return TRUE;
}
/*
* level_interpret_line()
* Interprets a line from the .lev file
*/
void level_interpret_line(const char *filename, int fileline, const char *line)
{
int param_count;
char *param[1024], *identifier;
char tmp[1024], *p, *q;
int i;
/* skip spaces */
for(p=(char*)line; isspace((int)*p); p++);
if(0 == *p) return;
/* reading the identifier */
for(q=tmp; *p && !isspace(*p) && q<tmp+1023; *q++ = *p++); *q=0;
if(tmp[0] == '/' && tmp[1] == '/') return; /* comment */
identifier = str_dup(tmp);
/* skip spaces */
for(; isspace((int)*p); p++);
/* read the arguments */
param_count = 0;
if(0 != *p) {
int quotes;
while(*p && param_count<1024) {
quotes = (*p == '"') && !!(p++); /* short-circuit AND */
for(q=tmp; *p && ((!quotes && !isspace(*p)) || (quotes && !(*p == '"' && *(p-1) != '\\'))) && q<tmp+1023; *q++ = *p++); *q=0;
quotes = (*p == '"') && !!(p++);
param[param_count++] = str_dup(tmp);
for(; isspace((int)*p); p++); /* skip spaces */
}
}
/* interpret the line */
level_interpret_parsed_line(filename, fileline, identifier, param_count, (const char**)param);
/* free the stuff */
for(i=0; i<param_count; i++)
free(param[i]);
free(identifier);
}
/*
* level_interpret_parsed_line()
* Interprets a line parsed by level_interpret_line()
*/
void level_interpret_parsed_line(const char *filename, int fileline, const char *identifier, int param_count, const char **param)
{
/* interpreting the command */
if(str_icmp(identifier, "theme") == 0) {
if(param_count == 1) {
if(brickdata_size() == 0) {
str_cpy(theme, param[0], sizeof(theme));
brickdata_load(theme);
}
}
else
logfile_message("Level loader - command 'theme' expects one parameter: brickset filepath. Did you forget to double quote the brickset filepath?");
}
else if(str_icmp(identifier, "bgtheme") == 0) {
if(param_count == 1)
str_cpy(bgtheme, param[0], sizeof(bgtheme));
else
logfile_message("Level loader - command 'bgtheme' expects one parameter: background filepath. Did you forget to double quote the background filepath?");
}
else if(str_icmp(identifier, "grouptheme") == 0) {
if(param_count == 1) {
if(editorgrp_group_count() == 0) {
str_cpy(grouptheme, param[0], sizeof(grouptheme));
editorgrp_load_from_file(grouptheme);
}
}
else
logfile_message("Level loader - command 'grouptheme' expects one parameter: grouptheme filepath. Did you forget to double quote the grouptheme filepath?");
}
else if(str_icmp(identifier, "music") == 0) {
if(param_count == 1)
str_cpy(musicfile, param[0], sizeof(musicfile));
else
logfile_message("Level loader - command 'music' expects one parameter: music filepath. Did you forget to double quote the music filepath?");
}
else if(str_icmp(identifier, "name") == 0) {
if(param_count == 1)
str_cpy(name, param[0], sizeof(name));
else
logfile_message("Level loader - command 'name' expects one parameter: level name. Did you forget to double quote the level name?");
}
else if(str_icmp(identifier, "author") == 0) {
if(param_count == 1)
str_cpy(author, param[0], sizeof(name));
else
logfile_message("Level loader - command 'author' expects one parameter: author name. Did you forget to double quote the author name?");
}
else if(str_icmp(identifier, "version") == 0) {
if(param_count == 1)
str_cpy(version, param[0], sizeof(name));
else
logfile_message("Level loader - command 'version' expects one parameter: level version");
}
else if(str_icmp(identifier, "requires") == 0) {
if(param_count == 1) {
int i;
sscanf(param[0], "%d.%d.%d", &requires[0], &requires[1], &requires[2]);
for(i=0; i<3; i++) requires[i] = clip(requires[i], 0, 99);
if(game_version_compare(requires[0], requires[1], requires[2]) < 0) {
fatal_error(
"This level requires version %d.%d.%d or greater of the game engine.\nYours is %s\nPlease check out for new versions at %s",
requires[0], requires[1], requires[2], GAME_VERSION_STRING, GAME_WEBSITE
);
}
}
else
logfile_message("Level loader - command 'requires' expects one parameter: minimum required engine version");
}
else if(str_icmp(identifier, "act") == 0) {
if(param_count == 1)
act = atoi(param[0]);
else
logfile_message("Level loader - command 'act' expects one parameter: act number");
}
else if(str_icmp(identifier, "waterlevel") == 0) {
if(param_count == 1)
waterlevel = atoi(param[0]);
else
logfile_message("Level loader - command 'waterlevel' expects one parameter: water level (y-coordinate, in pixels)");
}
else if(str_icmp(identifier, "watercolor") == 0) {
if(param_count == 3)
watercolor = image_rgb(atoi(param[0]), atoi(param[1]), atoi(param[2]));
else
logfile_message("Level loader - command 'watercolor' expects three parameters: red, green, blue");
}
else if(str_icmp(identifier, "spawn_point") == 0) {
if(param_count == 2) {
int x, y;
x = atoi(param[0]);
y = atoi(param[1]);
spawn_point = v2d_new(x, y);
}
else
logfile_message("Level loader - command 'spawn_point' expects two parameters: xpos, ypos");
}
else if(str_icmp(identifier, "dialogbox") == 0) {
if(param_count == 6 && dialogregion_size < DIALOGREGION_MAX) {
dialogregion_t *d = &(dialogregion[dialogregion_size++]);
d->disabled = FALSE;
d->rect_x = atoi(param[0]);
d->rect_y = atoi(param[1]);
d->rect_w = atoi(param[2]);
d->rect_h = atoi(param[3]);
str_cpy(d->title, param[4], sizeof(d->title));
str_cpy(d->message, param[5], sizeof(d->message));
}
else
logfile_message("Level loader - command 'dialogbox' expects six parameters: rect_xpos, rect_ypos, rect_width, rect_height, title, message. Did you forget to double quote the message?");
}
else if(str_icmp(identifier, "readonly") == 0) {
if(param_count == 0)
readonly = TRUE;
else
logfile_message("Level loader - command 'readonly' expects no parameters");
}
else if(str_icmp(identifier, "brick") == 0) {
if(param_count >= 3 && param_count <= 4) {
if(str_icmp(theme, "") != 0) {
int type;
int x, y;
bricklayer_t layer;
type = clip(atoi(param[0]), 0, brickdata_size()-1);
x = atoi(param[1]);
y = atoi(param[2]);
layer = (param_count >= 4) ? colorname2bricklayer(param[3]) : BRL_DEFAULT;
if(brickdata_get(type) != NULL) {
brick_t *brk = level_create_brick(type, v2d_new(x,y));
brk->layer = layer;
}
else
logfile_message("Level loader - invalid brick: %d", type);
}
else
logfile_message("Level loader - warning: cannot create a new brick if the theme is not defined");
}
else
logfile_message("Level loader - command 'brick' expects three or four parameters: type, xpos, ypos [, layer_name]");
}
else if(str_icmp(identifier, "item") == 0) {
if(param_count == 3) {
int type;
int x, y;
type = clip(atoi(param[0]), 0, ITEMDATA_MAX-1);
x = atoi(param[1]);
y = atoi(param[2]);
level_create_item(type, v2d_new(x,y));
}
else
logfile_message("Level loader - command 'item' expects three parameters: type, xpos, ypos");
}
else if((str_icmp(identifier, "enemy") == 0) || (str_icmp(identifier, "object") == 0)) {
if(param_count == 3) {
const char *name;
int x, y;
name = param[0];
x = atoi(param[1]);
y = atoi(param[2]);
if(str_icmp(name, DEFAULT_STARTUP_OBJECT) != 0)
level_create_enemy(name, v2d_new(x,y));
}
else
logfile_message("Level loader - command '%s' expects three parameters: enemy_name, xpos, ypos", identifier);
}
else if(str_icmp(identifier, "startup") == 0) {
if(param_count > 0) {
int i;
for(i=param_count-1; i>=0; i--)
add_to_startup_object_list(param[i]);
}
else
logfile_message("Level loader - command 'startup' expects one or more parameters: object_name1 [, object_name2 [, ... [, object_nameN] ... ] ]");
}
else if(str_icmp(identifier, "players") == 0) {
if(param_count > 0) {
int i, j;
for(i=0; i<param_count; i++) {
if(team_size < TEAM_MAX) {
for(j=0; j<team_size; j++) {
if(str_icmp(team[j]->name, param[i]) == 0)
fatal_error("Level loader - duplicate entry of player '%s'\nin '%s' near line %d", param[i], filename, fileline);
}
logfile_message("loading player '%s'...", param[i]);
team[team_size++] = player_create(param[i]);
}
else
fatal_error("Level loader - can't have more than %d players per level\nin '%s' near line %d", TEAM_MAX, filename, fileline);
}
}
else
logfile_message("Level loader - command 'players' expects one or more parameters: character_name1 [, character_name2 [, ... [, character_nameN] ... ] ]");
}
else
logfile_message("Level loader - unknown command '%s'\nin '%s' near line %d", identifier, filename, fileline);
}
/* scene functions */
/*
* level_init()
* Initializes the scene
*/
void level_init(void *path_to_lev_file)
{
int i;
const char *filepath = (const char*)path_to_lev_file;
logfile_message("level_init('%s')", filepath);
video_display_loading_screen();
/* main init */
str_cpy(file, filepath, sizeof(file));
gravity = 787.5;
level_width = level_height = 0;
level_timer = 0;
dialogregion_size = 0;
override_music = NULL;
quit_level = FALSE;
quit_level_img = image_create(image_width(video_get_backbuffer()), image_height(video_get_backbuffer()));
backgroundtheme = NULL;
must_load_another_level = FALSE;
must_restart_this_level = FALSE;
must_push_a_quest = FALSE;
dead_player_timeout = 0;
team_size = 0;
for(i=0; i<TEAM_MAX; i++)
team[i] = NULL;
player = NULL;
/* scripting controlled variables */
level_cleared = FALSE;
jump_to_next_stage = FALSE;
/* helpers */
particle_init();
editor_init();
/* level init */
level_load(file);
spawn_players();
/* dialog box */
dlgbox_active = FALSE;
dlgbox_starttime = 0;
dlgbox = actor_create();
dlgbox->position.y = VIDEO_SCREEN_H;
actor_change_animation(dlgbox, sprite_get_animation("SD_DIALOGBOX", 0));
dlgbox_title = font_create("default_ttf");
dlgbox_message = font_create("default_ttf");
logfile_message("level_init() ok");
}
/*
* level_update()
* Updates the scene (this one runs
* every cycle of the program)
*/
void level_update()
{
int i, cbox;
int got_dying_player = FALSE;
int block_quit = FALSE, block_pause = FALSE;
float dt = timer_get_delta();
brick_list_t *major_bricks, *bnode;
item_list_t *major_items, *inode;
enemy_list_t *major_enemies, *enode;
v2d_t cam = level_editmode() ? editor_camera : camera_get_position();
entitymanager_remove_dead_bricks();
entitymanager_remove_dead_items();
entitymanager_remove_dead_objects();
/* next stage in the quest... */
if(jump_to_next_stage) {
jump_to_next_stage = FALSE;
scenestack_pop();
return;
}
/* must load another level? */
if(must_load_another_level) {
must_load_another_level = FALSE;
restart(FALSE);
return;
}
/* must restart the current level? */
if(must_restart_this_level) {
must_restart_this_level = FALSE;
restart(TRUE);
return;
}
/* must push a quest? */
if(must_push_a_quest) {
must_push_a_quest = FALSE;
scenestack_pop();
quest_setlevel(quest_currentlevel() - 1);
scenestack_push(storyboard_get_scene(SCENE_QUEST), (void*)quest_to_be_pushed);
return;
}
/* updating the level... */
if(!editor_is_enabled()) {
/* displaying message: "do you really want to quit?" */
block_quit = FALSE;
for(i=0; i<team_size && !block_quit; i++)
block_quit = player_is_dying(team[i]);
if(wants_to_leave && !block_quit) {
char op[3][512];
confirmboxdata_t cbd = { op[0], op[1], op[2] };
wants_to_leave = FALSE;
image_blit(video_get_backbuffer(), quit_level_img, 0, 0, 0, 0, image_width(quit_level_img), image_height(quit_level_img));
music_pause();
lang_getstring("CBOX_QUIT_QUESTION", op[0], sizeof(op[0]));
lang_getstring("CBOX_QUIT_OPTION1", op[1], sizeof(op[1]));
lang_getstring("CBOX_QUIT_OPTION2", op[2], sizeof(op[2]));
scenestack_push(storyboard_get_scene(SCENE_CONFIRMBOX), (void*)&cbd);
return;
}
cbox = confirmbox_selected_option();
if(cbox == 1)
quit_level = TRUE;
else if(cbox == 2)
music_resume();
if(quit_level) {
if(fadefx_over()) {
scenestack_pop();
quest_abort();
return;
}
fadefx_out(image_rgb(0,0,0), 1.0);
return;
}
/* pause game */
block_pause = block_pause || (level_timer < 1.0f);
for(i=0; i<team_size; i++)
block_pause = block_pause || player_is_dying(team[i]);
if(wants_to_pause && !block_pause) {
wants_to_pause = FALSE;
sound_play( soundfactory_get("pause") );
scenestack_push(storyboard_get_scene(SCENE_PAUSE), NULL);
return;
}
/* open level editor */
if(editor_want_to_activate()) {
if(readonly) {
video_showmessage("No way!");
sound_play( soundfactory_get("deny") );
}
else {
editor_enable();
return;
}
}
/* dialog box */
update_dialogregions();
update_dlgbox();
/* things... player */
got_dying_player = FALSE;
for(i=0; i<team_size; i++) {
team[i]->entering_loop=FALSE;
if(player_is_dying(team[i]))
got_dying_player = TRUE;
}
/* -------------------------------------- */
/* updating the entities */
/* -------------------------------------- */
/* getting the major entities */
entitymanager_set_active_region(
(int)cam.x - VIDEO_SCREEN_W/2 - (DEFAULT_MARGIN*3)/2,
(int)cam.y - VIDEO_SCREEN_H/2 - (DEFAULT_MARGIN*3)/2,
VIDEO_SCREEN_W + (DEFAULT_MARGIN*3),
VIDEO_SCREEN_H + (DEFAULT_MARGIN*3)
);
major_enemies = entitymanager_retrieve_active_objects();
major_items = entitymanager_retrieve_active_items();
entitymanager_set_active_region(
(int)cam.x - VIDEO_SCREEN_W/2 - DEFAULT_MARGIN,
(int)cam.y - VIDEO_SCREEN_H/2 - DEFAULT_MARGIN,
VIDEO_SCREEN_W + 2*DEFAULT_MARGIN,
VIDEO_SCREEN_H + 2*DEFAULT_MARGIN
);
major_bricks = entitymanager_retrieve_active_bricks();
/* update background */
background_update(backgroundtheme);
/* update items */
for(inode = major_items; inode != NULL; inode = inode->next) {
float x = inode->data->actor->position.x;
float y = inode->data->actor->position.y;
float w = image_width(actor_image(inode->data->actor));
float h = image_height(actor_image(inode->data->actor));
int inside_playarea = inside_screen(x, y, w, h, DEFAULT_MARGIN);
int always_active = inode->data->always_active;
if(inside_playarea || always_active) {
/* update this item */
item_update(inode->data, team, team_size, major_bricks, major_items, major_enemies);
}
else if(!inside_playarea) {
/* this item is outside the screen... (and it's not always active) */
if(!inode->data->preserve)
inode->data->state = IS_DEAD;
else if(!inside_screen(inode->data->actor->spawn_point.x, inode->data->actor->spawn_point.y, w, h, DEFAULT_MARGIN))
inode->data->actor->position = inode->data->actor->spawn_point;
}
}
/* update objects */
for(enode = major_enemies; enode != NULL; enode = enode->next) {
float x = enode->data->actor->position.x;
float y = enode->data->actor->position.y;
float w = image_width(actor_image(enode->data->actor));
float h = image_height(actor_image(enode->data->actor));
int always_active = enode->data->always_active;
int inside_playarea = inside_screen(x, y, w, h, DEFAULT_MARGIN);
if(inside_playarea || always_active) {
/* update this object */
enemy_update(enode->data, team, team_size, major_bricks, major_items, major_enemies);
}
else if(!inside_playarea) {
/* this object is outside the play area... (and it's not always active) */
if(!enode->data->preserve)
enode->data->state = ES_DEAD;
else if(!inside_screen(enode->data->actor->spawn_point.x, enode->data->actor->spawn_point.y, w, h, DEFAULT_MARGIN))
enode->data->actor->position = enode->data->actor->spawn_point;
}
}
/* update players */
for(i=0; i<team_size; i++) {
float x = team[i]->actor->position.x;
float y = team[i]->actor->position.y;
float w = image_width(actor_image(team[i]->actor));
float h = image_height(actor_image(team[i]->actor));
float hy = team[i]->actor->hot_spot.y;
/* somebody is hurt! show it to the user */
if(team[i] != player) {
if(player_is_getting_hit(team[i]))
level_change_player(team[i]);
if(player_is_dying(team[i])) {
level_change_player(team[i]);
if(camera_focus != team[i]->actor)
camera_move_to(team[i]->actor->position, 0.0);
}
}
/* death */
if(got_dying_player && ((dead_player_timeout += dt) >= 2.5f)) {
if(player_get_lives() > 1) {
/* restart the level! */
if(fadefx_over()) {
player_set_lives(player_get_lives()-1);
restart(TRUE);
return;
}
fadefx_out(image_rgb(0,0,0), 1.0);
}
else {
/* game over */
scenestack_pop();
scenestack_push(storyboard_get_scene(SCENE_GAMEOVER), NULL);
return;
}
}
/* updating... */
if(entitymanager_get_number_of_bricks() > 0) {
if(inside_screen(x, y, w, h, DEFAULT_MARGIN/4) || player_is_dying(team[i]) || team[i]->actor->position.y < 0) {
if(!got_dying_player || player_is_dying(team[i]) || player_is_getting_hit(team[i]))
player_update(team[i], team, team_size, major_bricks, major_items, major_enemies);
}
/* pitfall */
if(team[i]->actor->position.y > level_height-(h-hy)) {
if(inside_screen(x,y,w,h,DEFAULT_MARGIN/4))
player_kill(team[i]);
}
}
}
/* some objects are attached to the player... */
for(enode = major_enemies; enode != NULL; enode = enode->next) {
float x = enode->data->actor->position.x;
float y = enode->data->actor->position.y;
float w = image_width(actor_image(enode->data->actor));
float h = image_height(actor_image(enode->data->actor));
int always_active = enode->data->always_active;
int inside_playarea = inside_screen(x, y, w, h, DEFAULT_MARGIN);
if(inside_playarea || always_active) {
if(enode->data->attached_to_player) {
enode->data->actor->position = enemy_get_observed_player(enode->data)->actor->position;
enode->data->actor->position = v2d_add(enode->data->actor->position, enode->data->attached_to_player_offset);
enode->data->attached_to_player = FALSE;
}
}
}
/* update bricks */
for(bnode = major_bricks; bnode != NULL; bnode = bnode->next) {
/* update this brick */
brick_update(bnode->data, team, team_size, major_bricks, major_items, major_enemies);
}
/* update particles */
particle_update_all(major_bricks);
/* "ungetting" major entities */
entitymanager_release_retrieved_brick_list(major_bricks);
entitymanager_release_retrieved_item_list(major_items);
entitymanager_release_retrieved_object_list(major_enemies);
/* -------------------------------------- */
/* updating the entities */
/* -------------------------------------- */
/* level timer */
if(!got_dying_player && !level_cleared)
level_timer += timer_get_delta();
/* if someone is dying, fade out the music */
if(got_dying_player)
music_set_volume(music_get_volume() - 0.5*dt);
/* update camera */
if(level_cleared)
camera_move_to(v2d_add(camera_focus->position, v2d_new(0, -90)), 0.17);
else if(!got_dying_player)
camera_move_to(camera_focus->position, 0); /* the camera will be locked on its focus (usually, the player) */
camera_update();
}
else {
entitymanager_set_active_region(
(int)cam.x - VIDEO_SCREEN_W/2 - DEFAULT_MARGIN,
(int)cam.y - VIDEO_SCREEN_H/2 - DEFAULT_MARGIN,
VIDEO_SCREEN_W + 2*DEFAULT_MARGIN,
VIDEO_SCREEN_H + 2*DEFAULT_MARGIN
);
/* level editor */
editor_update();
}
/* other stuff */
update_music();
}
/*
* level_render()
* Rendering function
*/
void level_render()
{
brick_list_t *major_bricks;
item_list_t *major_items;
enemy_list_t *major_enemies;
/* very important, if we restart the level */
if(level_timer < 0.05f)
return;
/* quit... */
if(quit_level) {
image_blit(quit_level_img, video_get_backbuffer(), 0, 0, 0, 0, image_width(quit_level_img), image_height(quit_level_img));
return;
}
/* render the level editor? */
if(editor_is_enabled()) {
editor_render();
return;
}
/* --------------------------- */
major_bricks = entitymanager_retrieve_active_bricks();
major_items = entitymanager_retrieve_active_items();
major_enemies = entitymanager_retrieve_active_objects();
/* background */
background_render_bg(backgroundtheme, camera_get_position());
/* entities */
render_entities(major_bricks, major_items, major_enemies);
/* water */
render_water();
/* foreground */
background_render_fg(backgroundtheme, camera_get_position());
/* hud */
render_hud(major_enemies);
entitymanager_release_retrieved_brick_list(major_bricks);
entitymanager_release_retrieved_item_list(major_items);
entitymanager_release_retrieved_object_list(major_enemies);
}
/*
* level_release()
* Releases the scene
*/
void level_release()
{
logfile_message("level_release()");
image_destroy(quit_level_img);
particle_release();
level_unload();
camera_release();
editor_release();
font_destroy(dlgbox_title);
font_destroy(dlgbox_message);
actor_destroy(dlgbox);
logfile_message("level_release() ok");
}
/*
* level_create_particle()
* Creates a new particle.
* Warning: image will be free'd internally.
*/
void level_create_particle(image_t *image, v2d_t position, v2d_t speed, int destroy_on_brick)
{
if(editor_is_enabled()) {
/* no, you can't create a new particle! */
image_destroy(image);
}
else
particle_add(image, position, speed, destroy_on_brick);
}
/*
* level_name()
* Returns the level name
*/
const char* level_name()
{
return name;
}
/*
* level_version()
* Returns the version of the level
*/
const char* level_version()
{
return version;
}
/*
* level_author()
* Returns the author of the level
*/
const char* level_author()
{
return author;
}
/*
* level_act()
* Returns the current act number
*/
int level_act()
{
return act;
}
/*
* level_player()
* Returns the current player
*/
player_t* level_player()
{
return player;
}
/*
* level_persist()
* Persists (saves) the current level
* Returns TRUE on success
*/
int level_persist()
{
return level_save(file);
}
/*
* level_change()
* Changes the stage. Useful if the .lev
* is active
*/
void level_change(const char* path_to_lev_file)
{
str_cpy(file, path_to_lev_file, sizeof(file));
must_load_another_level = TRUE;
logfile_message("changing level: opening '%s'...", path_to_lev_file);
}
/*
* level_change_player()
* Changes the current player (character switching)
*/
void level_change_player(player_t *new_player)
{
int i, player_id = -1;
for(i=0; i<team_size && player_id < 0; i++)
player_id = (team[i] == new_player) ? i : player_id;
if(player_id >= 0) {
player = team[player_id];
level_set_camera_focus(player->actor);
reconfigure_players_input_devices();
}
}
/*
* level_create_brick()
* Creates and adds a brick to the level. This function
* returns a pointer to the created brick.
*/
brick_t* level_create_brick(int type, v2d_t position)
{
brick_t *brick = brick_create(type);
brick->x = brick->sx = (int)position.x;
brick->y = brick->sy = (int)position.y;
entitymanager_store_brick(brick);
return brick;
}
/*
* level_create_item()
* Creates and adds an item to the level. Returns the
* created item.
*/
item_t* level_create_item(int type, v2d_t position)
{
item_t *item = item_create(type);
item->actor->spawn_point = position;
item->actor->position = position;
entitymanager_store_item(item);
return item;
}
/*
* level_create_enemy()
* Creates and adds an enemy to the level. Returns the
* created enemy.
*/
enemy_t* level_create_enemy(const char *name, v2d_t position)
{
enemy_t *object = enemy_create(name);
object->actor->spawn_point = position;
object->actor->position = position;
entitymanager_store_object(object);
return object;
}
/*
* level_gravity()
* Returns the gravity of the level
*/
float level_gravity()
{
return gravity;
}
/*
* level_add_to_score()
* Adds a value to the player's score.
* It also creates a flying text that
* shows that score.
*/
void level_add_to_score(int score)
{
item_t *flyingtext;
char buf[80];
int h = image_height(actor_image(player->actor));
player_set_score(player_get_score() + score);
sprintf(buf, "%d", score);
flyingtext = level_create_item(IT_FLYINGTEXT, v2d_add(player->actor->position, v2d_new(0,-h/2)));
flyingtext_set_text(flyingtext, buf);
}
/*
* level_create_animal()
* Creates a random animal
*/
item_t* level_create_animal(v2d_t position)
{
item_t *animal = level_create_item(IT_ANIMAL, position);
return animal;
}
/*
* level_set_camera_focus()
* Sets a new focus to the camera
*/
void level_set_camera_focus(actor_t *act)
{
camera_focus = act;
}
/*
* level_get_camera_focus()
* Gets the actor being focused by the camera
*/
actor_t* level_get_camera_focus()
{
return camera_focus;
}
/*
* level_editmode()
* Is the level editor activated?
*/
int level_editmode()
{
return editor_is_enabled();
}
/*
* level_size()
* Returns the size of the level
*/
v2d_t level_size()
{
return v2d_new(level_width, level_height);
}
/*
* level_override_music()
* Stops the music while the given sample is playing.
* After it gets finished, the music gets played again.
*/
void level_override_music(sound_t *sample)
{
if(music) music_stop();
override_music = sample;
sound_play(override_music);
}
/*
* level_set_spawn_point()
* Defines a new spawn point
*/
void level_set_spawn_point(v2d_t newpos)
{
spawn_point = newpos;
}
/*
* level_clear()
* Call this when the player clears this level
*/
void level_clear(actor_t *end_sign)
{
int i;
if(level_cleared)
return;
/* ignore input and focus the camera on the end sign */
for(i=0; i<team_size; i++)
input_ignore(team[i]->actor->input);
/* block music */
block_music = TRUE;
/* success! */
level_set_camera_focus(end_sign);
level_hide_dialogbox();
level_cleared = TRUE;
}
/*
* level_call_dialogbox()
* Calls a dialog box
*/
void level_call_dialogbox(const char *title, const char *message)
{
if(dlgbox_active && strcmp(font_get_text(dlgbox_title), title) == 0 && strcmp(font_get_text(dlgbox_message), message) == 0)
return;
dlgbox_active = TRUE;
dlgbox_starttime = timer_get_ticks();
font_set_text(dlgbox_title, "%s", title);
font_set_text(dlgbox_message, "%s", message);
font_set_width(dlgbox_message, 260);
}
/*
* level_hide_dialogbox()
* Hides the current dialog box (if any)
*/
void level_hide_dialogbox()
{
dlgbox_active = FALSE;
}
/*
* level_inside_screen()
* Returns TRUE if a given region is
* inside the screen position (camera-related)
*/
int level_inside_screen(int x, int y, int w, int h)
{
return inside_screen(x,y,w,h,DEFAULT_MARGIN);
}
/*
* level_has_been_cleared()
* Has this level been cleared?
*/
int level_has_been_cleared()
{
return level_cleared;
}
/*
* level_jump_to_next_stage()
* Jumps to the next stage in the quest
*/
void level_jump_to_next_stage()
{
jump_to_next_stage = TRUE;
}
/*
* level_ask_to_leave()
* Asks permission for the user to leave the level
*/
void level_ask_to_leave()
{
wants_to_leave = TRUE;
}
/*
* level_pause()
* Pauses the level
*/
void level_pause()
{
wants_to_pause = TRUE;
}
/*
* level_restart()
* Restarts the current level
*/
void level_restart()
{
must_restart_this_level = TRUE; /* schedules restart */
}
/*
* level_waterlevel()
* Returns the level of the water (the y-coordinate where the water begins)
*/
int level_waterlevel()
{
return waterlevel;
}
/*
* level_set_waterlevel()
* Sets a new waterlevel
*/
void level_set_waterlevel(int ycoord)
{
waterlevel = ycoord;
}
/*
* level_watercolor()
* Returns the color of the water
*/
uint32 level_watercolor()
{
return watercolor;
}
/*
* level_set_watercolor()
* Sets a new watercolor
*/
void level_set_watercolor(uint32 color)
{
watercolor = color;
}
/*
* level_push_quest()
* Pops this level, pushes a new quest.
* So, you'll have at least two quests on the scene stack,
* stored in consecutive positions.
*/
void level_push_quest(const char* path_to_qst_file)
{
/* schedules a quest push */
must_push_a_quest = TRUE;
str_cpy(quest_to_be_pushed, path_to_qst_file, sizeof(quest_to_be_pushed));
}
/*
* level_pop_quest()
* Pops this level, and also pops the current quest (if any)
* The scene stack is this:
* [bottom] ??..?? ---> current quest --> current level [top]
* After this command, it will be:
* [bottom] ??..?? [top]
*/
void level_pop_quest()
{
/* schedules a quest pop */
quest_abort();
level_jump_to_next_stage();
}
/* private functions */
/* renders the entities of the level: bricks,
* enemies, items, players, etc. */
void render_entities(brick_list_t *major_bricks, item_list_t *major_items, enemy_list_t *major_enemies)
{
brick_list_t *bnode;
item_list_t *inode;
enemy_list_t *enode;
/* starting up the render queue... */
renderqueue_begin( camera_get_position() );
/* render bricks - background */
for(bnode=major_bricks; bnode; bnode=bnode->next) {
brickdata_t *ref = bnode->data->brick_ref;
if(ref->zindex < 0.5f)
renderqueue_enqueue_brick(bnode->data);
}
/* render players (bring to back?) */
render_players(TRUE);
/* render bricks - platform level (back) */
for(bnode=major_bricks; bnode; bnode=bnode->next) {
brickdata_t *ref = bnode->data->brick_ref;
if(fabs(ref->zindex-0.5f) < EPSILON && ref->property != BRK_OBSTACLE)
renderqueue_enqueue_brick(bnode->data);
}
/* render items (bring to back) */
for(inode=major_items; inode; inode=inode->next) {
if(inode->data->bring_to_back)
renderqueue_enqueue_item(inode->data);
}
/* render bricks - platform level (front) */
for(bnode=major_bricks; bnode; bnode=bnode->next) {
brickdata_t *ref = bnode->data->brick_ref;
if(fabs(ref->zindex-0.5f) < EPSILON && ref->property == BRK_OBSTACLE)
renderqueue_enqueue_brick(bnode->data);
}
/* render non-HUD objects */
for(enode=major_enemies; enode; enode=enode->next) {
if(enode->data->zindex <= 1.0f)
renderqueue_enqueue_object(enode->data);
}
/* render players (bring to front?) */
render_players(FALSE);
/* render items (bring to front) */
for(inode=major_items; inode; inode=inode->next) {
if(!inode->data->bring_to_back)
renderqueue_enqueue_item(inode->data);
}
/* render particles */
renderqueue_enqueue_particles();
/* render bricks - foreground */
for(bnode=major_bricks; bnode; bnode=bnode->next) {
brickdata_t *ref = bnode->data->brick_ref;
if(ref->zindex > 0.5f)
renderqueue_enqueue_brick(bnode->data);
}
/* okay, enough! let's render */
renderqueue_end();
}
/* true if a given region is inside the screen position */
int inside_screen(int x, int y, int w, int h, int margin)
{
v2d_t cam = level_editmode() ? editor_camera : camera_get_position();
float a[4] = { x, y, x+w, y+h };
float b[4] = {
cam.x-VIDEO_SCREEN_W/2 - margin,
cam.y-VIDEO_SCREEN_H/2 - margin,
cam.x+VIDEO_SCREEN_W/2 + margin,
cam.y+VIDEO_SCREEN_H/2 + margin
};
return bounding_box(a,b);
}
/* calculates the size of the
* current level */
void update_level_size()
{
int max_x, max_y;
brick_list_t *p, *brick_list;
max_x = max_y = -INFINITY;
brick_list = entitymanager_retrieve_all_bricks();
for(p=brick_list; p; p=p->next) {
if(p->data->brick_ref->property != BRK_NONE) {
max_x = max(max_x, p->data->sx + image_width(brick_image(p->data)));
max_y = max(max_y, p->data->sy + image_height(brick_image(p->data)));
}
}
brick_list = entitymanager_release_retrieved_brick_list(brick_list);
level_width = max(max_x, 320);
level_height = max(max_y, 240);
}
/* returns the ID of a given brick,
* or -1 if it was not found */
int get_brick_id(brick_t *b)
{
int i;
for(i=0; i<brickdata_size(); i++) {
if(b->brick_ref == brickdata_get(i))
return i;
}
return -1;
}
/* restarts the level preserving
* the current spawn point */
void restart(int preserve_current_spawnpoint)
{
v2d_t sp = spawn_point;
level_release();
level_init((void*)file);
if(preserve_current_spawnpoint) {
spawn_point = sp;
spawn_players();
}
}
/* reconfigures the input devices of the
* players after switching characters */
void reconfigure_players_input_devices()
{
int i;
for(i=0; i<team_size; i++) {
if(NULL == team[i]->actor->input)
team[i]->actor->input = input_create_user(NULL);
if(team[i] == player) {
input_restore(team[i]->actor->input);
input_simulate_button_down(team[i]->actor->input, IB_FIRE2); /* bugfix (character switching) */
}
else
input_ignore(team[i]->actor->input);
}
}
/* renders the players */
void render_players(int bring_to_back)
{
int i;
for(i=team_size-1; i>=0; i--) {
if(team[i] != player && (team[i]->bring_to_back?TRUE:FALSE) == bring_to_back)
renderqueue_enqueue_player(team[i]);
}
if((player->bring_to_back?TRUE:FALSE) == bring_to_back) /* comparing two booleans */
renderqueue_enqueue_player(player);
}
/* updates the music */
void update_music()
{
if(music != NULL && !block_music) {
if(override_music && !sound_is_playing(override_music)) {
override_music = NULL;
if(!player->invincible && !player->got_speedshoes)
music_play(music, INFINITY);
}
if(!override_music && !music_is_playing())
music_play(music, INFINITY);
}
}
/* puts the players at the spawn point */
void spawn_players()
{
int i, v;
for(i=0; i<team_size; i++) {
v = ((int)spawn_point.x <= level_width/2) ? (team_size-1)-i : i;
team[i]->actor->mirror = ((int)spawn_point.x <= level_width/2) ? IF_NONE : IF_HFLIP;
team[i]->actor->spawn_point.x = team[i]->actor->position.x = spawn_point.x + 15*v;
team[i]->actor->spawn_point.y = team[i]->actor->position.y = spawn_point.y;
}
}
/* renders the hud */
void render_hud(enemy_list_t *major_enemies)
{
enemy_list_t *enode;
v2d_t fixedcam = v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2);
/* render objects with zindex > 1.0 (HUD) */
renderqueue_begin( camera_get_position() );
for(enode=major_enemies; enode; enode=enode->next) {
if(enode->data->zindex > 1.0f)
renderqueue_enqueue_object(enode->data);
}
renderqueue_end();
/* powerups */
if(!level_cleared)
render_powerups();
/* dialog box */
render_dlgbox(fixedcam);
}
/* renders water */
void render_water()
{
int y = waterlevel - ( (int)camera_get_position().y - VIDEO_SCREEN_H/2 );
if(y < VIDEO_SCREEN_H)
image_draw_waterfx(video_get_backbuffer(), y, watercolor);
}
/* updates the dialog box */
void update_dlgbox()
{
float speed = 100.0; /* y speed */
float dt = timer_get_delta();
uint32 t = timer_get_ticks();
if(dlgbox_active) {
if(t >= dlgbox_starttime + DLGBOX_MAXTIME) {
dlgbox_active = FALSE;
return;
}
dlgbox->position.x = (VIDEO_SCREEN_W - image_width(actor_image(dlgbox)))/2;
dlgbox->position.y = max(dlgbox->position.y - speed*dt, VIDEO_SCREEN_H - image_height(actor_image(dlgbox))*1.3);
}
else {
dlgbox->position.y = min(dlgbox->position.y + speed*dt, VIDEO_SCREEN_H);
}
font_set_position(dlgbox_title, v2d_add(dlgbox->position, v2d_new(7, 8)));
font_set_position(dlgbox_message, v2d_add(dlgbox->position, v2d_new(7, 20)));
}
/* renders the dialog box */
void render_dlgbox(v2d_t camera_position)
{
actor_render(dlgbox, camera_position);
font_render(dlgbox_title, camera_position);
font_render(dlgbox_message, camera_position);
}
/* camera facade */
void level_lock_camera(int x1, int y1, int x2, int y2) /* the camera can show any point in this rectangle */
{
camera_lock(x1+VIDEO_SCREEN_W/2, y1+VIDEO_SCREEN_H/2, x2-VIDEO_SCREEN_W/2, y2-VIDEO_SCREEN_H/2);
}
void level_unlock_camera()
{
camera_unlock();
}
int level_is_camera_locked()
{
return camera_is_locked();
}
/* music */
void level_restore_music()
{
if(music != NULL)
music_stop();
/* update_music will do the rest */
}
/* dialog regions */
/* update_dialogregions(): updates all the dialog regions.
* This checks if the player enters one region, and if he/she does,
* this function shows the corresponding dialog box */
void update_dialogregions()
{
int i;
float a[4], b[4];
if(level_timer < 2.0)
return;
a[0] = player->actor->position.x;
a[1] = player->actor->position.y;
a[2] = a[0] + image_width(actor_image(player->actor));
a[3] = a[1] + image_height(actor_image(player->actor));
for(i=0; i<dialogregion_size; i++) {
if(dialogregion[i].disabled)
continue;
b[0] = dialogregion[i].rect_x;
b[1] = dialogregion[i].rect_y;
b[2] = b[0]+dialogregion[i].rect_w;
b[3] = b[1]+dialogregion[i].rect_h;
if(bounding_box(a, b)) {
dialogregion[i].disabled = TRUE;
level_call_dialogbox(dialogregion[i].title, dialogregion[i].message);
break;
}
}
}
/* startup objects */
/* initializes the startup object list */
void init_startup_object_list()
{
startupobject_list = NULL;
}
/* releases the startup object list */
void release_startup_object_list()
{
startupobject_list_t *me, *next;
for(me=startupobject_list; me; me=next) {
next = me->next;
free(me->object_name);
free(me);
}
}
/* adds a new object to the startup object list */
/* (actually it inserts the new object in the first position of the linked list) */
void add_to_startup_object_list(const char *object_name)
{
startupobject_list_t *first_node = mallocx(sizeof *first_node);
first_node->object_name = str_dup(object_name);
first_node->next = startupobject_list;
startupobject_list = first_node;
}
/* spawns the startup objects */
void spawn_startup_objects()
{
startupobject_list_t *me;
enemy_t *e;
if(startupobject_list == NULL)
add_to_startup_object_list(DEFAULT_STARTUP_OBJECT);
for(me=startupobject_list; me; me=me->next) {
e = level_create_enemy(me->object_name, v2d_new(0,0));
e->created_from_editor = FALSE;
}
}
/* misc */
/* render powerups */
void render_powerups()
{
image_t *icon[MAX_POWERUPS]; /* icons */
int visible[MAX_POWERUPS]; /* is icon[i] visible? */
int i, c = 0; /* c is the icon count */
float t = timer_get_ticks() * 0.001;
for(i=0; i<MAX_POWERUPS; i++)
visible[i] = TRUE;
if(player) {
if(player->got_glasses)
icon[c++] = sprite_get_image( sprite_get_animation("SD_ICON", 6) , 0 );
switch (player->shield_type)
{
case SH_SHIELD:
icon[c++] = sprite_get_image( sprite_get_animation("SD_ICON", 7) , 0 );
break;
case SH_FIRESHIELD:
icon[c++] = sprite_get_image( sprite_get_animation("SD_ICON", 11) , 0 );
break;
case SH_THUNDERSHIELD:
icon[c++] = sprite_get_image( sprite_get_animation("SD_ICON", 12) , 0 );
break;
case SH_WATERSHIELD:
icon[c++] = sprite_get_image( sprite_get_animation("SD_ICON", 13) , 0 );
break;
case SH_ACIDSHIELD:
icon[c++] = sprite_get_image( sprite_get_animation("SD_ICON", 14) , 0 );
break;
case SH_WINDSHIELD:
icon[c++] = sprite_get_image( sprite_get_animation("SD_ICON", 15) , 0 );
break;
}
if(player->invincible) {
icon[c++] = sprite_get_image( sprite_get_animation("SD_ICON", 4) , 0 );
if(player->invtimer >= PLAYER_MAX_INVINCIBILITY*0.75) { /* it blinks */
/* we want something that blinks faster as player->invtimer tends to PLAYER_MAX_INVINCIBLITY */
float x = ((PLAYER_MAX_INVINCIBILITY-player->invtimer)/(PLAYER_MAX_INVINCIBILITY*0.25)); /* 1 = x --> 0 */
visible[c-1] = sin( (0.5*PI*t) / (x+0.1) ) >= 0;
}
}
if(player->got_speedshoes) {
icon[c++] = sprite_get_image( sprite_get_animation("SD_ICON", 5) , 0 );
if(player->speedshoes_timer >= PLAYER_MAX_SPEEDSHOES*0.75) { /* it blinks */
/* we want something that blinks faster as player->speedshoes_timer tends to PLAYER_MAX_SPEEDSHOES */
float x = ((PLAYER_MAX_SPEEDSHOES-player->speedshoes_timer)/(PLAYER_MAX_SPEEDSHOES*0.25)); /* 1 = x --> 0 */
visible[c-1] = sin( (0.5*PI*t) / (x+0.1) ) >= 0;
}
}
}
for(i=0; i<c; i++) {
if(visible[i])
image_draw(icon[i], video_get_backbuffer(), VIDEO_SCREEN_W - image_width(icon[i]) * (i+1) - 5*i - 15, 10, IF_NONE);
}
}
/*
MZZM
MMMMMMMMMMMZOOZM MMMMMMMMM
MM M=...........MOOOM=.........M MM MM
MM MM M7......77MOOOOOOM7.....77M MM MM
MM MM M=......7MOOOOOMM=.....77M MM MM
MM MM MM MMMMM MMMMMM M=......7MOOOMM==....77M MM MMMMMM MM
MM MM MM MMMMMMMM MMMMMM M=......7MOOOM==....77M MM MMMMMM MM
MM MM MM MM MM MM=......7MOM==....77MOOOM MM MM MM
MM MM MM MMMM MM MZM=......7MM==....77MOOOOOM MM MM MM
MM MM MM MMMMMM MM MZOOM=......7==....77MOOOOOOOOOM MM MM MM
MM MM MM MM MM MM MZOM=......7....77MOOOOOOOOOOM MM MM
MM MM MM MMM MM MMM MM MZM=..........MMMOOOOOOOOOOM MM MM
MMMM MMM MM MMMMMM MMM M=.........M..MOOOOOOOOM MM MMM MM
M=........7MMMOMMMOMMMMMM
M=......77MM..M...........M
M=....77MOM..MM..OM..MM..M
M=...77MOOM..MM..MM..MM..M
M.77M MM...M..MM..MM...M
MMM MMMMOMM MM MMM
MM
*/
/* Level Editor */
/*
* editor_init()
* Initializes the level editor data
*/
void editor_init()
{
logfile_message("editor_init()");
/* intializing... */
editor_enabled = FALSE;
editor_item_list_size = -1;
while(editor_item_list[++editor_item_list_size] >= 0) { }
editor_cursor_entity_type = EDT_ITEM;
editor_cursor_entity_id = 0;
editor_previous_video_resolution = video_get_resolution();
editor_previous_video_smooth = video_is_smooth();
editor_enemy_name = objects_get_list_of_names(&editor_enemy_name_length);
editor_enemy_selected_category_id = 0;
editor_enemy_category = objects_get_list_of_categories(&editor_enemy_category_length);
/* creating objects */
editor_bgimage = image_load(EDITOR_BGFILE);
editor_keyboard = input_create_user("editor1");
editor_keyboard2 = input_create_user("editor2");
editor_keyboard3 = input_create_user("editor3");
editor_mouse = input_create_mouse();
editor_cursor_font = font_create("default");
editor_properties_font = font_create("default");
editor_help_font = font_create("default");
/* groups */
editorgrp_init();
/* layer */
editor_layer = BRL_DEFAULT;
/* grid */
editor_grid_init();
/* done */
logfile_message("editor_init() ok");
}
/*
* editor_release()
* Releases the level editor data
*/
void editor_release()
{
logfile_message("editor_release()");
/* grid */
editor_grid_release();
/* groups */
editorgrp_release();
/* destroying objects */
image_unref(EDITOR_BGFILE);
input_destroy(editor_keyboard3);
input_destroy(editor_keyboard2);
input_destroy(editor_keyboard);
input_destroy(editor_mouse);
font_destroy(editor_properties_font);
font_destroy(editor_cursor_font);
font_destroy(editor_help_font);
/* releasing... */
editor_enabled = FALSE;
logfile_message("editor_release() ok");
}
/*
* editor_update()
* Updates the level editor
*/
void editor_update()
{
item_list_t *it, *major_items;
brick_list_t *major_bricks;
enemy_list_t *major_enemies;
image_t *cursor_arrow = sprite_get_image(sprite_get_animation("SD_ARROW", 0), 0);
int pick_object, delete_object = FALSE;
v2d_t topleft = v2d_subtract(editor_camera, v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2));
v2d_t pos;
/* disable the level editor */
if(!input_button_down(editor_keyboard, IB_FIRE3) && !input_button_down(editor_keyboard3, IB_FIRE1)) {
if(input_button_pressed(editor_keyboard, IB_FIRE4)) {
editor_disable();
return;
}
}
/* save the level */
if(input_button_down(editor_keyboard, IB_FIRE3)) {
if(input_button_pressed(editor_keyboard, IB_FIRE4)) {
editor_save();
return;
}
}
/* reload level */
if(input_button_down(editor_keyboard3, IB_FIRE1)) {
if(input_button_pressed(editor_keyboard, IB_FIRE4)) {
confirmboxdata_t cbd = { "Reload the level?", "YES", "NO" };
scenestack_push(storyboard_get_scene(SCENE_CONFIRMBOX), (void*)&cbd);
return;
}
}
if(1 == confirmbox_selected_option()) {
editorgrp_release();
level_unload();
editorgrp_init();
level_load(file);
level_cleared = FALSE;
jump_to_next_stage = FALSE;
spawn_players();
video_showmessage("The level has been reloaded.");
return;
}
/* ----------------------------------------- */
/* getting major entities */
major_enemies = entitymanager_retrieve_active_objects();
major_items = entitymanager_retrieve_active_items();
major_bricks = entitymanager_retrieve_active_bricks();
/* update items */
for(it=major_items; it!=NULL; it=it->next)
item_update(it->data, team, team_size, major_bricks, major_items, major_enemies);
/* change class / entity / object category */
if(input_button_down(editor_keyboard, IB_FIRE3)) {
/* change class */
if(input_button_pressed(editor_keyboard, IB_FIRE1) || input_button_pressed(editor_mouse, IB_DOWN))
editor_next_class();
if(input_button_pressed(editor_keyboard, IB_FIRE2) || input_button_pressed(editor_mouse, IB_UP))
editor_previous_class();
}
else if(input_button_down(editor_keyboard3, IB_FIRE1)) {
if(editor_cursor_entity_type == EDT_ENEMY) {
/* change object category */
if(input_button_pressed(editor_keyboard, IB_FIRE1) || input_button_pressed(editor_mouse, IB_DOWN))
editor_next_object_category();
if(input_button_pressed(editor_keyboard, IB_FIRE2) || input_button_pressed(editor_mouse, IB_UP))
editor_previous_object_category();
}
}
else {
/* change entity */
if(input_button_pressed(editor_keyboard, IB_FIRE1) || input_button_pressed(editor_mouse, IB_DOWN))
editor_next_entity();
if(input_button_pressed(editor_keyboard, IB_FIRE2) || input_button_pressed(editor_mouse, IB_UP))
editor_previous_entity();
}
/* change brick layer */
if(input_button_pressed(editor_keyboard3, IB_FIRE3)) {
if(editor_cursor_entity_type == EDT_BRICK || editor_cursor_entity_type == EDT_GROUP) {
editor_layer = (editor_layer + 1) % 3;
video_showmessage("Switched to %s layer", bricklayer2colorname(editor_layer));
}
else {
sound_play( soundfactory_get("deny") );
video_showmessage("Must be in brick/group mode");
}
}
/* help */
if(input_button_pressed(editor_keyboard3, IB_FIRE4)) {
scenestack_push(storyboard_get_scene(SCENE_EDITORHELP), NULL);
return;
}
/* mouse cursor. note: editor_mouse is a input_t*, but also a inputmouse_t*, so it's safe to cast it */
editor_cursor.x = clip(input_get_xy((inputmouse_t*)editor_mouse).x, 0, VIDEO_SCREEN_W - image_width(cursor_arrow));
editor_cursor.y = clip(input_get_xy((inputmouse_t*)editor_mouse).y, 0, VIDEO_SCREEN_H - image_height(cursor_arrow));
/* new spawn point */
if(input_button_pressed(editor_mouse, IB_FIRE1) && input_button_down(editor_keyboard, IB_FIRE3)) {
v2d_t nsp = editor_grid_snap(editor_cursor);
editor_action_t eda = editor_action_spawnpoint_new(TRUE, nsp, spawn_point);
editor_action_commit(eda);
editor_action_register(eda);
}
/* new object */
if(input_button_pressed(editor_mouse, IB_FIRE1) && !input_button_down(editor_keyboard, IB_FIRE3)) {
editor_action_t eda = editor_action_entity_new(TRUE, editor_cursor_entity_type, editor_cursor_entity_id, editor_grid_snap(editor_cursor));
editor_action_commit(eda);
editor_action_register(eda);
}
/* pick or delete object */
pick_object = input_button_pressed(editor_mouse, IB_FIRE3) || input_button_pressed(editor_keyboard2, IB_FIRE4);
delete_object = input_button_pressed(editor_mouse, IB_FIRE2) || editor_is_eraser_enabled();
if(pick_object || delete_object) {
brick_list_t *itb;
item_list_t *iti;
enemy_list_t *ite;
switch(editor_cursor_entity_type) {
/* brick */
case EDT_BRICK: {
brick_t *candidate = NULL;
for(itb=major_bricks;itb;itb=itb->next) {
float a[4] = {itb->data->x, itb->data->y, itb->data->x + image_width(itb->data->brick_ref->image), itb->data->y + image_height(itb->data->brick_ref->image)};
float b[4] = { editor_cursor.x+topleft.x , editor_cursor.y+topleft.y , editor_cursor.x+topleft.x+1 , editor_cursor.y+topleft.y+1 };
if(bounding_box(a,b)) {
if(!candidate || (candidate && itb->data->brick_ref->zindex >= candidate->brick_ref->zindex))
candidate = itb->data;
}
}
if(candidate != NULL) {
if(pick_object) {
editor_cursor_entity_id = get_brick_id(candidate);
editor_layer = candidate->layer;
}
else {
editor_action_t eda = editor_action_entity_new(FALSE, EDT_BRICK, get_brick_id(candidate), v2d_new(candidate->x, candidate->y));
editor_action_commit(eda);
editor_action_register(eda);
}
}
break;
}
/* item */
case EDT_ITEM: {
item_t *candidate = NULL;
for(iti=major_items;iti;iti=iti->next) {
float a[4] = {iti->data->actor->position.x-iti->data->actor->hot_spot.x, iti->data->actor->position.y-iti->data->actor->hot_spot.y, iti->data->actor->position.x-iti->data->actor->hot_spot.x + image_width(actor_image(iti->data->actor)), iti->data->actor->position.y-iti->data->actor->hot_spot.y + image_height(actor_image(iti->data->actor))};
float b[4] = { editor_cursor.x+topleft.x , editor_cursor.y+topleft.y , editor_cursor.x+topleft.x+1 , editor_cursor.y+topleft.y+1 };
if(bounding_box(a,b)) {
if(!candidate || (candidate && !(iti->data->bring_to_back)))
candidate = iti->data;
}
}
if(candidate != NULL) {
if(pick_object) {
int index = editor_item_list_get_index(candidate->type);
if(index >= 0) {
editor_cursor_itemid = index;
editor_cursor_entity_id = editor_item_list[index];
}
}
else {
editor_action_t eda = editor_action_entity_new(FALSE, EDT_ITEM, candidate->type, candidate->actor->position);
editor_action_commit(eda);
editor_action_register(eda);
}
}
break;
}
/* enemy */
case EDT_ENEMY: {
enemy_t *candidate = NULL;
int candidate_key = 0;
for(ite=major_enemies;ite;ite=ite->next) {
float a[4] = {ite->data->actor->position.x-ite->data->actor->hot_spot.x, ite->data->actor->position.y-ite->data->actor->hot_spot.y, ite->data->actor->position.x-ite->data->actor->hot_spot.x + image_width(actor_image(ite->data->actor)), ite->data->actor->position.y-ite->data->actor->hot_spot.y + image_height(actor_image(ite->data->actor))};
float b[4] = { editor_cursor.x+topleft.x , editor_cursor.y+topleft.y , editor_cursor.x+topleft.x+1 , editor_cursor.y+topleft.y+1 };
int mykey = editor_enemy_name2key(ite->data->name);
if(mykey >= 0 && bounding_box(a,b)) {
if(!candidate || (candidate && ite->data->zindex >= candidate->zindex)) {
candidate = ite->data;
candidate_key = mykey;
}
}
}
if(candidate != NULL) {
if(pick_object) {
editor_cursor_entity_id = candidate_key;
}
else {
editor_action_t eda = editor_action_entity_new(FALSE, EDT_ENEMY, candidate_key, candidate->actor->position);
editor_action_commit(eda);
editor_action_register(eda);
}
}
break;
}
/* can't pick-up/delete a group */
case EDT_GROUP:
break;
}
}
/* undo & redo */
if(input_button_down(editor_keyboard, IB_FIRE3)) {
if(input_button_pressed(editor_keyboard2, IB_FIRE1))
editor_action_undo();
else if(input_button_pressed(editor_keyboard2, IB_FIRE2))
editor_action_redo();
}
/* grid */
editor_grid_update();
/* scrolling */
editor_scroll();
/* cursor coordinates */
font_set_text(editor_cursor_font, "%d,%d", (int)editor_grid_snap(editor_cursor).x, (int)editor_grid_snap(editor_cursor).y);
pos.x = clip((int)editor_cursor.x, 10, VIDEO_SCREEN_W-font_get_textsize(editor_cursor_font).x-10);
pos.y = clip((int)editor_cursor.y-3*font_get_textsize(editor_cursor_font).y, 10, VIDEO_SCREEN_H-10);
font_set_position(editor_cursor_font, pos);
/* help label */
font_set_text(editor_help_font, "<color=ffff00>F1</color>: help");
font_set_position(editor_help_font, v2d_new(VIDEO_SCREEN_W - font_get_textsize(editor_help_font).x - 10, 10));
/* object properties */
font_set_position(editor_properties_font, v2d_new(10, 10));
if(editor_cursor_entity_type != EDT_ENEMY) {
font_set_text(
editor_properties_font,
"<color=ffff00>%s %d</color>\n%s",
editor_entity_class(editor_cursor_entity_type),
editor_cursor_entity_id,
editor_entity_info(editor_cursor_entity_type, editor_cursor_entity_id)
);
}
else {
font_set_text(
editor_properties_font,
"<color=77bbff>Selected category: %s</color>\n\n<color=ffff00>%s \"%s\"</color>\n%s\n%s",
editor_enemy_selected_category(),
editor_entity_class(editor_cursor_entity_type),
str_addslashes(editor_enemy_key2name(editor_cursor_entity_id)),
editor_enemy_annotation(editor_enemy_key2name(editor_cursor_entity_id)),
editor_entity_info(editor_cursor_entity_type, editor_cursor_entity_id)
);
}
/* "ungetting" major entities */
entitymanager_release_retrieved_brick_list(major_bricks);
entitymanager_release_retrieved_item_list(major_items);
entitymanager_release_retrieved_object_list(major_enemies);
}
/*
* editor_render()
* Renders the level editor
*/
void editor_render()
{
brick_list_t *major_bricks;
item_list_t *major_items;
enemy_list_t *major_enemies;
image_t *cursor;
v2d_t topleft = v2d_subtract(editor_camera, v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2));
major_bricks = entitymanager_retrieve_active_bricks();
major_items = entitymanager_retrieve_active_items();
major_enemies = entitymanager_retrieve_active_objects();
/* background */
editor_render_background();
/* grid */
editor_grid_render();
/* path of the moveable platforms */
editor_moveable_platforms_path_render(major_bricks);
/* entities */
render_entities(major_bricks, major_items, major_enemies);
if(!editor_is_eraser_enabled()) {
/* drawing the object */
editor_draw_object(editor_cursor_entity_type, editor_cursor_entity_id, v2d_subtract(editor_grid_snap(editor_cursor), topleft));
/* drawing the cursor arrow */
cursor = sprite_get_image(sprite_get_animation("SD_ARROW", 0), 0);
if(editor_layer == BRL_DEFAULT || (editor_cursor_entity_type != EDT_BRICK && editor_cursor_entity_type != EDT_GROUP))
image_draw(cursor, video_get_backbuffer(), (int)editor_cursor.x, (int)editor_cursor.y, IF_NONE);
else
image_draw_lit(cursor, video_get_backbuffer(), (int)editor_cursor.x, (int)editor_cursor.y, bricklayer2color(editor_layer), 0.5f, IF_NONE);
/* cursor coordinates */
font_render(editor_cursor_font, v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2));
}
else {
/* drawing an eraser */
cursor = sprite_get_image(sprite_get_animation("SD_ERASER", 0), 0);
image_draw(cursor, video_get_backbuffer(), (int)editor_cursor.x - image_width(cursor)/2, (int)editor_cursor.y - image_height(cursor)/2, IF_NONE);
}
/* draw editor water line */
editor_waterline_render((int)(waterlevel - topleft.y), image_rgb(255, 255, 255));
/* object properties */
font_render(editor_properties_font, v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2));
/* help label */
font_render(editor_help_font, v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2));
entitymanager_release_retrieved_brick_list(major_bricks);
entitymanager_release_retrieved_item_list(major_items);
entitymanager_release_retrieved_object_list(major_enemies);
}
/*
* editor_enable()
* Enables the level editor
*/
void editor_enable()
{
logfile_message("editor_enable()");
/* activating the editor */
editor_action_init();
editor_enabled = TRUE;
editor_camera.x = (int)camera_get_position().x;
editor_camera.y = (int)camera_get_position().y;
editor_cursor = v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2);
video_showmessage("Welcome to the Level Editor! Read readme.html to know how to use it.");
/* changing the video resolution */
editor_previous_video_resolution = video_get_resolution();
editor_previous_video_smooth = video_is_smooth();
video_changemode(VIDEORESOLUTION_EDT, FALSE, video_is_fullscreen());
logfile_message("editor_enable() ok");
}
/*
* editor_disable()
* Disables the level editor
*/
void editor_disable()
{
logfile_message("editor_disable()");
/* disabling the level editor */
update_level_size();
editor_action_release();
editor_enabled = FALSE;
/* restoring the video resolution */
video_changemode(editor_previous_video_resolution, editor_previous_video_smooth, video_is_fullscreen());
logfile_message("editor_disable() ok");
}
/*
* editor_is_enabled()
* Is the level editor activated?
*/
int editor_is_enabled()
{
return editor_enabled;
}
/*
* editor_want_to_activate()
* The level editor wants to be activated!
*/
int editor_want_to_activate()
{
return input_button_pressed(editor_keyboard, IB_FIRE4);
}
/*
* editor_render_background()
* Renders the background image of the
* level editor
*/
void editor_render_background()
{
float x = (float)VIDEO_SCREEN_W / image_width(editor_bgimage);
float y = (float)VIDEO_SCREEN_H / image_height(editor_bgimage);
image_draw_scaled(editor_bgimage, video_get_backbuffer(), 0, 0, v2d_new(x,y), IF_NONE);
}
/*
* editor_moveable_platforms_path_render()
* Renders the path of the moveable platforms
*/
void editor_moveable_platforms_path_render(brick_list_t *major_bricks)
{
brick_list_t *it;
for(it=major_bricks; it; it=it->next)
brick_render_path(it->data, editor_camera);
}
/*
* editor_waterline_render()
* Renders the line of the water
*/
void editor_waterline_render(int ycoord, uint32 color)
{
int x, x0 = 19 - (timer_get_ticks() / 25) % 20;
image_t *buf = video_get_backbuffer();
for(x=x0-10; x<VIDEO_SCREEN_W; x+=20)
image_line(buf, x, ycoord, x+10, ycoord, color);
}
/*
* editor_save()
* Saves the level
*/
void editor_save()
{
if(level_save(file)) {
sound_play( soundfactory_get("level saved") );
video_showmessage("Level saved.");
}
else {
sound_play( soundfactory_get("deny") );
video_showmessage("Can't save the level. Please check the logs...");
}
}
/*
* editor_scroll()
* Scrolling - "free-look mode"
*/
void editor_scroll()
{
float camera_speed;
float dt = timer_get_delta();
/* camera speed */
if(input_button_down(editor_keyboard, IB_FIRE3))
camera_speed = 5 * 750;
else
camera_speed = 750;
/* scrolling... */
if(input_button_down(editor_keyboard, IB_UP) || input_button_down(editor_keyboard2, IB_UP))
editor_camera.y -= camera_speed*dt;
if(input_button_down(editor_keyboard, IB_DOWN) || input_button_down(editor_keyboard2, IB_DOWN))
editor_camera.y += camera_speed*dt;
if(input_button_down(editor_keyboard, IB_LEFT) || input_button_down(editor_keyboard2, IB_LEFT))
editor_camera.x-= camera_speed*dt;
if(input_button_down(editor_keyboard, IB_RIGHT) || input_button_down(editor_keyboard2, IB_RIGHT))
editor_camera.x += camera_speed*dt;
/* make sure it doesn't go off the bounds */
editor_camera.x = (int)max(editor_camera.x, VIDEO_SCREEN_W/2);
editor_camera.y = (int)max(editor_camera.y, VIDEO_SCREEN_H/2);
camera_set_position(editor_camera);
}
/*
* editor_is_eraser_enabled()
* Is the eraser enabled?
*/
int editor_is_eraser_enabled()
{
if(
editor_cursor_entity_type != EDT_BRICK &&
editor_cursor_entity_type != EDT_ITEM &&
editor_cursor_entity_type != EDT_ENEMY
) {
if(input_button_pressed(editor_keyboard3, IB_FIRE2))
sound_play( soundfactory_get("deny") );
return FALSE;
}
else
return input_button_down(editor_keyboard3, IB_FIRE2);
}
/* private stuff (level editor) */
/* returns a string containing a text
* that corresponds to the given editor class
* object id */
const char *editor_entity_class(enum editor_entity_type objtype)
{
switch(objtype) {
case EDT_BRICK:
return "brick";
case EDT_ITEM:
return "built-in item";
case EDT_ENEMY:
return "object";
case EDT_GROUP:
return "group";
}
return "unknown";
}
/* returns a string containing information
* about a given object */
const char *editor_entity_info(enum editor_entity_type objtype, int objid)
{
static char buf[128];
strcpy(buf, "");
switch(objtype) {
case EDT_BRICK: {
brickdata_t *x = brickdata_get(objid);
if(x && x->image)
sprintf(buf, "angle: %d\nsize: %dx%d\nproperty: %s\nbehavior: %s\nzindex: %.2lf", x->angle, image_width(x->image), image_height(x->image), brick_get_property_name(x->property), brick_get_behavior_name(x->behavior), x->zindex);
else
sprintf(buf, "WARNING: missing brick");
break;
}
case EDT_ITEM: {
item_t *x = item_create(objid);
sprintf(buf, "obstacle: %s\nbring_to_back: %s", x->obstacle ? "TRUE" : "FALSE", x->bring_to_back ? "TRUE" : "FALSE");
item_destroy(x);
break;
}
case EDT_ENEMY: {
break;
}
case EDT_GROUP: {
break;
}
}
return buf;
}
/* returns the annotation of a given enemy */
const char* editor_enemy_annotation(const char *name)
{
static char buf[512] = "";
enemy_t *x = enemy_create(name);
str_cpy(buf, x->annotation, sizeof(buf));
enemy_destroy(x);
return buf;
}
/* returns the name of the selected category */
const char* editor_enemy_selected_category()
{
return editor_enemy_category[editor_enemy_selected_category_id];
}
/* next object category */
void editor_next_object_category()
{
editor_enemy_selected_category_id = (editor_enemy_selected_category_id + 1) % editor_enemy_category_length;
/* drop the entity if it's not in the correct category */
editor_next_entity();
editor_previous_entity();
}
/* previous object category */
void editor_previous_object_category()
{
editor_enemy_selected_category_id = ((editor_enemy_selected_category_id - 1) + editor_enemy_category_length) % editor_enemy_category_length;
/* drop the entity if it's not in the correct category */
editor_next_entity();
editor_previous_entity();
}
/* jump to next class */
void editor_next_class()
{
editor_cursor_entity_type =
(editor_cursor_entity_type == EDT_BRICK) ? EDT_ITEM :
(editor_cursor_entity_type == EDT_ITEM) ? EDT_ENEMY :
(editor_cursor_entity_type == EDT_ENEMY) ? EDT_GROUP :
(editor_cursor_entity_type == EDT_GROUP) ? EDT_BRICK :
editor_cursor_entity_type;
editor_cursor_entity_id = 0;
editor_cursor_itemid = 0;
if(editor_cursor_entity_type == EDT_GROUP && editorgrp_group_count() == 0)
editor_next_class();
if(editor_cursor_entity_type == EDT_ENEMY && editor_enemy_name_length == 0)
editor_next_class();
if(editor_cursor_entity_type == EDT_BRICK && brickdata_get(editor_cursor_entity_id) == NULL)
editor_next_entity();
}
/* jump to previous class */
void editor_previous_class()
{
editor_cursor_entity_type =
(editor_cursor_entity_type == EDT_ITEM) ? EDT_BRICK :
(editor_cursor_entity_type == EDT_ENEMY) ? EDT_ITEM :
(editor_cursor_entity_type == EDT_GROUP) ? EDT_ENEMY :
(editor_cursor_entity_type == EDT_BRICK) ? EDT_GROUP :
editor_cursor_entity_type;
editor_cursor_entity_id = 0;
editor_cursor_itemid = 0;
if(editor_cursor_entity_type == EDT_GROUP && editorgrp_group_count() == 0)
editor_previous_class();
if(editor_cursor_entity_type == EDT_ENEMY && editor_enemy_name_length == 0)
editor_previous_class();
if(editor_cursor_entity_type == EDT_BRICK && brickdata_get(editor_cursor_entity_id) == NULL)
editor_next_entity();
}
/* select the next object */
void editor_next_entity()
{
int size;
switch(editor_cursor_entity_type) {
/* brick */
case EDT_BRICK: {
size = brickdata_size();
editor_cursor_entity_id = (editor_cursor_entity_id + 1) % size;
if(brickdata_get(editor_cursor_entity_id) == NULL)
editor_next_entity(); /* invalid brick? */
break;
}
/* item */
case EDT_ITEM: {
size = editor_item_list_size;
editor_cursor_itemid = (editor_cursor_itemid + 1) % size;
editor_cursor_entity_id = editor_item_list[editor_cursor_itemid];
break;
}
/* enemy */
case EDT_ENEMY: {
enemy_t *enemy;
size = editor_enemy_name_length;
editor_cursor_entity_id = (editor_cursor_entity_id + 1) % size;
enemy = enemy_create(editor_enemy_key2name(editor_cursor_entity_id));
if(!enemy_belongs_to_category(enemy, editor_enemy_selected_category())) {
enemy_destroy(enemy);
editor_next_entity(); /* invalid category? */
}
else
enemy_destroy(enemy);
break;
}
/* group */
case EDT_GROUP: {
size = editorgrp_group_count();
editor_cursor_entity_id = (editor_cursor_entity_id + 1) % size;
break;
}
}
}
/* select the previous object */
void editor_previous_entity()
{
int size;
switch(editor_cursor_entity_type) {
/* brick */
case EDT_BRICK: {
size = brickdata_size();
editor_cursor_entity_id = ((editor_cursor_entity_id - 1) + size) % size;
if(brickdata_get(editor_cursor_entity_id) == NULL)
editor_previous_entity(); /* invalid brick? */
break;
}
/* item */
case EDT_ITEM: {
size = editor_item_list_size;
editor_cursor_itemid = ((editor_cursor_itemid - 1) + size) % size;
editor_cursor_entity_id = editor_item_list[editor_cursor_itemid];
break;
}
/* enemy */
case EDT_ENEMY: {
enemy_t *enemy;
size = editor_enemy_name_length;
editor_cursor_entity_id = ((editor_cursor_entity_id - 1) + size) % size;
enemy = enemy_create(editor_enemy_key2name(editor_cursor_entity_id));
if(!enemy_belongs_to_category(enemy, editor_enemy_selected_category())) {
enemy_destroy(enemy);
editor_previous_entity(); /* invalid category? */
}
else
enemy_destroy(enemy);
break;
}
/* group */
case EDT_GROUP: {
size = editorgrp_group_count();
editor_cursor_entity_id = ((editor_cursor_entity_id - 1) + size) % size;
break;
}
}
}
/* returns the index of item_id on
* editor_item_list or -1 if the search fails */
int editor_item_list_get_index(int item_id)
{
int i;
for(i=0; i<editor_item_list_size; i++) {
if(item_id == editor_item_list[i])
return i;
}
return -1;
}
/*
* editor_is_valid_item()
* Is the given item valid to be used in
* the level editor?
*/
int editor_is_valid_item(int item_id)
{
return (editor_item_list_get_index(item_id) != -1);
}
/* draws the given object at [position] */
void editor_draw_object(enum editor_entity_type obj_type, int obj_id, v2d_t position)
{
image_t *cursor = NULL;
v2d_t offset = v2d_new(0, 0);
float alpha = 1.0f;
/* getting the image of the current object */
switch(obj_type) {
case EDT_BRICK: {
if(brickdata_get(obj_id) != NULL) {
cursor = brickdata_get(obj_id)->image;
if(brickdata_get(obj_id)->property == BRK_NONE)
alpha = 0.5f;
}
break;
}
case EDT_ITEM: {
item_t *item = item_create(obj_id);
if(item != NULL) {
cursor = actor_image(item->actor);
offset = item->actor->hot_spot;
item_destroy(item);
}
break;
}
case EDT_ENEMY: {
enemy_t *enemy = enemy_create(editor_enemy_key2name(obj_id));
if(enemy != NULL) {
cursor = actor_image(enemy->actor);
offset = enemy->actor->hot_spot;
enemy_destroy(enemy);
}
break;
}
case EDT_GROUP: {
editorgrp_entity_list_t *list, *it;
list = editorgrp_get_group(obj_id);
for(it=list; it; it=it->next) {
enum editor_entity_type my_type = EDITORGRP_ENTITY_TO_EDT(it->entity.type);
editor_draw_object(my_type, it->entity.id, v2d_add(position, it->entity.position));
}
break;
}
}
/* drawing the object */
if(cursor != NULL)
image_draw_trans(cursor, video_get_backbuffer(), (int)(position.x-offset.x), (int)(position.y-offset.y), alpha, IF_NONE);
}
/* level editor: enemy name list */
int editor_enemy_name2key(const char *name)
{
int i;
for(i=0; i<editor_enemy_name_length; i++) {
if(strcmp(name, editor_enemy_name[i]) == 0)
return i;
}
return -1; /* not found */
}
const char* editor_enemy_key2name(int key)
{
key = clip(key, 0, editor_enemy_name_length-1);
return editor_enemy_name[key];
}
/* level editor: grid */
/* initializes the grid module */
void editor_grid_init()
{
editor_grid_enabled = TRUE;
}
/* releases the grid module */
void editor_grid_release()
{
}
/* updates the grid module */
void editor_grid_update()
{
if(input_button_pressed(editor_keyboard2, IB_FIRE3))
editor_grid_enabled = !editor_grid_enabled;
}
/* renders the grid */
void editor_grid_render()
{
if(editor_grid_enabled) {
int i, j;
image_t *grid;
uint32 color;
v2d_t v, topleft = v2d_subtract(editor_camera, v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2));
/* creating the grid image */
grid = image_create(EDITOR_GRID_W, EDITOR_GRID_H);
color = image_rgb(0,128,160);
image_clear(grid, video_get_maskcolor());
for(i=0; i<image_height(grid); i++)
image_putpixel(grid, image_width(grid)-1, i, color);
for(i=0; i<image_width(grid); i++)
image_putpixel(grid, i, image_height(grid)-1, color);
/* drawing the grid... */
for(i=0; i<=VIDEO_SCREEN_W/image_width(grid); i++) {
for(j=0; j<=VIDEO_SCREEN_H/image_height(grid); j++) {
v = v2d_subtract(editor_grid_snap(v2d_new(i*image_width(grid), j*image_height(grid))), topleft);
image_draw(grid, video_get_backbuffer(), (int)v.x, (int)v.y, IF_NONE);
}
}
/* done! */
image_destroy(grid);
}
}
/* returns the size of the grid */
v2d_t editor_grid_size()
{
if(!editor_grid_enabled)
return v2d_new(1,1);
else
return v2d_new(8,8);
}
/* aligns position to a cell in the grid */
v2d_t editor_grid_snap(v2d_t position)
{
v2d_t topleft = v2d_subtract(editor_camera, v2d_new(VIDEO_SCREEN_W/2, VIDEO_SCREEN_H/2));
int w = EDITOR_GRID_W;
int h = EDITOR_GRID_H;
int cx = (int)topleft.x % w;
int cy = (int)topleft.y % h;
int xpos = -cx + ((int)position.x / w) * w;
int ypos = -cy + ((int)position.y / h) * h;
return v2d_add(topleft, v2d_new(xpos, ypos));
}
/* level editor actions */
/* action: constructor (entity) */
editor_action_t editor_action_entity_new(int is_new_object, enum editor_entity_type obj_type, int obj_id, v2d_t obj_position)
{
editor_action_t o;
o.type = is_new_object ? EDA_NEWOBJECT : EDA_DELETEOBJECT;
o.obj_type = obj_type;
o.obj_id = obj_id;
o.obj_position = obj_position;
o.obj_old_position = obj_position;
o.layer = editor_layer;
/* are we removing a brick? Store its layer */
if(!is_new_object && obj_type == EDT_BRICK) {
brick_list_t *it, *brick_list = entitymanager_retrieve_all_bricks();
brickdata_t *ref = brickdata_get(o.obj_id);
for(it=brick_list; it; it=it->next) {
if(it->data->brick_ref == ref) {
float dist = v2d_magnitude(v2d_subtract(v2d_new(it->data->x, it->data->y), o.obj_position));
if(dist < EPSILON) {
it->data->state = BRS_DEAD;
o.layer = it->data->layer;
}
}
}
}
return o;
}
/* action: constructor (spawn point) */
editor_action_t editor_action_spawnpoint_new(int is_changing, v2d_t obj_position, v2d_t obj_old_position)
{
editor_action_t o;
o.type = is_changing ? EDA_CHANGESPAWN : EDA_RESTORESPAWN;
o.obj_id = 0;
o.obj_position = obj_position;
o.obj_old_position = obj_old_position;
o.obj_type = EDT_ITEM;
o.layer = editor_layer;
return o;
}
/* initializes the editor_action module */
void editor_action_init()
{
/* linked list */
editor_action_buffer_head = mallocx(sizeof *editor_action_buffer_head);
editor_action_buffer_head->in_group = FALSE;
editor_action_buffer_head->prev = NULL;
editor_action_buffer_head->next = NULL;
editor_action_buffer = editor_action_buffer_head;
editor_action_buffer_cursor = editor_action_buffer_head;
}
/* releases the editor_action module */
void editor_action_release()
{
/* linked list */
editor_action_buffer_head = editor_action_delete_list(editor_action_buffer_head);
editor_action_buffer = NULL;
editor_action_buffer_cursor = NULL;
}
/* registers a new editor_action */
void editor_action_register(editor_action_t action)
{
/* ugly, but these fancy group stuff
* shouldn't be availiable on the interface */
static int registering_group = FALSE;
static uint32 group_key;
if(action.obj_type != EDT_GROUP) {
editor_action_list_t *c, *it, *node;
/* creating new node */
node = mallocx(sizeof *node);
node->action = action;
node->in_group = registering_group;
if(node->in_group)
node->group_key = group_key;
/* cursor */
c = editor_action_buffer_cursor;
if(c != NULL)
c->next = editor_action_delete_list(c->next);
/* inserting the node into the linked list */
it = editor_action_buffer;
while(it->next != NULL)
it = it->next;
it->next = node;
node->prev = it;
node->next = NULL;
/* updating the cursor */
editor_action_buffer_cursor = node;
}
else {
static uint32 auto_increment = 0xbeef; /* dummy value */
editorgrp_entity_list_t *list, *it;
/* registering a group of objects */
registering_group = TRUE;
group_key = auto_increment++;
list = editorgrp_get_group(action.obj_id);
for(it=list; it; it=it->next) {
editor_action_t a;
editorgrp_entity_t e = it->entity;
enum editor_entity_type my_type = EDITORGRP_ENTITY_TO_EDT(e.type);
a = editor_action_entity_new(TRUE, my_type, e.id, v2d_add(e.position, action.obj_position));
editor_action_register(a);
}
registering_group = FALSE;
}
}
/* deletes an editor_action list */
editor_action_list_t* editor_action_delete_list(editor_action_list_t *list)
{
editor_action_list_t *p, *next;
p = list;
while(p != NULL) {
next = p->next;
free(p);
p = next;
}
return NULL;
}
/* undo */
void editor_action_undo()
{
editor_action_list_t *p;
editor_action_t a;
if(editor_action_buffer_cursor != editor_action_buffer_head) {
/* moving the cursor */
p = editor_action_buffer_cursor;
editor_action_buffer_cursor = editor_action_buffer_cursor->prev;
/* UNDOing a group? */
if(p->in_group && p->prev && p->prev->in_group && p->group_key == p->prev->group_key)
editor_action_undo();
/* undo */
a = p->action;
a.type = /* reverse of a.type ??? */
(a.type == EDA_NEWOBJECT) ? EDA_DELETEOBJECT :
(a.type == EDA_DELETEOBJECT) ? EDA_NEWOBJECT :
(a.type == EDA_CHANGESPAWN) ? EDA_RESTORESPAWN :
(a.type == EDA_RESTORESPAWN) ? EDA_CHANGESPAWN :
a.type;
editor_action_commit(a);
}
else
video_showmessage("Already at oldest change.");
}
/* redo */
void editor_action_redo()
{
editor_action_list_t *p;
editor_action_t a;
if(editor_action_buffer_cursor->next != NULL) {
/* moving the cursor */
editor_action_buffer_cursor = editor_action_buffer_cursor->next;
p = editor_action_buffer_cursor;
/* REDOing a group? */
if(p->in_group && p->next && p->next->in_group && p->group_key == p->next->group_key)
editor_action_redo();
/* redo */
a = p->action;
editor_action_commit(a);
}
else
video_showmessage("Already at newest change.");
}
/* commit action */
void editor_action_commit(editor_action_t action)
{
brick_list_t *brick_list;
item_list_t *item_list;
enemy_list_t *object_list;
brick_list = entitymanager_retrieve_all_bricks(); /* FIXME: retrieve relevant entities only? */
item_list = entitymanager_retrieve_all_items();
object_list = entitymanager_retrieve_all_objects();
if(action.type == EDA_NEWOBJECT) {
/* new object */
switch(action.obj_type) {
case EDT_BRICK: {
/* new brick */
brick_t *brk = level_create_brick(action.obj_id, action.obj_position);
brk->layer = action.layer;
break;
}
case EDT_ITEM: {
/* new item */
level_create_item(action.obj_id, action.obj_position);
break;
}
case EDT_ENEMY: {
/* new enemy */
level_create_enemy(editor_enemy_key2name(action.obj_id), action.obj_position);
break;
}
case EDT_GROUP: {
/* new group of objects */
editorgrp_entity_list_t *list, *it;
list = editorgrp_get_group(action.obj_id);
for(it=list; it; it=it->next) {
editor_action_t a;
editorgrp_entity_t e = it->entity;
enum editor_entity_type my_type = EDITORGRP_ENTITY_TO_EDT(e.type);
int old_layer = editor_layer;
/* e.layer has higher precedence than editor_layer */
editor_layer = (e.layer != BRL_DEFAULT) ? e.layer : editor_layer;
a = editor_action_entity_new(TRUE, my_type, e.id, v2d_add(e.position, action.obj_position));
editor_action_commit(a);
editor_layer = old_layer;
}
break;
}
}
}
else if(action.type == EDA_DELETEOBJECT) {
/* delete object */
switch(action.obj_type) {
case EDT_BRICK: {
/* delete brick */
brick_list_t *it;
brickdata_t *ref = brickdata_get(action.obj_id);
for(it=brick_list; it; it=it->next) {
if(it->data->brick_ref == ref) {
float dist = v2d_magnitude(v2d_subtract(v2d_new(it->data->x, it->data->y), action.obj_position));
if(dist < EPSILON)
it->data->state = BRS_DEAD;
}
}
break;
}
case EDT_ITEM: {
/* delete item */
item_list_t *it;
int id = action.obj_id;
for(it=item_list; it; it=it->next) {
if(it->data->type == id) {
float dist = v2d_magnitude(v2d_subtract(it->data->actor->position, action.obj_position));
if(dist < EPSILON)
it->data->state = IS_DEAD;
}
}
break;
}
case EDT_ENEMY: {
/* delete object */
enemy_list_t *it;
int id = action.obj_id;
for(it=object_list; it; it=it->next) {
if(editor_enemy_name2key(it->data->name) == id) {
float dist = v2d_magnitude(v2d_subtract(it->data->actor->position, action.obj_position));
if(dist < EPSILON)
it->data->state = ES_DEAD;
}
}
break;
}
case EDT_GROUP: {
/* can't delete a group directly */
break;
}
}
}
else if(action.type == EDA_CHANGESPAWN) {
/* change spawn point */
level_set_spawn_point(action.obj_position);
spawn_players();
}
else if(action.type == EDA_RESTORESPAWN) {
/* restore spawn point */
level_set_spawn_point(action.obj_old_position);
spawn_players();
}
brick_list = entitymanager_release_retrieved_brick_list(brick_list);
item_list = entitymanager_release_retrieved_item_list(item_list);
object_list = entitymanager_release_retrieved_object_list(object_list);
}
| 30.752478 | 361 | 0.609 |
94c3454a130385902581e58f16083e175197a650 | 243 | h | C | LiscError.h | frozenbears/Lisc | bc03bd3901aa6c91c61959a97ec3a9018e5bb8c0 | [
"MIT"
] | 2 | 2015-02-08T06:04:12.000Z | 2015-02-23T13:30:20.000Z | LiscError.h | frozenbears/Lisc | bc03bd3901aa6c91c61959a97ec3a9018e5bb8c0 | [
"MIT"
] | null | null | null | LiscError.h | frozenbears/Lisc | bc03bd3901aa6c91c61959a97ec3a9018e5bb8c0 | [
"MIT"
] | null | null | null |
#import <Cocoa/Cocoa.h>
@interface LiscError : NSException
+ (void)raiseSyntaxError:(NSString *)reason;
+ (void)raiseNameError:(NSString *)reason;
+ (void)raiseTypeError:(NSString *)reason;
+ (void)raiseIndexError:(NSString *)reason;
@end
| 20.25 | 44 | 0.740741 |
94c36bcbacbf1e4d47cecb75b99b8213e1d6ceab | 886 | h | C | System/Library/PrivateFrameworks/CloudDocsDaemon.framework/BRCDumper.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 12 | 2019-06-02T02:42:41.000Z | 2021-04-13T07:22:20.000Z | System/Library/PrivateFrameworks/CloudDocsDaemon.framework/BRCDumper.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/CloudDocsDaemon.framework/BRCDumper.h | lechium/iPhoneOS_12.1.1_Headers | aac688b174273dfcbade13bab104461f463db772 | [
"MIT"
] | 3 | 2019-06-11T02:46:10.000Z | 2019-12-21T14:58:16.000Z | /*
* This header is generated by classdump-dyld 1.0
* on Saturday, June 1, 2019 at 6:50:41 PM Mountain Standard Time
* Operating System: Version 12.1.1 (Build 16C5050a)
* Image Source: /System/Library/PrivateFrameworks/CloudDocsDaemon.framework/CloudDocsDaemon
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
@interface BRCDumper : NSObject
-(id)startStringForFgColor:(int)arg1 bgColor:(int)arg2 attr:(int)arg3 ;
-(id)stringForReset;
-(void)startFgColor:(int)arg1 bgColor:(int)arg2 attr:(int)arg3 ;
-(void)startFgColor:(int)arg1 attr:(int)arg2 ;
-(void)startBgColor:(int)arg1 attr:(int)arg2 ;
-(void)startFgColor:(int)arg1 ;
-(void)startBgColor:(int)arg1 ;
-(void)startAttributes:(int)arg1 ;
-(void)changeFgColor:(int)arg1 ;
-(void)changeBgColor:(int)arg1 ;
-(void)changeAttributes:(int)arg1 ;
-(void)write:(const char*)arg1 ;
-(void)reset;
@end
| 34.076923 | 91 | 0.748307 |
94c6fa30db9b17c00563a45885b637068a3c4fd8 | 2,970 | c | C | software/handheld2/src/codec2/cohpsk_mod.c | omc8db/DigitalVoice | 842e04be940b272fd5d077cc9815beb84370587d | [
"Apache-2.0"
] | 1 | 2018-08-28T18:17:37.000Z | 2018-08-28T18:17:37.000Z | software/handheld2/src/codec2/cohpsk_mod.c | omc8db/DigitalVoice | 842e04be940b272fd5d077cc9815beb84370587d | [
"Apache-2.0"
] | null | null | null | software/handheld2/src/codec2/cohpsk_mod.c | omc8db/DigitalVoice | 842e04be940b272fd5d077cc9815beb84370587d | [
"Apache-2.0"
] | 4 | 2017-12-25T16:05:55.000Z | 2020-03-13T12:29:00.000Z | /*---------------------------------------------------------------------------*\
FILE........: cohpsk_mod.c
AUTHOR......: David Rowe
DATE CREATED: April 5 2015
Given an input file of bits (note one bit per float, soft decision format),
outputs a raw file (8kHz, 16 bit shorts) of COHPSK modem samples
ready to send over a HF radio channel.
\*---------------------------------------------------------------------------*/
/*
Copyright (C) 2015 David Rowe
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <errno.h>
#include "codec2_cohpsk.h"
#include "codec2_fdmdv.h"
int main(int argc, char *argv[])
{
FILE *fin, *fout;
struct COHPSK *cohpsk;
float tx_bits_sd[COHPSK_BITS_PER_FRAME];
int tx_bits[COHPSK_BITS_PER_FRAME];
COMP tx_fdm[COHPSK_NOM_SAMPLES_PER_FRAME];
short tx_fdm_scaled[COHPSK_NOM_SAMPLES_PER_FRAME];
int frames;
int i;
if (argc < 3) {
printf("usage: %s InputOneFloatPerBitFile OutputModemRawFile\n", argv[0]);
exit(1);
}
if (strcmp(argv[1], "-") == 0) fin = stdin;
else if ( (fin = fopen(argv[1],"rb")) == NULL ) {
fprintf(stderr, "Error opening input file: %s: %s.\n",
argv[1], strerror(errno));
exit(1);
}
if (strcmp(argv[2], "-") == 0) fout = stdout;
else if ( (fout = fopen(argv[2],"wb")) == NULL ) {
fprintf(stderr, "Error opening output modem sample file: %s: %s.\n",
argv[2], strerror(errno));
exit(1);
}
cohpsk = cohpsk_create();
frames = 0;
while(fread(tx_bits_sd, sizeof(float), COHPSK_BITS_PER_FRAME, fin) == COHPSK_BITS_PER_FRAME) {
frames++;
for(i=0; i<COHPSK_BITS_PER_FRAME; i++)
tx_bits[i] = tx_bits_sd[i] < 0.0;
cohpsk_mod(cohpsk, tx_fdm, tx_bits);
cohpsk_clip(tx_fdm);
/* scale and save to disk as shorts */
for(i=0; i<COHPSK_NOM_SAMPLES_PER_FRAME; i++)
tx_fdm_scaled[i] = FDMDV_SCALE * tx_fdm[i].real;
fwrite(tx_fdm_scaled, sizeof(short), COHPSK_NOM_SAMPLES_PER_FRAME, fout);
/* if this is in a pipeline, we probably don't want the usual
buffering to occur */
if (fout == stdout) fflush(stdout);
if (fin == stdin) fflush(stdin);
}
fclose(fin);
fclose(fout);
cohpsk_destroy(cohpsk);
return 0;
}
| 29.117647 | 98 | 0.616162 |
94c75c25a92ef09429077d7752df1ddb5fed0ff0 | 4,018 | h | C | include/mlib/jbridge.h | taogashi/mlib | 56d0ac08205b3a09cac7ed97209454cc6262c924 | [
"Unlicense",
"MIT"
] | 12 | 2020-07-08T04:21:44.000Z | 2022-03-24T10:02:03.000Z | include/mlib/jbridge.h | taogashi/mlib | 56d0ac08205b3a09cac7ed97209454cc6262c924 | [
"Unlicense",
"MIT"
] | null | null | null | include/mlib/jbridge.h | taogashi/mlib | 56d0ac08205b3a09cac7ed97209454cc6262c924 | [
"Unlicense",
"MIT"
] | 2 | 2020-07-22T09:00:40.000Z | 2021-06-29T13:54:10.000Z | /*!
\file jbridge.h Definition of JSONBridge class
(c) Mircea Neacsu 2017. All rights reserved.
*/
#pragma once
#include "httpd.h"
namespace mlib {
/// JSON dictionary entry types
enum js_type {
JT_SHORT, ///< short int
JT_USHORT, ///< unsigned short int
JT_INT, ///< int
JT_UINT, ///< unsigned int
JT_LONG, ///< long
JT_ULONG, ///< unsigned long
JT_FLT, ///< float
JT_DBL, ///< double
JT_PSTR, ///< char*
JT_STR, ///< char
JT_BOOL, ///< bool
JT_OBJECT, ///< start of a composite object
JT_ENDOBJ, ///< end of composite object
JT_POSTFUN, ///< POST function call
};
/// JSON data dictionary entry
typedef struct jsonvar_t {
char *name; ///< external name of variable
void *addr; ///< memory address
js_type type; ///< data type (one of JT_... values)
unsigned short sz; ///< element size (used only for strings)
unsigned short cnt; ///< number of elements
} JSONVAR;
/// Mark the beginning of JSON dictionary
#define JSD_STARTDIC(dict) JSONVAR dict[] ={
/// Mark the end of JSON dictionary
#define JSD_ENDDIC {0, 0, JT_INT, 0, 0} }
/*!
Generates an entry in JSON dictionary for a variable that has the same
external name (name used in the JSON response) as the variable name.
\param V Name of variable
\param T Type of variable (one of JT_... values)
\param C Number of elements (for arrays)
\param S Element size (only for JT_STR and JT_PSTR types)
*/
#define JSD(V, T, C, S) {#V, &##V, T, S, C}
/*!
Generates an entry in JSON dictionary for a variable that has a different
external name (name used in the JSON response) than the variable name.
\param V variable name
\param N External (JSON) name of the variable
\param T Type of variable (one of JT_... values)
\param C Number of elements (for arrays)
\param S Element size (only for JT_STR and JT_PSTR types)
*/
#define JSDN(V, N, T, C, S) {N, &##V, T, S, C}
/*!
Generates an entry in JSON dictionary for a variable whose address is not
yet known. Address must be set using set_var function.
\param N External (JSON) name of the variable
\param T Type of variable (one of JT_... values)
\param C Number of elements (for arrays)
\param S Element size (only for JT_STR and JT_PSTR types)
*/
#define JSDX(N, T, C, S) {N, nullptr, T, S, C}
///Generate entry for a composite object
#define JSD_OBJECT(N) {N, 0, JT_OBJECT, 0, 1}
///Generate entry for end of composite object
#define JSD_ENDOBJ {"", 0, JT_ENDOBJ, 0, 1}
///Generate entry for POST function call
#define JSDN_POSTFUNC(F, N) {N, F, JT_POSTFUN, 0, 1}
/// JSON objects support
class JSONBridge {
public:
JSONBridge (const char *path, JSONVAR* dict);
~JSONBridge ();
void attach_to (httpd& server);
void lock ();
void unlock ();
const std::string& path ();
bool set_var (const char *name, void *addr, unsigned short count = 1, unsigned short sz = 0);
virtual void post_parse ();
http_connection& client ();
protected:
bool jsonify (const JSONVAR*& entry);
void bprintf (const char *fmt, ...);
void not_found (const char *varname);
bool strquote (const char *str);
JSONVAR *find (const char *name, int *idx);
private:
bool json_begin ();
void json_end ();
bool parse_urlencoded ();
std::string path_;
JSONVAR* dictionary;
http_connection *client_;
char *buffer;
char *bufptr;
criticalsection in_use;
static int callback (const char *uri, http_connection& client, JSONBridge *ctx);
};
/*==================== INLINE FUNCTIONS ===========================*/
/// Enter the critical section associated with this context
inline
void JSONBridge::lock (){ in_use.enter (); }
/// Leave the critical section associated with this context
inline
void JSONBridge::unlock (){ in_use.leave (); }
/// Return the context path
inline
const std::string& JSONBridge::path () { return path_; }
inline
http_connection& JSONBridge::client () { return *client_; };
}
| 28.097902 | 95 | 0.658288 |
94c9876f31f4d34eba97f42b907023a4bbf3d169 | 739 | h | C | include/battle_dome_cards.h | thechurchofcage/Complete-Fire-Red-Upgrade | e8bab9a1aab9d34c019940dab2015bac89ab8918 | [
"WTFPL"
] | null | null | null | include/battle_dome_cards.h | thechurchofcage/Complete-Fire-Red-Upgrade | e8bab9a1aab9d34c019940dab2015bac89ab8918 | [
"WTFPL"
] | null | null | null | include/battle_dome_cards.h | thechurchofcage/Complete-Fire-Red-Upgrade | e8bab9a1aab9d34c019940dab2015bac89ab8918 | [
"WTFPL"
] | null | null | null | #ifndef GUARD_BATTLE_DOME_CARDS_H
#define GUARD_BATTLE_DOME_CARDS_H
#include "global.h"
bool16 dp13_810BB8C(void);
u16 sub_818D3E4(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s16 y, u8 paletteSlot, u16 paletteTag);
u16 sub_818D7D8(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag);
u16 sub_818D820(u16 spriteId);
u16 sub_818D8AC(u16 species, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag);
u16 sub_818D8F0(u16 spriteId);
u16 sub_818D938(u16 species, bool8 isFrontPic, u16 destX, u16 destY, u8 paletteSlot, u8 windowId);
u8 sub_818D97C(u8 a0, u8 a1);
u8 sub_810C2A4(u16, u8, s16, s16, u8, u16);
void sub_810C2E8(u16);
#endif //GUARD_BATTLE_DOME_CARDS_H
| 41.055556 | 120 | 0.780785 |
94ccfb10e1d1bbddfef1e9aca3604d8d36343b4c | 389 | h | C | liblokatt/stack.h | amhk/attic-lokatt | 44ce52f0a583db2ca8b6f7ed735ba9a5044454bf | [
"MIT"
] | 1 | 2019-04-04T08:21:45.000Z | 2019-04-04T08:21:45.000Z | liblokatt/stack.h | amhk/attic-lokatt | 44ce52f0a583db2ca8b6f7ed735ba9a5044454bf | [
"MIT"
] | null | null | null | liblokatt/stack.h | amhk/attic-lokatt | 44ce52f0a583db2ca8b6f7ed735ba9a5044454bf | [
"MIT"
] | null | null | null | #ifndef LIBLOKATT_STACK_H
#define LIBLOKATT_STACK_H
#include <stddef.h>
struct stack {
void *data;
size_t item_size;
size_t current_size;
size_t max_size;
};
void stack_init(struct stack *stack, size_t item_size);
void *stack_top(const struct stack *stack);
void *stack_push(struct stack *stack);
void stack_pop(struct stack *stack);
void stack_destroy(struct stack *stack);
#endif
| 20.473684 | 55 | 0.77635 |
94ce81d19e2961f2bd9ecb30a51046d017f656ac | 1,190 | h | C | extra-parts/code/Matrix.h | rpbritton/keyboards | b5b52652a1f0249b460e7afefa58dc3232d66107 | [
"MIT"
] | null | null | null | extra-parts/code/Matrix.h | rpbritton/keyboards | b5b52652a1f0249b460e7afefa58dc3232d66107 | [
"MIT"
] | null | null | null | extra-parts/code/Matrix.h | rpbritton/keyboards | b5b52652a1f0249b460e7afefa58dc3232d66107 | [
"MIT"
] | null | null | null | #pragma once
class Matrix {
public:
Matrix() {};
void setup(void (*callback)(unsigned char, bool));
void loop();
private:
static const unsigned long k_debounce = 5000;
static const unsigned char k_numRows = 15;
static const unsigned char k_numCols = 5;
const unsigned char k_rowPins[k_numRows] = {
14, 15, 16, 17, 18, 19, 20, 21, 1, 2, 3, 4, 5, 6, 7
};
const unsigned char k_colPins[k_numCols] = {
0, 13, 23, 10, 9
};
const unsigned char k_returnValues[k_numRows][k_numCols] = {
{ 0, 14, 28, 41, 53 },
{ 1, 15, 29, 255, 54 },
{ 2, 16, 30, 42, 255 },
{ 3, 17, 31, 43, 55 },
{ 4, 18, 32, 44, 255 },
{ 5, 19, 33, 45, 255 },
{ 6, 20, 34, 46, 255 },
{ 7, 21, 35, 47, 56 },
{ 8, 22, 36, 48, 255 },
{ 9, 23, 37, 49, 255 },
{ 10, 24, 38, 50, 57 },
{ 11, 25, 39, 51, 58 },
{ 12, 26, 255, 52, 60 },
{ 13, 27, 40, 59, 61 },
{ 63, 255, 64, 65, 62 },
};
struct Button {
unsigned long debouncer = 0;
bool state = HIGH;
};
Button m_buttons[k_numRows][k_numCols];
void (*m_callback)(unsigned char, bool);
};
| 24.285714 | 63 | 0.502521 |
94d15327c462b670ce167a9c9554a08cb4c05558 | 3,384 | h | C | src/tests/test.h | fbenkstein/majak | 74605de6fd0fbc7ae92722f51d7bcd14e9e5eccc | [
"Apache-2.0"
] | 2 | 2018-10-16T20:54:38.000Z | 2018-10-18T19:43:44.000Z | src/tests/test.h | fbenkstein/majak | 74605de6fd0fbc7ae92722f51d7bcd14e9e5eccc | [
"Apache-2.0"
] | 8 | 2018-09-10T22:48:51.000Z | 2018-09-19T11:36:11.000Z | src/tests/test.h | fbenkstein/majak | 74605de6fd0fbc7ae92722f51d7bcd14e9e5eccc | [
"Apache-2.0"
] | null | null | null | // Copyright 2011 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef NINJA_TEST_H_
#define NINJA_TEST_H_
#include <ninja/disk_interface.h>
#include <ninja/filesystem.h>
#include <ninja/manifest_parser.h>
#include <ninja/state.h>
#include <ninja/util.h>
#include <gtest/gtest.h>
// Support utilites for tests.
namespace ninja {
struct Node;
}
/// A base test fixture that includes a State object with a
/// builtin "cat" rule.
struct StateTestWithBuiltinRules : public testing::Test {
StateTestWithBuiltinRules();
/// Add a "cat" rule to \a state. Used by some tests; it's
/// otherwise done by the ctor to state_.
void AddCatRule(ninja::State* state);
/// Short way to get a Node by its path from state_.
ninja::Node* GetNode(const std::string& path);
ninja::State state_;
};
void AssertParse(ninja::State* state, const char* input,
ninja::ManifestParserOptions = {});
void AssertHash(const char* expected, uint64_t actual);
void VerifyGraph(const ninja::State& state);
/// An implementation of DiskInterface that uses an in-memory representation
/// of disk state. It also logs file accesses and directory creations
/// so it can be used by tests to verify disk access patterns.
struct VirtualFileSystem : public ninja::DiskInterface {
VirtualFileSystem() : now_(1) {}
/// "Create" a file with contents.
void Create(const std::string& path, const std::string& contents);
/// Tick "time" forwards; subsequent file operations will be newer than
/// previous ones.
int Tick() { return ++now_; }
// DiskInterface
virtual ninja::TimeStamp Stat(const std::string& path,
std::string* err) const;
virtual bool WriteFile(const std::string& path, const std::string& contents);
virtual bool MakeDir(const std::string& path);
virtual Status ReadFile(const std::string& path, std::string* contents,
std::string* err);
virtual int RemoveFile(const std::string& path);
/// An entry for a single in-memory file.
struct Entry {
int mtime;
std::string stat_error; // If mtime is -1.
std::string contents;
};
std::vector<std::string> directories_made_;
std::vector<std::string> files_read_;
typedef std::map<std::string, Entry> FileMap;
FileMap files_;
std::set<std::string> files_removed_;
std::set<std::string> files_created_;
/// A simple fake timestamp for file operations.
int now_;
};
struct ScopedTempDir {
/// Create a temporary directory and chdir into it.
void CreateAndEnter(const std::string& name);
/// Clean up the temporary directory.
void Cleanup();
/// The temp directory containing our dir.
ninja::fs::path start_dir_;
/// The subdirectory name for our dir, or empty if it hasn't been set up.
std::string temp_dir_name_;
};
#endif // NINJA_TEST_H_
| 31.924528 | 79 | 0.705378 |
94d87e189763642c2743a4221f30cea31cf4ff6b | 4,879 | h | C | 3rd_party_libs/chai3d_a4/src/collisions/CCollisionBrute.h | atp42/jks-ros-pkg | 367fc00f2a9699f33d05c7957d319a80337f1ed4 | [
"FTL"
] | 3 | 2017-02-02T13:27:45.000Z | 2018-06-17T11:52:13.000Z | 3rd_party_libs/chai3d_a4/src/collisions/CCollisionBrute.h | salisbury-robotics/jks-ros-pkg | 367fc00f2a9699f33d05c7957d319a80337f1ed4 | [
"FTL"
] | null | null | null | 3rd_party_libs/chai3d_a4/src/collisions/CCollisionBrute.h | salisbury-robotics/jks-ros-pkg | 367fc00f2a9699f33d05c7957d319a80337f1ed4 | [
"FTL"
] | null | null | null | //===========================================================================
/*
Software License Agreement (BSD License)
Copyright (c) 2003-2012, CHAI3D.
(www.chai3d.org)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of CHAI3D nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
\author <http://www.chai3d.org>
\author Chris Sewell
\author Francois Conti
\version $MAJOR.$MINOR.$RELEASE $Rev: 733 $
*/
//===========================================================================
//---------------------------------------------------------------------------
#ifndef CCollisionBruteH
#define CCollisionBruteH
//---------------------------------------------------------------------------
#include "math/CMaths.h"
#include "graphics/CTriangle.h"
#include "graphics/CVertex.h"
#include "collisions/CGenericCollision.h"
#include <vector>
//---------------------------------------------------------------------------
using std::vector;
//---------------------------------------------------------------------------
//===========================================================================
/*!
\file CCollisionBrute.h
\brief
<b> Collision Detection </b> \n
Brute Force Model.
*/
//===========================================================================
//===========================================================================
/*!
\class cCollisionBrute
\ingroup collisions
\brief
cCollisionBrute provides methods to check for the intersection
of a line segment with a mesh by checking all triangles in the mesh.
*/
//===========================================================================
class cCollisionBrute : public cGenericCollision
{
public:
//-----------------------------------------------------------------------
// CONSTRUCTOR & DESTRUCTOR:
//-----------------------------------------------------------------------
//! Constructor of cCollisionBrute.
cCollisionBrute(vector<cTriangle> *a_triangles);
//! Destructor of cCollisionBrute.
virtual ~cCollisionBrute() {}
//-----------------------------------------------------------------------
// METHODS:
//-----------------------------------------------------------------------
//! No initialization is necessary for the brute force method.
virtual void initialize(const double a_radius = 0) {};
//! There isn't really a useful "visualization" of "check all triangles".
virtual void render() {};
//! Return the triangles intersected by the given segment, if any.
bool computeCollision(cGenericObject* a_object,
cVector3d& a_segmentPointA,
cVector3d& a_segmentPointB,
cCollisionRecorder& a_recorder,
cCollisionSettings& a_settings);
protected:
//-----------------------------------------------------------------------
// MEMBERS:
//-----------------------------------------------------------------------
//! Pointer to the list of triangles in the mesh.
vector<cTriangle> *m_triangles;
};
//---------------------------------------------------------------------------
#endif
//---------------------------------------------------------------------------
| 39.346774 | 78 | 0.481451 |
94dbe5118f732c4f1f91f074a321bb63b5cf6e4c | 1,262 | c | C | linux/acnsdkc/time/time.c | arrow-acs/acn-embedded | b31d4cf2055f8809fa7b80ec80703402fc09001e | [
"Apache-2.0"
] | 7 | 2017-03-27T01:08:22.000Z | 2019-08-20T18:29:03.000Z | linux/acnsdkc/time/time.c | konexios/moonstone-acn-embedded | b31d4cf2055f8809fa7b80ec80703402fc09001e | [
"Apache-2.0"
] | 5 | 2017-11-10T23:09:50.000Z | 2018-04-04T13:58:31.000Z | linux/acnsdkc/time/time.c | konexios/moonstone-acn-embedded | b31d4cf2055f8809fa7b80ec80703402fc09001e | [
"Apache-2.0"
] | 5 | 2017-03-29T02:15:10.000Z | 2019-02-22T13:09:42.000Z | /* Copyright (c) 2017 Arrow Electronics, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License 2.0
* which accompanies this distribution, and is available at
* http://apache.org/licenses/LICENSE-2.0
* Contributors: Arrow Electronics, Inc.
*/
#include <time/time.h>
#include <sys/mem.h>
#include <unistd.h>
void get_time(char *ts) {
struct tm *tmp;
int ms;
time_t s = time(NULL);
struct timeval tv;
gettimeofday(&tv, NULL);
tmp = gmtime(&s);
ms = (tv.tv_usec/1000)%1000;
sprintf(ts, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", 1900+tmp->tm_year, tmp->tm_mon+1, tmp->tm_mday,
tmp->tm_hour, tmp->tm_min, tmp->tm_sec, ms);
// printf("ts: %s\r\n", ts);
// strcpy(ts, "2017-02-01T12:56:03.602Z");
}
inline int msleep(int ms) {
return usleep(ms*1000);
}
void timestamp(timestamp_t *ts) {
struct tm *tmp;
int ms;
time_t s = time(NULL);
struct timeval tv;
gettimeofday(&tv, NULL);
tmp = gmtime(&s);
ms = (tv.tv_usec/1000)%1000;
ts->year = 1900 + tmp->tm_year;
ts->mon = 1 + tmp->tm_mon;
ts->day = tmp->tm_mday;
ts->hour = tmp->tm_hour;
ts->min = tmp->tm_min;
ts->sec = tmp->tm_sec;
ts->msec = ms;
}
| 25.755102 | 100 | 0.630745 |
94de26833b6d016197e6e1e201f3290faf35cd39 | 785 | h | C | src/model/FileHandler.h | seanballais/mp1-cmsc21-upvtc | ae0e3e6f03ff782432035697fc4228df47a438c1 | [
"Unlicense"
] | null | null | null | src/model/FileHandler.h | seanballais/mp1-cmsc21-upvtc | ae0e3e6f03ff782432035697fc4228df47a438c1 | [
"Unlicense"
] | null | null | null | src/model/FileHandler.h | seanballais/mp1-cmsc21-upvtc | ae0e3e6f03ff782432035697fc4228df47a438c1 | [
"Unlicense"
] | null | null | null | /*
* FileUtil.h
*
* Abstracts file functions.
*
*/
#ifndef FILEUTIL_H
#define FILEUTIL_H
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include <ctype.h>
// Project headers
#include "../utils/DataTypeDefinitions.h"
FILE* FileUtil_openFile(const string filename,
const string mode);
void FileUtil_modifyStudentInfoProperty(const int index,
const string studentNumber,
const string newVal,
const char mode);
string FileUtil_getStudentInfoProperty(const int index,
const string studentNumber);
#endif
| 26.166667 | 71 | 0.53121 |
03fe6576ab7a1b84d7d96647dc29d09e4c7a1c12 | 348 | h | C | source/level1/vidcon/capture/camera.h | roguematter/multicast-csf303 | 4eff7b4d69602bd44fb17b2dabf9b4150ac8d426 | [
"CC0-1.0"
] | null | null | null | source/level1/vidcon/capture/camera.h | roguematter/multicast-csf303 | 4eff7b4d69602bd44fb17b2dabf9b4150ac8d426 | [
"CC0-1.0"
] | null | null | null | source/level1/vidcon/capture/camera.h | roguematter/multicast-csf303 | 4eff7b4d69602bd44fb17b2dabf9b4150ac8d426 | [
"CC0-1.0"
] | null | null | null | extern "C"{
#include <avformat.h>
}
/*The camera object has the information related to the incoming stream the device path
*/
class Ccamera{
public:
char *m_device;
int m_width;
int m_height;
AVStream *video_st;
AVFormatContext *fmt_ctx;
AVInputFormat *iformat;
Ccamera();
~Ccamera();
AVStream* open_stream();
int close();
};
| 15.130435 | 88 | 0.701149 |
03fff3b59d4d9aefcfae0124e1ee5b1b95c321e7 | 17,278 | c | C | fntsrc/u8g_font_symb24r.c | JJPowelly/u8glib | eedf07de97852e1a453cfbe2ef906cedb8ca1169 | [
"BSD-2-Clause"
] | 1,209 | 2015-06-25T05:33:20.000Z | 2022-03-31T17:20:03.000Z | fntsrc/u8g_font_symb24r.c | JJPowelly/u8glib | eedf07de97852e1a453cfbe2ef906cedb8ca1169 | [
"BSD-2-Clause"
] | 201 | 2015-06-25T20:59:07.000Z | 2022-03-27T18:55:11.000Z | fntsrc/u8g_font_symb24r.c | JJPowelly/u8glib | eedf07de97852e1a453cfbe2ef906cedb8ca1169 | [
"BSD-2-Clause"
] | 354 | 2015-06-25T18:11:56.000Z | 2022-03-21T13:58:24.000Z | /*
Fontname: -Adobe-Symbol-Medium-R-Normal--34-240-100-100-P-191-Adobe-FontSpecific
Copyright: Copyright (c) 1984, 1987 Adobe Systems Incorporated. All Rights Reserved. Copyright (c) 1988, 1991 Digital Equipment Corporation. All Rights Reserved.
Capital A Height: 23, '1' Height: 23
Calculated Max Values w=27 h=33 x=15 y=26 dx=29 dy= 0 ascent=27 len=92
Font Bounding box w=40 h=34 x=-5 y=-7
Calculated Min Values x=-2 y=-7 dx= 0 dy= 0
Pure Font ascent =23 descent=-7
X Font ascent =23 descent=-7
Max Font ascent =27 descent=-7
*/
#include "u8g.h"
const u8g_fntpgm_uint8_t u8g_font_symb24r[5335] U8G_FONT_SECTION("u8g_font_symb24r") = {
0,40,34,251,249,23,5,133,13,247,32,127,249,27,249,23,
249,0,0,0,8,0,1,4,23,23,11,4,0,96,240,240,
240,240,240,96,96,96,96,96,96,96,96,96,96,0,0,0,
96,240,240,96,20,24,72,23,1,0,192,0,48,192,0,48,
192,0,96,96,0,96,96,0,96,48,0,192,48,0,192,63,
255,192,31,255,128,24,1,128,12,3,0,12,3,0,12,3,
0,6,6,0,6,6,0,3,12,0,3,12,0,3,12,0,
1,152,0,1,152,0,0,240,0,0,240,0,0,240,0,0,
96,0,14,23,46,16,1,0,6,48,6,48,6,48,6,48,
12,96,12,96,12,96,127,252,127,252,12,96,12,96,12,96,
24,192,24,192,24,192,255,248,255,248,24,192,24,192,49,128,
49,128,49,128,49,128,15,24,48,18,0,0,255,254,255,254,
0,6,0,6,0,6,0,6,0,6,0,6,0,6,0,6,
0,6,63,254,63,254,0,6,0,6,0,6,0,6,0,6,
0,6,0,6,0,6,0,6,255,254,255,254,23,23,69,27,
2,255,7,192,96,30,225,192,60,63,192,56,33,128,112,33,
128,112,35,0,240,98,0,224,70,0,224,204,0,224,204,0,
97,152,0,119,16,124,62,48,238,0,97,198,0,99,130,0,
199,2,0,135,2,1,142,6,3,14,4,3,14,12,6,14,
24,14,7,48,12,3,224,23,22,66,25,1,0,0,248,0,
3,140,0,3,6,0,7,6,0,7,6,0,7,6,0,7,
12,0,7,152,0,3,241,252,3,192,112,7,192,96,29,224,
96,56,240,192,112,240,128,96,121,128,224,63,0,224,30,0,
224,31,0,240,31,130,248,55,238,127,227,252,31,128,248,12,
17,34,14,1,0,126,0,127,128,7,192,1,224,0,224,0,
240,0,112,0,112,63,240,63,240,0,112,0,112,0,224,1,
224,3,192,255,0,124,0,8,29,29,11,2,250,3,7,6,
12,24,48,48,112,112,96,96,224,224,224,224,224,224,224,96,
96,112,112,48,48,24,12,6,7,3,8,29,29,11,1,250,
192,224,96,48,24,12,12,14,14,6,6,7,7,7,7,7,
7,7,6,6,14,14,12,12,24,48,96,224,192,11,14,28,
16,2,4,4,0,14,0,14,0,196,96,228,224,127,192,31,
0,31,0,127,192,228,224,196,96,14,0,14,0,4,0,16,
18,36,18,1,0,1,128,1,128,1,128,1,128,1,128,1,
128,1,128,1,128,255,255,255,255,1,128,1,128,1,128,1,
128,1,128,1,128,1,128,1,128,4,9,9,8,2,251,96,
240,240,240,16,48,96,224,192,17,2,6,18,0,8,255,255,
128,255,255,128,4,4,4,8,2,0,96,240,240,96,7,22,
22,9,1,0,2,2,6,6,4,12,12,8,24,24,16,48,
48,32,32,96,64,64,192,192,128,128,14,23,46,16,1,0,
15,192,28,224,56,112,48,48,112,56,112,56,96,24,224,28,
224,28,224,28,224,28,224,28,224,28,224,28,224,28,224,28,
96,24,112,56,112,56,48,48,56,112,28,224,15,192,9,23,
46,16,4,0,4,0,28,0,252,0,220,0,28,0,28,0,
28,0,28,0,28,0,28,0,28,0,28,0,28,0,28,0,
28,0,28,0,28,0,28,0,28,0,28,0,28,0,62,0,
255,128,14,23,46,16,1,0,15,128,31,192,63,224,97,240,
192,240,192,112,128,112,0,112,0,112,0,96,0,96,0,192,
0,192,1,128,3,0,3,0,6,0,12,0,24,0,48,12,
112,24,127,248,255,240,13,23,46,16,1,0,15,128,63,224,
113,224,64,224,192,96,128,96,0,96,0,192,0,192,1,128,
7,192,15,224,1,240,0,112,0,120,0,56,0,56,0,56,
0,48,0,48,96,96,121,192,127,128,15,23,46,16,0,0,
0,48,0,112,0,112,0,240,1,240,1,240,3,112,6,112,
6,112,12,112,24,112,24,112,48,112,32,112,96,112,192,112,
255,254,255,254,0,112,0,112,0,112,0,112,0,112,13,23,
46,16,1,0,15,248,15,240,31,240,16,0,48,0,32,0,
126,0,127,128,127,192,15,224,3,224,0,240,0,112,0,112,
0,112,0,48,0,48,0,48,0,112,0,96,224,192,251,128,
254,0,14,23,46,16,1,0,0,56,1,224,3,128,7,0,
14,0,28,0,56,0,56,0,112,0,119,192,255,240,240,120,
224,56,224,60,224,28,224,28,224,28,224,28,112,28,112,56,
56,56,28,112,15,192,13,23,46,16,1,0,127,248,127,248,
127,248,192,24,128,48,0,48,0,48,0,96,0,96,0,96,
0,192,0,192,0,192,1,192,1,128,1,128,1,128,3,0,
3,0,3,0,6,0,6,0,6,0,12,23,46,16,2,0,
31,128,113,192,96,224,224,96,192,96,224,96,224,224,112,192,
121,192,63,0,31,0,31,128,63,192,115,192,96,224,224,240,
192,112,192,112,224,112,224,112,96,96,121,192,31,128,14,23,
46,16,1,0,15,128,56,224,48,112,96,56,224,56,224,56,
224,60,224,28,224,28,224,28,240,28,112,28,120,124,63,252,
15,56,0,56,0,112,0,240,0,224,1,192,7,128,30,0,
112,0,4,15,15,9,2,0,96,240,240,96,0,0,0,0,
0,0,0,96,240,240,96,4,20,20,9,3,251,96,240,240,
96,0,0,0,0,0,0,0,96,240,240,240,16,48,96,224,
192,16,16,32,18,1,1,0,7,0,31,0,124,1,240,7,
128,30,0,120,0,224,0,224,0,120,0,30,0,7,128,1,
240,0,124,0,31,0,7,17,8,24,18,0,5,255,255,128,
255,255,128,0,0,0,0,0,0,0,0,0,0,0,0,255,
255,128,255,255,128,16,16,32,18,1,1,224,0,248,0,62,
0,15,128,1,224,0,120,0,30,0,7,0,7,0,30,0,
120,1,224,15,128,62,0,248,0,224,0,11,23,46,14,2,
0,63,0,99,128,193,192,192,224,192,224,224,224,192,224,1,
224,1,192,1,128,3,128,3,0,6,0,6,0,4,0,4,
0,4,0,0,0,0,0,12,0,30,0,30,0,12,0,17,
16,48,18,0,0,30,1,0,63,195,128,96,255,0,64,28,
0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,128,
255,255,128,0,0,0,0,0,0,0,0,0,0,0,0,255,
255,128,255,255,128,21,23,69,23,0,0,0,32,0,0,112,
0,0,112,0,0,112,0,0,248,0,0,248,0,0,188,0,
1,188,0,1,156,0,3,30,0,3,14,0,2,15,0,6,
15,0,6,7,0,12,7,128,15,255,128,8,3,128,24,3,
192,24,1,192,48,1,224,48,1,224,112,1,240,252,7,248,
18,23,69,22,1,0,255,224,0,63,254,0,28,31,0,28,
7,0,28,7,128,28,7,128,28,7,128,28,7,128,28,7,
0,28,15,0,28,62,0,31,248,0,28,31,0,28,7,128,
28,3,128,28,3,192,28,3,192,28,3,192,28,3,192,28,
7,128,28,15,128,63,255,0,255,248,0,22,23,69,23,0,
0,255,195,252,63,0,224,31,0,192,15,1,192,7,129,128,
7,195,0,3,198,0,1,230,0,1,236,0,0,248,0,0,
120,0,0,120,0,0,124,0,0,222,0,1,158,0,1,143,
0,3,15,128,6,7,128,14,3,192,12,3,224,24,1,224,
56,1,240,254,7,252,19,22,66,20,0,0,0,96,0,0,
96,0,0,240,0,0,240,0,0,240,0,1,248,0,1,56,
0,3,60,0,2,60,0,6,28,0,4,30,0,12,14,0,
12,15,0,8,15,0,24,7,0,16,7,128,48,3,128,32,
3,192,96,3,192,64,1,192,255,255,224,255,255,224,18,23,
69,20,1,0,255,255,128,63,255,128,28,3,128,28,1,128,
28,1,128,28,0,0,28,0,0,28,2,0,28,2,0,28,
2,0,28,14,0,31,254,0,28,6,0,28,2,0,28,2,
0,28,0,0,28,0,0,28,0,64,28,0,64,28,0,192,
28,1,192,63,255,128,255,255,128,23,23,69,25,1,0,1,
255,0,0,124,0,0,56,0,0,56,0,7,255,192,31,57,
240,60,56,120,120,56,60,120,56,60,240,56,30,240,56,30,
240,56,30,240,56,30,240,56,30,120,56,28,120,56,60,60,
56,120,31,57,240,7,255,192,0,56,0,0,56,0,0,124,
0,1,255,0,18,23,69,20,1,0,255,255,128,63,255,192,
60,1,192,28,0,192,28,0,64,28,0,64,28,0,0,28,
0,0,28,0,0,28,0,0,28,0,0,28,0,0,28,0,
0,28,0,0,28,0,0,28,0,0,28,0,0,28,0,0,
28,0,0,28,0,0,28,0,0,62,0,0,255,128,0,22,
23,69,24,1,0,255,135,252,62,1,240,28,0,224,28,0,
224,28,0,224,28,0,224,28,0,224,28,0,224,28,0,224,
28,0,224,28,0,224,31,255,224,28,0,224,28,0,224,28,
0,224,28,0,224,28,0,224,28,0,224,28,0,224,28,0,
224,28,0,224,62,1,240,255,135,252,9,23,46,11,1,0,
255,128,62,0,28,0,28,0,28,0,28,0,28,0,28,0,
28,0,28,0,28,0,28,0,28,0,28,0,28,0,28,0,
28,0,28,0,28,0,28,0,28,0,62,0,255,128,20,23,
69,20,0,0,0,120,0,0,220,0,0,134,0,0,135,0,
0,131,0,0,195,128,0,67,128,28,99,128,62,57,128,126,
29,128,199,7,128,199,1,224,6,1,176,14,1,128,14,1,
128,14,1,128,14,3,128,14,3,0,14,3,0,14,7,0,
7,6,0,3,156,0,1,248,0,22,23,69,23,1,0,255,
143,240,62,3,192,28,3,128,28,3,0,28,6,0,28,12,
0,28,24,0,28,48,0,28,96,0,29,192,0,31,224,0,
31,224,0,30,240,0,28,120,0,28,124,0,28,62,0,28,
31,0,28,15,128,28,7,128,28,3,192,28,1,224,62,1,
240,255,143,252,21,22,66,22,0,0,0,32,0,0,48,0,
0,112,0,0,112,0,0,248,0,0,248,0,0,188,0,1,
188,0,1,156,0,1,30,0,3,14,0,3,15,0,2,15,
0,6,7,0,6,7,128,12,3,128,12,3,192,8,3,192,
24,1,192,24,1,224,56,1,240,254,7,248,27,23,92,29,
1,0,254,0,15,224,30,0,15,128,31,0,15,0,31,0,
31,0,31,0,31,0,31,128,55,0,27,128,55,0,27,192,
39,0,27,192,103,0,25,224,103,0,25,224,199,0,24,224,
199,0,24,240,135,0,24,113,135,0,24,121,135,0,24,123,
7,0,24,63,7,0,24,63,7,0,24,30,7,0,24,30,
7,0,24,12,7,0,56,12,15,128,255,12,63,224,22,23,
69,23,1,0,252,3,252,62,0,96,30,0,96,31,0,96,
31,128,96,31,192,96,27,192,96,25,224,96,25,240,96,24,
240,96,24,120,96,24,60,96,24,60,96,24,30,96,24,15,
96,24,15,224,24,7,224,24,3,224,24,1,224,24,1,224,
24,0,224,56,0,96,255,0,32,22,23,69,23,1,0,1,
254,0,7,135,128,14,1,192,28,0,224,60,0,240,120,0,
112,120,0,120,112,0,56,240,0,60,240,0,60,240,0,60,
240,0,60,240,0,60,240,0,60,240,0,60,112,0,56,120,
0,120,56,0,112,60,0,240,28,0,224,14,1,192,7,207,
128,1,254,0,23,23,69,25,1,0,255,255,254,63,255,248,
28,0,112,28,0,112,28,0,112,28,0,112,28,0,112,28,
0,112,28,0,112,28,0,112,28,0,112,28,0,112,28,0,
112,28,0,112,28,0,112,28,0,112,28,0,112,28,0,112,
28,0,112,28,0,112,28,0,112,62,0,248,255,131,254,22,
23,69,24,1,0,1,254,0,7,135,128,14,1,192,28,0,
224,60,0,240,56,0,112,120,0,120,112,0,56,112,0,56,
242,1,60,243,3,60,243,255,60,243,255,60,243,3,60,242,
1,60,112,0,56,112,0,56,120,0,120,56,0,112,28,0,
224,14,1,192,7,135,128,1,254,0,17,23,69,18,1,0,
255,240,0,63,254,0,28,15,0,28,7,128,28,7,128,28,
3,128,28,3,128,28,3,128,28,3,128,28,7,128,28,7,
0,30,62,0,31,252,0,28,0,0,28,0,0,28,0,0,
28,0,0,28,0,0,28,0,0,28,0,0,28,0,0,62,
0,0,255,128,0,18,23,69,19,1,0,255,255,0,255,255,
0,120,3,0,60,1,0,62,1,128,30,0,0,15,0,0,
7,128,0,7,192,0,3,192,0,1,224,0,0,192,0,1,
192,0,1,128,0,3,0,0,6,0,0,12,0,64,28,0,
192,24,0,128,48,1,128,127,255,128,255,255,128,255,255,128,
19,23,69,20,1,0,255,255,224,248,227,224,192,224,224,192,
224,96,128,224,32,128,224,32,0,224,0,0,224,0,0,224,
0,0,224,0,0,224,0,0,224,0,0,224,0,0,224,0,
0,224,0,0,224,0,0,224,0,0,224,0,0,224,0,0,
224,0,0,224,0,1,240,0,7,252,0,23,23,69,23,0,
0,255,193,254,62,0,112,31,0,96,15,0,224,15,128,192,
7,129,128,3,193,128,3,227,0,1,227,0,0,246,0,0,
252,0,0,124,0,0,56,0,0,56,0,0,56,0,0,56,
0,0,56,0,0,56,0,0,56,0,0,56,0,0,56,0,
0,124,0,1,255,0,13,24,48,14,1,249,3,224,15,240,
31,240,48,0,96,0,64,0,192,0,192,0,128,0,128,0,
128,0,192,0,192,0,240,0,127,240,63,240,31,248,0,24,
0,8,0,8,0,24,7,240,7,240,7,192,23,23,69,25,
1,0,0,254,0,3,131,128,14,0,224,30,0,240,28,0,
112,60,0,120,56,0,56,120,0,60,120,0,60,120,0,60,
120,0,60,120,0,60,120,0,60,56,0,56,60,0,120,28,
0,112,14,0,224,7,1,192,129,131,2,192,130,6,255,199,
254,255,199,254,255,199,254,19,23,69,21,1,0,127,255,192,
127,255,192,127,255,192,96,0,192,64,0,64,0,0,0,0,
0,0,0,0,0,8,2,0,12,6,0,15,254,0,15,254,
0,15,254,0,8,2,0,8,2,0,0,0,0,0,0,0,
192,0,96,192,0,96,64,0,64,127,255,192,127,255,192,127,
255,192,25,23,92,26,0,0,224,255,131,128,112,62,7,0,
56,28,14,0,56,28,14,0,60,28,30,0,60,28,30,0,
60,28,30,0,60,28,30,0,60,28,30,0,28,28,28,0,
30,28,60,0,15,156,248,0,3,255,224,0,0,28,0,0,
0,28,0,0,0,28,0,0,0,28,0,0,0,28,0,0,
0,28,0,0,0,28,0,0,0,28,0,0,0,62,0,0,
0,255,128,0,19,23,69,20,1,0,127,255,192,120,3,192,
96,7,128,96,15,0,64,15,0,64,30,0,0,62,0,0,
60,0,0,120,0,0,248,0,0,240,0,1,224,0,1,224,
0,3,192,0,7,192,0,7,128,0,15,0,0,31,0,32,
30,0,32,62,0,96,60,0,224,120,3,192,255,255,192,7,
28,28,11,3,251,254,224,192,192,192,192,192,192,192,192,192,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,224,
254,17,16,48,28,5,0,1,224,0,1,224,0,1,224,0,
1,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,240,7,128,240,7,
128,240,7,128,240,7,128,7,28,28,11,1,251,254,14,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,14,254,20,23,69,21,1,0,0,
96,0,0,96,0,0,96,0,0,96,0,0,96,0,0,96,
0,0,96,0,0,96,0,0,96,0,0,96,0,0,96,0,
0,96,0,0,96,0,0,96,0,0,96,0,0,96,0,0,
96,0,0,96,0,0,96,0,0,96,0,0,96,0,255,255,
240,255,255,240,16,2,4,16,0,249,255,255,255,255,20,1,
3,17,15,26,255,255,240,19,17,51,20,1,0,15,193,128,
28,225,128,56,51,128,112,19,128,112,23,0,240,31,0,224,
15,0,224,14,0,224,14,0,224,14,0,224,28,0,240,30,
0,240,30,32,112,58,32,120,115,224,60,225,192,15,193,192,
14,32,64,18,2,249,15,128,25,224,48,224,112,112,96,112,
96,112,96,112,96,112,96,112,96,96,103,192,103,224,96,112,
96,56,96,56,96,60,96,28,96,28,96,28,96,28,96,28,
96,56,120,120,111,240,99,192,96,0,96,0,96,0,96,0,
224,0,224,0,224,0,17,25,75,18,0,249,24,0,0,60,
14,0,126,14,0,70,30,0,194,28,0,195,60,0,3,56,
0,1,112,0,1,112,0,1,224,0,1,224,0,1,192,0,
3,192,0,3,128,0,7,192,0,7,192,0,15,64,0,14,
64,0,30,96,0,28,97,128,60,97,128,56,51,0,120,63,
0,112,62,0,112,30,0,14,25,50,16,1,0,15,128,31,
224,48,240,32,120,48,48,56,0,28,0,14,0,7,128,3,
192,7,240,28,240,56,120,112,56,240,60,224,28,224,28,224,
28,224,28,240,28,240,56,112,56,120,112,31,224,7,128,12,
18,36,14,1,255,31,128,57,224,112,224,224,224,224,64,224,
0,112,0,120,0,31,128,120,0,240,0,224,0,224,0,224,
16,240,48,120,48,63,224,15,128,15,30,60,17,1,249,1,
0,1,0,1,0,1,0,1,0,1,0,15,192,29,112,57,
56,113,28,113,28,225,30,225,14,225,14,225,14,225,14,225,
14,241,14,113,12,113,28,57,24,29,112,7,224,1,0,1,
0,1,0,1,0,1,0,1,0,1,0,15,24,48,13,254,
249,56,14,124,14,124,14,198,28,134,28,130,28,3,56,3,
56,1,48,1,48,1,96,1,224,1,192,0,192,0,192,1,
128,1,192,1,192,3,192,3,192,3,192,3,192,3,128,1,
128,17,24,72,20,0,249,24,56,0,124,254,0,223,222,0,
207,15,0,143,7,0,14,7,0,14,7,0,14,7,0,14,
7,0,14,7,0,14,7,0,14,7,0,14,7,0,14,7,
0,14,7,0,14,7,0,14,7,0,0,7,0,0,7,0,
0,7,0,0,7,0,0,7,0,0,3,0,0,3,128,10,
17,34,11,0,0,4,0,124,0,252,0,60,0,28,0,28,
0,28,0,28,0,28,0,28,0,28,0,28,0,28,0,28,
64,28,192,15,192,15,0,18,24,72,20,1,249,6,60,0,
30,126,0,56,255,0,112,199,128,112,195,128,240,195,192,224,
193,192,224,193,192,224,193,192,224,193,192,240,193,192,240,193,
128,112,195,128,120,195,0,56,199,0,30,220,0,7,248,0,
0,192,0,0,192,0,0,192,0,0,192,0,0,192,0,0,
192,0,0,192,0,17,17,51,18,1,0,8,7,0,248,31,
128,248,63,128,56,99,0,24,192,0,25,128,0,27,0,0,
31,128,0,31,128,0,27,192,0,25,224,0,24,240,0,24,
240,0,24,120,0,24,60,0,24,62,0,24,127,128,17,25,
75,18,1,0,56,0,0,124,0,0,126,0,0,198,0,0,
195,0,0,131,0,0,1,0,0,1,0,0,1,128,0,3,
128,0,3,128,0,7,128,0,7,192,0,15,192,0,14,192,
0,30,64,0,28,96,0,28,96,0,56,96,0,56,96,128,
112,48,128,112,57,128,224,63,0,224,31,0,224,14,0,17,
24,72,19,1,249,112,56,0,112,56,0,112,56,0,112,56,
0,112,56,0,112,56,0,112,56,0,112,56,0,112,56,0,
112,56,0,112,56,0,112,56,0,112,120,0,120,120,128,127,
253,128,127,159,128,110,30,0,96,0,0,96,0,0,96,0,
0,224,0,0,224,0,0,224,0,0,96,0,0,16,17,34,
17,255,0,24,6,248,7,60,7,28,7,28,7,30,6,14,
6,14,12,7,12,7,24,7,152,3,176,3,160,1,224,1,
192,1,192,0,128,15,17,34,18,1,0,7,192,28,112,48,
56,112,60,112,28,224,30,224,14,224,14,224,14,224,14,224,
14,240,14,112,28,120,28,56,56,30,112,15,224,17,17,51,
18,0,0,15,255,128,63,255,128,63,255,128,102,56,0,198,
56,0,6,48,0,6,48,0,6,48,0,6,48,0,6,48,
0,4,48,0,12,48,0,12,48,128,28,57,128,60,63,0,
60,31,0,56,30,0,14,23,46,17,1,0,7,128,28,224,
24,112,48,48,112,56,112,56,240,60,224,28,224,28,224,28,
224,28,255,252,255,252,224,28,224,28,224,28,224,28,112,56,
112,56,112,56,56,112,28,224,15,192,14,25,50,18,2,249,
7,192,31,224,48,240,96,120,96,120,224,60,224,60,224,28,
224,28,224,28,224,28,224,24,224,24,224,56,240,112,248,224,
239,192,231,0,224,0,224,0,224,0,224,0,224,0,224,0,
224,0,18,18,54,20,1,0,3,255,192,15,255,192,63,255,
192,124,48,0,120,24,0,240,28,0,240,14,0,224,15,0,
224,7,0,224,7,0,240,7,0,112,7,0,112,15,0,56,
14,0,60,30,0,30,56,0,7,240,0,1,192,0,14,17,
34,14,0,0,15,252,63,252,63,252,99,128,195,128,195,128,
3,0,3,0,3,0,3,0,3,0,3,8,3,136,3,152,
3,248,1,240,1,224,17,18,54,19,0,0,0,16,0,60,
24,0,124,28,0,252,6,0,206,7,0,142,3,0,14,3,
0,14,3,128,14,3,128,14,3,128,14,3,128,14,3,128,
14,3,0,14,7,0,7,7,0,7,14,0,3,156,0,1,
248,0,21,19,57,23,0,0,31,255,248,63,255,248,127,255,
248,231,131,128,222,0,192,60,0,224,56,56,112,120,56,112,
120,56,56,120,56,56,112,56,56,112,56,56,112,56,56,112,
16,56,120,16,56,120,56,112,56,40,112,28,236,224,15,135,
192,20,17,51,22,1,0,15,14,0,28,7,128,56,1,192,
112,97,224,112,224,224,224,224,240,224,224,240,224,224,112,224,
224,112,224,224,112,224,224,112,224,64,112,224,224,240,112,224,
224,113,177,224,63,31,192,30,15,0,14,33,66,16,1,249,
48,0,96,192,99,224,103,192,63,128,24,0,48,0,32,0,
32,0,48,0,49,240,31,240,31,224,48,0,96,0,64,0,
192,0,128,0,128,0,128,0,192,0,192,0,248,0,127,240,
63,252,31,252,0,12,0,4,0,4,0,12,3,248,3,248,
1,224,22,24,72,22,0,249,240,48,60,120,48,120,60,48,
240,28,48,224,28,48,224,28,48,224,28,48,224,28,48,224,
30,48,224,30,49,224,30,49,224,14,49,192,14,49,192,6,
49,192,7,51,128,3,183,0,1,254,0,0,48,0,0,48,
0,0,48,0,0,48,0,0,48,0,0,48,0,0,48,0,
13,32,64,16,2,249,24,0,56,112,48,240,51,224,63,192,
14,0,12,0,24,0,16,0,48,0,32,0,96,0,64,0,
64,0,192,0,192,0,192,0,192,0,192,0,224,0,96,0,
127,192,63,240,31,248,15,248,0,24,0,8,0,8,0,24,
3,248,7,240,3,224,11,29,58,16,2,250,7,224,14,0,
12,0,12,0,12,0,12,0,12,0,12,0,12,0,12,0,
12,0,28,0,28,0,112,0,192,0,112,0,28,0,28,0,
12,0,12,0,12,0,12,0,12,0,12,0,12,0,12,0,
12,0,14,0,7,224,2,28,28,7,2,250,192,192,192,192,
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
192,192,192,192,192,192,192,192,11,29,58,16,2,250,252,0,
14,0,6,0,6,0,6,0,6,0,6,0,6,0,6,0,
6,0,6,0,7,0,7,0,1,192,0,96,1,192,7,0,
7,0,6,0,6,0,6,0,6,0,6,0,6,0,6,0,
6,0,6,0,14,0,252,0,15,4,8,18,1,7,24,0,
127,134,227,254,192,56,255};
| 49.649425 | 163 | 0.621542 |
ff007cd0000eb804809ceabf6e959597289f84a0 | 2,245 | h | C | ProjectMorpheus3D/ProjectMorpheus3D/Mat3.h | Veer390/ProjectMorpheus | 96b5966090d346f0c39086b346dae1fa62e2b462 | [
"MIT"
] | null | null | null | ProjectMorpheus3D/ProjectMorpheus3D/Mat3.h | Veer390/ProjectMorpheus | 96b5966090d346f0c39086b346dae1fa62e2b462 | [
"MIT"
] | null | null | null | ProjectMorpheus3D/ProjectMorpheus3D/Mat3.h | Veer390/ProjectMorpheus | 96b5966090d346f0c39086b346dae1fa62e2b462 | [
"MIT"
] | null | null | null | #pragma once
#include "Vec3.h"
template <typename T>
class _Mat3
{
public:
_Mat3 & operator=(const _Mat3& rhs)
{
memcpy(elements, rhs.elements, sizeof(elements));
return *this;
}
_Mat3& operator*=(T rhs)
{
for (auto& row : elements)
{
for (T& e : row)
{
e *= rhs;
}
}
return *this;
}
_Mat3 operator*(T rhs) const
{
_Mat3 result = *this;
return result *= rhs;
}
_Mat3& operator*=(const _Mat3& rhs)
{
return *this = *this * rhs;
}
_Mat3 operator*(const _Mat3& rhs) const
{
_Mat3 result;
for (size_t j = 0; j < 3; j++)
{
for (size_t k = 0; k < 3; k++)
{
T sum = (T)0.0;
for (size_t i = 0; i < 3; i++)
{
sum += elements[j][i] * rhs.elements[i][k];
}
result.elements[j][k] = sum;
}
}
return result;
}
static _Mat3 Identity()
{
return {
(T)1.0,(T)0.0,(T)0.0,
(T)0.0,(T)1.0,(T)0.0,
(T)0.0,(T)0.0,(T)1.0
};
}
static _Mat3 Scaling(T factor)
{
return{
factor,(T)0.0,(T)0.0,
(T)0.0,factor,(T)0.0,
(T)0.0,(T)0.0,factor
};
}
static _Mat3 RotationZ(T theta)
{
const T sinTheta = sin(theta);
const T cosTheta = cos(theta);
return{
cosTheta, sinTheta, (T)0.0,
-sinTheta, cosTheta, (T)0.0,
(T)0.0, (T)0.0, (T)1.0
};
}
static _Mat3 RotationY(T theta)
{
const T sinTheta = sin(theta);
const T cosTheta = cos(theta);
return{
cosTheta, (T)0.0,-sinTheta,
(T)0.0, (T)1.0, (T)0.0,
sinTheta, (T)0.0, cosTheta
};
}
static _Mat3 RotationX(T theta)
{
const T sinTheta = sin(theta);
const T cosTheta = cos(theta);
return{
(T)1.0, (T)0.0, (T)0.0,
(T)0.0, cosTheta, sinTheta,
(T)0.0,-sinTheta, cosTheta,
};
}
public:
// [ row ][ col ]
T elements[3][3];
};
template<typename T>
_Vec3<T>& operator*=(_Vec3<T>& lhs, const _Mat3<T>& rhs)
{
return lhs = lhs * rhs;
}
template<typename T>
_Vec3<T> operator*(const _Vec3<T>& lhs, const _Mat3<T>& rhs)
{
return{
lhs.x * rhs.elements[0][0] + lhs.y * rhs.elements[1][0] + lhs.z * rhs.elements[2][0],
lhs.x * rhs.elements[0][1] + lhs.y * rhs.elements[1][1] + lhs.z * rhs.elements[2][1],
lhs.x * rhs.elements[0][2] + lhs.y * rhs.elements[1][2] + lhs.z * rhs.elements[2][2]
};
}
typedef _Mat3<float> Mat3;
typedef _Mat3<double> Mad3; | 19.025424 | 87 | 0.566147 |
ff0413d4e6d64dd6240c0f70a46fa3721ad0bce1 | 2,064 | h | C | GPFinder/ViewControllers/GPDetailViewController.h | barrettmark/GPRatings | 0b222970bc616a270613c256c97f7ffa3424ef6c | [
"CC-BY-3.0"
] | 1 | 2021-02-23T07:52:18.000Z | 2021-02-23T07:52:18.000Z | GPFinder/ViewControllers/GPDetailViewController.h | barrettmark/GPRatings | 0b222970bc616a270613c256c97f7ffa3424ef6c | [
"CC-BY-3.0"
] | null | null | null | GPFinder/ViewControllers/GPDetailViewController.h | barrettmark/GPRatings | 0b222970bc616a270613c256c97f7ffa3424ef6c | [
"CC-BY-3.0"
] | 2 | 2017-07-18T08:33:57.000Z | 2021-02-23T07:52:18.000Z | //
// GPDetailViewController.h
// GPFInder
//
// Created by barrettmark.com on 20/02/2012.
//
#import <UIKit/UIKit.h>
#import "GP+methods.h"
#import "GPDisplayStrings.h"
/**
* This class displays information about a specific GP
*/
@interface GPDetailViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (retain, nonatomic) IBOutlet UITableView *tableView;
/**
* Labels for UIView fields
*/
@property (retain, nonatomic) IBOutlet UILabel *nameLabel;
@property (retain, nonatomic) IBOutlet UILabel *addressLabel;
@property (retain, nonatomic) IBOutlet UIImageView *ratingImageView;
@property (retain, nonatomic) IBOutlet UIButton *phoneButton;
@property (retain, nonatomic) IBOutlet UITableViewCell *gpTableViewCell;
@property (retain, nonatomic) IBOutlet UILabel *maleGPsLabel;
@property (retain, nonatomic) IBOutlet UILabel *femaleGPsLabel;
@property (retain, nonatomic) IBOutlet UILabel *distanceLabel;
/**
* Users location or queried location to display on map for directions
*/
@property (retain, nonatomic) CLLocation *location;
/**
* GP to view
*/
@property (retain, nonatomic) GP *gp;
/**
* Order for GP properties
*/
@property (retain, nonatomic) NSDictionary *viewOrder;
/**
* GP properties to display
*/
@property (retain, nonatomic) NSArray *keys;
/**
* Nicer, more readable list of GP properties
*/
@property (retain, nonatomic) GPDisplayStrings *gpDetailStrings;
/**
* Get value from GP model for a given key. Cast value to string
*/
- (NSString *)textForKey:(NSString *)key;
/**
* Using the keys property figure out which row data to display
*/
- (NSString *)keyForIndexPath:(NSIndexPath *)indexPath;
/**
* Make phone call
*/
- (void)makeCall:(NSString *)phoneNumber;
/**
* Methods called when user taps appropriate row
*
* @see didSelectRowAtIndexPath:
*/
- (void)telephoneRowSelected;
- (void)directionsRowSelected;
/**
* Actions based on user interactions
*/
- (IBAction)phoneButtonPressed:(id)sender;
- (IBAction)directionsButtonSelected:(id)sender;
@end
| 23.454545 | 97 | 0.734981 |
ff07c46460f27490253454faaccae027e9551d40 | 46 | h | C | libi2cp/includes/i2cp/parser.h | str4d/i2p-tools | 255cf5f5b398b1c913de99db0325219d239435d4 | [
"MIT"
] | 15 | 2015-06-02T14:38:07.000Z | 2021-11-28T19:16:17.000Z | libi2cp/includes/i2cp/parser.h | str4d/i2p-tools | 255cf5f5b398b1c913de99db0325219d239435d4 | [
"MIT"
] | 5 | 2015-04-30T13:08:31.000Z | 2015-06-09T17:20:01.000Z | libi2cp/includes/i2cp/parser.h | str4d/i2p-tools | 255cf5f5b398b1c913de99db0325219d239435d4 | [
"MIT"
] | 10 | 2015-04-25T18:03:23.000Z | 2020-10-26T07:18:37.000Z | #ifndef _stream_h
#define _stream_h
#endif
| 6.571429 | 17 | 0.76087 |
ff07fd466171ddae07ccf88a85f6f25bca8d582e | 368 | h | C | Classes/NSInvocationAdditions.h | gpummer/MPWFoundation | 8e120e76ea67c266aebb8fbc9aa9f4d84d7cf165 | [
"BSD-3-Clause"
] | 57 | 2015-01-04T08:09:05.000Z | 2021-11-23T10:50:33.000Z | Classes/NSInvocationAdditions.h | gpummer/MPWFoundation | 8e120e76ea67c266aebb8fbc9aa9f4d84d7cf165 | [
"BSD-3-Clause"
] | 7 | 2015-03-18T07:27:25.000Z | 2021-08-24T10:24:15.000Z | Classes/NSInvocationAdditions.h | gpummer/MPWFoundation | 8e120e76ea67c266aebb8fbc9aa9f4d84d7cf165 | [
"BSD-3-Clause"
] | 17 | 2015-02-08T04:16:19.000Z | 2021-08-17T19:52:23.000Z | /* NSInvocationAdditions.h Copyright (c) 1998-2017 by Marcel Weiher, All Rights Reserved.
*/
#import <Foundation/Foundation.h>
@interface NSInvocation(OneStepCreation)
//inline IMP objc_msg_lookup( id obj, SEL msg );
+invocationWithTarget:newTarget andSelector:(SEL)newSel;
//-(void)setReturnType:(int)returnType;
-returnValueAfterInvokingWithTarget:target;
@end
| 24.533333 | 89 | 0.790761 |
ff08ecbbf77ebda3c9ce692ff5595f79c364141b | 729 | h | C | System/Library/PrivateFrameworks/StoreKitUI.framework/SKUIScrollViewDelegateObserver.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | System/Library/PrivateFrameworks/StoreKitUI.framework/SKUIScrollViewDelegateObserver.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/StoreKitUI.framework/SKUIScrollViewDelegateObserver.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, September 27, 2020 at 11:44:33 AM Mountain Standard Time
* Operating System: Version 14.0 (Build 18A373)
* Image Source: /System/Library/PrivateFrameworks/StoreKitUI.framework/StoreKitUI
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
@protocol SKUIScrollViewDelegateObserver <NSObject>
@optional
-(void)observedScrollViewDidEndDecelerating:(id)arg1;
-(void)observedScrollViewDidScroll:(id)arg1;
-(void)observedScrollViewWillBeginDecelerating:(id)arg1;
-(void)observedScrollViewWillBeginDragging:(id)arg1;
-(void)observedScrollViewWillEndDragging:(id)arg1 withVelocity:(CGPoint)arg2 targetContentOffset:(CGPoint)arg3;
@end
| 36.45 | 111 | 0.8107 |
ff0b131154c6c56563dba40427782c6f752a7f5a | 1,231 | h | C | Dark Basic Public Shared/Official Plugins/DarkPHYSICS/DarkPHYSICS/RigidBodyPointInPlaneJoint.h | domydev/Dark-Basic-Pro | 237fd8d859782cb27b9d5994f3c34bc5372b6c04 | [
"MIT"
] | 231 | 2018-01-28T00:06:56.000Z | 2022-03-31T21:39:56.000Z | Dark Basic Public Shared/Official Plugins/DarkPHYSICS/DarkPHYSICS/RigidBodyPointInPlaneJoint.h | domydev/Dark-Basic-Pro | 237fd8d859782cb27b9d5994f3c34bc5372b6c04 | [
"MIT"
] | 9 | 2016-02-10T10:46:16.000Z | 2017-12-06T17:27:51.000Z | Dark Basic Public Shared/Official Plugins/DarkPHYSICS/DarkPHYSICS/RigidBodyPointInPlaneJoint.h | domydev/Dark-Basic-Pro | 237fd8d859782cb27b9d5994f3c34bc5372b6c04 | [
"MIT"
] | 66 | 2018-01-28T21:54:52.000Z | 2022-02-16T22:50:57.000Z |
/////////////////////////////////////////////////////////////////////////////////////
// RIGID BODY COMMANDS //////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
DARKSDK void dbPhyMakePointInPlaneJoint ( int iJoint, int iA, int iB, float fAnchorX, float fAnchorY, float fAnchorZ, float fAxisX, float fAxisY, float fAxisZ );
DARKSDK void dbPhyMakePointInPlaneJoint ( int iJoint, int iA, int iB );
DARKSDK void dbPhySetPointInPlaneJointLocalAnchor ( int iJoint, int iIndex, float fX, float fY, float fZ );
DARKSDK void dbPhySetPointInPlaneJointLocalAxis ( int iJoint, int iIndex, float fX, float fY, float fZ );
DARKSDK void dbPhySetPointInPlaneJointGlobalAnchor ( int iJoint, int iIndex, float fX, float fY, float fZ );
DARKSDK void dbPhySetPointInPlaneJointGlobalAxis ( int iJoint, int iIndex, float fX, float fY, float fZ );
DARKSDK void dbPhyBuildPointInPlaneJoint ( int iJoint );
bool dbPhySetupPointInPlaneJoint ( int iJoint, int iA, int iB );
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
| 61.55 | 164 | 0.519903 |
ff0d4c9c34baf2650c0461cb8ee69b5f23de5e52 | 11,330 | h | C | saasquatch/saasquatch/saasquatch.h | saasquatch/mobile-sdk-objectivec-cocoapod | 40b6d3299aff2fe4f627ad27be8447fd6effc5a7 | [
"MIT"
] | 1 | 2017-10-14T02:22:18.000Z | 2017-10-14T02:22:18.000Z | saasquatch/saasquatch/saasquatch.h | saasquatch/mobile-sdk-objectivec-cocoapod | 40b6d3299aff2fe4f627ad27be8447fd6effc5a7 | [
"MIT"
] | 1 | 2017-01-20T12:51:30.000Z | 2017-06-06T12:01:44.000Z | saasquatch/saasquatch/saasquatch.h | saasquatch/mobile-sdk-objectivec-cocoapod | 40b6d3299aff2fe4f627ad27be8447fd6effc5a7 | [
"MIT"
] | 1 | 2018-01-30T09:27:48.000Z | 2018-01-30T09:27:48.000Z | //
// saasquatch.h
// saasquatch
//
// Created by Brendan Crawford on 2016-04-14.
// Updated by Trevor Lee on 2017-06-20
//
#import <UIKit/UIKit.h>
//! Project version number for saasquatch.
FOUNDATION_EXPORT double saasquatchVersionNumber;
//! Project version string for saasquatch.
FOUNDATION_EXPORT const unsigned char saasquatchVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <saasquatch/PublicHeader.h>
/*!
* `Saasquatch` is the Referral Saasquatch iOS SDK which provides a set of methods for interfacing with Referral SaaSquatch. It can register a user with Referral SaaSquatch, retrieve information about users and referral codes, validate referral codes, and apply referral codes to a user's account.
*/
@interface Saasquatch : NSObject
/*!
* Registers a user with Referral SaaSquatch.
*
* @param tenant Identifies which tenant to connect to. For your app, you will get two tenant aliases
* @param userID A user ID from your system (must be unique for every user).
* @param accountID We use this ID to link a group of users together.
* @param token The JWT to sign the request.
* @param userInfo A Foundation object from which to generate JSON for the request.
* @param completionHandler A block object to be executed when the task finishes.
*
*
* @note The top level object in **userInfo** will be an NSDictionary containing the JSON data to be passed to the Referral SaaSquatch server. This requires the `id` and `accountId` values and can include several others. For a complete description see the Referral SaaSquatch REST API docs.
*
*
* <b>See:</b> <a href="http://docs.referralsaasquatch.com/api/methods/#open_create_user"> Referral SaaSquatch REST API reference</a> for a list of available fields.
*
*/
+ (void)registerUserForTenant:(NSString *)tenant
withUserID:(NSString *)userID
withAccountID:(NSString *)accountID
withToken:(NSString *)token
withUserInfo:(id)userInfo
completionHandler:(void (^)(id userInfo,
NSError *error))completionHandler;
/*!
* Gets a user's information from Referral Saasquatch.
*
* @param tenant Identifies which tenant to connect to. For your app, you will get two tenant aliases
* @param userId A user ID from your system (must be unique for every user).
* @param accountID We use this ID to link a group of users together.
* @param token The JWT to sign the request.
* @param completionHandler A block object to be executed when the task finishes.
*
* <b>See:</b> <a href="http://docs.referralsaasquatch.com/api/methods/#open_get_user"> Referral SaaSquatch REST API reference</a> for a list of available fields.
*
*/
+ (void)userForTenant:(NSString *)tenant
withUserID:(NSString *)userId
withAccountID:(NSString *)accountID
withToken:(NSString *)token
completionHandler:(void (^)(id userInfo,
NSError *error))completionHandler;
/*!
* Gets a user's information by their referral code.
*
* @param referralCode The referral code of the user being looked up.
* @param tenant Identifies which tenant to connect to.
* @param token The JWT to sign the request.
* @param completionHandler A block object to be executed when the task finishes.
*
* <b>See:</b> <a href="http://docs.referralsaasquatch.com/api/methods/#open_get_user_by_code"> Referral SaaSquatch REST API reference</a> for a list of available fields.
*
*/
+ (void)userByReferralCode:(NSString *)referralCode
forTenant:(NSString *)tenant
withToken:(NSString *)token
completionHandler:(void (^)(id userInfo,
NSError *error))completionHandler;
/*!
* Checks if a referral code exists and retrieves information about the code and it's reward.
*
* @param referralCode The referral code being validated.
* @param tenant Identifies which tenant to connect to. For your app, you will get two tenant aliases.
* @param token The JWT to sign the request.
* @param completionHandler A block object to be executed when the task finishes.
*
* <b>See:</b> <a href="http://docs.referralsaasquatch.com/api/methods/#open_validate_code"> Referral SaaSquatch REST API reference</a> for a list of available fields.
*
*/
+ (void)lookupReferralCode:(NSString *)referralCode
forTenant:(NSString *)tenant
withToken:(NSString *)token
completionHandler:(void (^)(id userInfo,
NSError *error))completionHandler;
/*!
* Applies a referral code to a user's account.
*
* @param referralCode The referral code to be applied.
* @param tenant Identifies which tenant to connect to. For your app, you will get two tenant aliases.
* @param userID A user ID from your system (must be unique for every user).
* @param accountID We use this ID to link a group of users together.
* @param token The JWT to sign the request.
* @param completionHandler A block object to be executed when the task finishes.
*
* <b>See:</b> <a href="http://docs.referralsaasquatch.com/api/methods/#open_apply_code"> Referral SaaSquatch REST API reference</a> for a list of available fields.
*
*/
+ (void)applyReferralCode:(NSString *)referralCode
forTenant:(NSString *)tenant
toUserID:(NSString *)userID
toAccountID:(NSString *)accountID
withToken:(NSString *)token
completionHandler:(void (^)(id userInfo,
NSError *error))completionHandler;
/*!
* Returns the list of referrals for the tenant with options for filtering.
*
* @param tenant Identifies which tenant to connect to.
* @param token The JWT to sign the request.
* @param accountID When included, filters the results to only referrals that were referred by users with this account id.
* @param userID When included, filters the results to only referrals that were referred by users with this user id.
* @param datePaid When included, filters the results either to the exact timestamp if only one value is given.
* @param dateEnded When included, filters the results either to the exact timestamp if only one value is given.
* @param referredStatus When included, filters the result to only include referred users with that status. Statuses that are accepted: PENDING, APPROVED or DENIED.
* @param referrerStatus When included, filters the result to only include referrers with that status. Statuses that are accepted: PENDING, APPROVED or DENIED.
* @param limit A limit on the number of results returned. Defaults to 10.
* @param offset When included offsets the first result returns in the list. Use this to paginate through a long list of results. Defaults to 0.
* @param completionHandler A block object to be executed when the task finishes.
*
* <b>See:</b> <a href="http://docs.referralsaasquatch.com/api/methods/#open_list_referrals"> Referral SaaSquatch REST API reference</a> for a list of available fields.
*
*/
+ (void)listReferralsForTenant:(NSString *)tenant
withToken:(NSString *)token
forReferringAccountID:(NSString *)accountID
forReferringUserID:(NSString *)userID
beforeDateReferralPaid:(NSString *)datePaid
beforeDateReferralEnded:(NSString *)dateEnded
withReferredModerationStatus:(NSString *)referredStatus
withReferrerModerationStatus:(NSString *)referrerStatus
withLimit:(NSString *)limit
withOffset:(NSString *)offset
completionHandler:(void (^)(id userInfo,
NSError *error))completionHandler;
/*!
* Generates a cookie account/user with Referral SaaSquatch.
*
* @param tenant Identifies which tenant to connect to.
* @param token The JWT to sign the request.
* @param userInfo A Foundation object from which to generate JSON for the request.
* @param completionHandler A block object to be executed when the task finishes.
*
* <b>See:</b> <a href="http://docs.referralsaasquatch.com/api/methods"> Referral SaaSquatch REST API reference</a> for a list of available fields.
*
*/
+ (void)createCookieUser:(NSString *)tenant
withToken:(NSString *)token
withUserInfo:(id)userInfo
completionHandler:(void (^)(id, NSError *))completionHandler;
/*!
* Updates/creates a user and an account with Referral SaaSquatch.
*
* @param tenant Identifies which tenant to connect to.
* @param userID When included, filters the results to only referrals that were referred by users with this user id.
* @param accountID When included, filters the results to only referrals that were referred by users with this account id.
* @param token The JWT to sign the request.
* @param userInfo A Foundation object from which to generate JSON for the request.
* @param completionHandler A block object to be executed when the task finishes.
*
* <b>See:</b> <a href="http://docs.referralsaasquatch.com/api/methods"> Referral SaaSquatch REST API reference</a> for a list of available fields.
*
*/
+ (void)userUpsert:(NSString *)tenant
withUserID:(NSString *)userID
withAccountID: (NSString *)accountID
withToken:(NSString *)token
withUserInfo:(id)userInfo
completionHandler:(void (^)(id, NSError *))completionHandler;
/*!
* Allows customers to request share links for a particular engagement medium
*
* @param tenant Identifies which tenant to connect to.
* @param token The JWT to sign the request.
* @param accountID When included, filters the results to only referrals that were referred by users with this account id.
* @param userID When included, filters the results to only referrals that were referred by users with this user id.
* @param engagementMedium [OPTIONAL] Identifies which medium to return. Can be one of [EMAIL, EMBED, HOSTED, MOBILE, POPUP, UNKNOWN]
* @param shareMedium [OPTIONAL] Identifies which sharelink to return. Can be one of [DIRECT, EMAIL, FACEBOOK, FBMESSENGER, LINKEDIN, SMS, TWITTER, UNKNOWN, WHATSAPP] * @param completionHandler A block object to be executed when the task finishes.
*
* <b>See:</b> <a href="http://docs.referralsaasquatch.com/api/methods"> Referral SaaSquatch REST API reference</a> for a list of available fields.
*
*/
+ (void)getShareLinks:(NSString *)tenant
withToken:(NSString *)token
forReferringUserID:(NSString *)userID
forReferringAccountID:(NSString *)accountID
withEngagementMedium:(NSString *)engagementMedium
withShareMedium:(NSString *)shareMedium
completionHandler:(void (^)(id, NSError *))completionHandler;
@end
| 52.943925 | 297 | 0.680671 |
ff12bb0893e84ee7587009e0bc359378099b2776 | 4,216 | h | C | Video/Render/Core/DispSvr/3.X/3.2.X/3.2.X/D3D9VideoPlane.h | goodspeed24e/2011Corel | 4efb585a589ea5587a877f4184493b758fa6f9b2 | [
"MIT"
] | 1 | 2019-07-24T07:59:07.000Z | 2019-07-24T07:59:07.000Z | Video/Render/Core/DispSvr/3.X/3.2.X/3.2.X/D3D9VideoPlane.h | goodspeed24e/2011Corel | 4efb585a589ea5587a877f4184493b758fa6f9b2 | [
"MIT"
] | null | null | null | Video/Render/Core/DispSvr/3.X/3.2.X/3.2.X/D3D9VideoPlane.h | goodspeed24e/2011Corel | 4efb585a589ea5587a877f4184493b758fa6f9b2 | [
"MIT"
] | 6 | 2015-03-17T12:11:38.000Z | 2022-01-29T01:15:52.000Z | #ifndef _DISPSVR_D3D9_VIDEO_PLANE_H_
#define _DISPSVR_D3D9_VIDEO_PLANE_H_
MIDL_INTERFACE("B05B4BC5-3BB3-4341-BE96-5215B9D5F99D") IDispSvrVideoPlaneCallback;
namespace DispSvr
{
struct VideoProcessorStub
{
GUID guidVP;
D3DFORMAT RenderTargetFormat;
VideoProcessorCaps sCaps;
ValueRange FilterRanges[6];
float fFilterValue[6];
TpfnVBltFactoryMethod pfnVBltFactory;
VideoProcessorStub *pDelegateVPStub;
};
/// D3D9PlaneConfig is a static storage to save settings that do not change when planes are created or destroyed.
struct D3D9PlaneConfig
{
VideoProcessorStub *pVideoProcessorStub;
TEXTURE_USAGE_FLAG eTextureUsage;
};
/// Plane object represents IDispSvrVideoMixerPlane and IDispSvrVideoMixerVideoPlane and
/// delegates commands to the underlying mixer implementation.
class CD3D9VideoMixerPlane : public IDispSvrVideoMixerVideoPlane,
public IDispSvrVideoMixerDependentView,
public IDispSvrVideoMixerPlaneStereoControl
{
public:
static HRESULT Create(const PlaneInit &InitOpt, CD3D9VideoMixerPlane **ppPlane);
virtual ~CD3D9VideoMixerPlane();
// IUnknown
STDMETHOD(QueryInterface)(REFIID riid, void **ppv);
STDMETHOD_(ULONG, AddRef)();
STDMETHOD_(ULONG, Release)();
// IDispSvrVideoMixerPlane
STDMETHOD(GetPlaneDesc)(PlaneDesc *pDesc);
STDMETHOD(SetExternalSurface)(const ExternalSurfaceDesc *pEx);
STDMETHOD(UpdateFromBuffer)(UpdateBuffer *pBuffer);
STDMETHOD(LockBuffer)(LockedRect *pOut, const RECT *rcSrc, DWORD dwFlags);
STDMETHOD(UnlockBuffer)();
STDMETHOD(SetPlanarAlpha)(float fAlpha);
STDMETHOD(GetPlanarAlpha)(float *pfAlpha);
STDMETHOD(SetPosition)(const NORMALIZEDRECT *rcDst, const RECT *rcSrc, const NORMALIZEDRECT *rcCrop, float fAspectRatio);
STDMETHOD(GetPosition)(NORMALIZEDRECT *rcDst, RECT *rcSrc, NORMALIZEDRECT *rcCrop, float *pfAspectRatio);
STDMETHOD(SetDirtyRect)(const RECT *rcDirty);
// IDispSvrVideoMixerVideoPlane
STDMETHOD(SetVideoProperty)(const VideoProperty *pProperty);
STDMETHOD(GetVideoProperty)(VideoProperty *pProperty);
STDMETHOD(SetColorControl)(const ColorControl *pCC);
STDMETHOD(GetColorControl)(ColorControl *pCC);
//IDispSvrVideoMixerDependentView
STDMETHOD(SetDeptViewExternalSurface)(UINT uViewID, const DispSvr::ExternalSurfaceDesc *pEx);
STDMETHOD(UpdateDeptViewFromBuffer)(UINT uViewID, DispSvr::UpdateBuffer *pBuffer);
STDMETHOD(LockDeptViewBuffer)(UINT uViewID, DispSvr::LockedRect *pOut, const RECT *rcSrc, DWORD dwFlags);
STDMETHOD(UnlockDeptViewBuffer)(UINT uViewID);
// IDispSvrVideoMixerPlaneStereoControl
STDMETHOD(SetStereoStreamMode)(STEREO_STREAM_MODE eMode);
STDMETHOD(GetStereoStreamMode)(STEREO_STREAM_MODE *peMode);
STDMETHOD(SetPlaneMetaData)(const LPBYTE pMetaData, DWORD dwSize) ;
STDMETHOD(GetPlaneMetaData)(LPBYTE *ppMetaData, LPDWORD pdwSize);
STDMETHOD(SetOffsetProperty)(const DispSvr::StereoOffsetProperty *pProperty);
STDMETHOD(GetOffsetProperty)(DispSvr::StereoOffsetProperty *pProperty);
protected:
CD3D9VideoMixerPlane(const PlaneInit &InitOpt);
STDMETHOD(_QueryStatusOfExternalSurface)(PLANE_ID PlaneID, const ExternalSurfaceDesc *pEx, UINT uDeptViewID = NULL);
STDMETHOD(_SetExternalSurface)(PLANE_ID PlaneID, const ExternalSurfaceDesc *pEx, UINT uDeptViewID = NULL);
bool IsVideoPlane() const { return m_InitOpt.PlaneID == PLANE_MAINVIDEO || m_InitOpt.PlaneID == PLANE_SUBVIDEO; };
HRESULT PrepareDeptViewBuffer(PLANE_ID PlaneID, UINT uViewID);
HRESULT Init();
protected:
IDispSvrVideoPlaneCallback *m_pPlaneCB;
IDispSvrVideoMixer *m_pMixer;
CD3D9VideoMixerModel *m_pModel;
CD3D9TexturePool *m_pTexturePool;
LONG m_cRef;
PlaneInit m_InitOpt;
bool m_bExternalSurface;
};
}
interface IDispSvrVideoPlaneCallback : public IUnknown
{
virtual const DispSvr::D3D9PlaneConfig &GetPlaneConfig(DispSvr::PLANE_ID PlaneID) = 0;
STDMETHOD_(void, OnVideoPositionChange)() = 0;
STDMETHOD_(void, OnDestroyPlane)(DispSvr::PLANE_ID PlaneID) = 0;
STDMETHOD(OnCreatePlane)(const DispSvr::PlaneInit &pInit) = 0;
};
#endif // _DISPSVR_D3D9_VIDEO_PLANE_H_ | 42.16 | 123 | 0.77538 |
ff14fda41e5facc4c71fa26db798a62fa88f7310 | 1,733 | c | C | src/ECEP1/fila_circular.c | dreis0/algoritmos-estrutura-dados | dd570a7d8e4ec4b6ba5617b2861f9efee97ab912 | [
"MIT"
] | null | null | null | src/ECEP1/fila_circular.c | dreis0/algoritmos-estrutura-dados | dd570a7d8e4ec4b6ba5617b2861f9efee97ab912 | [
"MIT"
] | null | null | null | src/ECEP1/fila_circular.c | dreis0/algoritmos-estrutura-dados | dd570a7d8e4ec4b6ba5617b2861f9efee97ab912 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
struct fila_circular_estatica
{
int *itens;
int tamanho, quantidade, indiceInicio, indiceFim;
};
struct fila_circular_estatica *cria_fila(int);
void enfileria(struct fila_circular_estatica *, int);
int desenfileira(struct fila_circular_estatica *);
int main()
{
char operacao;
int valor, tamanho, desenfileriado;
scanf("%d", &tamanho);
struct fila_circular_estatica *fila = cria_fila(tamanho);
while (scanf("\n%c", &operacao) != EOF)
{
if (operacao == 'E')
{
scanf(" %d", &valor);
enfileria(fila, valor);
}
else if (operacao == 'D')
{
desenfileriado = desenfileira(fila);
if (desenfileriado != -1)
printf("%d\n", desenfileriado);
}
}
return 0;
}
struct fila_circular_estatica *cria_fila(int tamanho)
{
struct fila_circular_estatica *f = (struct fila_circular_estatica *)malloc(sizeof(struct fila_circular_estatica));
f->itens = (int *)malloc(sizeof(int) * tamanho);
f->indiceInicio = 0;
f->indiceFim = 0;
f->tamanho = tamanho;
return f;
}
void enfileria(struct fila_circular_estatica *fila, int novoValor)
{
int novoFim = (fila->indiceFim + 1) % fila->tamanho;
if (novoFim != fila->indiceInicio)
{
fila->itens[fila->indiceFim] = novoValor;
fila->indiceFim = novoFim;
}
}
int desenfileira(struct fila_circular_estatica *fila)
{
int desenfileirado = -1;
if (fila->indiceFim != fila->indiceInicio)
{
desenfileirado = fila->itens[fila->indiceInicio];
fila->indiceInicio = (fila->indiceInicio + 1) % fila->tamanho;
}
return desenfileirado;
} | 23.418919 | 118 | 0.624928 |
ff1539c97ea3383e48e749e3613511307c8fa97b | 456 | h | C | GameEngine/GameEngine/src/graphics/3D/model_comp/mesh3D.h | llGuy/gamedev | 16aa203934fd767926c58558e021630288556399 | [
"MIT"
] | null | null | null | GameEngine/GameEngine/src/graphics/3D/model_comp/mesh3D.h | llGuy/gamedev | 16aa203934fd767926c58558e021630288556399 | [
"MIT"
] | 4 | 2018-12-24T11:16:53.000Z | 2018-12-24T11:20:29.000Z | GameEngine/GameEngine/src/graphics/3D/model_comp/mesh3D.h | llGuy/gamedev | 16aa203934fd767926c58558e021630288556399 | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
#include "mesh_comp.h"
struct mesh3D_model_computation : model_computation
{
u32 x, z;
mesh3D_model_computation(u32 x, u32 z)
: x(x), z(z)
{
}
auto compute(object<model_data> & obj) -> void override;
private:
__forceinline auto get_index(u32 x_, u32 z_) -> u32
{
return x_ + x * z_;
}
auto create_vertices(void) -> std::vector<glm::vec2>;
auto create_indices(void) -> std::vector<u32>;
};
| 15.724138 | 60 | 0.657895 |
ff15fb21b422e9d688376a350df364883cb78c00 | 2,591 | h | C | Source/Runtime/Core/Public/MonsterEngine/Core/Window/Window.h | MonstersEntmt/MonsterEngine | 0b742388b1ef0385975d1537ccb06cd7d1245750 | [
"MIT"
] | 1 | 2022-03-26T14:41:35.000Z | 2022-03-26T14:41:35.000Z | Source/Runtime/Core/Public/MonsterEngine/Core/Window/Window.h | MonstersEntmt/MonsterEngine | 0b742388b1ef0385975d1537ccb06cd7d1245750 | [
"MIT"
] | null | null | null | Source/Runtime/Core/Public/MonsterEngine/Core/Window/Window.h | MonstersEntmt/MonsterEngine | 0b742388b1ef0385975d1537ccb06cd7d1245750 | [
"MIT"
] | null | null | null | #pragma once
#include <cstdint>
#include <map>
#include <string>
#include <string_view>
typedef struct GLFWwindow GLFWwindow;
typedef struct GLFWmonitor GLFWmonitor;
typedef struct GLFWvidmode GLFWvidmode;
namespace MonsterEngine::Core {
enum class WindowState : uint32_t {
NORMAL = 0,
MAXIMIZED,
ICONIFIED,
FULLSCREEN
};
struct MonsterEngine_CoreAPI WindowData {
public:
int32_t x = 0x80000000, y = 0x80000000; // 0x80000000 for x and y just means that it will auto center the window on the primary monitor.
uint32_t w = 1280, h = 720;
uint32_t fw = 0, fh = 0;
float sx = 1.0f, sy = 1.0f;
WindowState state = WindowState::MAXIMIZED;
};
class MonsterEngine_CoreAPI Window {
public:
friend class WindowManager;
public:
inline bool isCreated() const { return this->windowPtr; }
inline bool isFocused() const { return this->focused; }
inline void getPos(int32_t& x, int32_t& y) const {
x = this->windowData.x;
y = this->windowData.y;
}
inline void getSize(uint32_t& w, uint32_t& h) const {
w = this->windowData.w;
h = this->windowData.h;
}
inline void getFramebufferSize(uint32_t& fw, uint32_t& fh) const {
fw = this->windowData.fw;
fh = this->windowData.fh;
}
inline const std::string& getTitle() const { return this->title; }
inline void getState(WindowState& state) const { state = this->windowData.state; }
inline bool isNormal() const { return this->windowData.state == WindowState::NORMAL; }
inline bool isMaximized() const { return this->windowData.state == WindowState::MAXIMIZED; }
inline bool isIconified() const { return this->windowData.state == WindowState::ICONIFIED; }
inline bool isFullscreened() const { return this->windowData.state == WindowState::FULLSCREEN; }
GLFWmonitor* getMonitor() const;
const GLFWvidmode* getVideoMode(GLFWmonitor* monitor = nullptr) const;
void setPos(int32_t x, int32_t y);
void setSize(uint32_t w, uint32_t h);
void setTitle(std::string_view title);
void restore();
void maximize();
void iconify();
void fullscreen();
private:
Window() = default;
Window(const Window&) = delete;
Window(Window&&) = delete;
Window& operator=(const Window&) = delete;
Window& operator=(Window&&) = delete;
void create(Window* share = nullptr);
void destroy();
private:
GLFWwindow* windowPtr = nullptr;
WindowData windowData;
WindowData prevWindowData;
std::string title;
bool focused = false;
int32_t refreshRate = 0x80000000; // 0x80000000 means get the highest refresh rate.
};
} // namespace MonsterEngine::Core | 30.127907 | 138 | 0.708607 |
ff1734edb04ef718e87bda5a5a5781cb01f34ea0 | 2,772 | h | C | OpenSees/SRC/reliability/analysis/gFunction/TclGFunEvaluator.h | kuanshi/ductile-fracture | ccb350564df54f5c5ec3a079100effe261b46650 | [
"MIT"
] | 8 | 2019-03-05T16:25:10.000Z | 2020-04-17T14:12:03.000Z | SRC/reliability/analysis/gFunction/TclGFunEvaluator.h | steva44/OpenSees | 417c3be117992a108c6bbbcf5c9b63806b9362ab | [
"TCL"
] | null | null | null | SRC/reliability/analysis/gFunction/TclGFunEvaluator.h | steva44/OpenSees | 417c3be117992a108c6bbbcf5c9b63806b9362ab | [
"TCL"
] | 3 | 2019-09-21T03:11:11.000Z | 2020-01-19T07:29:37.000Z | /* ****************************************************************** **
** OpenSees - Open System for Earthquake Engineering Simulation **
** Pacific Earthquake Engineering Research Center **
** **
** **
** (C) Copyright 2001, The Regents of the University of California **
** All Rights Reserved. **
** **
** Commercial use of this program without express permission of the **
** University of California, Berkeley, is strictly prohibited. See **
** file 'COPYRIGHT' in main directory for information on usage and **
** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
** **
** Developed by: **
** Frank McKenna (fmckenna@ce.berkeley.edu) **
** Gregory L. Fenves (fenves@ce.berkeley.edu) **
** Filip C. Filippou (filippou@ce.berkeley.edu) **
** **
** Reliability module developed by: **
** Terje Haukaas (haukaas@ce.berkeley.edu) **
** Armen Der Kiureghian (adk@ce.berkeley.edu) **
** **
** ****************************************************************** */
// $Revision: 1.7 $
// $Date: 2010-09-13 21:39:25 $
// $Source: /usr/local/cvs/OpenSees/SRC/reliability/analysis/gFunction/TclGFunEvaluator.h,v $
//
// Written by Terje Haukaas (haukaas@ce.berkeley.edu)
//
#ifndef TclGFunEvaluator_h
#define TclGFunEvaluator_h
#include <GFunEvaluator.h>
#include <Vector.h>
#include <Domain.h>
#include <ReliabilityDomain.h>
#include <tcl.h>
class TclGFunEvaluator : public GFunEvaluator
{
public:
TclGFunEvaluator(Tcl_Interp *passedTclInterp,
ReliabilityDomain *passedReliabilityDomain,
Domain *passedOpenSeesDomain,
TCL_Char *fileName);
~TclGFunEvaluator();
int evaluateG(const Vector &x);
double getG(void);
int runGFunAnalysis(const Vector &x);
int tokenizeSpecials(TCL_Char *theExpression, Tcl_Obj *passedList);
protected:
private:
int setTclRandomVariables(const Vector &x);
Tcl_Interp *theTclInterp;
ReliabilityDomain *theReliabilityDomain;
Domain *theOpenSeesDomain;
char fileName[256];
double g;
};
#endif
| 36.96 | 93 | 0.476551 |
ff1813acb804c9634aca25db727b750fb07b3c07 | 802 | h | C | ARReader/ARComposing/ARTextComponent/ARTextLayout.h | ArchyVan/ARReader | f3f7b705756f3704043732f4fc17cd2bc3153818 | [
"MIT"
] | 6 | 2017-02-04T10:08:50.000Z | 2021-04-24T16:28:34.000Z | ARReader/ARComposing/ARTextComponent/ARTextLayout.h | ArchyVan/ARReader | f3f7b705756f3704043732f4fc17cd2bc3153818 | [
"MIT"
] | 4 | 2017-03-08T07:46:04.000Z | 2017-09-02T00:08:31.000Z | ARReader/ARComposing/ARTextComponent/ARTextLayout.h | ArchyVan/ARReader | f3f7b705756f3704043732f4fc17cd2bc3153818 | [
"MIT"
] | null | null | null | //
// ARTextLayout.h
// ARReader
//
// Created by Objective-C on 2017/2/13.
// Copyright © 2017年 Archy Van. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>
#import "ARTextLine.h"
NS_ASSUME_NONNULL_BEGIN
@interface ARTextLayout : NSObject
+ (instancetype)layoutWithCTFrame:(CTFrameRef)CTFrame size:(CGSize)size fontSize:(CGFloat)fontSize;
@property (nonatomic, readonly) CTFrameRef CTFrame;
@property (nonatomic, readonly) NSString *content;
@property (nonatomic, readonly) NSUInteger rowCount;
@property (nonatomic, readonly) NSUInteger wordCount;
@property (nonatomic, readonly) CGFloat fontSize;
@property (nonatomic, readonly) CGSize layoutSize;
@property (nonatomic, readonly, strong) NSArray<ARTextLine *> *lines;
@end
NS_ASSUME_NONNULL_END
| 25.0625 | 99 | 0.756858 |
ff1c9a41cd46e5034b9ed0434acde0d8854dfc4d | 5,856 | h | C | src/libqgit2/qgitobject.h | lingnand/Helium | d1f8fab6eb5d60e35b3287f6ea35cd1fae71f816 | [
"BSD-3-Clause"
] | 8 | 2021-04-16T02:05:54.000Z | 2022-03-16T13:56:23.000Z | src/libqgit2/qgitobject.h | lingnand/Helium | d1f8fab6eb5d60e35b3287f6ea35cd1fae71f816 | [
"BSD-3-Clause"
] | null | null | null | src/libqgit2/qgitobject.h | lingnand/Helium | d1f8fab6eb5d60e35b3287f6ea35cd1fae71f816 | [
"BSD-3-Clause"
] | 2 | 2021-04-17T10:49:58.000Z | 2021-07-21T20:39:52.000Z | /******************************************************************************
* This file is part of the libqgit2 library
* Copyright (c) 2011 Laszlo Papp <djszapi@archlinux.us>
* Copyright (C) 2013 Leonardo Giordani
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef LIBQGIT2_OBJECT_H
#define LIBQGIT2_OBJECT_H
#include <QtCore/QString>
#include <QtCore/QDateTime>
#include <QtCore/QSharedPointer>
#include "libqgit2_config.h"
#include "git2.h"
namespace LibQGit2
{
class Repository;
class OId;
class Commit;
class Tag;
class Tree;
class Blob;
/**
* @brief Wrapper class for git_object.
*
* This is the base class for every repository object, i.e. blob, commit,
* tag and tree. Every object is identified with it's LibQGit2::OId.
*
* @ingroup LibQGit2
* @{
*/
class LIBQGIT2_EXPORT Object
{
public:
/**
* @brief The type of an \c Object.
*/
enum Type {
BadType, ///< Not a valid Object type
CommitType,
TreeType,
BlobType,
TagType
};
/**
* Create an Object.
*
* Creates an Object that points to the given object.
* The pointer to the underlaying git_object is managed by this
* Object, and is automatically freed when no more referenced.
*/
explicit Object(git_object *object = 0);
/**
* Copy constructor.
*/
Object(const Object& other);
/**
* Destroy the object.
*/
~Object();
/**
* Gets the type of this \c Object.
*/
Type type() const;
/**
* Convert into a commit object.
*
* If the underlaying git_object is a commit this returns a valid
* Commit object, otherwise it returns an empty one.
*/
Commit toCommit() const;
/**
* Convert into a tag object.
*
* If the underlaying git_object is a tag this returns a valid
* Tag object, otherwise it returns an empty one.
*/
Tag toTag() const;
/**
* Convert into a tree object.
*
* If the underlaying git_object is a tree this returns a valid
* Tag object, otherwise it returns an empty one.
*/
Tree toTree() const;
/**
* Convert into a blob object.
*
* If the underlaying git_object is a blob this returns a valid
* Tag object, otherwise it returns an empty one.
*/
Blob toBlob() const;
/**
* Check if the pointer is null.
*
* Returns true if the git_object pointer owned by this
* instance is null.
*/
bool isNull() const;
/**
* Get the OId (SHA1) of a repository object.
*
* This returns the OId of the object.
* Remember that in-memory objects created by git_object_new()
* do not have a SHA1 id until they are written on a repository.
*
* @return the OId of the object
*/
OId oid() const;
/**
* Check if this is a commit.
*
* Returns true if the object represents a commit; false otherwise.
*/
bool isCommit() const;
/**
* Check if this is a tag.
*
* Returns true if the object represents a tag; false otherwise.
*/
bool isTag() const;
/**
* Check if this is a tree.
*
* Returns true if the object represents a tree; false otherwise.
*/
bool isTree() const;
/**
* Check if this is a blob.
*
* Returns true if the object represents a blob; false otherwise.
*/
bool isBlob() const;
/**
* Get the object type as a string.
*/
QString typeString() const;
/**
* Get the repository that owns this object.
*/
Repository owner() const;
git_object* data() const;
const git_object* constData() const;
private:
QSharedPointer<git_object> d;
static Type resolveType(git_otype);
friend class TreeEntry;
};
/**
* Compares two Objects. Objects are equal when their oid are equal.
*/
bool operator ==(const Object &o1, const Object &o2);
/**
* Compares two Objects. Objects are different when their oid are different.
*/
bool operator !=(const Object &o1, const Object &o2);
/**@}*/
}
#endif // LIBQGIT2_OBJECT_H
| 28.990099 | 81 | 0.516052 |
ff1e04fe11ddc62fee2f5cc9253cdd4ac112d60b | 12,834 | h | C | include/orcvio/obj/ObjectLMLite.h | shanmo/OrcVIO-Object-Mapping | e5337a56da72b23ebf5c9d9f87534fe2edc9c54c | [
"MIT"
] | 1 | 2021-10-14T03:31:16.000Z | 2021-10-14T03:31:16.000Z | include/orcvio/obj/ObjectLMLite.h | shanmo/OrcVIO-Object-Mapping | e5337a56da72b23ebf5c9d9f87534fe2edc9c54c | [
"MIT"
] | null | null | null | include/orcvio/obj/ObjectLMLite.h | shanmo/OrcVIO-Object-Mapping | e5337a56da72b23ebf5c9d9f87534fe2edc9c54c | [
"MIT"
] | null | null | null | /* -*- c-basic-offset: 4; */
#ifndef OBJECTLMLITE_H
#define OBJECTLMLITE_H
#include <memory>
#include <numeric>
#include <type_traits>
#include "sophus/se3.hpp"
#include "orcvio/utils/EigenLevenbergMarquardt.h"
#include "orcvio/utils/se3_ops.hpp"
#include "orcvio/obj/ObjectFeature.h"
namespace orcvio
{
/**
* @brief The LMObjectTraj class
*
* Represents A single object with pose, shape and keypoints
*/
class LMObjectStateLite {
public:
typedef int Index;
/**
* @brief Tangent
*
* Type for dx
*/
typedef Eigen::Matrix<double, Eigen::Dynamic, 1> Tangent;
typedef LMSE3 wTo_Type;
typedef Eigen::Matrix<double, 3, 1> ShapeType;
typedef Eigen::Matrix<double, Eigen::Dynamic, 3> SemanticKeyPtsType;
typedef Eigen::Matrix<double, Eigen::Dynamic, 4> HomSemanticKeyPtsType;
constexpr static int wTo_DoF = LMSE3::DoF;
constexpr static int ShapeDoF = 3;
constexpr static int KeyptDoF = 3;
static int DoF() {
return wTo_DoF + ShapeDoF;
}
/**
* @brief Convert from homogeneous keypints to 3D keypoints
*
* @param sem_kps_hom
* @return
*/
static SemanticKeyPtsType toSemanticKeyPts(const HomSemanticKeyPtsType& sem_kps_hom) {
Eigen::VectorXd last_col = sem_kps_hom.block(0,3, sem_kps_hom.rows(), 1);
return (sem_kps_hom.block(0,0, sem_kps_hom.rows(), 3).array().colwise()
/ last_col.array()).matrix();
}
/**
* @brief Convert from 3D keypoints to Homogeneous keypoints
* @param sem_kps_hom
* @return
*/
static HomSemanticKeyPtsType toHomSemanticKeyPts(const SemanticKeyPtsType& deformation) {
HomSemanticKeyPtsType sem_kps_hom = HomSemanticKeyPtsType::Ones(deformation.rows(), 4);
sem_kps_hom.block(0, 0, deformation.rows(), 3) = deformation;
return sem_kps_hom;
}
/**
* @brief Default constructor
*/
LMObjectStateLite() = default;
/**
* @brief Constructor when Semantic keypints are provided as homoegeneous coordinates
* @param wTo (4x4)
* @param shape (3)
* @param sem_kps_hom (keypoint number x 4)
*/
template<typename DefT, typename std::enable_if<DefT::ColsAtCompileTime == 4, int>::type = 0>
LMObjectStateLite(const wTo_Type& wTo,
const ShapeType& shape,
const DefT& sem_kps_hom)
: wTo_(wTo),
shape_(shape),
semantic_key_pts_(toSemanticKeyPts(sem_kps_hom)),
hom_semantic_key_pts_(sem_kps_hom)
{
assert(wTo.matrix().allFinite());
assert(shape.allFinite());
assert(sem_kps_hom.allFinite());
assert(allFinite());
}
/**
* @brief Constructor when Semantic keypints are provided as non homoegeneous coordinates
*
* @param wTo (4x4)
* @param shape (3)
* @param sem_kps_inhomo (keypoint number x 3)
*/
template<typename DefT, typename std::enable_if<DefT::ColsAtCompileTime == 3, int>::type = 0>
LMObjectStateLite(const wTo_Type& wTo,
const ShapeType& shape,
const DefT& sem_kps_inhomo)
: wTo_(wTo),
shape_(shape),
semantic_key_pts_(sem_kps_inhomo),
hom_semantic_key_pts_(toHomSemanticKeyPts(sem_kps_inhomo))
{
assert(allFinite());
}
int dof() const {
return DoF();
}
/// Needed for LM compatibility
int size() const {
return dof();
}
LMSE3 getwTo() const { return wTo_; }
ShapeType getShape() const { return shape_; }
SemanticKeyPtsType getSemanticKeyPts() const { return semantic_key_pts_; }
HomSemanticKeyPtsType getHomSemanticKeyPts() const { return hom_semantic_key_pts_; }
/// Filter out the invalid semantic keypoints
Eigen::MatrixX4d getValidSemanticKeyPts(const std::vector<int>& valid_idx) const {
Eigen::MatrixX4d valid_keypoints(valid_idx.size(), 4);
int valididx = 0;
for (auto const& idx : valid_idx)
valid_keypoints.row(valididx++) = hom_semantic_key_pts_.row(idx);
return valid_keypoints;
}
/// In the big Vector45d vector where does wTo block start
int block_start_wTo() const {
return 0;
}
/// In the big Vector45d vector where does shape block start
int block_start_shape() const {
return wTo_DoF;
}
/// Compute scaled norm given diag vector (Needed for LM compatibility)
double scaled_norm(const Tangent& diag) const {
double sum = 0;
sum += wTo_.scaled_norm(diag.block<wTo_DoF, 1>(block_start_wTo(), 0));
sum += diag.block<ShapeDoF, 1>(block_start_shape(), 0).cwiseProduct(shape_).stableNorm();
return sum;
}
/// Support addition for this object time (Needed for LM compatibility)
friend LMObjectStateLite operator+(const LMObjectStateLite& x,
const LMObjectStateLite::Tangent& dx) ;
/// Support addition for this object time (Needed for LM compatibility)
LMObjectStateLite& operator+=(const LMObjectStateLite::Tangent& dx) ;
friend std::ostream& operator<<(std::ostream& o, const LMObjectStateLite& x) ;
bool allFinite() const {
assert(wTo_.matrix().allFinite());
assert(shape_.allFinite());
assert(semantic_key_pts_.allFinite());
return wTo_.matrix().allFinite() && shape_.allFinite() && semantic_key_pts_.allFinite();
}
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
private:
LMSE3 wTo_{ Eigen::Matrix4d::Identity() };
ShapeType shape_{ ShapeType::Zero() };
SemanticKeyPtsType semantic_key_pts_;
HomSemanticKeyPtsType hom_semantic_key_pts_;
};
typedef EigenLevenbergMarquardt::DenseFunctor<double, Eigen::Dynamic, Eigen::Dynamic, LMObjectStateLite>
DenseFunctorObjectStateLite;
/**
* @brief The ObjectLM to handle error methods for fitting Object pose, mean shape, and Keypoint positions.
*/
class ObjectLMLite : public DenseFunctorObjectStateLite
{
public:
/// Type aliaces for LM compatibility
typedef LMObjectStateLite InputType;
typedef Eigen::VectorXd DiffType;
ObjectLMLite(const Eigen::Vector3d &object_mean_shape,
const Eigen::Matrix3d &camera_intrinsics,
const Eigen::MatrixX3d &object_keypoints_mean,
const ObjectFeature &features,
const vector_eigen<Eigen::Matrix4d> &camposes,
const Eigen::VectorXd &residual_weights,
const bool use_left_perturbation_flag,
const bool use_new_bbox_residual_flag,
const double huber_epsilon = std::numeric_limits<double>::infinity());
/**
* @brief Compute bounding box error
*
* @param bbox: Object bounding box
* @param cTw: Transform from world to camera optical frame, s.t. x_c = cTw x_w
* @param camera_intrinsics: Camera intrinsic matrix
* @param use_left_perturbation_flag: flag for perturbation
* @param use_new_bbox_residual_flag: flag for new bounding box residual
* @return computed error
*/
struct ErrorBBoxQuadric : DenseFunctorObjectStateLite
{
typedef LMObjectStateLite InputType;
typedef Eigen::VectorXd DiffType;
constexpr static int ErrPerFrame = 4;
ErrorBBoxQuadric(const vector_eigen<Eigen::MatrixX2d> &zs,
const vector_eigen<Eigen::Vector4d> &bboxes,
const vector_eigen<Eigen::Matrix4d> &cTw,
const Eigen::Matrix3d &camera_intrinsics,
const Eigen::MatrixX3d &object_keypoints_mean,
const bool use_left_perturbation_flag,
const bool use_new_bbox_residual_flag);
/// Computes error vector for LM
int operator()(const InputType &object, Eigen::Ref<ValueType> fvec) const;
/// Computes jacobian for LM wrt object state
int df(const InputType &object, Eigen::Ref<JacobianType> fjac) const;
/// computes scaled norm for LM
double scaled_norm(const DiffType &diag, const InputType &object) const;
static int NErrors(const vector_eigen<Eigen::Vector4d> &zb)
{
return ErrPerFrame * zb.size();
}
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
protected:
ValueType operator()(const LMObjectStateLite &object, const size_t frameid) const;
// get jacobian wrt object state per frame
int df(const LMObjectStateLite &object,
const size_t frameid, Eigen::Ref<JacobianType> fjac) const;
size_t numFrames() const { return bboxes_.size() - 1; }
int nerrors() const
{
return ErrPerFrame * bboxes_.size();
}
int block_start_frame(int frameid) const
{
return ErrPerFrame * frameid;
}
const vector_eigen<Eigen::Vector4d> bboxes_;
const vector_eigen<Eigen::Matrix4d> frames_cTw_;
const Eigen::Matrix3d camera_intrinsics_;
const std::vector<std::vector<int>> valid_indices_;
const bool use_left_perturbation_flag_;
const bool use_new_bbox_residual_flag_;
};
/**
* @brief Compute regularization term due to object deformation from object mean
*
* @param feat: Object semantic features
* @param object_mean_shape: Object mean shape
*
* @return computed error
*/
struct ErrorQuadVRegularization : DenseFunctorObjectStateLite
{
typedef LMObjectStateLite InputType;
typedef Eigen::VectorXd DiffType;
ErrorQuadVRegularization(const vector_eigen<Eigen::Vector4d> &zb,
const Eigen::MatrixX3d &object_keypoints_mean,
const Eigen::Vector3d &object_mean_shape);
int operator()(const InputType &objec_mean_shape, Eigen::Ref<ValueType> fvec) const;
int df(const InputType &objec_mean_shape, Eigen::Ref<JacobianType> fjac) const;
double scaled_norm(const DiffType &diag, const InputType &wTo) const;
static int NErrors(const vector_eigen<Eigen::Vector4d> &zb)
{
// TODO FIXME why -1
return ErrPerFrame * (zb.size() - 1);
// return ErrPerFrame * zb.size();
}
protected:
constexpr static int ErrPerFrame = LMObjectStateLite::ShapeDoF;
size_t numFrames() const { return zb_.size() - 1; }
const Eigen::Vector3d object_mean_shape_;
const vector_eigen<Eigen::Vector4d> zb_;
};
struct Huber
{
typedef Eigen::VectorXd InputType;
typedef Eigen::VectorXd ValueType;
typedef Eigen::MatrixXd JacobianType;
Huber(double huber_epsilon) : huber_epsilon_(huber_epsilon) {}
int operator()(const InputType &x, Eigen::Ref<ValueType> fvec) const;
int df(const InputType &x, const Eigen::MatrixXd &fwdJac,
Eigen::Ref<JacobianType> fjac) const;
protected:
double huber_epsilon_;
};
const Eigen::Matrix3d &getCameraIntrinsics() const { return camera_intrinsics_; }
const Eigen::Vector3d &getObjectMeanShape() const { return object_mean_shape_; }
int operator()(const InputType &object, Eigen::Ref<ValueType> fvec) const;
// jacobian wrt object state
int df(const InputType &object, Eigen::Ref<JacobianType> fjac) const;
double scaled_norm(const DiffType &diag, const InputType &object) const;
int block_start_functor(int index) const
{
return std::accumulate(residual_functors_.begin(),
residual_functors_.begin() + index,
static_cast<int>(0),
[](const int sum, const std::shared_ptr<const DenseFunctorObjectStateLite> &res_f) {
return sum + res_f->values();
});
}
protected:
const Eigen::Vector3d object_mean_shape_;
const Eigen::Matrix3d camera_intrinsics_;
const Eigen::MatrixX3d object_keypoints_mean_;
const ObjectFeature features_;
const std::vector<std::shared_ptr<const DenseFunctorObjectStateLite>> residual_functors_;
const Eigen::VectorXd residual_weights_;
const Huber huber_;
};
LMObjectStateLite operator+(const LMObjectStateLite& x, const LMObjectStateLite::Tangent& dx) ;
std::ostream& operator<<(std::ostream& o, const LMObjectStateLite& x) ;
} // end namespace orcvio
#endif // OBJECTLMLITE_H
| 36.152113 | 119 | 0.633785 |
ff203e49cbb39985bf2729ecb7276fe58fdbd09a | 1,136 | c | C | L10/E03/pg.c | Davidefassio/APA | e66afc8409cd344b47a78dfb3739a146256f3008 | [
"MIT"
] | null | null | null | L10/E03/pg.c | Davidefassio/APA | e66afc8409cd344b47a78dfb3739a146256f3008 | [
"MIT"
] | null | null | null | L10/E03/pg.c | Davidefassio/APA | e66afc8409cd344b47a78dfb3739a146256f3008 | [
"MIT"
] | null | null | null | #include "pg.h"
int pg_read(FILE *fp, pg_t *pgp){
if(fscanf(fp, "%s %s %s", pgp->cod, pgp->nome, pgp->classe) != 3)
return 0;
if(stat_read(fp, &pgp->b_stat) == 0) return 0;
pgp->equip = equipArray_init();
pgp->eq_stat.hp = pgp->eq_stat.mp = pgp->eq_stat.atk = pgp->eq_stat.def = pgp->eq_stat.mag = pgp->eq_stat.spr = 0;
return 1;
}
void pg_clean(pg_t *pgp){
equipArray_free(pgp->equip);
}
void pg_print(FILE *fp, pg_t *pgp, invArray_t invArray){
stat_t tmp = {pgp->b_stat.hp + pgp->eq_stat.hp, pgp->b_stat.mp + pgp->eq_stat.mp, pgp->b_stat.atk + pgp->eq_stat.atk, pgp->b_stat.def + pgp->eq_stat.def, pgp->b_stat.mag + pgp->eq_stat.mag, pgp->b_stat.spr + pgp->eq_stat.spr};
fprintf(fp, "%s %s %s ", pgp->cod, pgp->nome, pgp->classe);
stat_print(fp, &tmp, 1);
fprintf(fp, "\n");
}
void pg_updateEquip(pg_t *pgp, invArray_t invArray){
stat_t tmp = equipArray_update(pgp->equip, invArray);
pgp->eq_stat.hp += tmp.hp; pgp->eq_stat.mp += tmp.mp;
pgp->eq_stat.atk += tmp.atk; pgp->eq_stat.def += tmp.def;
pgp->eq_stat.mag += tmp.mag; pgp->eq_stat.spr += tmp.spr;
}
| 36.645161 | 230 | 0.623239 |
ff22569faeca0f0c103458573b3cf454142d07bd | 528 | h | C | Hugh_Utils/HughKeyChainStore.h | Hugh1991/Hugh_Utils | 5f7431d96488bcf6d2bb73773c2dcf50f07480e7 | [
"MIT"
] | null | null | null | Hugh_Utils/HughKeyChainStore.h | Hugh1991/Hugh_Utils | 5f7431d96488bcf6d2bb73773c2dcf50f07480e7 | [
"MIT"
] | null | null | null | Hugh_Utils/HughKeyChainStore.h | Hugh1991/Hugh_Utils | 5f7431d96488bcf6d2bb73773c2dcf50f07480e7 | [
"MIT"
] | null | null | null | //
// HughKeyChainStore.h
//
// Created by Hugh on 18/10/25.
// Copyright © 2018年 Hugh. All rights reserved.
//
#import <Foundation/Foundation.h>
#define KEY_USERNAME_PASSWORD @"com.xiaoniu.integral.usernamepassword"
#define KEY_USERNAME @"com.xiaoniu.integral.username"
#define KEY_PASSWORD @"com.xiaoniu.integral.password"
@interface HughKeyChainStore : NSObject
+ (void)save:(NSString *)service data:(id)data;
+ (id)load:(NSString *)service;
+ (void)deleteKeyData:(NSString *)service;
@end
| 22 | 72 | 0.706439 |
ff23c013b40f7851aa09320b3523a33255ff4d69 | 511 | h | C | src/views/help/LHelpWidget.h | lotusczp/Lobster | ceb5ec720fdbbd5eddba5eeccc2f875a62d4332e | [
"Apache-2.0",
"MIT"
] | 6 | 2021-01-30T00:06:22.000Z | 2022-02-16T08:20:09.000Z | src/views/help/LHelpWidget.h | lotusczp/Lobster | ceb5ec720fdbbd5eddba5eeccc2f875a62d4332e | [
"Apache-2.0",
"MIT"
] | null | null | null | src/views/help/LHelpWidget.h | lotusczp/Lobster | ceb5ec720fdbbd5eddba5eeccc2f875a62d4332e | [
"Apache-2.0",
"MIT"
] | 1 | 2021-08-11T05:19:11.000Z | 2021-08-11T05:19:11.000Z | #ifndef LHELPWIDGET_H
#define LHELPWIDGET_H
#include <QWidget>
#include <QListWidgetItem>
namespace Ui {
class LHelpWidget;
}
class LHelpWidget : public QWidget
{
Q_OBJECT
public:
explicit LHelpWidget(QWidget *parent = 0);
~LHelpWidget();
private slots:
void on_homeButton_clicked();
void on_backwardButton_clicked();
void on_forwardButton_clicked();
void on_listWidget_itemDoubleClicked(QListWidgetItem *item);
private:
Ui::LHelpWidget *ui;
};
#endif // LHELPWIDGET_H
| 15.484848 | 64 | 0.735812 |
ff2e3345716327e2706323f5348024ba2f2c7c20 | 5,031 | h | C | src/pwm.h | KorfLab/StochHMM | 965ee4fbe2f2dac8868387989901369cba452086 | [
"MIT"
] | 127 | 2015-01-16T13:05:48.000Z | 2022-01-27T15:17:25.000Z | src/pwm.h | johnson056029/nycuPPproj | a6231db4b0a29ddd509bff75e00d11c3f83d43a7 | [
"MIT"
] | 11 | 2015-03-19T16:51:42.000Z | 2021-09-10T02:15:00.000Z | src/pwm.h | johnson056029/nycuPPproj | a6231db4b0a29ddd509bff75e00d11c3f83d43a7 | [
"MIT"
] | 41 | 2015-06-04T02:02:09.000Z | 2021-11-09T17:14:15.000Z | //
// pwm.h
//Copyright (c) 2007-2012 Paul C Lott
//University of California, Davis
//Genome and Biomedical Sciences Facility
//UC Davis Genome Center
//Ian Korf Lab
//Website: www.korflab.ucdavis.edu
//Email: lottpaul@gmail.com
//
//Permission is hereby granted, free of charge, to any person obtaining a copy of
//this software and associated documentation files (the "Software"), to deal in
//the Software without restriction, including without limitation the rights to
//use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
//the Software, and to permit persons to whom the Software is furnished to do so,
//subject to the following conditions:
//
//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.
//
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
//FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
//COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
//IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
//CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef StochHMM_pwm_cpp
#define StochHMM_pwm_cpp
#include <vector>
#include <math.h>
#include <algorithm>
#include <vector>
#include <list>
#include <bitset>
#include "track.h"
#include "sequences.h"
#include "stochTypes.h"
#include "emm.h"
namespace StochHMM{
class matrixPosition;
//Position Weight Matrix Class
//Before using we need to calculate the pValues for the matrix
class PWM{
public:
PWM();
void import(std::string& file);
void import(const char* file);
bool parse(const std::string& matrix);
void score(sequences* seqs);
void scoreSimple(sequences* seqs);
void scoreUndefSpacer(sequences* seqs);
void scoreVariableSpacer(sequences* seqs);
void score(sequence* seq);
void scoreSimple(sequence* seq);
void scoreUndefSpacer(sequence* seq);
void scoreVariableSpacer(sequence* seq);
inline void setBackground(emm* bg){bgWeight = bg;}
inline void setTrack(track* tr){trk = tr;}
inline void setSimpleThreshold(float thresh){simpleThreshold = thresh;};
inline void setCurrentThreshold(float* thresh){currentThreshold = thresh;}
inline track* getTrack(){return trk;}
std::string stringify();
void print();
private:
bool _parseTrack(std::string& txt);
bool _parseAmbiguous(std::string& txt);
bool _parsePositions(std::string& txt);
bool _parseThreshold(std::string& txt);
bool _parseBackground(std::string& txt);
bool _parseSpacer(std::string& txt);
bool _splitPositions(std::string& txt ,stringList& sts);
bool _getOrderedPositionNames(stringList& states, stringList& names);
void _finalizeTransitions();
float calculateBack(sequences *seqs, size_t position, float sum);
float calculateBack(sequence *seq, size_t position, float sum);
track* trk;
valueType valType;
bool simple;
bool variableSpacer;
bool undefinedSpacer;
float simpleThreshold;
float* currentThreshold;
std::vector<matrixPosition*> weightMatrix;
std::map<std::string,size_t> positionNames;
std::vector<matrixPosition*> frontWeightMatrix;
std::vector<matrixPosition*> backWeightMatrix;
std::list<float>* backScores;
std::bitset<1024>* backScored;
std::vector<size_t> undefSpacerSizes;
std::vector<matrixPosition*> variableSpacerMatrix;
std::bitset<1024>* variableTransition;
std::string frontWeightName;
std::string backWeightName;
size_t min_spacer;
size_t max_spacer;
emm* bgWeight; //Background weight
};
/*! \class matrixPosition
Stores weight information for a position in the position weight matrix
*/
class matrixPosition{
public:
matrixPosition();
~matrixPosition();
bool parse(std::string& txt, track* trk, stringList& names);
float getEmissionValue(sequences*, size_t);
float getEmissionValue(sequence*, size_t);
inline emm* getEmission(){return positionMatrix;};
inline void addTransition(emm* trans){transitions.push_back(trans);}
inline std::vector<std::string>& getTransitionNames(){return transition_names;}
inline void setThreshold(float thresh){threshold = thresh;}
inline float* getThresholdPtr(){return &threshold;}
inline float getThreshold(){return threshold;}
inline size_t transitionsSize(){return transitions.size();}
inline bool isThresholdSet(){return thresholdSet;}
std::string stringify();
private:
emm* positionMatrix; //Weight information for position
bool thresholdSet; //True if a threshold is set for this position(global threshold)
float threshold; //Global threshold for position
std::vector<emm*> transitions; //The next weights after this position (Transitions)
std::vector<std::string> transition_names; //Next weights after this position
std::string name; //Name assigned to this position
};
}
#endif
| 32.882353 | 86 | 0.747565 |
ff336b63154535caf0f4fbded19a757e0bb04701 | 10,397 | h | C | include/scgapi/ContactGroup.h | Syniverse-SCG/Messaging-C-Plus-Plus | 8b5b9ebc48a2a86664bbdf43255d08c033d3f6fe | [
"MIT"
] | 1 | 2019-12-05T08:42:03.000Z | 2019-12-05T08:42:03.000Z | include/scgapi/ContactGroup.h | Syniverse-SCG/Messaging-C-Plus-Plus | 8b5b9ebc48a2a86664bbdf43255d08c033d3f6fe | [
"MIT"
] | null | null | null | include/scgapi/ContactGroup.h | Syniverse-SCG/Messaging-C-Plus-Plus | 8b5b9ebc48a2a86664bbdf43255d08c033d3f6fe | [
"MIT"
] | 1 | 2022-02-22T17:15:35.000Z | 2022-02-22T17:15:35.000Z |
#pragma once
#include <set>
#include <boost/fusion/adapted.hpp>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include "scgapi/BaseData.h"
#include "scgapi/Contact.h"
namespace scg_api {
/*! \class ContactGroup ContactGroup.h scg_api/ContactGroup.h
*
* This resource can represent a collection of Contacts meant to
* support bulk messaging operations (e.g. the ability to deliver
* messages to multiple contacts via a single API call.) Contact
* group can be represented as a fixed list of contacts or can be
* represented as a specific criteria (filter) and each time the
* group is referenced, SCG will compute the list of contacts that
* match the criteria to define the contacts within the contact group.
* Contact groups are owned by Clients and composed of Contacts.
*/
class ContactGroup : public BaseData
{
public:
// Read only members
/// [read only]
std::string id;
/// [read only] Processing, Ready
std::string status;
/// [read only] Count of members in the group.
std::int64_t member_count = 0;
/// [read only] The creation date of the object.
std::int64_t created_date = 0;
/// [read only] The last modification date of the object.
std::int64_t last_update_date = 0;
/*! [read only] The group type:
* - DYNAMIC meaning the list of members associated with the
* group is calculated dynamically whenever the group
* is referenced by applying the CRITERIA to the customer
* contact list
* - STATIC meaning the list of members is determined at the
* time of contact group creation and hence static.
* Customers will be also able to add or remove contacts
* from a STATIC group by accessing the contacts list
* associated with the group.
*/
std::string type;
// Special members
int version_number = 0;
// Read/write members
/// Customer supplied id of the contact group
std::string external_id;
std::string name;
std::string description;
/*! Filter definition for creation of the group. Users can use
* either criteria or members.
*/
std::string criteria;
/// The application id this contact belong to
std::int64_t application_id = 0;
/*! \internal */
template <typename listT>
struct AddContactsPayload {
listT contacts;
};
/*! \class Resource ContactGroup.h scg_api/ContactGroup.h
*
* Resource class for ContactGroup
*
*/
class Resource : public ResourceImpl<ContactGroup>
{
public:
using data_t = ContactGroup;
Resource(Session& session)
: ResourceImpl(
session,
session.GetUrl() + "/scg-external-api/api/v1/contact_groups")
{
}
/*! List ContactGroups
*
* \arg filter Key/Value pairs of attributes that can
* filter the result-set.
* - id
* - external_id
* - name
* - type
* - status
* - created_date
* - last_update_date
*
* \arg lp List Parameters
*
* \returns Iterator to the result-set.
*/
auto List(const filter_t *filter = nullptr,
const ListParameters *lp = nullptr) {
return List_(filter, lp);
}
/*! Create an instance of a ContactGroup on the server.
*
* \arg obj ContactGroup object where the relevant data-
* members are set to valid values.
* \returns id of the new object.
*/
auto Create(const data_t& obj) {
return Create_(obj);
}
/*! Update a ContactGroup on the server
*
* The ContactGroup instance must be received
* from the server. You cannot update an instance
* you have instantiated yourself.
*/
auto Update(const data_t& obj) {
return Update_(obj);
}
/*! Delete a ContactGroup
*
* \arg id of the ContactGroups to delete on the server.
*/
auto Delete(const std::string& id) {
return Delete_(id);
}
/*! Get a ContactGroup object from the server.
*
* \arg id of the ContactGroup you want.
*
* \return unique pointer to a ContactGroup
*
*/
auto Get(const std::string& id) {
return Get_(id);
}
/*! \internal */
template <typename listT>
auto AddContact(listT list, const std::string& id) {
auto url = GetContactsUrl(id);
AddContactsPayload<listT> contacts_list;
contacts_list.contacts = std::move(list);
auto reply = DoPost<decltype(contacts_list)>(contacts_list, url);
}
/*! \internal */
auto DeleteContact(const std::string& gid,
const std::string& cid) {
auto url = GetContactsUrl(gid) + "/" + cid;
return DeleteUrl_(url);
}
/*! \internal */
const std::set< std::string > *
GetReadOnlyNames() override {
static const std::set<std::string> names = {
"id", "status", "member_count", "type", "created_date",
"last_update_date", "application_id"
};
return &names;
}
/*! \internal */
std::string GetContactsUrl(const std::string& id) const {
return GetResourceUrl() + "/" + id + "/contacts";
}
/*! \internal */
auto ListContacts(const std::string& id,
const filter_t *filter = nullptr,
const ListParameters *lp = nullptr) {
if (!contact_res_) {
contact_res_ = std::make_unique<Contact::Resource>(
GetSession(), GetContactsUrl(id));
}
return contact_res_->List(filter, lp);
}
private:
std::unique_ptr<Contact::Resource> contact_res_;
};
/*! Assign a data object to a resource.
*
* Can be used to distribute data objects among a pool of
* resources, each using their own Scg instances and worker-threads.
*/
void SetResource(Resource *res) {
res_ = res;
res_exists_ = res_->GetExists();
}
/*! Update a ContactGroup on the server
*
* The ContactGroup instance must be received
* from the server. You cannot update an instance
* you have instantiated yourself.
*/
void Update() {
VerifyForOperations();
res_->Update(*this);
}
/*! Delete a ContactGroup on the server
*
* The ContactGroup instance must be received
* from the server. You cannot update an instance
* you have instantiated yourself.
*
* You can delete a ContactGroup if you have the ID using
* the Resource::Delete method.
*/
void Delete() {
VerifyForOperations();
res_->Delete(id);
}
/*! Add a contact to a STATIC group
*
* The ContactGroup instance must be received
* from the server. You cannot update an instance
* you have instantiated yourself.
*
*/
void AddContact(const Contact& contact) {
assert(!contact.id.empty());
AddContact(contact.id);
}
/*! Add a contact to a STATIC group
*
* The ContactGroup instance must be received
* from the server. You cannot update an instance
* you have instantiated yourself.
*
*/
void AddContact(const std::string& id) {
std::vector<std::string> contacts
= std::initializer_list<std::string>{id};
AddContact<std::vector<std::string>>(std::move(contacts));
}
/*! Bulk add contacts.
*
* \arg list C++ container with contact objects.
* Typically a std::list<Contact> or std::vector<Contact>.
*/
template <typename listT = std::vector<std::string>>
void AddContact(listT contacts) {
VerifyForOperations();
res_->AddContact<listT>(std::move(contacts), id);
}
/*! Delete a contact to a STATIC group
*
* The Contact itself is not deleted, just it's
* inclusion in this Contact Group.
*
* The ContactGroup instance must be received
* from the server. You cannot update an instance
* you have instantiated yourself.
*
*/
void DeleteContact(const Contact& contact) {
VerifyForOperations();
DeleteContact(contact.id);
}
/*! Delete a contact to a STATIC group
*
* The Contact itself is not deleted, just it's
* inclusion in this Contact Group.
*
* The ContactGroup instance must be received
* from the server. You cannot update an instance
* you have instantiated yourself.
*
*/
void DeleteContact(const std::string& cid) {
VerifyForOperations();
res_->DeleteContact(id, cid);
}
/*! List contacts from this group.
*
* \arg filter Please see scgapi::Contact::Resource::List()
* \arg lp List Parameters
*
* The ContactGroup instance must be received
* from the server. You cannot update an instance
* you have instantiated yourself.
*
* \returns Iterator to result set.
*
*/
auto ListContacts(const filter_t *filter = nullptr,
const ListParameters *lp = nullptr) {
VerifyForOperations();
return res_->ListContacts(id, filter, lp);
}
private:
void VerifyForOperations() {
VerifyForOperations_(id);
}
Resource *res_ = {};
};
} // namespace
BOOST_FUSION_ADAPT_STRUCT(
scg_api::ContactGroup,
(std::string, id)
(std::string, status)
(std::int64_t, member_count)
(std::int64_t, created_date)
(std::int64_t, last_update_date)
(std::string, type)
(int, version_number)
(std::string, external_id)
(std::string, name)
(std::string, description)
(std::string, criteria)
(std::int64_t, application_id))
BOOST_FUSION_ADAPT_TPL_STRUCT(
(listT),
(scg_api::ContactGroup::AddContactsPayload)(listT),
(typename BOOST_IDENTITY_TYPE((listT)), contacts))
| 29.536932 | 77 | 0.591132 |
ff367883c534c48f495e944f6f3a43ee944a18b2 | 257 | h | C | apps/wavelet/daubechies_constants.h | OAID/Halide | 769b8554ec36b70ea53c73605ad021cf431476fc | [
"Apache-2.0"
] | 4,303 | 2015-01-02T12:04:37.000Z | 2022-03-31T11:35:06.000Z | apps/wavelet/daubechies_constants.h | OAID/Halide | 769b8554ec36b70ea53c73605ad021cf431476fc | [
"Apache-2.0"
] | 4,323 | 2015-01-01T13:31:25.000Z | 2022-03-31T22:43:57.000Z | apps/wavelet/daubechies_constants.h | OAID/Halide | 769b8554ec36b70ea53c73605ad021cf431476fc | [
"Apache-2.0"
] | 1,032 | 2015-01-12T12:50:16.000Z | 2022-03-28T01:55:11.000Z | #ifndef DAUBECHIES_CONSTANTS_H_
#define DAUBECHIES_CONSTANTS_H_
const float D0 = 0.4829629131445341f;
const float D1 = 0.83651630373780772f;
const float D2 = 0.22414386804201339f;
const float D3 = -0.12940952255126034f;
#endif // DAUBECHIES_CONSTANTS_H_
| 25.7 | 39 | 0.81323 |
ff3727dcc00f263ac8bd56caf46691c36d0e990b | 23,740 | c | C | net/rras/ndis/ndiswan/cl.c | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | net/rras/ndis/ndiswan/cl.c | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | net/rras/ndis/ndiswan/cl.c | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*++
Copyright (c) 1990-1997 Microsoft Corporation
Module Name:
cl.c
Abstract:
This file contains the functions that implement the ndiswan
NDIS 5.0 client interface. These functions are used to interface
with NDIS 5.0 miniports/call managers.
Author:
Tony Bell (TonyBe) January 9, 1997
Environment:
Kernel Mode
Revision History:
TonyBe 01/09/97 Created
--*/
//
// We want to initialize all of the global variables now!
//
#include "wan.h"
#include "atm.h"
#define __FILE_SIG__ CL_FILESIG
NDIS_STATUS
ClCreateVc(
IN NDIS_HANDLE ProtocolAfContext,
IN NDIS_HANDLE NdisVcHandle,
OUT PNDIS_HANDLE ProtocolVcContext
)
{
PCL_AFSAPCB AfSapCB = (PCL_AFSAPCB)ProtocolAfContext;
POPENCB OpenCB = AfSapCB->OpenCB;
PLINKCB LinkCB;
PBUNDLECB BundleCB;
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClCreateVc: Enter"));
//
// Get a linkcb
//
LinkCB = NdisWanAllocateLinkCB(OpenCB, 0);
if (LinkCB == NULL) {
//
// Error getting LinkCB!
//
return (NDIS_STATUS_RESOURCES);
}
LinkCB->NdisLinkHandle = NdisVcHandle;
LinkCB->ConnectionWrapperID = NdisVcHandle;
LinkCB->AfSapCB = AfSapCB;
//
// Set some default values
//
LinkCB->RFlowSpec.PeakBandwidth =
LinkCB->SFlowSpec.PeakBandwidth = 28800 / 8;
LinkCB->SendWindow = OpenCB->WanInfo.MaxTransmit;
//
// Get a bundlecb
//
BundleCB = NdisWanAllocateBundleCB();
if (BundleCB == NULL) {
NdisWanFreeLinkCB(LinkCB);
//
// Error getting BundleCB!
//
return (NDIS_STATUS_RESOURCES);
}
//
// Add LinkCB to BundleCB
//
AcquireBundleLock(BundleCB);
AddLinkToBundle(BundleCB, LinkCB);
ReleaseBundleLock(BundleCB);
//
// Place BundleCB in active connection table
//
if (NULL == InsertBundleInConnectionTable(BundleCB)) {
//
// Error inserting link in ConnectionTable
//
RemoveLinkFromBundle(BundleCB, LinkCB, FALSE);
NdisWanFreeLinkCB(LinkCB);
return (NDIS_STATUS_RESOURCES);
}
//
// Place LinkCB in active connection table
//
if (NULL == InsertLinkInConnectionTable(LinkCB)) {
//
// Error inserting bundle in connectiontable
//
RemoveLinkFromBundle(BundleCB, LinkCB, FALSE);
NdisWanFreeLinkCB(LinkCB);
return (NDIS_STATUS_RESOURCES);
}
*ProtocolVcContext = LinkCB->hLinkHandle;
NdisAcquireSpinLock(&AfSapCB->Lock);
REF_CLAFSAPCB(AfSapCB);
NdisReleaseSpinLock(&AfSapCB->Lock);
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClCreateVc: Exit"));
return (NDIS_STATUS_SUCCESS);
}
NDIS_STATUS
ClDeleteVc(
IN NDIS_HANDLE ProtocolVcContext
)
{
PLINKCB LinkCB;
PBUNDLECB BundleCB;
PCL_AFSAPCB AfSapCB;
if (!IsLinkValid(ProtocolVcContext, FALSE, &LinkCB)) {
NdisWanDbgOut(DBG_FAILURE, DBG_CL,
("NDISWAN: Possible double delete of VcContext %x\n",
ProtocolVcContext));
return (NDIS_STATUS_FAILURE);
}
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClDeleteVc: Enter %p", LinkCB));
NdisAcquireSpinLock(&LinkCB->Lock);
AfSapCB = LinkCB->AfSapCB;
//
// For the ref applied in IsLinkValid. We
// don't have to use the full deref code here as we know the ref
// applied at CreateVc will keep the link around.
//
LinkCB->RefCount--;
//
// For the createvc reference
//
DEREF_LINKCB_LOCKED(LinkCB);
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClDeleteVc: Exit"));
DEREF_CLAFSAPCB(AfSapCB);
return(NDIS_STATUS_SUCCESS);
}
VOID
ClOpenAfComplete(
IN NDIS_STATUS Status,
IN NDIS_HANDLE ProtocolAfContext,
IN NDIS_HANDLE NdisAfHandle
)
{
PCL_AFSAPCB AfSapCB = (PCL_AFSAPCB)ProtocolAfContext;
POPENCB OpenCB = AfSapCB->OpenCB;
PCO_SAP Sap;
NDIS_HANDLE SapHandle;
UCHAR SapBuffer[CLSAP_BUFFERSIZE];
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClOpenAfComplete: Enter %p %x", AfSapCB, Status));
NdisAcquireSpinLock(&AfSapCB->Lock);
AfSapCB->Flags &= ~(AF_OPENING);
if (Status == NDIS_STATUS_SUCCESS) {
AfSapCB->Flags |=
(AF_OPENED | SAP_REGISTERING);
AfSapCB->AfHandle = NdisAfHandle;
NdisReleaseSpinLock(&AfSapCB->Lock);
//
// If we successfully opened the AddressFamily we
// need to register our SAP.
//
NdisAcquireSpinLock(&OpenCB->Lock);
InsertHeadList(&OpenCB->AfSapCBList,
&AfSapCB->Linkage);
NdisReleaseSpinLock(&OpenCB->Lock);
Sap = (PCO_SAP)SapBuffer;
//
// Register our SAP
//
Sap->SapType = SAP_TYPE_NDISWAN_PPP;
Sap->SapLength = sizeof(DEVICECLASS_NDISWAN_SAP);
NdisMoveMemory(Sap->Sap,
DEVICECLASS_NDISWAN_SAP,
sizeof(DEVICECLASS_NDISWAN_SAP));
Status =
NdisClRegisterSap(AfSapCB->AfHandle,
AfSapCB,
Sap,
&SapHandle);
if (Status != NDIS_STATUS_PENDING) {
ClRegisterSapComplete(Status, AfSapCB, Sap, SapHandle);
}
NdisWanDbgOut(DBG_TRACE, DBG_PROTOCOL,
("ClRegisterSap SapHandle 0x%x status: 0x%x", SapHandle, Status));
} else {
AfSapCB->Flags |= AF_OPEN_FAILED;
NdisReleaseSpinLock(&AfSapCB->Lock);
//
// We failed to register the address family so free
// associated memory.
//
NdisWanFreeClAfSapCB(AfSapCB);
//
// Since the open af was initiated from the notification
// of a new af from ndis we have to decrement the af
// registering count.
//
NdisAcquireSpinLock(&OpenCB->Lock);
if (--OpenCB->AfRegisteringCount == 0) {
NdisWanSetNotificationEvent(&OpenCB->AfRegisteringEvent);
}
NdisReleaseSpinLock(&OpenCB->Lock);
}
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClOpenAfComplete: Exit"));
}
VOID
ClCloseAfComplete(
IN NDIS_STATUS Status,
IN NDIS_HANDLE ProtocolAfContext
)
{
PCL_AFSAPCB AfSapCB = (PCL_AFSAPCB)ProtocolAfContext;
POPENCB OpenCB = AfSapCB->OpenCB;
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClCloseAfComplete: Enter %p %x", AfSapCB, Status));
//
// BUG 494260
// NDIS should not be invoking this deregister handler at a raised
// IRQL (i.e while holding a spinlock). Bug 494260 documents this
// this issue.
//
// This assert has been commented out to prevent breaks on checked build.
// When 494260 is fixed, this ASSERT should be uncommented.
//
// ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);
do {
//
// If the close attempt failed there must be another
// thread that is already doing the close. Let the
// other thread cleanup the afsapcb.
//
if (Status != NDIS_STATUS_SUCCESS) {
break;
}
NdisAcquireSpinLock(&AfSapCB->Lock);
AfSapCB->Flags &= ~(AF_CLOSING);
AfSapCB->Flags |= (AF_CLOSED);
NdisReleaseSpinLock(&AfSapCB->Lock);
NdisAcquireSpinLock(&OpenCB->Lock);
RemoveEntryList(&AfSapCB->Linkage);
NdisReleaseSpinLock(&OpenCB->Lock);
NdisWanFreeClAfSapCB(AfSapCB);
} while (FALSE);
//
// Refer comment above
//
// ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClCloseAfComplete: Exit"));
}
VOID
ClRegisterSapComplete(
IN NDIS_STATUS Status,
IN NDIS_HANDLE ProtocolSapContext,
IN PCO_SAP Sap,
IN NDIS_HANDLE NdisSapHandle
)
{
PCL_AFSAPCB AfSapCB = (PCL_AFSAPCB)ProtocolSapContext;
POPENCB OpenCB = AfSapCB->OpenCB;
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClRegisterSapComplete: Enter %p %x", AfSapCB, Status));
NdisAcquireSpinLock(&AfSapCB->Lock);
AfSapCB->Flags &= ~(SAP_REGISTERING);
if (Status == NDIS_STATUS_SUCCESS) {
AfSapCB->Flags |= SAP_REGISTERED;
AfSapCB->SapHandle = NdisSapHandle;
NdisReleaseSpinLock(&AfSapCB->Lock);
} else {
//
// We failed to register our sap so close the address family
//
AfSapCB->Flags &= ~(AF_OPENED);
AfSapCB->Flags |=
(SAP_REGISTER_FAILED | AF_CLOSING);
NdisReleaseSpinLock(&AfSapCB->Lock);
NdisAcquireSpinLock(&OpenCB->Lock);
RemoveEntryList(&AfSapCB->Linkage);
InsertTailList(&OpenCB->AfSapCBClosing, &AfSapCB->Linkage);
NdisReleaseSpinLock(&OpenCB->Lock);
NdisClCloseAddressFamily(AfSapCB->AfHandle);
if (Status != NDIS_STATUS_PENDING) {
ClCloseAfComplete(Status, AfSapCB);
}
}
//
// Since the open af was initiated from the notification
// of a new af from ndis we have to decrement the af
// registering count.
//
NdisAcquireSpinLock(&OpenCB->Lock);
if (--OpenCB->AfRegisteringCount == 0) {
NdisWanSetNotificationEvent(&OpenCB->AfRegisteringEvent);
}
NdisReleaseSpinLock(&OpenCB->Lock);
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClRegisterSapComplete: Exit"));
}
VOID
ClDeregisterSapComplete(
IN NDIS_STATUS Status,
IN NDIS_HANDLE ProtocolSapContext
)
{
PCL_AFSAPCB AfSapCB = (PCL_AFSAPCB)ProtocolSapContext;
POPENCB OpenCB = AfSapCB->OpenCB;
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClDeregisterSapComplete: Enter %p %x", AfSapCB, Status));
//
// BUG 494260
// NDIS should not be invoking this deregister handler at a raised
// IRQL (i.e while holding a spinlock). Bug 494260 documents this
// this issue.
//
// This assert has been commented out to prevent breaks on checked build.
// When 494260 is fixed, this ASSERT should be uncommented.
//
// ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);
NdisAcquireSpinLock(&AfSapCB->Lock);
ASSERT(AfSapCB->Flags & AF_OPENED);
AfSapCB->Flags &= ~(AF_OPENED | SAP_DEREGISTERING);
AfSapCB->Flags |= (AF_CLOSING);
NdisReleaseSpinLock(&AfSapCB->Lock);
Status =
NdisClCloseAddressFamily(AfSapCB->AfHandle);
if (Status != NDIS_STATUS_PENDING) {
ClCloseAfComplete(Status, AfSapCB);
}
//
// Refer comment above
//
// ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClDeregisterSapComplete: Exit"));
}
VOID
ClMakeCallComplete(
IN NDIS_STATUS Status,
IN NDIS_HANDLE ProtocolVcContext,
IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
IN PCO_CALL_PARAMETERS CallParameters
)
{
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClMakeCallComplete: Enter %p %x", ProtocolVcContext, Status));
DbgBreakPoint();
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClMakeCallComplete: Exit"));
}
VOID
ClModifyQoSComplete(
IN NDIS_STATUS Status,
IN NDIS_HANDLE ProtocolVcContext,
IN PCO_CALL_PARAMETERS CallParameters
)
{
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClModifyQoSComplete: Enter %p %x", ProtocolVcContext, Status));
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClModifyQoSComplete: Exit"));
}
VOID
ClCloseCallComplete(
IN NDIS_STATUS Status,
IN NDIS_HANDLE ProtocolVcContext,
IN NDIS_HANDLE ProtocolPartyContext OPTIONAL
)
{
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClCloseCallComplete: Enter %p %x", ProtocolVcContext, Status));
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClCloseCallComplete: Exit"));
}
NDIS_STATUS
ClIncomingCall(
IN NDIS_HANDLE ProtocolSapContext,
IN NDIS_HANDLE ProtocolVcContext,
IN OUT PCO_CALL_PARAMETERS CallParameters
)
{
PCL_AFSAPCB AfSapCB = (PCL_AFSAPCB)ProtocolSapContext;
PLINKCB LinkCB;
POPENCB OpenCB = AfSapCB->OpenCB;
PBUNDLECB BundleCB;
BOOLEAN AtmUseLLC = FALSE;
BOOLEAN MediaBroadband = FALSE;
PWAN_LINK_INFO LinkInfo;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClIncomingCall: Enter %p %p", AfSapCB, ProtocolVcContext));
do {
if (!AreLinkAndBundleValid(ProtocolVcContext,
TRUE,
&LinkCB,
&BundleCB)) {
Status = NDIS_STATUS_FAILURE;
break;
}
NdisAcquireSpinLock(&LinkCB->Lock);
LinkCB->ClCallState = CL_CALL_CONNECTED;
NdisReleaseSpinLock(&LinkCB->Lock);
AcquireBundleLock(BundleCB);
NdisMoveMemory(&LinkCB->SFlowSpec,
&CallParameters->CallMgrParameters->Transmit,
sizeof(FLOWSPEC));
NdisMoveMemory(&LinkCB->RFlowSpec,
&CallParameters->CallMgrParameters->Receive,
sizeof(FLOWSPEC));
if (LinkCB->SFlowSpec.PeakBandwidth == 0) {
LinkCB->SFlowSpec.PeakBandwidth = 28800 / 8;
}
if (LinkCB->RFlowSpec.PeakBandwidth == 0) {
LinkCB->RFlowSpec.PeakBandwidth = LinkCB->SFlowSpec.PeakBandwidth;
}
LinkInfo = &LinkCB->LinkInfo;
//
// Assume all CoNDIS miniports support PPP framing
//
LinkInfo->SendFramingBits =
LinkInfo->RecvFramingBits = PPP_FRAMING;
LinkCB->RecvHandler = ReceivePPP;
if (OpenCB->MediumType == NdisMediumAtm ||
(OpenCB->MediumType == NdisMediumWan &&
(OpenCB->MediumSubType == NdisWanMediumAtm ||
OpenCB->MediumSubType == NdisWanMediumPppoe)) ||
(OpenCB->MediumType == NdisMediumCoWan &&
(OpenCB->MediumSubType == NdisWanMediumAtm ||
OpenCB->MediumSubType == NdisWanMediumPppoe))) {
MediaBroadband = TRUE;
LinkCB->RecvHandler = DetectBroadbandFraming;
}
if (MediaBroadband) {
if (CallParameters->Flags & PERMANENT_VC) {
//
// Per TomF we are going to use NULL encap as
// our default PVC encapsulation
//
if (gbAtmUseLLCOnPVC) {
AtmUseLLC = TRUE;
}
} else {
//
// If this is an ATM SVC we need to see
// if the SVC needs LLC framing or not
//
if (gbAtmUseLLCOnSVC) {
AtmUseLLC = TRUE;
} else {
ULONG IeCount;
Q2931_IE UNALIGNED *Ie;
ATM_BLLI_IE UNALIGNED *Bli;
Q2931_CALLMGR_PARAMETERS *cmparams;
cmparams = (Q2931_CALLMGR_PARAMETERS*)
&(CallParameters->CallMgrParameters->CallMgrSpecific.Parameters[0]);
Bli = NULL;
Ie = (Q2931_IE UNALIGNED *)&cmparams->InfoElements[0];
for (IeCount = 0;
IeCount < cmparams->InfoElementCount;
IeCount++) {
if (Ie->IEType == IE_BLLI) {
Bli = (ATM_BLLI_IE UNALIGNED*)&Ie->IE[0];
break;
}
Ie = (Q2931_IE UNALIGNED *)((ULONG_PTR)Ie + Ie->IELength);
}
if (Bli != NULL) {
AtmUseLLC = (Bli->Layer2Protocol == BLLI_L2_LLC);
}
}
}
if (AtmUseLLC) {
LinkInfo->SendFramingBits |= LLC_ENCAPSULATION;
LinkInfo->RecvFramingBits |= LLC_ENCAPSULATION;
LinkCB->RecvHandler = ReceiveLLC;
}
if (!(LinkInfo->SendFramingBits & LLC_ENCAPSULATION)) {
LinkInfo->SendFramingBits |= PPP_COMPRESS_ADDRESS_CONTROL;
LinkInfo->RecvFramingBits |= PPP_COMPRESS_ADDRESS_CONTROL;
}
}
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("SPeakBandwidth %d SendWindow %d",
LinkCB->SFlowSpec.PeakBandwidth,
LinkCB->SendWindow));
if (CallParameters->Flags & PERMANENT_VC) {
//
// This is a PVC so we will disable idle data detection
// thus allowing the connection to remain active
//
BundleCB->Flags |= DISABLE_IDLE_DETECT;
}
BundleCB->FramingInfo.RecvFramingBits =
BundleCB->FramingInfo.SendFramingBits = PPP_FRAMING;
UpdateBundleInfo(BundleCB);
//
// Deref for the ref applied by AreLinkAndBundleValid. This
// will release the BundleCB->Lock!
//
DEREF_BUNDLECB_LOCKED(BundleCB);
//
// Deref for the ref applied by AreLinkAndBundleValid.
//
DEREF_LINKCB(LinkCB);
} while (0);
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClIncomingCall: Exit"));
return (Status);
}
VOID
ClIncomingCallQoSChange(
IN NDIS_HANDLE ProtocolVcContext,
IN PCO_CALL_PARAMETERS CallParameters
)
{
PLINKCB LinkCB;
PBUNDLECB BundleCB;
POPENCB OpenCB;
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClIncomingCallQoSChange: Enter %p", ProtocolVcContext));
do {
if (!AreLinkAndBundleValid(ProtocolVcContext,
TRUE,
&LinkCB,
&BundleCB)) {
break;
}
AcquireBundleLock(BundleCB);
OpenCB = LinkCB->OpenCB;
//
// Do I need to pass this info to 5.0 Clients?????
//
NdisMoveMemory(&LinkCB->SFlowSpec,
&CallParameters->CallMgrParameters->Transmit,
sizeof(FLOWSPEC));
NdisMoveMemory(&LinkCB->RFlowSpec,
&CallParameters->CallMgrParameters->Receive,
sizeof(FLOWSPEC));
if (LinkCB->SFlowSpec.PeakBandwidth == 0) {
LinkCB->SFlowSpec.PeakBandwidth = 28800 / 8;
}
if (LinkCB->RFlowSpec.PeakBandwidth == 0) {
LinkCB->RFlowSpec.PeakBandwidth = LinkCB->SFlowSpec.PeakBandwidth;
}
UpdateBundleInfo(BundleCB);
//
// Deref for the ref applied by AreLinkAndBundleValid. This will
// release the BundleCB->Lock.
//
DEREF_BUNDLECB_LOCKED(BundleCB);
//
// Deref for the ref applied by AreLinkAndBundleValid.
//
DEREF_LINKCB(LinkCB);
} while (0);
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClIncomingCallQoSChange: Exit"));
}
VOID
ClIncomingCloseCall(
IN NDIS_STATUS CloseStatus,
IN NDIS_HANDLE ProtocolVcContext,
IN PVOID CloseData OPTIONAL,
IN UINT Size OPTIONAL
)
{
PLINKCB LinkCB;
PBUNDLECB BundleCB;
PRECV_DESC RecvDesc;
NDIS_STATUS Status;
ULONG i;
BOOLEAN FreeBundle = FALSE;
BOOLEAN FreeLink = FALSE;
NdisWanDbgOut(DBG_TRACE, DBG_CL,
("ClIncomingCloseCall: Enter %p %x", ProtocolVcContext, CloseStatus));
do {
if (!AreLinkAndBundleValid(ProtocolVcContext,
TRUE,
&LinkCB,
&BundleCB)) {
#if DBG
DbgPrint("NDISWAN: CloseCall after link has gone down VcContext %x\n",
ProtocolVcContext);
DbgBreakPoint();
#endif
break;
}
NdisAcquireSpinLock(&LinkCB->Lock);
//
// Link is now going down
//
LinkCB->State = LINK_GOING_DOWN;
if (LinkCB->VcRefCount == 0) {
LinkCB->ClCallState = CL_CALL_CLOSED;
NdisReleaseSpinLock(&LinkCB->Lock);
Status =
NdisClCloseCall(LinkCB->NdisLinkHandle,
NULL,
NULL,
0);
if (Status != NDIS_STATUS_PENDING) {
ClCloseCallComplete(Status,
LinkCB,
NULL);
}
} else {
LinkCB->ClCallState = CL_CALL_CLOSE_PENDING;
NdisReleaseSpinLock(&LinkCB->Lock);
}
NdisAcquireSpinLock(&IoRecvList.Lock);
RecvDesc = (PRECV_DESC)IoRecvList.DescList.Flink;
while ((PVOID)RecvDesc != (PVOID)&IoRecvList.DescList) {
PRECV_DESC Next;
Next = (PRECV_DESC)RecvDesc->Linkage.Flink;
if (RecvDesc->LinkCB == LinkCB) {
RemoveEntryList(&RecvDesc->Linkage);
LinkCB->RecvDescCount--;
IoRecvList.ulDescCount--;
NdisWanFreeRecvDesc(RecvDesc);
}
RecvDesc = Next;
}
NdisReleaseSpinLock(&IoRecvList.Lock);
//
// Flush the Bundle's fragment send queues that
// have sends pending on this link
//
AcquireBundleLock(BundleCB);
for (i = 0; i < MAX_MCML; i++) {
PSEND_DESC SendDesc;
PSEND_FRAG_INFO FragInfo;
FragInfo = &BundleCB->SendFragInfo[i];
SendDesc = (PSEND_DESC)FragInfo->FragQueue.Flink;
while ((PVOID)SendDesc != (PVOID)&FragInfo->FragQueue) {
if (SendDesc->LinkCB == LinkCB) {
PSEND_DESC NextSendDesc;
NextSendDesc = (PSEND_DESC)SendDesc->Linkage.Flink;
RemoveEntryList(&SendDesc->Linkage);
FragInfo->FragQueueDepth--;
(*LinkCB->SendHandler)(SendDesc);
SendDesc = NextSendDesc;
} else {
SendDesc = (PSEND_DESC)SendDesc->Linkage.Flink;
}
}
}
UpdateBundleInfo(BundleCB);
ReleaseBundleLock(BundleCB);
//
// Deref's for the refs applied by AreLinkAndBundleValid.
//
DEREF_LINKCB(LinkCB);
DEREF_BUNDLECB(BundleCB);
} while (0);
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClIncomingCloseCall: Exit"));
}
VOID
ClCallConnected(
IN NDIS_HANDLE ProtocolVcContext
)
{
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClCallConnected: Enter %p", ProtocolVcContext));
NdisWanDbgOut(DBG_TRACE, DBG_CL, ("ClCallConnected: Exit"));
}
| 27.381776 | 103 | 0.553917 |
ff37d540378d97dbec60bb78022fdfca869848b1 | 2,801 | c | C | libft/ft_printf/ft_printf.c | UnitedSalvatore/FDF | 3e3806b9c855fa018f98c0fd954c979e0926f421 | [
"WTFPL"
] | null | null | null | libft/ft_printf/ft_printf.c | UnitedSalvatore/FDF | 3e3806b9c855fa018f98c0fd954c979e0926f421 | [
"WTFPL"
] | null | null | null | libft/ft_printf/ft_printf.c | UnitedSalvatore/FDF | 3e3806b9c855fa018f98c0fd954c979e0926f421 | [
"WTFPL"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_printf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ypikul <ypikul@student.unit.ua> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/14 00:03:07 by ypikul #+# #+# */
/* Updated: 2018/03/11 18:39:54 by ypikul ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include "ft_printf_.h"
#include "libft.h"
static t_arg *ft_default_arg(t_arg *spec)
{
spec->minus = 0;
spec->zero = 0;
spec->plus = 0;
spec->space = 0;
spec->hash = 0;
spec->min_width = 0;
spec->precision = -1;
spec->size = NONE;
return (spec);
}
static const char *ft_parse_arg(const char *format, va_list *arg, t_arg *spec)
{
while (*format)
{
if (ft_strchr("-0+ #", *format))
format = ft_parse_flags(format, spec);
else if (*format == '*' || ft_isdigit(*format))
format = ft_parse_min_width(format, arg, spec);
else if (*format == '.')
format = ft_parse_precision(format, arg, spec);
else if (ft_strchr("hljz", *format))
format = ft_parse_size(format, spec);
else
break ;
}
format = ft_handle_conversion(format, arg, spec);
return (format);
}
static size_t ft_vprintf(const char *format, va_list *arg, t_arg *spec)
{
while (*format)
{
if (*format == '%')
{
ft_default_arg(spec);
format = ft_parse_arg(++format, arg, spec);
}
else
ft_add_to_buf(*format++, &spec->buffer);
}
if (spec->buffer.size != 0)
{
write(spec->buffer.fd, spec->buffer.buf, spec->buffer.size);
spec->buffer.written += spec->buffer.size;
spec->buffer.size = 0;
}
return (spec->buffer.written);
}
int ft_printf(const char *format, ...)
{
va_list arg;
t_arg spec;
int done;
if (format == NULL || BUFF_SIZE < 1)
return (-1);
va_start(arg, format);
ft_memset(&spec.buffer, 0, sizeof(spec.buffer));
spec.buffer.fd = STDOUT_FILENO;
done = (int)ft_vprintf(format, &arg, &spec);
va_end(arg);
return (done);
}
int ft_dprintf(int fd, const char *format, ...)
{
va_list arg;
t_arg spec;
int done;
if (format == NULL || BUFF_SIZE < 1)
return (-1);
va_start(arg, format);
ft_memset(&spec.buffer, 0, sizeof(spec.buffer));
spec.buffer.fd = fd;
done = (int)ft_vprintf(format, &arg, &spec);
va_end(arg);
return (done);
}
| 27.732673 | 80 | 0.471617 |
ff3845a8b0ae8aef58d8f44c5fe213468a832dbb | 489 | h | C | include/Timer.h | filipecaixeta/NeonEdgeGame | 7dbc825507d731d60a96b4a82975a70e6aa68d7e | [
"MIT"
] | 6 | 2017-05-10T19:25:23.000Z | 2021-04-08T23:55:17.000Z | include/Timer.h | filipecaixeta/NeonEdgeGame | 7dbc825507d731d60a96b4a82975a70e6aa68d7e | [
"MIT"
] | 1 | 2017-11-10T12:17:26.000Z | 2017-11-10T12:17:26.000Z | include/Timer.h | filipecaixeta/NeonEdgeGame | 7dbc825507d731d60a96b4a82975a70e6aa68d7e | [
"MIT"
] | 5 | 2017-05-30T01:07:46.000Z | 2021-04-08T23:55:19.000Z | #ifndef TIMER_H_
#define TIMER_H_
#define MAX_FLOAT 3.4e+38f
#define MIN_FLOAT -3.4e+38f
#define MAX_INT 3767.0f
#define MIN_INT -3767.0f
class Timer {
public:
Timer();
Timer(float limit);
~Timer();
void Start();
void Stop();
void Reset();
void Update(float dt);
void SetLimit(float l);
bool IsRunning();
float GetElapsed();
float GetTime();
private:
float time = 0;
float limit = 0;
bool running = false;
};
#endif /* TIMER_H_ */
| 15.28125 | 29 | 0.627812 |
ff38e62bfd619869e4d49917f72441596ca10826 | 6,848 | h | C | src/GaIA/pkgs/libsmbios/libsmbios-2.2.19/src/include/smbios/ISmi.h | uninth/UNItools | c8b1fbfd5d3753b5b14fa19033e39737dedefc00 | [
"BSD-3-Clause"
] | null | null | null | src/GaIA/pkgs/libsmbios/libsmbios-2.2.19/src/include/smbios/ISmi.h | uninth/UNItools | c8b1fbfd5d3753b5b14fa19033e39737dedefc00 | [
"BSD-3-Clause"
] | null | null | null | src/GaIA/pkgs/libsmbios/libsmbios-2.2.19/src/include/smbios/ISmi.h | uninth/UNItools | c8b1fbfd5d3753b5b14fa19033e39737dedefc00 | [
"BSD-3-Clause"
] | 1 | 2021-06-08T15:59:26.000Z | 2021-06-08T15:59:26.000Z | // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
/*
* Copyright (C) 2005 Dell Inc.
* by Michael Brown <Michael_E_Brown@dell.com>
* Licensed under the Open Software License version 2.1
*
* Alternatively, you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
#ifndef SMIINTERFACE_H
#define SMIINTERFACE_H
// compat header should always be first header, if system headers included
#include "smbios/compat.h"
#include <iostream>
#include <memory>
// types.h should be first user-defined header.
#include "smbios/types.h"
#include "smbios/IFactory.h"
#include "smbios/IException.h"
// abi_prefix should be last header included before declarations
#include "smbios/config/abi_prefix.hpp"
namespace smi
{
//! Abstract base class for the smi read write operations
/**
*/
// Exceptions
DECLARE_EXCEPTION( SmiException );
DECLARE_EXCEPTION_EX( InvalidSmiMode, smi, SmiException );
DECLARE_EXCEPTION_EX( ParameterError, smi, SmiException );
DECLARE_EXCEPTION_EX( UnhandledSmi, smi, SmiException );
DECLARE_EXCEPTION_EX( UnsupportedSmi, smi, SmiException );
DECLARE_EXCEPTION_EX( SmiExecutedWithError, smi, SmiException );
DECLARE_EXCEPTION_EX( PasswordVerificationFailed, smi, SmiException );
DECLARE_EXCEPTION_EX( ConfigError, smi, SmiException );
class IDellCallingInterfaceSmi
{
public:
virtual ~IDellCallingInterfaceSmi();
// compiler-generated copy and operator = are good for now, I think.
virtual void setClass( u16 newClass ) = 0;
virtual void setSelect( u16 newSelect ) = 0;
virtual void setArg( u8 argNumber, u32 argValue ) = 0;
virtual u32 getRes( u8 resNumber ) const = 0;
virtual void setArgAsPhysicalAddress( u8 argNumber, u32 bufferOffset ) = 0;
virtual void setBufferSize(size_t size) = 0;
virtual void setBufferContents(const u8 *, size_t size) = 0;
virtual const u8 *getBufferPtr() = 0;
virtual void execute() = 0;
protected:
explicit IDellCallingInterfaceSmi();
};
// NOTE: does not hand out singletons
class SmiFactory : public virtual factory::IFactory
{
public:
enum { DELL_CALLING_INTERFACE_SMI_RAW, DELL_CALLING_INTERFACE_SMI,};
static SmiFactory *getFactory();
virtual ~SmiFactory() throw();
virtual std::auto_ptr<IDellCallingInterfaceSmi> makeNew(u8 type) = 0; // not for use
protected:
SmiFactory();
};
enum {cbARG1 = 0, cbARG2 = 1, cbARG3 = 2, cbARG4 = 3};
enum {cbRES1 = 0, cbRES2 = 1, cbRES3 = 2, cbRES4 = 3};
// non-member helper functions
// These encapsulate some common calling-interface SMI functions
//
void doSimpleCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4], u32 res[4]);
std::auto_ptr<smi::IDellCallingInterfaceSmi> setupCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4]);
u32 getAuthenticationKey(const std::string &password);
enum password_format_enum { PW_FORMAT_UNKNOWN, PW_FORMAT_SCAN_CODE, PW_FORMAT_ASCII };
password_format_enum getPasswordFormat();
#if 0
// not yet implemented
std::string getServiceTag();
void setServiceTag(const std::string &password, const std::string &newTag);
std::string getAssetTag();
void setAssetTag(const std::string &password, const std::string &newTag);
#endif
bool getPasswordStatus(u16 which);
u32 readNVStorage (u32 location, u32 *minValue, u32 *maxValue);
u32 readBatteryModeSetting(u32 location, u32 *minValue, u32 *maxValue);
u32 readACModeSetting (u32 location, u32 *minValue, u32 *maxValue);
u32 readSystemStatus(u32 *failingSensorHandle);
u32 writeNVStorage (const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
u32 writeBatteryModeSetting(const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
u32 writeACModeSetting (const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
void getDisplayType(u32 &type, u32 &resolution, u32 &memSizeX256kb);
void getPanelResolution(u32 &horiz, u32 &vert);
void getActiveDisplays(u32 &bits);
void setActiveDisplays(u32 &bits);
void getPropertyOwnershipTag(char *tagBuf, size_t size);
void setPropertyOwnershipTag(const std::string password, const char *newTag, size_t size);
// newer interface
extern const int Bluetooth_Devices_Disable; // docs appear to be wrong. They say 0x0152, but this looks backwards from reality
extern const int Bluetooth_Devices_Enable; // docs appear to be wrong. They say 0x0153, but this looks backwards from reality
extern const int Cellular_Radio_Disable;
extern const int Cellular_Radio_Enable;
extern const int WiFi_Locator_Disable;
extern const int WiFi_Locator_Enable;
extern const int Wireless_LAN_Disable;
extern const int Wireless_LAN_Enable;
extern const int Wireless_Switch_Bluetooth_Control_Disable;
extern const int Wireless_Switch_Bluetooth_Control_Enable;
extern const int Wireless_Switch_Cellular_Control_Disable;
extern const int Wireless_Switch_Cellular_Control_Enable;
extern const int Wireless_Switch_Wireless_LAN_Control_Disable;
extern const int Wireless_Switch_Wireless_LAN_Control_Enable;
// old interface
extern const int Radio_Transmission_Enable;
extern const int Radio_Transmission_Disable;
extern const int Wireless_Device_Disable;
extern const int Wireless_Device_App_Control;
extern const int Wireless_Device_App_Or_Hotkey_Control;
enum radioNum { WLAN_RADIO_NUM=1, BLUETOOTH_RADIO_NUM=2, WWAN_RADIO_NUM=3 };
void wirelessRadioControl(bool enable, bool boot, bool runtime, int enable_token, int disable_token, int radioNum, std::string password);
enum { WLAN_SWITCH_CTL=1, BLUETOOTH_SWITCH_CTL=2, WWAN_SWITCH_CTL=4, LOCATOR_SWITCH_CTL=5 };
void wirelessSwitchControl(bool enable, bool boot, bool runtime, int enable_token, int disable_token, int switchNum, std::string password);
enum radioStatusCode { STATUS_ENABLED, STATUS_DISABLED, STATUS_NOT_PRESENT, STATUS_UNSUPPORTED, STATUS_UNKNOWN };
radioStatusCode wirelessRadioStatus(radioNum which, std::ostream &cout=std::cout, u32 defRes2=0);
}
// always should be last thing in header file
#include "smbios/config/abi_suffix.hpp"
#endif /* SMIINTERFACE_H */
| 42.01227 | 143 | 0.739194 |
ff3bd3a05f9b397f08a1f60047a148b52e8cc7bf | 19,058 | h | C | include/mosys/platform.h | dhendrix/mosys | 8baa261c5a7335ed9e089eb70564654c82305a9f | [
"BSD-3-Clause"
] | null | null | null | include/mosys/platform.h | dhendrix/mosys | 8baa261c5a7335ed9e089eb70564654c82305a9f | [
"BSD-3-Clause"
] | null | null | null | include/mosys/platform.h | dhendrix/mosys | 8baa261c5a7335ed9e089eb70564654c82305a9f | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright 2012, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MOSYS_PLATFORM_H__
#define MOSYS_PLATFORM_H__
#include <sys/types.h>
#include "lib/elog.h"
#include "mosys/mosys.h"
struct kv_pair;
struct gpio_map;
struct nonspd_mem_info;
#if 0
/* disabled via build option for mosys standalone binary */
#ifndef MOSYS_AS_LIBRARY
#define MOSYS_AS_LIBRARY 1
#endif
#endif
#define MOSYS_DATA_ROOT "/var/log/mosysdata"
/* defined platform types */
enum platform_type {
PLATFORM_DEFAULT,
PLATFORM_X86,
PLATFORM_X86_64,
PLATFORM_ARMV7,
PLATFORM_ARMV8,
};
/*
* Command types. These are exposed via "mosys -tv" to help with automated
* testing.
*/
enum arg_type {
ARG_TYPE_GETTER, /* "getter" functions */
ARG_TYPE_SETTER, /* "setter" functions */
ARG_TYPE_SUB, /* branch deeper into command hierachy */
};
/* nested command lists */
struct platform_intf;
struct platform_cmd {
const char *name; /* command name */
const char *desc; /* command help text */
const char *usage; /* command usage text */
enum arg_type type; /* argument type */
union { /* sub-commands or function */
struct platform_cmd *sub;
int (*func)(struct platform_intf *intf,
struct platform_cmd *cmd,
int argc, char **argv);
} arg;
};
/* platform operations handlers */
struct pci_intf;
struct mmio_intf;
struct io_intf;
struct smi_intf;
struct i2c_intf;
struct amb_intf;
struct sp_intf;
struct msr_intf;
struct mce_intf;
struct edac_intf;
struct cpuid_intf;
struct platform_op {
struct pci_intf *pci; /* pci interface */
struct mmio_intf *mmio; /* mmio interface */
struct io_intf *io; /* io interface */
struct smi_intf *smi; /* smi interface */
struct i2c_intf *i2c; /* i2c interface */
struct amb_intf *amb; /* amb interface */
struct sp_intf *sp; /* sensorpath interface */
struct msr_intf *msr; /* msr interface */
struct mce_intf *mce; /* mcelog interface */
struct edac_intf *edac; /* edac interface */
struct cpuid_intf *cpuid; /* cpuid instruction interface */
struct fru_intf *fru; /* FRU interface */
struct sched_intf *sched; /* process scheduler interface */
};
/* sensor related callbacks */
struct sensor;
struct sensor_array;
struct sensor_cb {
struct sensor_array *(*get_sensors)(struct platform_intf *intf);
void (*add_sensors)(struct platform_intf *intf,
struct sensor_array *array);
/* methods for reading data and setting thresholds */
int (*read_fantach)(struct platform_intf *intf, const char *name);
int (*set_fantach)(struct platform_intf *intf, const char *sensor_name,
unsigned int percent);
int (*set_fantach_auto)(struct platform_intf *intf,
const char *sensor_name);
int (*set_fantach_off)(struct platform_intf *intf,
const char *sensor_name);
int (*read_thermal)(struct platform_intf *intf, const char *name);
int (*set_thermal)(struct platform_intf *intf, const char *sensor_name,
const char *param, double val);
int (*read_voltage)(struct platform_intf *intf, const char *name);
int (*set_voltage)(struct platform_intf *intf, const char *sensor_name,
const char *param, double val);
/* current and power are typically not set explicitly */
int (*read_current)(struct platform_intf *intf, const char *name);
int (*read_power)(struct platform_intf *intf, const char *name);
};
/*
* mappings of logical DIMM to physical
* not all map types apply to all platforms
*/
enum dimm_map_type {
DIMM_TO_BUS, /* SPD bus */
DIMM_TO_ADDRESS, /* SPD address */
DIMM_TO_CHANNEL, /* AMB channel */
DIMM_TO_DEVICE, /* AMB device */
DIMM_TO_NODE, /* NUMA node */
};
/* dimm error types */
enum dimm_error_type {
DIMM_ERROR_SBE = 1, /* single-bit error */
DIMM_ERROR_MBE = 2, /* multi-bit error */
};
/* dimm error threshold types */
enum dimm_threshold_type {
DIMM_THRESHOLD_EVENTLOG = 1, /* eventlog */
DIMM_THRESHOLD_COUNT = 2, /* counter */
};
#define DIMM_ALL_MASK 0xffff
/* memory related callbacks */
struct smbios_table;
struct memory_component;
struct memory_spd_cb {
int (*read)(struct platform_intf *intf,
int dimm, int reg, int len, unsigned char *buf);
int (*write)(struct platform_intf *intf,
int dimm, int reg, int len, unsigned char *buf);
};
struct memory_cb {
int (*dimm_count)(struct platform_intf *intf);
int (*dimm_map)(struct platform_intf *intf,
enum dimm_map_type type, int dimm);
int (*dimm_convert)(struct platform_intf *intf,
uint64_t address);
int (*dimm_location)(struct platform_intf *intf, int array,
const char *location);
int (*dimm_print)(struct platform_intf *intf, int array, int index,
struct smbios_table *device, struct kv_pair *kv);
int (*dimm_test)(struct platform_intf *intf,
const char *type, int dimm, int count);
int (*dimm_speed)(struct platform_intf *intf,
int dimm, struct kv_pair *kv);
int (*dimm_present)(struct platform_intf *intf, int dimm);
uint32_t (*error_count)(struct platform_intf *intf,
enum dimm_error_type type, int dimm);
int (*error_clear)(struct platform_intf *intf,
enum dimm_error_type type, int dimm);
int (*error_threshold)(struct platform_intf *intf,
enum dimm_threshold_type type, uint32_t value);
/* Translate an address to its components. Fill in the array of
* components of size num_components with components that make up the
* physical_address. num_components should be updated to reflect the
* number of entries added to the array. */
int (*address_translate)(struct platform_intf *intf,
uint64_t physical_address,
struct memory_component *components,
size_t *num_components);
struct memory_spd_cb *spd;
/* for systems where SPD-formatted memory info is not available */
int (*nonspd_mem_info)(struct platform_intf *intf,
const struct nonspd_mem_info **info);
};
/* eventlog related callbacks */
enum smbios_log_entry_type;
struct smbios_log_entry;
struct smbios_table_log;
struct eventlog_cb {
int (*print_type)(struct platform_intf *intf,
struct smbios_log_entry *entry,
struct kv_pair *kv);
int (*print_data)(struct platform_intf *intf,
struct smbios_log_entry *entry,
struct kv_pair *kv);
int (*print_multi)(struct platform_intf *intf,
struct smbios_log_entry *entry,
int start_id);
int (*verify)(struct platform_intf *intf,
struct smbios_log_entry *entry);
int (*verify_header)(struct elog_header *elog_header);
int (*add)(struct platform_intf *intf, enum smbios_log_entry_type type,
size_t data_size, uint8_t *data);
int (*clear)(struct platform_intf *intf);
int (*fetch)(struct platform_intf *intf, uint8_t **data,
size_t *length, off_t *header_offset, off_t *data_offset);
int (*write)(struct platform_intf *intf, uint8_t *data, size_t length);
};
/* boot number callbacks */
struct bootnum_cb {
uint32_t(*read)(struct platform_intf *intf);
int (*reset)(struct platform_intf *intf);
};
/* NVRAM callbacks */
struct nvram_cb {
int (*list)(struct platform_intf *intf);
int (*clear)(struct platform_intf *intf);
int (*dump)(struct platform_intf *intf);
int (*vboot_read)(struct platform_intf *intf);
int (*vboot_write)(struct platform_intf *intf,
const char *hexstring);
};
/* EEPROM and EEPROM-related callbacks */
struct eeprom_enet_cb {
int (*read)(struct platform_intf *intf, int argc, char **argv);
int (*write)(struct platform_intf *intf, int argc, char **argv);
};
struct eeprom_cb {
struct eeprom_enet_cb *enet;
struct eeprom *eeprom_list;
};
enum led_state {
LED_STATE_OFF,
LED_STATE_ON,
LED_STATE_STANDBY,
LED_STATE_SLOW,
LED_STATE_FAST,
};
enum storage_phy_speed {
PHY_SPEED_UNKNOWN,
PHY_SPEED_SATA1,
PHY_SPEED_SATA2,
PHY_SPEED_SATA3,
};
/* smbios callbacks */
struct smbios_cb {
char *(*bios_vendor)(struct platform_intf *intf);
char *(*system_vendor)(struct platform_intf *intf);
char *(*system_name)(struct platform_intf *intf);
char *(*system_version)(struct platform_intf *intf);
char *(*system_family)(struct platform_intf *intf);
char *(*system_sku)(struct platform_intf *intf);
char *(*system_serial)(struct platform_intf *intf);
};
/* vpd callbacks */
struct vpd_cb {
char *(*system_serial)(struct platform_intf *intf);
char *(*system_sku)(struct platform_intf *intf);
char *(*google_hwqualid)(struct platform_intf *intf);
};
/* system information callbacks */
struct mce;
struct edac_event;
struct gtune_var;
struct sys_cb {
/* methods useful for probing */
char *(*vendor)(struct platform_intf *intf);
char *(*name)(struct platform_intf *intf);
char *(*version)(struct platform_intf *intf);
char *(*family)(struct platform_intf *intf);
char *(*variant)(struct platform_intf *intf);
/*
* Query identifiers for chassis id, brand code, customization id, and
* SKU number.
*/
char *(*chassis)(struct platform_intf *intf);
char *(*brand)(struct platform_intf *intf);
char *(*customization)(struct platform_intf *intf);
int (*sku_number)(struct platform_intf *intf);
/* Obtain the model name of this device. With unified builds a board
* can support multiple models. This allows the model to be obtained,
* which can be used to adjust how various packages work. */
char *(*model)(struct platform_intf *intf);
/* firmware info */
char *(*firmware_vendor)(struct platform_intf *intf);
char *(*firmware_version)(struct platform_intf *intf);
/* Boot-time initialization. This may include things the BIOS / kernel
did not initialize. */
int (*init_platform)(struct platform_intf *intf);
/* read and write platform-specific settings */
int (*print_settings)(struct platform_intf *intf);
/* custom reset function */
int (*reset)(struct platform_intf *intf);
#if 0
int (*tune_settings)(struct platform_intf *intf, int argc, char **argv);
/* Machine Check Exceptions */
int (*mce_handler)(struct platform_intf *intf, struct mce *mce);
int (*mce_printall)(struct platform_intf *intf);
/* Error Detection And Correction */
int (*edac_setup)(struct platform_intf *intf);
int (*edac_handler)(struct platform_intf *intf,
struct edac_event *event);
#endif
#if 0
/* FIXME: these should go into another set of callbacks, or something */
/* CPU enumeration and information */
int (*get_cores_per_socket)(struct platform_intf *intf);
int (*get_logical_cores_enabled)(struct platform_intf *intf);
int (*get_physical_cores_enabled)(struct platform_intf *intf);
int (*get_sockets_enabled)(struct platform_intf *intf);
int (*query_socket)(struct platform_intf *intf, int num);
uint8_t (*get_microcode)(struct platform_intf *intf, int cpu);
// enum cpu_types (*get_cpu_type)(struct platform_intf *intf, int node);
#endif
#if 0
/* Tunable variable list */
struct gtune_var **gtune_var_list;
#endif
};
/* flash callbacks */
struct flash_cb {
int (*dump)(struct platform_intf *intf, const char *file);
int (*verify)(struct platform_intf *intf, const char *file);
int (*print_map)(struct platform_intf *intf, const char *file);
int (*print_checksum)(struct platform_intf *intf, const char *file);
int (*size)(struct platform_intf *intf);
};
/* gpio callbacks */
struct gpio_cb {
/* read level for a specific GPIO */
int (*read)(struct platform_intf *intf, struct gpio_map *gpio);
/* get mapping for a specific GPIO */
struct gpio_map *(*map)(struct platform_intf *intf, const char *name);
/* list all GPIOs for the platform */
int (*list)(struct platform_intf *intf);
/* set a specific GPIO state to 0 or 1 */
int (*set)(struct platform_intf *intf, const char *name, int state);
};
/* fru callbacks */
struct fru_cb {
int (*info)(struct platform_intf *intf, struct eeprom *eeprom);
int (*verify)(struct platform_intf *intf, struct eeprom *eeprom);
int (*create)(struct platform_intf *intf, struct eeprom *eeprom,
char *mfg, char *prod, char *serial, char *part,
char *timestamp);
int (*read)(struct platform_intf *intf,
struct eeprom *eeprom, const char *fname);
int (*write)(struct platform_intf *intf,
struct eeprom *eeprom, const char *fname);
};
/* "legacy" ec callbacks (before support for multiple ECs was introduced) */
struct legacy_ec_cb {
const char *(*vendor)(struct platform_intf *intf);
const char *(*name)(struct platform_intf *intf);
const char *(*fw_version)(struct platform_intf *intf);
int (*setup)(struct platform_intf *intf);
int (*destroy)(struct platform_intf *intf);
void *priv; /* private data for EC */
};
struct ec_cb {
const char *(*vendor)(struct platform_intf *intf, struct ec_cb *ec);
const char *(*name)(struct platform_intf *intf, struct ec_cb *ec);
const char *(*fw_version)(struct platform_intf *intf, struct ec_cb *ec);
int (*pd_chip_info)(struct platform_intf *intf, struct ec_cb *ec,
int port);
int (*setup)(struct platform_intf *intf, struct ec_cb *ec);
int (*destroy)(struct platform_intf *intf, struct ec_cb *ec);
void *priv; /* private data for EC */
};
/* hid touchpad callbacks */
struct hid_tp_cb {
const char *(*vendor)(struct platform_intf *intf);
const char *(*name)(struct platform_intf *intf);
const char *(*fw_version)(struct platform_intf *intf);
const char *(*hw_version)(struct platform_intf *intf);
};
/* hid callbacks */
struct hid_cb {
struct hid_tp_cb *tp;
};
/* pci callbacks */
struct pci_function_info;
struct pci_cb {
const struct pci_entity_info * (*lookup)(struct platform_intf * intf,
int bus, int dev, int func);
};
/* battery related callbacks */
struct battery_cb {
const char *(*get_fud)(struct platform_intf *intf);
int (*set_fud)(struct platform_intf *intf,
int day, int month, int year);
int (*update)(struct platform_intf *intf);
};
enum psu_types {
PSU_TYPE_UNKNOWN,
PSU_TYPE_BATTERY, /* AC + rechargeable battery */
PSU_TYPE_AC_ONLY, /* No battery in system */
PSU_TYPE_AC_PRIMARY, /* AC as primary source + backup battery */
};
/* power supply related callbacks */
struct psu_cb {
enum psu_types (*type)(struct platform_intf *intf);
};
/* storage device callbacks */
struct storage_cb {
const char *(*get_model_name)(struct platform_intf *intf);
enum storage_phy_speed (*get_phy_speed)(struct platform_intf *intf);
int (*set_phy_speed)(struct platform_intf *intf,
enum storage_phy_speed phy_speed);
};
/* platform-specific callbacks */
struct platform_cb {
struct sensor_cb *sensor; /* sensor callbacks */
struct memory_cb *memory; /* memory callbacks */
struct eventlog_cb *eventlog; /* eventlog callbacks */
struct bootnum_cb *bootnum; /* boot number callbacks */
struct smbios_cb *smbios; /* smbios related callbacks */
struct sys_cb *sys; /* system callbacks */
struct flash_cb *flash; /* flash related callbacks */
struct nvram_cb *nvram; /* nvram related callbacks */
struct gpio_cb *gpio; /* gpio callbacks */
struct eeprom_cb *eeprom; /* eeprom callbacks */
struct fru_cb *fru; /* fru callbacks */
struct pci_cb *pci; /* pci callbacks */
struct vpd_cb *vpd; /* vpd callbacks */
struct ec_cb *ec; /* ec callbacks */
struct ec_cb *pd; /* pd callbacks */
struct ec_cb *sh; /* sh callbacks */
struct ec_cb *fp; /* fp callbacks */
struct legacy_ec_cb *legacy_ec; /* legacy ec callbacks */
struct hid_cb *hid; /* hid callbacks */
struct battery_cb *battery; /* battery callbacks */
struct storage_cb *storage; /* storage callbacks */
struct psu_cb *psu; /* power supply callbacks */
};
/* SKU based platform information, provided by lib/sku.h */
struct sku_info;
/*
* Top-level interface handler.
* One of these should be defined for each supported platform.
*/
struct platform_intf {
enum platform_type type; /* numeric platform type */
const char *name; /* canonical platform name */
const char **id_list; /* list of supported ids */
const struct sku_info *sku_info; /* SKU information */
struct platform_cmd **sub; /* list of commands */
struct platform_op *op; /* operations */
struct platform_cb *cb; /* callbacks */
/*
* returns 1 to indicate platform identified
* returns 0 otherwise
*/
int (*probe)(struct platform_intf *intf);
int (*setup)(struct platform_intf *intf);
int (*setup_post)(struct platform_intf *intf);
int (*destroy)(struct platform_intf *intf);
const char *version_id; /*platform board id */
};
/* The global list of all platforms. */
extern struct platform_intf *platform_intf_list[];
/*
* mosys_platform_setup - determine current platform and return handler
*
* returns pointer to pre-defined interface for detected platform
* returns NULL if platform not identified or other error
*
*/
extern struct platform_intf *mosys_platform_setup(const char *p_opt);
/*
* mosys_platform_destroy - clean up platform interface
*
* @intf: platform interface
*
*/
extern void mosys_platform_destroy(struct platform_intf *intf);
/*
* platform_cmd_usage - print usage help text for command
*
* @cmd: command pointer
*
*/
extern void platform_cmd_usage(struct platform_cmd *cmd);
/*
* print_tree - print command tree for this platform
*
* @intf: platform interface
*/
extern void print_tree(struct platform_intf *intf);
extern int print_platforms(void);
#endif /* MOSYS_PLATFORM_H__ */
| 33.493849 | 76 | 0.706632 |
ff446a52016c85896654927ded275695ca7c810d | 406 | h | C | 3rdparty/FlyCube/src/Modules/Utilities/VKUtility.h | CU-Production/FlyCube-Demos | 2763720818499bc9244eb4b16e60e647a5c88827 | [
"MIT"
] | 8 | 2021-03-17T19:25:12.000Z | 2022-02-05T02:08:21.000Z | 3rdparty/FlyCube/src/Modules/Utilities/VKUtility.h | THISISAGOODNAME/SSSR | ea4b6350b2da3d5656c7aa8c87f9965144369d22 | [
"MIT"
] | null | null | null | 3rdparty/FlyCube/src/Modules/Utilities/VKUtility.h | THISISAGOODNAME/SSSR | ea4b6350b2da3d5656c7aa8c87f9965144369d22 | [
"MIT"
] | 2 | 2021-09-22T14:39:51.000Z | 2021-11-08T09:47:38.000Z | #pragma once
#define CUSTOM_FAILED(hr) ((static_cast<VkResult>((hr))) != VK_SUCCESS)
#ifdef _WIN32
#include "DXUtility.h"
#else
#define ASSERT( isTrue, ... ) (void)(isTrue)
#define WARN_ONCE_IF( isTrue, ... ) (void)(isTrue)
#define WARN_ONCE_IF_NOT( isTrue, ... ) (void)(isTrue)
#define ERROR( msg, ... )
#define DEBUGPRINT( msg, ... ) do {} while(0)
#define ASSERT_SUCCEEDED( hr, ... ) (void)(hr)
#endif
| 29 | 71 | 0.665025 |
ff45dedc2ab9ff8f67f3bb197f4dc1e3bf3ac183 | 5,938 | h | C | lua/test/src/luaProject/Scripts/calls.h | sorrowed/embLua | 9d508a383e831f850c3a9aebc2f237d7d565a69a | [
"MIT"
] | 26 | 2018-01-15T10:04:49.000Z | 2021-11-06T12:46:08.000Z | lua/test/src/luaProject/Scripts/calls.h | sorrowed/embLua | 9d508a383e831f850c3a9aebc2f237d7d565a69a | [
"MIT"
] | 2 | 2020-04-25T14:13:39.000Z | 2021-02-16T10:20:04.000Z | lua/test/src/luaProject/Scripts/calls.h | sorrowed/embLua | 9d508a383e831f850c3a9aebc2f237d7d565a69a | [
"MIT"
] | 4 | 2019-05-08T17:44:31.000Z | 2021-09-14T23:04:18.000Z | static const char* calls="print(\"testing functions and calls\")\n\
assert(type(1<2) == 'boolean')\n\
assert(type(true) == 'boolean' and type(false) == 'boolean')\n\
assert(type(nil) == 'nil' and type(-3) == 'number' and type'x' == 'string' and\n\
type{} == 'table' and type(type) == 'function')\n\
assert(type(assert) == type(print))\n\
f = nil\n\
function f (x) return a:x (x) end\n\
assert(type(f) == 'function')\n\
fact = false\n\
do\n\
local res = 1\n\
local function fact (n)\n\
if n==0 then return res\n\
else return n*fact(n-1)\n\
end\n\
end\n\
assert(fact(5) == 120)\n\
end\n\
assert(fact == false)\n\
a = {i = 10}\n\
self = 20\n\
function a:x (x) return x+self.i end\n\
function a.y (x) return x+self end\n\
assert(a:x(1)+10 == a.y(1))\n\
a.t = {i=-100}\n\
a[\"t\"].x = function (self, a,b) return self.i+a+b end\n\
assert(a.t:x(2,3) == -95)\n\
do\n\
local a = {x=0}\n\
function a:add (x) self.x, a.y = self.x+x, 20; return self end\n\
assert(a:add(10):add(20):add(30).x == 60 and a.y == 20)\n\
end\n\
local a = {b={c={}}}\n\
function a.b.c.f1 (x) return x+1 end\n\
function a.b.c:f2 (x,y) self[x] = y end\n\
assert(a.b.c.f1(4) == 5)\n\
a.b.c:f2('k', 12); assert(a.b.c.k == 12)\n\
print('+')\n\
t = nil -- 'declare' t\n\
function f(a,b,c) local d = 'a'; t={a,b,c,d} end\n\
f( -- this line change must be valid\n\
1,2)\n\
assert(t[1] == 1 and t[2] == 2 and t[3] == nil and t[4] == 'a')\n\
f(1,2, -- this one too\n\
3,4)\n\
assert(t[1] == 1 and t[2] == 2 and t[3] == 3 and t[4] == 'a')\n\
function fat(x)\n\
if x <= 1 then return 1\n\
else return x*loadstring(\"return fat(\" .. x-1 .. \")\")()\n\
end\n\
end\n\
assert(loadstring \"loadstring 'assert(fat(6)==720)' () \")()\n\
a = loadstring('return fat(5), 3')\n\
a,b = a()\n\
assert(a == 120 and b == 3)\n\
print('+')\n\
function err_on_n (n)\n\
if n==0 then error(); exit(1);\n\
else err_on_n (n-1); exit(1);\n\
end\n\
end\n\
do\n\
function dummy (n)\n\
if n > 0 then\n\
assert(not pcall(err_on_n, n))\n\
dummy(n-1)\n\
end\n\
end\n\
end\n\
dummy(10)\n\
function deep (n)\n\
if n>0 then deep(n-1) end\n\
end\n\
deep(10)\n\
deep(200)\n\
function deep (n) if n>0 then return deep(n-1) else return 101 end end\n\
assert(deep(30000) == 101)\n\
a = {}\n\
function a:deep (n) if n>0 then return self:deep(n-1) else return 101 end end\n\
assert(a:deep(30000) == 101)\n\
print('+')\n\
a = nil\n\
(function (x) a=x end)(23)\n\
assert(a == 23 and (function (x) return x*2 end)(20) == 40)\n\
local x,y,z,a\n\
a = {}; lim = 2000\n\
for i=1, lim do a[i]=i end\n\
assert(select(lim, unpack(a)) == lim and select('#', unpack(a)) == lim)\n\
x = unpack(a)\n\
assert(x == 1)\n\
x = {unpack(a)}\n\
assert(#x == lim and x[1] == 1 and x[lim] == lim)\n\
x = {unpack(a, lim-2)}\n\
assert(#x == 3 and x[1] == lim-2 and x[3] == lim)\n\
x = {unpack(a, 10, 6)}\n\
assert(next(x) == nil) -- no elements\n\
x = {unpack(a, 11, 10)}\n\
assert(next(x) == nil) -- no elements\n\
x,y = unpack(a, 10, 10)\n\
assert(x == 10 and y == nil)\n\
x,y,z = unpack(a, 10, 11)\n\
assert(x == 10 and y == 11 and z == nil)\n\
a,x = unpack{1}\n\
assert(a==1 and x==nil)\n\
a,x = unpack({1,2}, 1, 1)\n\
assert(a==1 and x==nil)\n\
Y = function (le)\n\
local function a (f)\n\
return le(function (x) return f(f)(x) end)\n\
end\n\
return a(a)\n\
end\n\
F = function (f)\n\
return function (n)\n\
if n == 0 then return 1\n\
else return n*f(n-1) end\n\
end\n\
end\n\
fat = Y(F)\n\
assert(fat(0) == 1 and fat(4) == 24 and Y(F)(5)==5*Y(F)(4))\n\
local function g (z)\n\
local function f (a,b,c,d)\n\
return function (x,y) return a+b+c+d+a+x+y+z end\n\
end\n\
return f(z,z+1,z+2,z+3)\n\
end\n\
f = g(10)\n\
assert(f(9, 16) == 10+11+12+13+10+9+16+10)\n\
Y, F, f = nil\n\
print('+')\n\
function unlpack (t, i)\n\
i = i or 1\n\
if (i <= #t) then\n\
return t[i], unlpack(t, i+1)\n\
end\n\
end\n\
function equaltab (t1, t2)\n\
assert(#t1 == #t2)\n\
for i,v1 in ipairs(t1) do\n\
assert(v1 == t2[i])\n\
end\n\
end\n\
local function pack (...)\n\
local x = {...}\n\
x.n = select('#', ...)\n\
return x\n\
end\n\
function f() return 1,2,30,4 end\n\
function ret2 (a,b) return a,b end\n\
local a,b,c,d = unlpack{1,2,3}\n\
assert(a==1 and b==2 and c==3 and d==nil)\n\
a = {1,2,3,4,false,10,'alo',false,assert}\n\
equaltab(pack(unlpack(a)), a)\n\
equaltab(pack(unlpack(a), -1), {1,-1})\n\
a,b,c,d = ret2(f()), ret2(f())\n\
assert(a==1 and b==1 and c==2 and d==nil)\n\
a,b,c,d = unlpack(pack(ret2(f()), ret2(f())))\n\
assert(a==1 and b==1 and c==2 and d==nil)\n\
a,b,c,d = unlpack(pack(ret2(f()), (ret2(f()))))\n\
assert(a==1 and b==1 and c==nil and d==nil)\n\
a = ret2{ unlpack{1,2,3}, unlpack{3,2,1}, unlpack{\"a\", \"b\"}}\n\
assert(a[1] == 1 and a[2] == 3 and a[3] == \"a\" and a[4] == \"b\")\n\
rawget({}, \"x\", 1)\n\
rawset({}, \"x\", 1, 2)\n\
assert(math.sin(1,2) == math.sin(1))\n\
table.sort({10,9,8,4,19,23,0,0}, function (a,b) return a<b end, \"extra arg\")\n\
x = \"-- a comment\\0\\0\\0\\n x = 10 + \\n23; \\\n\
local a = function () x = 'hi' end; \\\n\
return '\\0'\"\n\
local i = 0\n\
function read1 (x)\n\
return function ()\n\
collectgarbage()\n\
i=i+1\n\
return string.sub(x, i, i)\n\
end\n\
end\n\
i = 0\n\
local a, b = load(read1(\"*a = 123\"))\n\
assert(not a and type(b) == \"string\" and i == 2)\n\
a, b = load(function () error(\"hhi\") end)\n\
assert(not a and string.find(b, \"hhi\"))\n\
x = [[\n\
return function (x)\n\
return function (y)\n\
return function (z)\n\
return x+y+z\n\
end\n\
end\n\
end\n\
]]\n\
a = assert(load(read1(x)))\n\
assert(a()(2)(3)(10) == 15)\n\
assert((function () return nil end)(4) == nil)\n\
assert((function () local a; return a end)(4) == nil)\n\
assert((function (a) return a end)() == nil)\n\
print(' OK')\n\
return deep";
| 29.69 | 81 | 0.543112 |
ff47cfc773c06b8ffe183bc06debb61cf1ed7720 | 1,002 | h | C | testPlayer.h | faddistr/PSOC4SPlayer | e764a85ebdfbbd7fa1808a55a32159059bc99204 | [
"Unlicense"
] | 2 | 2020-04-26T11:53:04.000Z | 2021-04-19T20:06:19.000Z | testPlayer.h | faddistr/PSOC4SPlayer | e764a85ebdfbbd7fa1808a55a32159059bc99204 | [
"Unlicense"
] | null | null | null | testPlayer.h | faddistr/PSOC4SPlayer | e764a85ebdfbbd7fa1808a55a32159059bc99204 | [
"Unlicense"
] | 1 | 2018-07-17T09:53:45.000Z | 2018-07-17T09:53:45.000Z | /** @file
* @brief Header file for test purpose player
*/
#ifndef TESTPLAYER_H
#define TESTPLAYER_H
#include <stdbool.h>
#include <stdint.h>
/**
* @defgroup TestPlayer
*
* Various test signal generation functions
* This module is not controlled through player.c module
* @{
*/
/** Various modes of player */
typedef enum
{
TEST_PLAY_SINE, /** Play sine, 1KHz for 16K sample rate */
TEST_PLAY_NOTE, /** Play note for 16K sample rate */
TEST_PLAY_MODE_COUNT,
} testPlayerMode_t;
/**
* @brief Play test signal
*
* @param[in] mode mode of the player
* @param[in] arg additional argument if required (note)
*
* @return false in case of error
*/
bool testPlayerPlay(testPlayerMode_t mode, uint8_t arg);
/**
* @brief Stop(pause) test signal generation
*
* @param none
*
* @return none
*/
void testPlayerStop(void);
/**
* @brief Resume test signal generation
*
* @param none
*
* @return none
*/
void testPlayerStart(void);
/** @} */
#endif /* TESTPLAYER_H */ | 19.269231 | 62 | 0.672655 |
ff48d5ca5629c854345aea272ec79b73fa9ff4dd | 74 | h | C | avx-piecewise/naive.h | clayne/toys | ec06411e2d3b920403607888d4a573e41390ee5b | [
"BSD-2-Clause"
] | null | null | null | avx-piecewise/naive.h | clayne/toys | ec06411e2d3b920403607888d4a573e41390ee5b | [
"BSD-2-Clause"
] | null | null | null | avx-piecewise/naive.h | clayne/toys | ec06411e2d3b920403607888d4a573e41390ee5b | [
"BSD-2-Clause"
] | null | null | null | #pragma once
float naive(float x, float* x_boudary, float* a, float* b);
| 18.5 | 59 | 0.702703 |
ff4a6e69fcf5883abfd2dc59c05a01582faac541 | 515 | h | C | qqtw/qqheaders7.2/ArkAppScanCodeViewController.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 5 | 2018-02-20T14:24:17.000Z | 2020-08-06T09:31:21.000Z | qqtw/qqheaders7.2/ArkAppScanCodeViewController.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 1 | 2020-06-10T07:49:16.000Z | 2020-06-12T02:08:35.000Z | qqtw/qqheaders7.2/ArkAppScanCodeViewController.h | onezens/SmartQQ | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | null | null | null | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "MQQRCodeReaderViewController.h"
@interface ArkAppScanCodeViewController : MQQRCodeReaderViewController
{
CDUnknownBlockType _cancelBlock;
}
- (void).cxx_destruct;
@property(copy, nonatomic) CDUnknownBlockType cancelBlock; // @synthesize cancelBlock=_cancelBlock;
- (id)initWithCancelBlock:(CDUnknownBlockType)arg1;
- (void)viewWillDisappear:(_Bool)arg1;
@end
| 24.52381 | 99 | 0.757282 |
ff4b760ab9fe5c724a81a84268608143e2853dc6 | 1,519 | h | C | KWD/DSP/include/utiltypes.h | hardkernel/buildroot_avs_avs_client | 8841a75bf985ff3c95c02b0c0bf4a1d68aea229e | [
"Apache-2.0"
] | 1 | 2021-03-03T03:18:09.000Z | 2021-03-03T03:18:09.000Z | KWD/DSP/include/utiltypes.h | hardkernel/buildroot_avs_avs_client | 8841a75bf985ff3c95c02b0c0bf4a1d68aea229e | [
"Apache-2.0"
] | null | null | null | KWD/DSP/include/utiltypes.h | hardkernel/buildroot_avs_avs_client | 8841a75bf985ff3c95c02b0c0bf4a1d68aea229e | [
"Apache-2.0"
] | null | null | null | /****************************************************************************
*
* Utility types
* -------------
*
****************************************************************************
*
* Description: Utility types
*
* Copyright: Copyright DEMA Consulting 2008-2012, All rights reserved.
* Owner: DEMA Consulting.
* 93 Richardson Road
* Dublin, NH 03444
*
***************************************************************************/
/**
* @addtogroup Debugging
* @{
*/
#ifndef _UTILTYPES_H_INCLUDED
#define _UTILTYPES_H_INCLUDED
#ifndef WIN32
#ifndef IN
#define IN
#endif
#ifndef OUT
#define OUT
#endif
#ifndef IN_OUT
#define IN_OUT
#endif
#ifndef E_FAIL
#define E_FAIL (-1)
#endif
#ifndef S_OK
#define S_OK (0)
#endif
#ifndef LRESULT
#define LRESULT int
#endif
#ifndef afx_msg
#define afx_msg
#endif
#ifndef FAILED
#define FAILED(hr) ((hr) < 0)
#endif
#ifndef DLLSYMBOL
#define DLLSYMBOL
#endif
#ifndef HRESULT
#define HRESULT int
#endif
#ifndef SUCCEEDED
#define SUCCEEDED(hr) ((hr) >= 0)
#endif
#ifndef HWND
#define HWND unsigned int
#endif
#ifndef BYTE
#define BYTE unsigned char
#endif
#ifndef WORD
#define WORD unsigned short
#endif
#ifndef DWORD
#define DWORD unsigned long
#endif
//#ifndef UINT
//#define UINT unsigned int
//#endif
#ifndef HIWORD
#define HIWORD(x) (((x) >> 16) & 0xffff)
#endif
#ifndef LOWORD
#define LOWORD(x) ((x) & 0xffff)
#endif
#endif // !WIN32
#endif // _UTILTYPES_H_INCLUDED
/**
* @}
* End of file.
*/
| 14.196262 | 77 | 0.571429 |
ff4bf3a2fa33005415218534e5a1d0f8e0407f01 | 1,236 | h | C | include/usql/SQLParser.h | cybergarage/usql | b3d9f4356a141cd52cff2b78a0f65bfbfb8f8730 | [
"BSD-3-Clause"
] | 49 | 2015-02-26T07:48:41.000Z | 2022-03-31T19:18:04.000Z | include/usql/SQLParser.h | cybergarage/uSQL4CC | b3d9f4356a141cd52cff2b78a0f65bfbfb8f8730 | [
"BSD-3-Clause"
] | 4 | 2015-01-26T11:58:57.000Z | 2015-01-26T12:10:25.000Z | include/usql/SQLParser.h | cybergarage/uSQL4CC | b3d9f4356a141cd52cff2b78a0f65bfbfb8f8730 | [
"BSD-3-Clause"
] | 14 | 2015-04-08T08:30:31.000Z | 2022-03-08T03:20:54.000Z | /******************************************************************
*
* uSQL for C++
*
* Copyright (C) Satoshi Konno 2012
*
* This is licensed under BSD-style license, see file COPYING.
*
******************************************************************/
#ifndef _USQL_SQLPARSER_H_
#define _USQL_SQLPARSER_H_
#include <string>
#include <vector>
#include <stack>
#include <usql/SQLError.h>
#include <usql/SQLStatement.h>
#include <usql/SQLNode.h>
#include <usql/SQLNodes.h>
namespace uSQL {
class SQLParser {
private:
SQLStatementList statements;
SQLError error;
private:
void clear();
public:
SQLParser();
virtual ~SQLParser();
virtual bool parse(const std::string &queryString);
void setStatementType(int type);
void addStatement(SQLStatement *stmt)
{
statements.push_back(stmt);
}
int getStatementCount() {
return (int)statements.size();
}
SQLStatement *getStatement(size_t n)
{
if ((statements.size()-1) < n)
return NULL;
return statements.at(n);
}
SQLStatement *getStatement()
{
return getStatement(0);
}
SQLStatementList *getStatements()
{
return &statements;
}
SQLError *getError()
{
return &error;
}
};
}
#endif
| 15.259259 | 67 | 0.59466 |
ff4c30890feb02a488ae383da1b0fa9c9c6460e4 | 627 | h | C | examples/demo-tall/socket/include/sync_long.h | IBM/scheduler-library | 7d2feee4f010c421e68dd9eec983476207a0dac3 | [
"Apache-2.0"
] | 3 | 2020-05-26T20:17:44.000Z | 2022-01-07T16:59:58.000Z | examples/demo-me/socket/include/sync_long.h | IBM/scheduler-library | 7d2feee4f010c421e68dd9eec983476207a0dac3 | [
"Apache-2.0"
] | 6 | 2020-06-09T05:52:57.000Z | 2020-08-11T20:52:42.000Z | examples/demo-tall/socket/include/sync_long.h | IBM/scheduler-library | 7d2feee4f010c421e68dd9eec983476207a0dac3 | [
"Apache-2.0"
] | 3 | 2020-06-29T15:27:38.000Z | 2021-04-01T05:25:09.000Z | #ifndef INC_SYNC_LONG
#define INC_SYNC_LONG
#include <complex.h>
#include "sdr_type.h"
#include "sdr_base.h"
#ifdef INT_TIME
/* This is RECV-Synch-Long internal Timing information (gathering resources) */
extern uint64_t sylg_total_sec;
extern uint64_t sylg_total_usec;
extern uint64_t sylg_firG_sec;
extern uint64_t sylg_firG_usec;
extern uint64_t sylg_search_sec;
extern uint64_t sylg_search_usec;
extern uint64_t sylg_outgen_sec;
extern uint64_t sylg_outgen_usec;
#endif
void sync_long( unsigned num_inputs, fx_pt* input, fx_pt* input_delayed, float* freq_offset_out, unsigned* num_outputs, fx_pt* output );
#endif
| 22.392857 | 136 | 0.811802 |
ff4c52a0654a2c716b60d898d79c18d2a358399b | 1,153 | h | C | resource.h | udaken/axvtag | a512ff6b4a0d8ff1e6a98c600023d6cd334c02b2 | [
"MIT"
] | null | null | null | resource.h | udaken/axvtag | a512ff6b4a0d8ff1e6a98c600023d6cd334c02b2 | [
"MIT"
] | null | null | null | resource.h | udaken/axvtag | a512ff6b4a0d8ff1e6a98c600023d6cd334c02b2 | [
"MIT"
] | null | null | null | //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ で生成されたインクルード ファイル。
// axvtag.rc で使用
//
#define IDD_DIALOG1 101
#define IDC_CHECK_PARNTHESIS 1001
#define IDC_CHECK_FULLWIDTH_PARNTHESIS 1002
#define IDC_CHECK_SQUARE_BRACKET 1003
#define IDC_CHECK_FULLWIDTH_SUARE_BRACKET 1004
#define IDC_CHECK_BLACK_LENTICULAR_BRACKET 1005
#define IDC_CHECK_CORNER_BRACKET 1006
#define IDC_CHECK_WHITE_CORNER_BRACKET 1007
#define IDC_EDIT_EXCLUDE_PATTERN 1008
#define IDC_SLIDER1 1009
#define IDC_CHECK_WHITE_LENTICULAR_BRACKET 1010
#define IDC_CHECK_DOUBLE_ANGLE_BRACKET 1011
#define IDC_CHECK_SPACE 1012
#define IDC_CHECK_ADD_COUNT_TO_PATH 1013
#define IDC_CHECK_SHOW_UNTAGGED_FILES 1014
#define IDC_CHECK_INCLUDE_TAG_CHARS 1015
#define IDC_EDIT1 1016
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1017
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
| 34.939394 | 47 | 0.746748 |
ff4c65179dd476398cf42cd57c0487c7b2d096ac | 8,809 | h | C | src/schdcl.h | alfredkayser/DScheme | d963b38f032a80627dfa3292ab75950263ccb26d | [
"CC0-1.0"
] | 1 | 2021-08-16T21:18:32.000Z | 2021-08-16T21:18:32.000Z | src/schdcl.h | alfredkayser/DScheme | d963b38f032a80627dfa3292ab75950263ccb26d | [
"CC0-1.0"
] | null | null | null | src/schdcl.h | alfredkayser/DScheme | d963b38f032a80627dfa3292ab75950263ccb26d | [
"CC0-1.0"
] | null | null | null | /**********************************************************************
** MODULE INFORMATION*
**********************
** FILE NAME: SCHDCL.H
** SYSTEM NAME: SCHEME
** ORIGINAL AUTHOR(S): Alfred Kayser
** VERSION NUMBER: 1.5.5
** CREATION DATE: 88/10/17
**
** DESCRIPTION: Prototype header for the Scheme system
***********************************************************************
** CHANGES INFORMATION **
*************************
** REVISION: $Revision: $
** CHANGER: $Author: $
** WORKFILE: $Workfile: $
** LOGFILE: $Logfile: $
** LOGINFO: $Log: $
**********************************************************************/
#ifndef STATIC
#define STATIC
#endif
/***************** Prototype(s) for SCHEME.C **************************/
int CDECL DSinit __((GLOBAL **, ...));
int PASCAL DScheme __((GLOBAL *));
int PASCAL DSextdef __((GLOBAL *, EXTDEF *));
int PASCAL DSmultidef __((GLOBAL *, EXTDEF *));
int PASCAL DSeval __((GLOBAL *, CELP, CELP *));
int PASCAL DSread __((GLOBAL *, PORT *, CELP *));
int PASCAL DSinitport __((GLOBAL *, PORT **, int, UNTYPE *, INP_FUN, OUT_FUN, CTL_FUN));
int PASCAL DS_fopen __((GLOBAL *, PORT **, CONST char *, int));
int PASCAL DSclose __((GLOBAL **));
int CDECL DsWaiter __((void));
void PASCAL DsFuncDef __((EXTDEF *));
#ifdef MSCX
char * strupr __((char *p));
int stricmp __((char *s1, char *s2));
#endif
/***************** Prototype(s) for SCHPRC.C **************************/
CELP PASCAL DsCompare __((CELP a1, CELP a2));
CELP PASCAL DsEqv __((CELP a1, CELP a2));
CELP PASCAL DsEqual __((CELP a1, CELP a2));
CELP PASCAL DsCmpChar __((CELP a1, CELP a2, int t));
CELP PASCAL DsCmpTime __((CELP a1, CELP a2, int t));
CELP PASCAL DsAssQ __((CELP key, CELP list));
CELP PASCAL DsAssV __((CELP key, CELP list));
CELP PASCAL DsAssoc __((CELP key, CELP list));
CELP PASCAL DsMemQ __((CELP key, CELP list));
CELP PASCAL DsMemV __((CELP key, CELP list));
CELP PASCAL DsMember __((CELP key, CELP list));
CELP PASCAL Ds_math1 __((int opcode, CELP arg));
CELP CDECL Ds_load __((CELP name));
LONG PASCAL DsLength __((CELP l));
/***************** Prototype(s) for SCHCEL.C **************************/
CELP PASCAL DsGetCell __((int typ));
CELP PASCAL DsCons __((CELP a, CELP b));
CELP PASCAL DsCons1 __((CELP a));
CELP PASCAL DsFltCell __((REAL v));
CELP PASCAL DsIntCell __((LONG l));
CELP PASCAL DsPrtCell __((PORT *prt));
CELP PASCAL DsChrCell __((int l));
CELP PASCAL DsSymbol __((CONST char *symbol));
CELP PASCAL DsInsExt __((CONST char *name));
CELP PASCAL DsStrTime __((CONST char *str));
void PASCAL DsMark __((CELP p));
void PASCAL DsFreeCell __((CELP temp));
char * PASCAL DsTimeStr __((CELP elem));
CELP PASCAL DsInsKey __((CELP key));
CELP PASCAL DsTimeReal __((CELP p));
CELP PASCAL DsRealTime __((CELP p));
CELP CDECL DsCar __((CELP l));
CELP CDECL DsCdr __((CELP l));
CELP CDECL DsCaar __((CELP l));
CELP CDECL DsCadr __((CELP l));
CELP CDECL DsCdar __((CELP l));
CELP CDECL DsCddr __((CELP l));
CELP CDECL DsCaaar __((CELP l));
CELP CDECL DsCaadr __((CELP l));
CELP CDECL DsCadar __((CELP l));
CELP CDECL DsCaddr __((CELP l));
CELP CDECL DsCdaar __((CELP l));
CELP CDECL DsCdadr __((CELP l));
CELP CDECL DsCddar __((CELP l));
CELP CDECL DsCdddr __((CELP l));
void PASCAL DsIniCells __((DWORD numcels));
void PASCAL DsAllocCells __((int blocksize));
void PASCAL DsRelease __((CELP p));
void PASCAL DsProtect __((CELP p));
DWORD PASCAL DsGarbageCollect __((CELP cels));
void PASCAL DsCollect __((void));
void FAR * PASCAL DsFarMalloc __((int size));
/***************** Prototype(s) for SCHTIM.C **************************/
WORD PASCAL DsGetDays __((int day, int month, int year));
void PASCAL DsSetDays __((int julian, int *day, int *month, int *year));
int PASCAL DsDayOfWeek __((int julian));
CELP PASCAL DsMakeTime __((time_t t));
/***************** Prototype(s) for SCHRDR.C **************************/
void PASCAL DsIniParser __((void));
CELP PASCAL DsRead __((PORT *));
CELP PASCAL DsStrNumber __((char *s, int base));
CELP PASCAL DsStrReal __((char *s));
char * PASCAL ltostr __((long num, int base));
/****************** Prototype(s) for SCHIO.C **************************/
void PASCAL DsIniIO __((void));
void PASCAL DsIniPorts __((int,int,int,int));
int PASCAL DsInput __((PORT *));
void PASCAL DsUnput __((PORT *, int));
int PASCAL DsPeek __((PORT *));
void PASCAL DsOuts __((PORT *, CONST char *));
void CDECL DsOutf __((PORT *, CONST char *, ...));
void PASCAL DsOutc __((PORT *, CELP, int));
PORT * PASCAL DsInitPort __((int, UNTYPE*, INP_FUN, OUT_FUN, CTL_FUN));
PORT * PASCAL DsFOpen __((CONST char *, int));
void PASCAL DsClosePort __((PORT *));
void PASCAL DsFlushPort __((PORT *));
void PASCAL DsStdPorts __((void));
int PASCAL DsEInput __((UNTYPE *stream));
void PASCAL DsEOutput __((int c, UNTYPE *stream));
/***************** Prototype(s) for SCHNUM.C **************************/
int PASCAL DSmath __((GLOBAL *));
CELP PASCAL DsCmpNumber __((CELP, CELP, int));
USHORT PASCAL DsGetNTag __((CELP));
/***************** Prototype(s) for SCHERR.C **************************/
void PASCAL DsNoInitError __((CONST char *));
int PASCAL DsRetCode __((void));
int PASCAL DsErrorLevel __((int));
int PASCAL DsHandleError __((void));
int CDECL DsRepError __((GLOBAL *, int, CELP));
void PASCAL DsClearError __((void));
void PASCAL DsMemError __((CONST char *));
void PASCAL DsStkError __((void));
void PASCAL DsVError __((int));
void PASCAL DsTypError __((CELP));
void PASCAL DsError __((int, CELP));
void PASCAL DsPError __((int, PORT *));
char * PASCAL DsErrMsg __((int));
void PASCAL DsStrError __((int, CONST char *));
/***************** Prototype(s) for SCHEXT.C **************************/
int PASCAL DSextend __((GLOBAL *));
CELP CDECL Ds_globals __((void));
/***************** Prototype(s) for SCHTRA.C **************************/
void PASCAL DsTraceInit __((void));
/***************** Prototype(s) for SCHEVA.C **************************/
CELP PASCAL DsEval __((CELP));
void PASCAL DsDefVar __((CELP));
/***************** Prototype(s) for SCHSTR.C **************************/
void PASCAL DsIniBuf __((int));
void PASCAL DsFreeBuf __((char *));
void PASCAL DsBufDefrag __((void));
int PASCAL DsFragmented __((void));
CELP PASCAL DsStrCell __((CONST char *));
CELP CDECL Ds_lstvec __((CELP l));
CELP PASCAL DsGetStr __((int n));
CELP PASCAL DsCmpVector __((CELP a1,CELP a2));
/***************** Prototype(s) for SCHBI2.C **************************/
CELP PASCAL DsStrBig __((char *));
char * PASCAL DsBigStr __((CELP));
CELP PASCAL big_cpy __((CELP));
CELP PASCAL big_add __((CELP, CELP));
CELP PASCAL big_sub __((CELP, CELP));
CELP PASCAL big_mul __((CELP, CELP));
CELP PASCAL big_div __((CELP, CELP, CELP *));
CELP PASCAL big_muli __((ULONG, CELP));
void PASCAL big_free __((CELP));
int PASCAL big_len __((CELP));
CELP PASCAL big_mul10 __((int, CELP));
int PASCAL big_cmp __((CELP, CELP));
CELP PASCAL big_adds __((CELP, CELP));
CELP PASCAL big_subs __((CELP, CELP));
CELP PASCAL big_muls __((CELP, CELP));
CELP PASCAL big_divs __((CELP, CELP, CELP *));
CELP PASCAL int2big __((CELP));
CELP PASCAL real2big __((CELP));
CELP PASCAL big2int __((CELP));
REAL PASCAL big2real __((CELP));
CELP PASCAL makebig __((CELP));
REAL PASCAL makeflo __((CELP));
REAL PASCAL makeflo2 __((CELP, int));
/***************** Prototype(s) for SCHUTL.C **************************/
int CDECL DSutinit __((GLOBAL *));
/***************** Prototype(s) for SCHTST.C **************************/
void CDECL main __((int, char **));
void PASCAL DSGCmessage __((int));
/***************** Prototype(s) for SCHINFO.C *************************/
void PASCAL info __((void));
| 40.408257 | 95 | 0.529686 |
ff4cc69020f4ef6a17d883fcb6211f29a369909f | 7,048 | h | C | Modules/Rendering/Media/Shaders/vaASSAO_types.h | KakCAT/ASSAO | 06881a1632576468b9816d3d28aa06b49a06afa8 | [
"MIT"
] | 234 | 2016-11-16T06:00:37.000Z | 2022-01-06T05:19:14.000Z | Modules/Rendering/Media/Shaders/vaASSAO_types.h | KakCAT/ASSAO | 06881a1632576468b9816d3d28aa06b49a06afa8 | [
"MIT"
] | 9 | 2017-01-06T17:00:37.000Z | 2021-09-03T22:10:00.000Z | Modules/Rendering/Media/Shaders/vaASSAO_types.h | KakCAT/ASSAO | 06881a1632576468b9816d3d28aa06b49a06afa8 | [
"MIT"
] | 34 | 2016-11-16T16:30:33.000Z | 2022-02-23T06:41:30.000Z | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2016, Intel Corporation
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of
// the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// File changes (yyyy-mm-dd)
// 2016-09-07: filip.strugar@intel.com: first commit
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef __VA_INTELSSAO_TYPES_H__
#define __VA_INTELSSAO_TYPES_H__
// #ifdef __INTELLISENSE__
// #undef INTEL_SSAO_INCLUDED_FROM_CPP
// #endif
#ifdef INTEL_SSAO_INCLUDED_FROM_CPP
namespace VertexAsylum
{
#else
#include "vaShaderCore.h"
// for definitions
#include "vaShared.hlsl"
#endif
#define SSAO_SAMPLERS_SLOT0 0
#define SSAO_SAMPLERS_SLOT1 1
#define SSAO_SAMPLERS_SLOT2 2
#define SSAO_SAMPLERS_SLOT3 3
#define SSAO_NORMALMAP_OUT_UAV_SLOT 4
#define SSAO_DEBUGGINGOUTPUT_OUT_UAV_SLOT 3
#define SSAO_CONSTANTS_BUFFERSLOT 1
#define SSAO_TEXTURE_SLOT0 0
#define SSAO_TEXTURE_SLOT1 1
#define SSAO_TEXTURE_SLOT2 2
#define SSAO_TEXTURE_SLOT3 3
#define SSAO_TEXTURE_SLOT4 4
#define SSAO_TEXTURE_SLOT5 5
#define SSAO_MAX_TAPS 32
#define SSAO_MAX_REF_TAPS 512
#define SSAO_ADAPTIVE_TAP_BASE_COUNT 5
#define SSAO_ADAPTIVE_TAP_FLEXIBLE_COUNT (SSAO_MAX_TAPS-SSAO_ADAPTIVE_TAP_BASE_COUNT)
#define SSAO_DEPTH_MIP_LEVELS 4
#define SSAO_ALLOW_INTERNAL_SHADER_DEBUGGING
// just for debugging
#ifdef SSAO_ALLOW_INTERNAL_SHADER_DEBUGGING
#define SSAO_DEBUGGING_DUMP_UAV_SLOT 2
#endif
#define SSAO_LOAD_COUNTER_UAV_SLOT 4
// This lets the Low Quality preset use R8 instead of R8G8 texture for storing intermediate AO results: turns out there's little impact on most architectures (below 5%).
// There's added complexity to using this and a added requirement to re-create textures based on quality mode, so I'm keeping it out of the final code, but
// it's certainly an option especially if scratch memory size is of high importance on Low preset.
#define SSAO_USE_SEPARATE_LOWQ_AORESULTS_TEXTURE 0
struct ASSAOConstants
{
vaVector2 ViewportPixelSize; // .zw == 1.0 / ViewportSize.xy
vaVector2 HalfViewportPixelSize; // .zw == 1.0 / ViewportHalfSize.xy
vaVector2 DepthUnpackConsts;
vaVector2 CameraTanHalfFOV;
vaVector2 NDCToViewMul;
vaVector2 NDCToViewAdd;
vaVector2i PerPassFullResCoordOffset;
vaVector2 PerPassFullResUVOffset;
vaVector2 Viewport2xPixelSize;
vaVector2 Viewport2xPixelSize_x_025; // Viewport2xPixelSize * 0.25 (for fusing add+mul into mad)
float EffectRadius; // world (viewspace) maximum size of the shadow
float EffectShadowStrength; // global strength of the effect (0 - 5)
float EffectShadowPow;
float EffectShadowClamp;
float EffectFadeOutMul; // effect fade out from distance (ex. 25)
float EffectFadeOutAdd; // effect fade out to distance (ex. 100)
float EffectHorizonAngleThreshold; // limit errors on slopes and caused by insufficient geometry tessellation (0.05 to 0.5)
float EffectSamplingRadiusNearLimitRec; // if viewspace pixel closer than this, don't enlarge shadow sampling radius anymore (makes no sense to grow beyond some distance, not enough samples to cover everything, so just limit the shadow growth; could be SSAOSettingsFadeOutFrom * 0.1 or less)
float DepthPrecisionOffsetMod;
float NegRecEffectRadius; // -1.0 / EffectRadius
float LoadCounterAvgDiv; // 1.0 / ( halfDepthMip[SSAO_DEPTH_MIP_LEVELS-1].sizeX * halfDepthMip[SSAO_DEPTH_MIP_LEVELS-1].sizeY )
float AdaptiveSampleCountLimit;
float InvSharpness;
int PassIndex;
vaVector2 QuarterResPixelSize; // used for importance map only
vaVector4 PatternRotScaleMatrices[5];
float UnusedNormalsUnpackMul;
float UnusedNormalsUnpackAdd;
float DetailAOStrength;
float Dummy0;
// **********************************************************************************
// ** stuff below not needed in production code **
//
// float MaxViewspaceDepth;
// float MaxViewspaceDepthRec;
// vaVector2 Dummy;
//
// for quality level 4 (reference) and similar - not needed in production code
int AutoMatchSampleCount;
float DebugRefSamplesDistribution;
float Dummy1;
float Dummy2;
//
#ifdef SSAO_ALLOW_INTERNAL_SHADER_DEBUGGING
vaVector2i DebugCursorPos;
vaVector2i FullResOffset;
#endif
//
vaVector4 SamplesArray[SSAO_MAX_REF_TAPS];
//
// **********************************************************************************
};
#ifdef INTEL_SSAO_INCLUDED_FROM_CPP
} // close the namespace
#endif
#endif // __VA_INTELSSAO_TYPES_H__ | 47.302013 | 319 | 0.57605 |
ff4ddf2092e3e27f38b2a5734dfe8a371592f848 | 317 | c | C | 13_sumkv.c | pashkunlizun/TTTTT | 42ffa5c638d387fdbb3cfb3d5ee9642218dd86d4 | [
"BSD-3-Clause"
] | null | null | null | 13_sumkv.c | pashkunlizun/TTTTT | 42ffa5c638d387fdbb3cfb3d5ee9642218dd86d4 | [
"BSD-3-Clause"
] | null | null | null | 13_sumkv.c | pashkunlizun/TTTTT | 42ffa5c638d387fdbb3cfb3d5ee9642218dd86d4 | [
"BSD-3-Clause"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
int n = 0,min = 0,a=0,b=2;
printf("Введите количество элементов: ");
scanf("%d",&n);
unsigned int x[n],sum=0;
for (int i=0;i<n;i++)
{
scanf("%d",&x[i]);
a=x[i];
x[i]=pow(a,b);
}
for (int i=0;i<n;i++)
{
sum=sum+x[i];
}
printf("%d",sum);
}
| 13.782609 | 41 | 0.55836 |
ff4f7670f30fbe911c458ddee69f6a8bb5c54d0f | 710 | c | C | ZappyServer/server/utils/concatList.c | gillioa/Zappy | 4de8a9be40b018f68d56ddb7d8813192653838f4 | [
"MIT"
] | null | null | null | ZappyServer/server/utils/concatList.c | gillioa/Zappy | 4de8a9be40b018f68d56ddb7d8813192653838f4 | [
"MIT"
] | null | null | null | ZappyServer/server/utils/concatList.c | gillioa/Zappy | 4de8a9be40b018f68d56ddb7d8813192653838f4 | [
"MIT"
] | null | null | null | /*
** concatList.c for in /home/thebau-j/rendu/blowshitup/ServerZappy/server/utils
**
** Made by
** Login <thebau_j@epitech.net>
**
** Started on Sun Jul 13 16:07:16 2014
** Last update Sun Jul 13 16:07:17 2014
*/
#include <stdlib.h>
#include <string.h>
#include "list.h"
char *_concatList(t_list *l)
{
char *copy_addr;
char *content;
size_t size;
t_node *it;
size = 0;
it = l->head;
content = NULL;
while (it != NULL)
{
size += strlen((char*)it->data);
content = realloc(content, sizeof(char) * (size + 1));
copy_addr = content + size - strlen((char*)it->data);
strcpy(copy_addr, (char*)it->data);
it = rm_node(l, it);
}
return content;
}
| 20.285714 | 80 | 0.602817 |
ff505f1d6febf80388fb4e940cda24adec28892b | 332 | h | C | Include/GUI/IAction.h | nhamil/modeler-3d | 1f5bb3a16cdfc25db1081d8df461685385fa88c4 | [
"MIT"
] | 1 | 2017-09-29T23:41:45.000Z | 2017-09-29T23:41:45.000Z | Include/GUI/IAction.h | nhamil/modeler-3d | 1f5bb3a16cdfc25db1081d8df461685385fa88c4 | [
"MIT"
] | null | null | null | Include/GUI/IAction.h | nhamil/modeler-3d | 1f5bb3a16cdfc25db1081d8df461685385fa88c4 | [
"MIT"
] | null | null | null | #pragma once
namespace Gui
{
class Widget;
class IAction
{
public:
virtual ~IAction() {}
virtual void OnActionPerformed(Widget* caller) = 0;
};
class IMoveAction
{
public:
virtual ~IMoveAction() {}
virtual void OnActionPerformed(Widget* caller, int32 x, int32 y, int32 dx, int32 dy, uint32 buttons) = 0;
};
}
| 13.28 | 109 | 0.680723 |
ff51cb5967e3eac83763c26002a5afe56302319f | 408 | c | C | 4-Chapter/7/main.c | EdwardWang/Programming-Abstractions-in-C | 03d8805b835c39ba5385c32698d982074569ae3c | [
"MIT"
] | null | null | null | 4-Chapter/7/main.c | EdwardWang/Programming-Abstractions-in-C | 03d8805b835c39ba5385c32698d982074569ae3c | [
"MIT"
] | null | null | null | 4-Chapter/7/main.c | EdwardWang/Programming-Abstractions-in-C | 03d8805b835c39ba5385c32698d982074569ae3c | [
"MIT"
] | null | null | null | #include <stdio.h>
int DigitRoot(int n);
int main(int argc, char *argv[])
{
printf("%d\n", DigitRoot(1729));
return 0;
}
int DigitSum(int n)
{
if (n == 0) {
return 0;
} else {
return (DigitSum(n/10) + n%10);
}
}
int DigitRoot(int n)
{
if (n / 10 == 0)
return n;
else {
int sum;
sum = DigitSum(n);
return DigitRoot(sum);
}
}
| 13.6 | 39 | 0.485294 |
ff5526781ff8dc6894014688316854189a6bbc9b | 2,297 | h | C | VulkanSamples/HelloWorldVKRay/common/include/log_helpers.h | centauroWaRRIor/VulkanSamples | 5a7c58de820207cc0931a9db8c90f00453e31631 | [
"MIT"
] | null | null | null | VulkanSamples/HelloWorldVKRay/common/include/log_helpers.h | centauroWaRRIor/VulkanSamples | 5a7c58de820207cc0931a9db8c90f00453e31631 | [
"MIT"
] | null | null | null | VulkanSamples/HelloWorldVKRay/common/include/log_helpers.h | centauroWaRRIor/VulkanSamples | 5a7c58de820207cc0931a9db8c90f00453e31631 | [
"MIT"
] | null | null | null | #pragma once
#include <array>
#include <numeric>
#include <sstream>
#include <iostream>
#include <string>
#include <vector>
#include "unused.h"
namespace vksamples {
namespace common {
class LogHelpers {
public:
template <typename... Args>
static std::string StringFormat(char const *format, Args... args) {
std::vector<char> buffer;
buffer.resize(static_cast<size_t>(snprintf(nullptr, 0, format, args...)) + 1);
snprintf(buffer.data(), buffer.size(), format, args...);
return std::string(buffer.data(), buffer.data() + buffer.size() - 1);
}
static std::string Join(std::vector<std::string> &strings, std::string const &delim) {
if (strings.empty()) {
return std::string();
}
return std::accumulate(strings.begin() + 1, strings.end(), strings[0], [&delim](std::string &ss, std::string &s) {
return ss.empty() ? s : ss + delim + s;
});
}
static std::string FormatBytes(uint64_t const bytes) {
if (bytes < 1024) {
return StringFormat("%llu B", bytes);
}
static std::array<std::string const, 6> const suffixes = { {"KB", "MB", "GB", "TB", "PB", "EB"} };
float size = static_cast<float>(bytes);
for (std::string const &suffix : suffixes) {
size /= 1024.0f;
if (size < 1024.0f) {
return StringFormat("%.3f %s", size, suffix.c_str());
}
}
return StringFormat("%.3f %s", size, suffixes.end()->c_str());
}
// output to log in a piece meal fashion, allowing for unlimited size string logging
static void LogLargeString(const char *output) {
std::istringstream log_stream(output);
std::vector<std::string> output_log = {};
int line_count = 0;
std::string current_log_line;
while (std::getline(log_stream, current_log_line)) {
++line_count;
output_log.push_back(LogHelpers::StringFormat("%d: %s", line_count, current_log_line.c_str()));
if (25 <= output_log.size()) {
std::cout << LogHelpers::Join(output_log, "\n").c_str() << std::endl;
output_log.clear();
}
}
if (0 < output_log.size()) {
std::cout << LogHelpers::Join(output_log, "\n").c_str() << std::endl;
}
}
};
} // namespace common
} // namespace vksamples | 31.902778 | 118 | 0.598607 |
ff56a1c6bf11e896b5311ed2a6343688046a00a0 | 537 | h | C | swift/Flare/Flare/Flare.h | CiscoDevNet/flare | def72b74961a27c441f31039b4c3b1c61a870f1d | [
"Apache-2.0"
] | 18 | 2015-10-29T13:02:09.000Z | 2021-11-15T15:34:34.000Z | swift/Flare/Flare/Flare.h | CiscoDevNet/flare | def72b74961a27c441f31039b4c3b1c61a870f1d | [
"Apache-2.0"
] | 4 | 2015-11-03T17:29:29.000Z | 2016-03-31T13:41:16.000Z | swift/Flare/Flare/Flare.h | CiscoDevNet/flare | def72b74961a27c441f31039b4c3b1c61a870f1d | [
"Apache-2.0"
] | 11 | 2015-10-28T14:13:37.000Z | 2021-11-15T15:34:36.000Z | //
// Flare.h
// Flare
//
// Created by Andrew Zamler-Carhart on 8/14/15.
// Copyright (c) 2015 Andrew Zamler-Carhart. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
//! Project version number for Flare.
FOUNDATION_EXPORT double FlareVersionNumber;
//! Project version string for Flare.
FOUNDATION_EXPORT const unsigned char FlareVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Flare/PublicHeader.h>
| 25.571429 | 130 | 0.757914 |
ff57d992b111d7bec09ada1ef251aa8391fd38f4 | 521 | h | C | XVim2/XcodeHeader/IDESourceEditor/_TtC15IDESourceEditor31StaticAnalyzerStepVisualization.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 2,453 | 2017-09-07T00:07:49.000Z | 2022-03-29T22:32:10.000Z | XVim2/XcodeHeader/IDESourceEditor/_TtC15IDESourceEditor31StaticAnalyzerStepVisualization.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 373 | 2017-09-20T04:16:11.000Z | 2022-03-26T17:01:37.000Z | XVim2/XcodeHeader/IDESourceEditor/_TtC15IDESourceEditor31StaticAnalyzerStepVisualization.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 260 | 2017-09-16T15:31:41.000Z | 2022-02-07T02:52:29.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 30 2020 21:18:12).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <objc/NSObject.h>
#import <IDESourceEditor/CALayerDelegate-Protocol.h>
@class MISSING_TYPE;
__attribute__((visibility("hidden")))
@interface _TtC15IDESourceEditor31StaticAnalyzerStepVisualization : NSObject <CALayerDelegate>
{
MISSING_TYPE *visualization;
MISSING_TYPE *stepLayers;
MISSING_TYPE *hitTestViews;
}
- (void).cxx_destruct;
- (id)init;
@end
| 20.038462 | 94 | 0.735125 |
ff581ba1b85fc53efd8c2bcb24a1b617e60ec9ce | 734 | h | C | Wikipedia/Code/UIImage+ColorMask.h | jindulys/Wikipedia | 78609a2397ff1d5826443a65d40ebd491e68678c | [
"MIT"
] | 1 | 2016-10-10T14:39:30.000Z | 2016-10-10T14:39:30.000Z | Wikipedia/Code/UIImage+ColorMask.h | jindulys/Wikipedia | 78609a2397ff1d5826443a65d40ebd491e68678c | [
"MIT"
] | null | null | null | Wikipedia/Code/UIImage+ColorMask.h | jindulys/Wikipedia | 78609a2397ff1d5826443a65d40ebd491e68678c | [
"MIT"
] | null | null | null | // Created by Monte Hurd and Adam Baso on 2/13/14.
// Copyright (c) 2013 Wikimedia Foundation. Provided under MIT-style license; please copy and modify!
#import <UIKit/UIKit.h>
@interface UIImage (ColorMask)
// Pass this method a color and it will return an image based on this image
// but with any parts which were not transparent changed to be "color". This is
// handier that it sounds for fine-tuning the appearance of button images without
// the need for regenerating new pngs. Because of the way the filter is set
// up below, this method can be called repeatedly w/no image quality degradation.
// Intended for use with images which don't have gradients / shadows.
- (UIImage*)getImageOfColor:(CGColorRef)CGColor;
@end
| 43.176471 | 102 | 0.76158 |
ff58a2ad622b7eddeca660e297babbb3b71d9564 | 1,976 | h | C | admin/wmi/wbem/winmgmt/wbemtest/wt_converter.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | admin/wmi/wbem/winmgmt/wbemtest/wt_converter.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | admin/wmi/wbem/winmgmt/wbemtest/wt_converter.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*++
Copyright (C) 1998-2001 Microsoft Corporation
Module Name:
Converter.h
Abstract:
interface for the CConverter class.
History:
9/15/98 Created
9/22/98 Removed Convert(ULONG); Added Convert(CVar) & Convert(CVarVector)
--*/
#ifndef __CONVERTER_H
#define __CONVERTER_H
#define ERR_NOERROR 0x00000000
#define ERR_UNKNOWN 0x00000001
#define ERR_INVALID_SIGNED_VALUE 0x00000002
#define ERR_INVALID_TOKEN 0x00000003
#define ERR_OUT_OF_RANGE 0x00000004
#define ERR_NULL_CIMTYPE 0x00000005
#define ERR_INVALID_INPUT_STRING 0x00000006
#define ERR_NULL_TOKEN 0x00000007
#define ERR_UNKNOWN_BASE 0x00000008
#define ERR_UNMATCHED_BRACE 0x00000009
#define BASE_DEC 10
#define BASE_HEX 16
typedef long CIMType;
class CConverter
{
CIMType m_ct; // CIM type
char* m_szString; // Input string
// char* m_szCurrent; // Current token pointer
CConverter(const char* szString, CIMType ct);
virtual ~CConverter();
UINT SetBoundary(BOOL bNeg, ULONG *uMaxSize);
BOOL Done(char *ch);
BOOL Separator();
BOOL IsValidDec(char ch);
BOOL IsValidHex(char ch);
char PeekToken(char *ch);
BOOL GetToken(char **ch);
void ReplaceToken(char **ch);
UINT Token_Sequence(CVarVector *pVarVec);
UINT Token_Sequence(CVar *pVar);
UINT Token_Number(char **ch, CVar *pVar);
UINT Token_Digit(char **ch, ULONG *ulRes);
UINT Token_Separator(char **ch);
UINT Token_DecField(char **ch, BOOL bNeg, ULONG *pVal);
UINT Token_HexField(char **ch, BOOL bNeg, ULONG *pVal);
UINT Token_DecDigit(char **ch, ULONG *pVal);
UINT Token_HexDigit(char **ch, ULONG *pVal);
UINT Token_Comment(char **ch);
UINT Token_WhiteSpace(char **ch);
public:
static UINT Convert(const char* szString, CIMType ct, ULONG *ulRes);
static UINT Convert(const char* szString, CIMType ct, CVar *pVar);
static UINT Convert(const char* szString, CIMType ct, CVarVector *pVarVec);
};
#endif //__CONVERTER_H
| 26.346667 | 77 | 0.722166 |
ff5abd8168ad0c0a5775ca0a1746af2f8d80f385 | 1,371 | c | C | base-usage/systemcall/memory_map.c | sczzq/symmetrical-spoon | aa0c27bb40a482789c7c6a7088307320a007b49b | [
"Unlicense"
] | null | null | null | base-usage/systemcall/memory_map.c | sczzq/symmetrical-spoon | aa0c27bb40a482789c7c6a7088307320a007b49b | [
"Unlicense"
] | null | null | null | base-usage/systemcall/memory_map.c | sczzq/symmetrical-spoon | aa0c27bb40a482789c7c6a7088307320a007b49b | [
"Unlicense"
] | null | null | null | /*************************************************************************
> File Name: memory_map.c
> Author: ziqiang
> Mail: ziqiang_free@163.com
> Created Time: Thu 25 May 2017 10:07:33 PM CST
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
int a;
int b = 0;
static int c = 1;
int foo(int);
int h(int);
int foo(int arg)
{
printf("function address: %p\n", &foo);
printf("in function foo, argument address %p\n", &arg);
char a[100] = {0};
printf("in function foo, local variable address %p\n", a);
char* p = (char *)malloc(100);
printf("in function foo, malloc address %p\n", p);
free(p);
h(1);
return 0;
}
int h(int arg)
{
printf("function address: %p\n", &h);
printf("in function h, argument address %p\n", &arg);
char a[100] = {0};
printf("in function h, local variable address %p\n", a);
char* p = (char *)malloc(100);
printf("in function h, malloc address %p\n", p);
free(p);
static int hha = 0;
printf("in function h, static variable address %p\n", &hha);
return 0;
}
int main(int argc, char* argv[])
{
printf("main function address %p\n", &main);
printf("in main, argument address %p, %p\n", &argc, argv);
printf("global variable address %p\n", &a);
printf("global variable address %p\n", &b);
printf("global variable address %p\n", &c);
foo(1);
h(1);
}
| 22.47541 | 74 | 0.563093 |
ff5acebae65de6a17827442cd565bb4424fbd6d4 | 272 | h | C | Toggles/DarkThemeToggle/UIUserInterfaceStyleArbiter.h | Shade-Zepheri/Nougat | 2cb7dd244a1a39918b484a99101808266d366b9d | [
"Apache-2.0"
] | 46 | 2018-02-26T03:01:45.000Z | 2022-02-13T03:37:52.000Z | Toggles/DarkThemeToggle/UIUserInterfaceStyleArbiter.h | Mighel881/Nougat | ad7d16084c44ddac436861cb8d77525a0a340f80 | [
"Apache-2.0"
] | 12 | 2018-08-09T05:38:00.000Z | 2021-04-11T14:14:31.000Z | Toggles/DarkThemeToggle/UIUserInterfaceStyleArbiter.h | Mighel881/Nougat | ad7d16084c44ddac436861cb8d77525a0a340f80 | [
"Apache-2.0"
] | 13 | 2018-08-11T06:10:27.000Z | 2021-12-29T08:45:38.000Z | #import <UIKit/UIKit.h>
// Private header to get and set state
@interface UIUserInterfaceStyleArbiter : NSObject
@property (readonly, nonatomic) UIUserInterfaceStyle currentStyle NS_AVAILABLE_IOS(13.0);
+ (instancetype)sharedInstance;
- (void)toggleCurrentStyle;
@end | 24.727273 | 90 | 0.797794 |
ff5cffaa8a4bfbb1e0043d13a15be74afa808bbb | 2,331 | c | C | usr/src/libI77/util.c | r1mikey/research-unix-v7 | 8b0bf75e2f5cf013ff7f236c4589711cbc3a12ff | [
"MIT"
] | 43 | 2020-02-12T08:14:49.000Z | 2022-03-30T19:25:52.000Z | usr/src/libI77/util.c | r1mikey/research-unix-v7 | 8b0bf75e2f5cf013ff7f236c4589711cbc3a12ff | [
"MIT"
] | null | null | null | usr/src/libI77/util.c | r1mikey/research-unix-v7 | 8b0bf75e2f5cf013ff7f236c4589711cbc3a12ff | [
"MIT"
] | 6 | 2020-02-13T12:56:27.000Z | 2022-02-11T20:59:46.000Z | #include <sys/types.h>
#include <sys/stat.h>
#include <sys/dir.h>
#include "fio.h"
#define DIRSIZE 14
g_char(a,alen,b) char *a,*b; ftnlen alen;
{ char *x=a+alen-1,*y=b+alen-1;
*(y+1)=0;
for(;x>=a && *x==' ';x--) *y--=0;
for(;x>=a;*y--= *x--);
}
b_char(a,b,blen) char *a,*b; ftnlen blen;
{ int i;
for(i=0;i<blen && *a!=0;i++) *b++= *a++;
for(;i<blen;i++) *b++=' ';
}
inode(a) char *a;
{ struct stat x;
if(stat(a,&x)<0) return(-1);
return(x.st_ino);
}
#define DONE {*bufpos++=0; close(file); return;}
#define INTBOUND sizeof(int)-1
#define register
mvgbt(n,len,a,b) char *a,*b;
{ register int num=n*len;
if( ((int)a&INTBOUND)==0 && ((int)b&INTBOUND)==0 && (num&INTBOUND)==0 )
{ register int *x=(int *)a,*y=(int *)b;
num /= sizeof(int);
if(x>y) for(;num>0;num--) *y++= *x++;
else for(num--;num>=0;num--) *(y+num)= *(x+num);
}
else
{ register char *x=a,*y=b;
if(x>y) for(;num>0;num--) *y++= *x++;
else for(num--;num>=0;num--) *(y+num)= *(x+num);
}
}
char *curdir()
{ char name[256],*bufpos = name;
struct stat x;
struct direct y;
int file,i;
*bufpos++ = 0;
loop: stat(".",&x);
if((file=open("..",0))<0) goto done;
do
{ if(read(file,&y,sizeof(y))<sizeof(y)) goto done;
} while(y.d_ino!=x.st_ino);
close(file);
if(y.d_ino!=2)
{ dcat(name,y.d_name);
chdir("..");
goto loop;
}
if(stat(y.d_name,&x)<0 || chdir("/")<0
|| (file=open("/",0))<0) goto done;
i=x.st_dev;
do
{ if(read(file,&y,sizeof(y))<sizeof(y)) goto done;
if(y.d_ino==0) continue;
if(stat(y.d_name,&x)<0) goto done;
} while(x.st_dev!=i || (x.st_mode&S_IFMT)!=S_IFDIR);
if(strcmp(".",y.d_name) || strcmp("..",y.d_name))
dcat(name,y.d_name);
dcat(name,"/");
done:
bufpos=calloc(strlen(name)+1,1);
strcpy(bufpos,name);
chdir(name);
close(file);
return(bufpos);
}
dcat(a,b) char *a,*b;
{
int i,j;
i=strlen(b);
j=strlen(a);
mvgbt(1,j+1,a,a+i+1);
mvgbt(1,i,b,a);
a[i]='/';
}
fullpath(a,b,errflag) char *a,*b;
{
char *a1,*a2,*npart,*dpart,*p;
a1=curdir();
npart=NULL;
for(p=a;*p!=0;p++)
if(*p=='/') npart=p;
if(npart==NULL)
{ dpart=NULL;
npart=a;
}
else
{ dpart=a;
*npart++ = 0;
}
if(dpart!=NULL)
{ chdir(dpart);
a2=curdir();
strcpy(b,a2);
}
else
{ a2=NULL;
strcpy(b, a1);
}
strcat(b,npart);
chdir(a1);
if(a1!=NULL)
{ free(a1);
a1=NULL;
}
if(a2!=NULL)
{ free(a2);
}
return(0);
}
| 19.754237 | 72 | 0.555127 |
ff5e9038b81d6b6394579fde8085cd034ff29596 | 19,719 | c | C | src/TimeIntegration/TimeGLMGEEInitialize.c | LLNL/mhysa | e97d841191718cfa6d81b38d904340e2c753df85 | [
"MIT"
] | 12 | 2020-03-16T16:50:03.000Z | 2022-03-20T10:09:10.000Z | src/TimeIntegration/TimeGLMGEEInitialize.c | zhangzhg0508/mhysa | e97d841191718cfa6d81b38d904340e2c753df85 | [
"MIT"
] | null | null | null | src/TimeIntegration/TimeGLMGEEInitialize.c | zhangzhg0508/mhysa | e97d841191718cfa6d81b38d904340e2c753df85 | [
"MIT"
] | 4 | 2020-03-16T16:50:04.000Z | 2021-06-04T05:36:45.000Z | /*! @file TimeGLMGEEInitialize.c
@brief Initialize the #_GLM_GEE_ time integrator
@author Debojyoti Ghosh
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <basic.h>
#include <matops.h>
#include <arrayfunctions.h>
#include <mpivars.h>
#include <timeintegration.h>
/*!
Initialize the GLM-GEE (#_GLM_GEE_) time integation method: This function
allocates the arrays to store the Butcher tableaux, and sets their
coefficients, as well as other parameters for the GLM-GEE methods.
Reference:
+ Constantinescu, E. M., "Estimating Global Errors in Time Stepping.", Submitted,
2015 (http://arxiv.org/abs/1503.05166).
*/
int TimeGLMGEEInitialize(
char *class, /*!< Class of time integration method; must match #_GLM_GEE_ */
char *type, /*!< Name of the #_GLM_GEE_ method to use */
void *s, /*!< Object of type #GLMGEEParameters */
void *m /*!< MPI object of type #MPIVariables */
)
{
GLMGEEParameters *params = (GLMGEEParameters*) s;
MPIVariables *mpi = (MPIVariables*) m;
int i,j;
if (!strcmp(class,_GLM_GEE_)) {
if (!strcmp(type,_GLM_GEE_23_)) {
params->nstages = 3;
params->r = 2;
params->gamma = 0.0;
} else if (!strcmp(type,_GLM_GEE_24_)) {
params->nstages = 4;
params->r = 2;
params->gamma = 0.0;
} else if (!strcmp(type,_GLM_GEE_25I_)) {
params->nstages = 5;
params->r = 2;
params->gamma = 0.0;
} else if (!strcmp(type,_GLM_GEE_35_)) {
params->nstages = 5;
params->r = 2;
params->gamma = 0.0;
} else if (!strcmp(type,_GLM_GEE_EXRK2A_)) {
params->nstages = 6;
params->r = 2;
params->gamma = 0.25;
} else if (!strcmp(type,_GLM_GEE_RK32G1_)) {
params->nstages = 8;
params->r = 2;
params->gamma = 0.0;
} else if (!strcmp(type,_GLM_GEE_RK285EX_)) {
params->nstages = 9;
params->r = 2;
params->gamma = 0.25;
} else {
fprintf(stderr,"Error in TimeGLMGEEInitialize(): %s is not a supported ",type);
fprintf(stderr,"multi-stage time integration scheme of class %s.\n",class);
return(1);
}
int s = params->nstages;
int r = params->r;
params->A_yyt = (double*) calloc (s*s,sizeof(double));
params->B_yyt = (double*) calloc (s*r,sizeof(double));
params->C_yyt = (double*) calloc (s*r,sizeof(double));
params->D_yyt = (double*) calloc (r*r,sizeof(double));
params->c_yyt = (double*) calloc (s ,sizeof(double));
_ArraySetValue_(params->A_yyt,s*s,0.0);
_ArraySetValue_(params->B_yyt,s*r,0.0);
_ArraySetValue_(params->C_yyt,s*r,0.0);
_ArraySetValue_(params->D_yyt,r*r,0.0);
_ArraySetValue_(params->c_yyt,s ,0.0);
params->A_yeps = (double*) calloc (s*s,sizeof(double));
params->B_yeps = (double*) calloc (s*r,sizeof(double));
params->C_yeps = (double*) calloc (s*r,sizeof(double));
params->D_yeps = (double*) calloc (r*r,sizeof(double));
params->c_yeps = (double*) calloc (s ,sizeof(double));
_ArraySetValue_(params->A_yeps,s*s,0.0);
_ArraySetValue_(params->B_yeps,s*r,0.0);
_ArraySetValue_(params->C_yeps,s*r,0.0);
_ArraySetValue_(params->D_yeps,r*r,0.0);
_ArraySetValue_(params->c_yeps,s ,0.0);
if (!strcmp(type,_GLM_GEE_23_)) {
params->A_yeps[1*s+0] = 1.0;
params->A_yeps[2*s+0] = params->A_yeps[2*s+1] = 0.25;
params->B_yeps[0*s+0] = params->B_yeps[0*s+1] = 1.0/12.0; params->B_yeps[0*s+2] = 5.0/6.0;
params->B_yeps[1*s+0] = params->B_yeps[1*s+1] = 1.0/12.0; params->B_yeps[1*s+2] = -1.0/6.0;
params->C_yeps[0*r+0] = 1.0;
params->C_yeps[1*r+0] = 1.0; params->C_yeps[1*r+1] = 10.0;
params->C_yeps[2*r+0] = 1.0; params->C_yeps[2*r+1] = -1.0;
params->D_yeps[0*r+0] = 1.0;
params->D_yeps[1*r+1] = 1.0;
params->A_yyt[1*s+0] = 1.0;
params->A_yyt[2*s+0] = params->A_yyt[2*s+1] = 0.25;
params->B_yyt[0*s+0] = params->B_yyt[0*s+1] = 1.0/12.0; params->B_yyt[0*s+2] = 5.0/6.0;
params->B_yyt[1*s+0] = params->B_yyt[1*s+1] = 1.0/6.0; params->B_yyt[1*s+2] = 2.0/3.0;
params->C_yyt[0*r+0] = 1.0;
params->C_yyt[1*r+0] = -9.0; params->C_yyt[1*r+1] = 10.0;
params->C_yyt[2*r+0] = 2.0; params->C_yyt[2*r+1] = -1.0;
params->D_yyt[0*r+0] = 1.0;
params->D_yyt[1*r+1] = 1.0;
} else if (!strcmp(type,_GLM_GEE_24_)) {
params->A_yyt[1*s+0] = 0.75;
params->A_yyt[2*s+0] = 0.25;
params->A_yyt[2*s+1] = 29.0/60.0;
params->A_yyt[3*s+0] = -21.0/44.0;
params->A_yyt[3*s+1] = 145.0/44.0;
params->A_yyt[3*s+2] = -20.0/11.0;
params->B_yyt[0*s+0] = 109.0/275.0;
params->B_yyt[0*s+1] = 58.0/75.0;
params->B_yyt[0*s+2] = -37.0/110.0;
params->B_yyt[0*s+3] = 1.0/6.0;
params->B_yyt[1*s+0] = 3.0/11.0;
params->B_yyt[1*s+2] = 75.0/88.0;
params->B_yyt[1*s+3] = -1.0/8.0;
params->C_yyt[0*r+1] = 1.0;
params->C_yyt[1*r+0] = 75.0/58.0;
params->C_yyt[1*r+1] = -17.0/58.0;
params->C_yyt[2*r+1] = params->C_yyt[3*r+1] = 1.0;
params->D_yyt[0*r+0] = 1.0;
params->D_yyt[1*r+1] = 1.0;
double T[r*r],Tinv[r*r];
T[0*r+0] = 1.0;
T[0*r+1] = 0.0;
T[1*r+0] = 1.0;
T[1*r+1] = 1.0-params->gamma;
_MatrixInvert_(T,Tinv,r);
_ArrayCopy1D_(params->A_yyt,params->A_yeps,(s*s));
_MatrixMultiplyNonSquare_(Tinv,params->B_yyt,params->B_yeps,r,r,s);
_MatrixMultiplyNonSquare_(params->C_yyt,T,params->C_yeps,s,r,r);
_ArrayCopy1D_(params->D_yyt,params->D_yeps,(r*r));
} else if (!strcmp(type,_GLM_GEE_25I_)) {
params->A_yyt[1*s+0]=-0.94079244066783383269;
params->A_yyt[2*s+0]= 0.64228187778301907108;
params->A_yyt[2*s+1]= 0.10915356933958500042;
params->A_yyt[3*s+0]=-0.51764297742287450812;
params->A_yyt[3*s+1]= 0.74414270351096040738;
params->A_yyt[3*s+2]=-0.71404164927824538121;
params->A_yyt[4*s+0]=-0.44696561556825969206;
params->A_yyt[4*s+1]=-0.76768425657590196518;
params->A_yyt[4*s+2]= 0.20111608138142987881;
params->A_yyt[4*s+3]= 0.93828186737840469796;
params->B_yyt[0*s+0]=-0.029309178948150356153;
params->B_yyt[0*s+1]=-0.49671981884013874923;
params->B_yyt[0*s+2]= 0.34275801517650053274;
params->B_yyt[0*s+3]= 0.32941112623949194988;
params->B_yyt[0*s+4]= 0.85385985637229662276;
params->B_yyt[1*s+0]= 0.78133219686062535272;
params->B_yyt[1*s+1]= 0.074238691892675897635;
params->B_yyt[1*s+2]= 0.57957363498384957966;
params->B_yyt[1*s+3]=-0.24638502829674959968;
params->B_yyt[1*s+4]=-0.18875949544040123033;
params->C_yyt[0*r+0]= 0.16911424754448327735;
params->C_yyt[0*r+1]= 0.83088575245551672265;
params->C_yyt[1*r+0]= 0.53638465733199574340;
params->C_yyt[1*r+1]= 0.46361534266800425660;
params->C_yyt[2*r+0]= 0.39901579167169582526;
params->C_yyt[2*r+1]= 0.60098420832830417474;
params->C_yyt[3*r+0]= 0.87689005530618575480;
params->C_yyt[3*r+1]= 0.12310994469381424520;
params->C_yyt[4*r+0]= 0.99056100455550913009;
params->C_yyt[4*r+1]= 0.0094389954444908699092;
params->D_yyt[0*r+0] = 1.0;
params->D_yyt[1*r+1] = 1.0;
double T[r*r],Tinv[r*r];
T[0*r+0] = 1.0;
T[0*r+1] = 0.0;
T[1*r+0] = 1.0;
T[1*r+1] = 1.0-params->gamma;
_MatrixInvert_(T,Tinv,r);
_ArrayCopy1D_(params->A_yyt,params->A_yeps,(s*s));
_MatrixMultiplyNonSquare_(Tinv,params->B_yyt,params->B_yeps,r,r,s);
_MatrixMultiplyNonSquare_(params->C_yyt,T,params->C_yeps,s,r,r);
_ArrayCopy1D_(params->D_yyt,params->D_yeps,(r*r));
} else if (!strcmp(type,_GLM_GEE_35_)) {
params->A_yyt[1*s+0] = - 2169604947363702313.0 / 24313474998937147335.0;
params->A_yyt[2*s+0] = 46526746497697123895.0 / 94116917485856474137.0;
params->A_yyt[2*s+1] = -10297879244026594958.0 / 49199457603717988219.0;
params->A_yyt[3*s+0] = 23364788935845982499.0 / 87425311444725389446.0;
params->A_yyt[3*s+1] = -79205144337496116638.0 / 148994349441340815519.0;
params->A_yyt[3*s+2] = 40051189859317443782.0 / 36487615018004984309.0;
params->A_yyt[4*s+0] = 42089522664062539205.0 / 124911313006412840286.0;
params->A_yyt[4*s+1] = -15074384760342762939.0 / 137927286865289746282.0;
params->A_yyt[4*s+2] = -62274678522253371016.0 / 125918573676298591413.0;
params->A_yyt[4*s+3] = 13755475729852471739.0 / 79257927066651693390.0;
params->B_yyt[0*s+0] = 61546696837458703723.0 / 56982519523786160813.0;
params->B_yyt[0*s+1] = -55810892792806293355.0 / 206957624151308356511.0;
params->B_yyt[0*s+2] = 24061048952676379087.0 / 158739347956038723465.0;
params->B_yyt[0*s+3] = 3577972206874351339.0 / 7599733370677197135.0;
params->B_yyt[0*s+4] = -59449832954780563947.0 / 137360038685338563670.0;
params->B_yyt[1*s+0] = - 9738262186984159168.0 / 99299082461487742983.0;
params->B_yyt[1*s+1] = -32797097931948613195.0 / 61521565616362163366.0;
params->B_yyt[1*s+2] = 42895514606418420631.0 / 71714201188501437336.0;
params->B_yyt[1*s+3] = 22608567633166065068.0 / 55371917805607957003.0;
params->B_yyt[1*s+4] = 94655809487476459565.0 / 151517167160302729021.0;
params->C_yyt[0*r+0] = 70820309139834661559.0 / 80863923579509469826.0;
params->C_yyt[0*r+1] = 10043614439674808267.0 / 80863923579509469826.0;
params->C_yyt[1*r+0] = 161694774978034105510.0 / 106187653640211060371.0;
params->C_yyt[1*r+1] = -55507121337823045139.0 / 106187653640211060371.0;
params->C_yyt[2*r+0] = 78486094644566264568.0 / 88171030896733822981.0;
params->C_yyt[2*r+1] = 9684936252167558413.0 / 88171030896733822981.0;
params->C_yyt[3*r+0] = 65394922146334854435.0 / 84570853840405479554.0;
params->C_yyt[3*r+1] = 19175931694070625119.0 / 84570853840405479554.0;
params->C_yyt[4*r+0] = 8607282770183754108.0 / 108658046436496925911.0;
params->C_yyt[4*r+1] = 100050763666313171803.0 / 108658046436496925911.0;
params->D_yyt[0*r+0] = 1.0;
params->D_yyt[1*r+1] = 1.0;
double T[r*r],Tinv[r*r];
T[0*r+0] = 1.0;
T[0*r+1] = 0.0;
T[1*r+0] = 1.0;
T[1*r+1] = 1.0-params->gamma;
_MatrixInvert_(T,Tinv,r);
_ArrayCopy1D_(params->A_yyt,params->A_yeps,(s*s));
_MatrixMultiplyNonSquare_(Tinv,params->B_yyt,params->B_yeps,r,r,s);
_MatrixMultiplyNonSquare_(params->C_yyt,T,params->C_yeps,s,r,r);
_ArrayCopy1D_(params->D_yyt,params->D_yeps,(r*r));
} else if (!strcmp(type,_GLM_GEE_EXRK2A_)) {
params->A_yeps[1*s+0] = 1.0;
params->A_yeps[3*s+2] = 0.5;
params->A_yeps[4*s+2] = 0.25;
params->A_yeps[4*s+3] = 0.25;
params->A_yeps[5*s+2] = 0.25;
params->A_yeps[5*s+3] = 0.25;
params->A_yeps[5*s+4] = 0.5;
params->B_yeps[0*s+0] = params->B_yeps[0*s+1] = 0.5;
params->B_yeps[1*s+0] = params->B_yeps[1*s+1] = -2.0/3.0;
params->B_yeps[1*s+2] = params->B_yeps[1*s+3] = params->B_yeps[1*s+4]
= params->B_yeps[1*s+5] = 1.0/3.0;
params->C_yeps[0*r+0] = 1.0;
params->C_yeps[1*r+0] = 1.0;
params->C_yeps[2*r+0] = 1.0; params->C_yeps[2*r+1] = 0.75;
params->C_yeps[3*r+0] = 1.0; params->C_yeps[3*r+1] = 0.75;
params->C_yeps[4*r+0] = 1.0; params->C_yeps[4*r+1] = 0.75;
params->C_yeps[5*r+0] = 1.0; params->C_yeps[5*r+1] = 0.75;
params->D_yeps[0*r+0] = 1.0;
params->D_yeps[1*r+1] = 1.0;
params->A_yyt[1*s+0] = 1.0;
params->A_yyt[3*s+2] = 0.5;
params->A_yyt[4*s+2] = 0.25;
params->A_yyt[4*s+3] = 0.25;
params->A_yyt[5*s+2] = 0.25;
params->A_yyt[5*s+3] = 0.25;
params->A_yyt[5*s+4] = 0.5;
params->B_yyt[0*s+0] = params->B_yyt[0*s+1] = 0.5;
params->B_yyt[1*s+2] = params->B_yyt[1*s+3] = params->B_yyt[1*s+4]
= params->B_yyt[1*s+5] = 0.25;
params->C_yyt[0*r+0] = 1.0;
params->C_yyt[1*r+0] = 1.0;
params->C_yyt[2*r+1] = 1.0;
params->C_yyt[3*r+1] = 1.0;
params->C_yyt[4*r+1] = 1.0;
params->C_yyt[5*r+1] = 1.0;
params->D_yyt[0*r+0] = 1.0;
params->D_yyt[1*r+1] = 1.0;
} else if (!strcmp(type,_GLM_GEE_RK32G1_)) {
params->A_yeps[1*s+0] = 0.5;
params->A_yeps[2*s+0] = -1.0;
params->A_yeps[2*s+1] = 2.0;
params->A_yeps[3*s+0] = 1.0/6.0;
params->A_yeps[3*s+1] = 2.0/3.0;
params->A_yeps[3*s+2] = 1.0/6.0;
params->A_yeps[5*s+0] = -7.0/24.0;
params->A_yeps[5*s+1] = 1.0/3.0;
params->A_yeps[5*s+2] = 1.0/12.0;
params->A_yeps[5*s+3] = -1.0/8.0;
params->A_yeps[5*s+4] = 0.5;
params->A_yeps[6*s+0] = 7.0/6.0;
params->A_yeps[6*s+1] = -4.0/3.0;
params->A_yeps[6*s+2] = -1.0/3.0;
params->A_yeps[6*s+3] = 0.5;
params->A_yeps[6*s+4] = -1.0;
params->A_yeps[6*s+5] = 2.0;
params->A_yeps[7*s+4] = 1.0/6.0;
params->A_yeps[7*s+5] = 2.0/3.0;
params->A_yeps[7*s+6] = 1.0/6.0;
params->B_yeps[0*s+0] = 1.0/6.0;
params->B_yeps[0*s+1] = 2.0/3.0;
params->B_yeps[0*s+2] = 1.0/6.0;
params->B_yeps[1*s+0] = -1.0/6.0;
params->B_yeps[1*s+1] = -2.0/3.0;
params->B_yeps[1*s+2] = -1.0/6.0;
params->B_yeps[1*s+4] = 1.0/6.0;
params->B_yeps[1*s+5] = 2.0/3.0;
params->B_yeps[1*s+6] = 1.0/6.0;
params->C_yeps[0*r+0] = 1.0;
params->C_yeps[1*r+0] = 1.0;
params->C_yeps[2*r+0] = 1.0;
params->C_yeps[3*r+0] = 1.0;
params->C_yeps[4*r+0] = 1.0;
params->C_yeps[5*r+0] = 1.0;
params->C_yeps[6*r+0] = 1.0;
params->C_yeps[7*r+0] = 1.0;
params->C_yeps[4*r+1] = 1.0;
params->C_yeps[5*r+1] = 1.0;
params->C_yeps[6*r+1] = 1.0;
params->C_yeps[7*r+1] = 1.0;
params->D_yeps[0*r+0] = 1.0;
params->D_yeps[1*r+1] = 1.0;
double T[r*r],Tinv[r*r];
T[0*r+0] = 1.0;
T[0*r+1] = 0.0;
T[1*r+0] = 1.0;
T[1*r+1] = 1.0-params->gamma;
_MatrixInvert_(T,Tinv,r);
_ArrayCopy1D_(params->A_yeps,params->A_yyt,(s*s));
_MatrixMultiplyNonSquare_(T,params->B_yeps,params->B_yyt,r,r,s);
_MatrixMultiplyNonSquare_(params->C_yeps,Tinv,params->C_yyt,s,r,r);
_ArrayCopy1D_(params->D_yeps,params->D_yyt,(r*r));
} else if (!strcmp(type,_GLM_GEE_RK285EX_)) {
params->A_yeps[1*s+0] = 0.585786437626904966;
params->A_yeps[2*s+0] = 0.149999999999999994;
params->A_yeps[2*s+1] = 0.849999999999999978;
params->A_yeps[4*s+3] = 0.292893218813452483;
params->A_yeps[5*s+3] = 0.0749999999999999972;
params->A_yeps[5*s+4] = 0.424999999999999989;
params->A_yeps[6*s+3] = 0.176776695296636893;
params->A_yeps[6*s+4] = 0.176776695296636893;
params->A_yeps[6*s+5] = 0.146446609406726241;
params->A_yeps[7*s+3] = 0.176776695296636893;
params->A_yeps[7*s+4] = 0.176776695296636893;
params->A_yeps[7*s+5] = 0.146446609406726241;
params->A_yeps[7*s+6] = 0.292893218813452483;
params->A_yeps[8*s+3] = 0.176776695296636893;
params->A_yeps[8*s+4] = 0.176776695296636893;
params->A_yeps[8*s+5] = 0.146446609406726241;
params->A_yeps[8*s+6] = 0.0749999999999999972;
params->A_yeps[8*s+7] = 0.424999999999999989;
params->B_yeps[0*s+0] = 0.353553390593273786;
params->B_yeps[0*s+1] = 0.353553390593273786;
params->B_yeps[0*s+2] = 0.292893218813452483;
params->B_yeps[1*s+0] =-0.471404520791031678;
params->B_yeps[1*s+1] =-0.471404520791031678;
params->B_yeps[1*s+2] =-0.390524291751269959;
params->B_yeps[1*s+3] = 0.235702260395515839;
params->B_yeps[1*s+4] = 0.235702260395515839;
params->B_yeps[1*s+5] = 0.195262145875634979;
params->B_yeps[1*s+6] = 0.235702260395515839;
params->B_yeps[1*s+7] = 0.235702260395515839;
params->B_yeps[1*s+8] = 0.195262145875634979;
params->C_yeps[0*r+0] = 1.0;
params->C_yeps[1*r+0] = 1.0;
params->C_yeps[2*r+0] = 1.0;
params->C_yeps[3*r+0] = 1.0; params->C_yeps[3*r+1] = 0.75;
params->C_yeps[4*r+0] = 1.0; params->C_yeps[4*r+1] = 0.75;
params->C_yeps[5*r+0] = 1.0; params->C_yeps[5*r+1] = 0.75;
params->C_yeps[6*r+0] = 1.0; params->C_yeps[6*r+1] = 0.75;
params->C_yeps[7*r+0] = 1.0; params->C_yeps[7*r+1] = 0.75;
params->C_yeps[8*r+0] = 1.0; params->C_yeps[8*r+1] = 0.75;
params->D_yeps[0*r+0] = 1.0;
params->D_yeps[1*r+1] = 1.0;
double T[r*r],Tinv[r*r];
T[0*r+0] = 1.0;
T[0*r+1] = 0.0;
T[1*r+0] = 1.0;
T[1*r+1] = 1.0-params->gamma;
_MatrixInvert_(T,Tinv,r);
_ArrayCopy1D_(params->A_yeps,params->A_yyt,(s*s));
_MatrixMultiplyNonSquare_(T,params->B_yeps,params->B_yyt,r,r,s);
_MatrixMultiplyNonSquare_(params->C_yeps,Tinv,params->C_yyt,s,r,r);
_ArrayCopy1D_(params->D_yeps,params->D_yyt,(r*r));
}
for (i=0; i<s; i++) {
for (j=0; j<s; j++) {
params->c_yyt[i] += params->A_yyt [i*s+j];
params->c_yeps[i] += params->A_yeps[i*s+j];
}
}
if (!mpi->rank) {
FILE *in;
int ferr;
in = fopen("glm_gee.inp","r");
strcat(params->ee_mode,_GLM_GEE_YEPS_);
if (in) {
printf("Reading GLM-GEE method parameters from glm_gee.inp.\n");
char word[_MAX_STRING_SIZE_];
ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
if (!strcmp(word,"begin")) {
while (strcmp(word,"end")) {
ferr = fscanf(in,"%s",word); if (ferr != 1) return(1);
if (!strcmp(word,"ee_mode")) {
ferr = fscanf(in,"%s",params->ee_mode);
if (ferr != 1) return(1);
} else if (strcmp(word,"end")) {
char useless[_MAX_STRING_SIZE_];
ferr = fscanf(in,"%s",useless); if (ferr != 1) return(ferr);
printf("Warning: keyword %s in file \"glm_gee.inp\" with value %s not ",word,useless);
printf("recognized or extraneous. Ignoring.\n");
}
}
} else {
fprintf(stderr,"Error: Illegal format in file \"glm_gee.inp\".\n");
return(1);
}
fclose(in);
if (strcmp(params->ee_mode,_GLM_GEE_YEPS_) && strcmp(params->ee_mode,_GLM_GEE_YYT_)) {
fprintf(stderr,"Error in TimeGLMGEEInitialize(): %s is not a valid value for ",params->ee_mode);
fprintf(stderr,"ee_mode. Acceptable inputs are %s or %s.\n",_GLM_GEE_YEPS_,_GLM_GEE_YYT_);
strcat(params->ee_mode,_GLM_GEE_YEPS_);
}
}
printf("GLM-GEE time integration error estimation mode: %s\n",params->ee_mode);
}
IERR MPIBroadcast_character(params->ee_mode,_MAX_STRING_SIZE_,0,&mpi->world);
if (!strcmp(params->ee_mode,_GLM_GEE_YYT_)) {
params->A = params->A_yyt;
params->B = params->B_yyt;
params->C = params->C_yyt;
params->D = params->D_yyt;
params->c = params->c_yyt;
} else {
params->A = params->A_yeps;
params->B = params->B_yeps;
params->C = params->C_yeps;
params->D = params->D_yeps;
params->c = params->c_yeps;
}
} else {
fprintf(stderr,"Error in TimeGLMGEEInitialize(): Code should not have ");
fprintf(stderr,"reached here for %s class of time-integrators. This is a ",class);
fprintf(stderr,"coding mistake.\n");
return(1);
}
return(0);
}
| 39.125 | 106 | 0.583194 |
ff5f14b3ea3774f6c645b94abd4d9169f267fa39 | 35,712 | c | C | src/cparser.c | mwik/cliparser | 26896e48a0490ab5f2b6da9818cb4f9669114232 | [
"BSD-3-Clause"
] | 1 | 2017-10-21T16:42:08.000Z | 2017-10-21T16:42:08.000Z | src/cparser.c | mwik/cliparser | 26896e48a0490ab5f2b6da9818cb4f9669114232 | [
"BSD-3-Clause"
] | 1 | 2021-12-16T17:22:03.000Z | 2021-12-16T17:22:03.000Z | src/cparser.c | mwik/cliparser | 26896e48a0490ab5f2b6da9818cb4f9669114232 | [
"BSD-3-Clause"
] | 3 | 2016-04-13T07:16:48.000Z | 2021-12-29T01:49:46.000Z | /**
* \file cparser.c
* \brief parser top-level API
* \version \verbatim $Id: cparser.c 159 2011-10-29 09:29:58Z henry $ \endverbatim
*/
/*
* Copyright (c) 2008-2009, 2011, Henry Kwok
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY HENRY KWOK ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL HENRY KWOK BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "cparser.h"
#include "cparser_priv.h"
#include "cparser_token.h"
#include "cparser_io.h"
#include "cparser_fsm.h"
void
cparser_print_prompt (const cparser_t *parser)
{
assert(parser);
if (cparser_is_in_privileged_mode(parser)) {
parser->cfg.printc(parser, '+');
}
parser->cfg.prints(parser, parser->prompt[parser->root_level]);
}
/**
* \brief Print the description of a node out.
* \details For keyword nodes, the keyword itself is printed. For parameter
* nodes, a string of the form <[type]:[parameter]> is printed. For
* end nodes, \<LF\> is printed. This call should never be invoked with
* a root node.
*
* \param parser Pointer to the parser structure.
* \param node Pointer to the node to be printed.
* \param add_lf 1 to add LF before printing the node; 0 otherwise.
* \param print_desc 1 to print the description of the node; 0 otherwise.
*/
static void
cparser_help_print_node (cparser_t *parser, cparser_node_t *node,
const int add_lf, const int print_desc)
{
assert(parser && node);
if (!NODE_USABLE(parser, node)) {
return;
}
if (add_lf) {
parser->cfg.printc(parser, '\n');
}
switch (node->type) {
case CPARSER_NODE_ROOT:
assert(0); /* this should never happen */
case CPARSER_NODE_END:
parser->cfg.prints(parser, "<LF>");
break;
case CPARSER_NODE_LIST:
parser->cfg.prints(parser, "[ ");
cparser_list_node_t *lnode = (cparser_list_node_t *)node->param;
assert(lnode);
while (lnode) {
parser->cfg.prints(parser, lnode->keyword);
lnode = lnode->next;
if (lnode) {
parser->cfg.prints(parser, " | ");
}
}
parser->cfg.prints(parser, " ]");
break;
default:
parser->cfg.prints(parser, node->param);
if (print_desc && node->desc) {
parser->cfg.prints(parser, " - ");
parser->cfg.prints(parser, node->desc);
}
break;
}
}
/**
* \brief Print an error message due to some kind of parsing error.
*
* \param parser Pointer to the parser structure.
* \param msg Pointer to the error messsage string.
*
* \return None.
*/
static void
cparser_print_error (cparser_t *parser, const char *msg)
{
int n, m;
assert(parser && msg);
parser->cfg.printc(parser, '\n');
m = strlen(parser->prompt[parser->root_level]) + 1;
for (n = 0; n < m+parser->last_good; n++) {
parser->cfg.printc(parser, ' ');
}
parser->cfg.printc(parser, '^');
parser->cfg.prints(parser, msg);
}
/**
* \brief Reset the user input section of the parser structure.
*
* \param parser Pointer to the parser structure.
*/
static void
cparser_input_reset (cparser_t *parser)
{
assert(parser);
parser->user_buf = NULL;
parser->user_buf_size = 0;
parser->user_buf_count = 0;
parser->user_input_cb = NULL;
}
int
cparser_is_user_input (cparser_t *parser, int *do_echo)
{
assert(parser && do_echo);
if (parser->user_buf) {
assert(parser->user_input_cb && parser->user_buf_size);
*do_echo = parser->user_do_echo;
return 1;
}
assert(!parser->user_input_cb && !parser->user_buf_size);
*do_echo = 0;
return 0;
}
static void
cparser_record_command (cparser_t *parser, cparser_result_t rc)
{
assert(parser);
/* Save the state of the command */
parser->last_line_idx = CURRENT_LINE(parser);
parser->last_rc = rc;
parser->last_end_node = parser->cur_node;
}
/**
* \brief If the command is not complete, attempt to complete the command.
* If there is a complete comamnd, execute the glue (& action)
* function of a command.
*
* \param parser Pointer to the parser structure.
*
* \return CPARSER_OK if a valid command is executed; CPARSER_NOT_OK
* otherwise.
*/
static cparser_result_t
cparser_execute_cmd (cparser_t *parser)
{
int do_echo;
cparser_result_t rc = CPARSER_OK;
assert(VALID_PARSER(parser));
/*
* Enter a command. There are three possibilites:
* 1. If we are in WHITESPACE state, we check if there is
* only one child of keyword type. If yes, we recurse
* into it and repeat until either: a) there is more than
* one choice, b) We are at a END node. If there is more
* than one choice, we look for an END node. In either
* case, if an END node is found, we execute the action
* function.
*
* 2. If we are in TOKEN state, we check if we have an unique
* match. If yes, re recurse into it and repeat just
* like WHITESPACE state until we find an END node.
*
* 3. If we are in ERROR state, we print out an error.
*
* Afterward, we reset the parser state and move to the
* next line buffer.
*/
if ((CPARSER_STATE_TOKEN == parser->state) ||
(CPARSER_STATE_WHITESPACE == parser->state)) {
cparser_node_t *child;
if (CPARSER_STATE_TOKEN == parser->state) {
cparser_token_t *token;
cparser_node_t *match;
int is_complete;
token = CUR_TOKEN(parser);
if ((1 <= cparser_match(parser, token->buf, token->token_len,
parser->cur_node, &match,
&is_complete)) &&
(is_complete)) {
cparser_complete_fn fn = cparser_complete_fn_tbl[match->type];
if (fn) {
fn(parser, match, token->buf, token->token_len);
}
rc = cparser_input(parser, ' ', CPARSER_CHAR_REGULAR);
assert(CPARSER_OK == rc);
} else {
cparser_print_error(parser, "Incomplete command\n");
rc = CPARSER_ERR_INCOMP_CMD;
/* Reset the internal buffer, state and cur_node */
cparser_record_command(parser, rc);
cparser_fsm_reset(parser);
cparser_print_prompt(parser);
return rc;
}
}
/* Look for a single keyword node child */
child = parser->cur_node->children;
assert(child);
while ((CPARSER_NODE_KEYWORD == child->type) &&
NODE_USABLE(parser, child) && (!child->sibling)) {
cparser_token_t *token = CUR_TOKEN(parser);
cparser_complete_keyword(parser, child, token->buf, token->token_len);
rc = cparser_input(parser, ' ', CPARSER_CHAR_REGULAR);
assert(CPARSER_OK == rc);
child = parser->cur_node->children;
assert(child);
}
/* Look for an end node */
child = parser->cur_node->children;
while ((NULL != child) &&
!((CPARSER_NODE_END == child->type) && NODE_USABLE(parser, child))) {
child = child->sibling;
}
if (child) {
assert(CPARSER_NODE_END == child->type);
/* Execute the glue function */
parser->cur_node = child;
parser->cfg.printc(parser, '\n');
rc = ((cparser_glue_fn)child->param)(parser);
} else {
if (parser->token_tos) {
cparser_print_error(parser, "Incomplete command\n");
rc = CPARSER_ERR_INCOMP_CMD;
}
/* Reset FSM states and advance to the next line */
cparser_record_command(parser, rc);
cparser_fsm_reset(parser);
if (CPARSER_OK == rc) {
/* This is just a blank line */
parser->cfg.printc(parser, '\n');
}
cparser_print_prompt(parser);
return rc;
}
} else if (CPARSER_STATE_ERROR == parser->state) {
cparser_print_error(parser, "Parse error\n");
rc = CPARSER_ERR_PARSE_ERR;
}
/* Reset FSM states and advance to the next line */
cparser_record_command(parser, rc);
cparser_fsm_reset(parser);
if (!cparser_is_user_input(parser, &do_echo)) {
cparser_print_prompt(parser);
}
return rc;
}
static cparser_result_t
cparser_match_prefix (const cparser_t *parser, const char *token,
const int token_len, const cparser_node_t *parent,
const char ch, const int offset)
{
int local_is_complete;
cparser_node_t *child;
cparser_result_t rc;
assert(parent && ch);
for (child = parent->children; NULL != child; child = child->sibling) {
if (!NODE_USABLE(parser, child)) {
continue;
}
rc = cparser_match_fn_tbl[child->type](token, token_len, child,
&local_is_complete);
if (CPARSER_NOT_OK == rc) {
continue;
}
if (CPARSER_NODE_KEYWORD != child->type) {
return CPARSER_NOT_OK;
}
/* There is a match. Make sure that it is part of this node as well */
if (*((char *)child->param + offset) != ch) {
return CPARSER_NOT_OK;
}
}
return CPARSER_OK;
}
/**
* \brief Generate context-sensitive help.
*
* \param parser Pointer to the parser structure.
*/
static cparser_result_t
cparser_help (cparser_t *parser)
{
cparser_node_t *node;
cparser_token_t *token;
int local_is_complete;
assert(VALID_PARSER(parser));
if (CPARSER_STATE_WHITESPACE == parser->state) {
/* Just print out every children */
for (node = parser->cur_node->children; NULL != node;
node = node->sibling) {
cparser_help_print_node(parser, node, 1, 1);
}
} else if (CPARSER_STATE_ERROR == parser->state) {
/*
* We have some problem parsing. Just print out the last known
* good parse point and list the valid options.
*/
cparser_print_error(parser, "Last known good parse point.");
for (node = parser->cur_node->children; NULL != node;
node = node->sibling) {
cparser_help_print_node(parser, node, 1, 1);
}
} else {
/* We have a partial match */
node = parser->cur_node->children;
token = CUR_TOKEN(parser);
for (node = parser->cur_node->children; NULL != node;
node = node->sibling) {
if (!NODE_USABLE(parser, node)) {
continue;
}
if (CPARSER_OK ==
cparser_match_fn_tbl[node->type](token->buf, token->token_len,
node, &local_is_complete)) {
cparser_help_print_node(parser, node, 1, 1);
}
}
}
cparser_line_print(parser, 1, 1);
return CPARSER_OK;
}
/**
* \brief Complete one level in the parse tree.
* \details There are serveral cases we will complete one level:
*
* 1. If in TOKEN state, the token is unique and complete.
* 2. If in WHITESPACE state, there is only one child and it
* is not a LF.
*/
static int
cparser_complete_one_level (cparser_t *parser)
{
cparser_token_t *token;
cparser_node_t *match;
int is_complete = 0, num_matches, keep_going = 0, rc;
const char *ch_ptr;
switch (parser->state) {
case CPARSER_STATE_ERROR:
/* If we are in ERROR, there cannot be a match. So, just quit */
parser->cfg.printc(parser, '\a');
break;
case CPARSER_STATE_WHITESPACE:
if (parser->cur_node && parser->cur_node->children &&
!parser->cur_node->children->sibling &&
(CPARSER_NODE_KEYWORD == parser->cur_node->children->type)) {
ch_ptr = parser->cur_node->children->param;
while (*ch_ptr) {
rc = cparser_input(parser, *ch_ptr, CPARSER_CHAR_REGULAR);
assert(CPARSER_OK == rc);
ch_ptr++;
}
rc = cparser_input(parser, ' ', CPARSER_CHAR_REGULAR);
assert(CPARSER_OK == rc);
} else {
/*
* If we are in WHITESPACE, just dump all children. Since there is no
* way any token can match to a NULL string.
*/
cparser_help(parser);
}
break;
case CPARSER_STATE_TOKEN:
{
/* Complete a command */
token = CUR_TOKEN(parser);
num_matches = cparser_match(parser, token->buf, token->token_len,
parser->cur_node, &match,
&is_complete);
if ((1 == num_matches) && (is_complete)) {
cparser_complete_fn fn = cparser_complete_fn_tbl[match->type];
/*
* If the only matched node is a keyword, we feel the rest of
* keyword in. Otherwise, we assume this parameter is complete
* and just insert a space.
*/
if (fn) {
fn(parser, match, token->buf, token->token_len);
}
rc = cparser_input(parser, ' ', CPARSER_CHAR_REGULAR);
assert(CPARSER_OK == rc);
keep_going = 1;
} else {
int offset, orig_offset;
/*
* If we have more than one match, we should try to complete
* as much as possible. To do that, we grab the node in the
* (first) matched node and check that the next character
* from it is common among all matched nodes. If it is common
* to all matched nodes, we continue to feed them into the
* parser. However, this is only useful for keywords. If there
* is a parameter token in the match, we automatically abort.
*/
offset = orig_offset = token->token_len;
ch_ptr = match->param + token->token_len;
while (('\0' != *ch_ptr) &&
(CPARSER_OK ==
cparser_match_prefix(parser, token->buf, token->token_len,
parser->cur_node, *ch_ptr,
offset))) {
rc = cparser_input(parser, *ch_ptr, CPARSER_CHAR_REGULAR);
assert(CPARSER_OK == rc);
ch_ptr++;
offset++;
}
if (orig_offset == offset) {
/* If there is no common prefix at all, just display help */
cparser_help(parser);
}
}
break;
}
default: assert(0);
}
return keep_going;
}
cparser_result_t
cparser_input (cparser_t *parser, char ch, cparser_char_t ch_type)
{
int n, do_echo;
cparser_result_t rc;
if (!VALID_PARSER(parser)) {
return CPARSER_ERR_INVALID_PARAMS;
}
if (cparser_is_user_input(parser, &do_echo)) {
/* Process user input */
if (CPARSER_CHAR_REGULAR != ch_type) {
return CPARSER_OK;
}
if ('\n' == ch) {
/* We have a complete input. Call the callback. */
assert(parser->user_input_cb);
parser->user_buf[parser->user_buf_count] = '\0';
rc = parser->user_input_cb(parser, parser->user_buf,
parser->user_buf_count);
cparser_input_reset(parser);
cparser_print_prompt(parser);
return rc;
}
if ((parser->cfg.ch_erase == ch) || (parser->cfg.ch_del == ch)) {
if (parser->user_buf_count > 0) {
parser->user_buf_count--;
}
if (parser->user_do_echo) {
parser->cfg.printc(parser, '\b');
}
} else if ((parser->user_buf_count + 1) < parser->user_buf_size) {
parser->user_buf[parser->user_buf_count] = ch;
parser->user_buf_count++;
if (parser->user_do_echo) {
parser->cfg.printc(parser, ch);
}
}
return CPARSER_OK;
}
switch (ch_type) {
case CPARSER_CHAR_REGULAR:
{
if ((parser->cfg.ch_complete == ch) ||
(parser->cfg.ch_help == ch)) {
/*
* Completion and help character do not go into the line
* buffer. So, do nothing.
*/
break;
}
if ((parser->cfg.ch_erase == ch) || (parser->cfg.ch_del == ch)) {
rc = cparser_line_delete(parser);
assert(CPARSER_ERR_INVALID_PARAMS != rc);
if (CPARSER_ERR_NOT_EXIST == rc) {
return CPARSER_OK;
}
} else if ('\n' == ch) {
/* Put the rest of the line into parser FSM */
for (n = cparser_line_current(parser);
n < cparser_line_last(parser); n++) {
rc = cparser_fsm_input(parser, cparser_line_char(parser, n));
assert(CPARSER_OK == rc);
}
} else {
(void)cparser_line_insert(parser, ch);
}
break;
}
case CPARSER_CHAR_UP_ARROW:
{
rc = cparser_line_prev_line(parser);
assert(CPARSER_OK == rc);
/* Reset the token stack and re-enter the command */
cparser_fsm_reset(parser);
for (n = 0; n < cparser_line_current(parser); n++) {
rc = cparser_fsm_input(parser, cparser_line_char(parser, n));
assert(CPARSER_OK == rc);
}
return CPARSER_OK;
}
case CPARSER_CHAR_DOWN_ARROW:
{
rc = cparser_line_next_line(parser);
assert(CPARSER_OK == rc);
/* Reset the token stack and re-enter the command */
cparser_fsm_reset(parser);
for (n = 0; n < cparser_line_current(parser); n++) {
rc = cparser_fsm_input(parser, cparser_line_char(parser, n));
assert(CPARSER_OK == rc);
}
return CPARSER_OK;
}
case CPARSER_CHAR_LEFT_ARROW:
{
ch = cparser_line_prev_char(parser);
if (!ch) {
parser->cfg.printc(parser, '\a');
return CPARSER_OK;
}
break;
}
case CPARSER_CHAR_RIGHT_ARROW:
{
ch = cparser_line_next_char(parser);
if (!ch) {
parser->cfg.printc(parser, '\a');
return CPARSER_OK;
}
break;
}
case CPARSER_CHAR_FIRST:
{
do {
ch = cparser_line_prev_char(parser);
if (ch) {
cparser_fsm_input(parser, ch);
}
} while (ch);
return CPARSER_OK;
}
case CPARSER_CHAR_LAST:
{
do {
ch = cparser_line_next_char(parser);
if (ch) {
cparser_fsm_input(parser, ch);
}
} while (ch);
return CPARSER_OK;
}
default:
{
/* An unknown character. Alert and continue */
parser->cfg.printc(parser, '\a');
return CPARSER_NOT_OK;
}
} /* switch (ch_type) */
/* Handle special characters */
if (ch == parser->cfg.ch_complete) {
while (cparser_complete_one_level(parser));
return CPARSER_OK;
} else if (ch == parser->cfg.ch_help) {
/* Ask for context sensitve help */
cparser_help(parser);
return CPARSER_OK;
} else if ('\n' == ch) {
rc = cparser_execute_cmd(parser);
cparser_line_advance(parser);
return rc;
}
return cparser_fsm_input(parser, (char)ch);
}
cparser_result_t
cparser_run (cparser_t *parser)
{
int ch;
cparser_char_t ch_type = 0;
if (!VALID_PARSER(parser)) return CPARSER_ERR_INVALID_PARAMS;
parser->cfg.io_init(parser);
cparser_print_prompt(parser);
parser->done = 0;
while (!parser->done) {
parser->cfg.cparser_getch(parser, &ch, &ch_type);
cparser_input(parser, ch, ch_type);
} /* while not done */
parser->cfg.io_cleanup(parser);
return CPARSER_OK;
}
cparser_result_t
cparser_init (cparser_cfg_t *cfg, cparser_t *parser)
{
int n;
if (!parser || !cfg || !cfg->root || !cfg->ch_erase) {
return CPARSER_ERR_INVALID_PARAMS;
}
parser->cfg = *cfg;
parser->cfg.prompt[CPARSER_MAX_PROMPT-1] = '\0';
/* Initialize sub-mode states */
parser->root_level = 0;
parser->root[0] = parser->cfg.root;
snprintf(parser->prompt[0], sizeof(parser->prompt[0]), "%s",
parser->cfg.prompt);
for (n = 0; n < CPARSER_MAX_NESTED_LEVELS; n++) {
parser->context.cookie[n] = NULL;
}
parser->context.parser = parser;
/* Initialize line buffering states */
parser->max_line = 0;
parser->cur_line = 0;
for (n = 0; n < CPARSER_MAX_LINES; n++) {
cparser_line_reset(&parser->lines[n]);
}
/* Initialize parser FSM state */
cparser_fsm_reset(parser);
parser->is_privileged_mode = 0;
/* Clear the user input state */
cparser_input_reset(parser);
return CPARSER_OK;
}
cparser_result_t
cparser_quit (cparser_t *parser)
{
if (!parser) {
return CPARSER_ERR_INVALID_PARAMS;
}
parser->done = 1;
return CPARSER_OK;
}
cparser_result_t
cparser_submode_enter (cparser_t *parser, void *cookie, const char *prompt)
{
cparser_node_t *new_root;
if (!parser) {
return CPARSER_ERR_INVALID_PARAMS;
}
if ((CPARSER_MAX_NESTED_LEVELS-1) == parser->root_level) {
return CPARSER_NOT_OK;
}
parser->root_level++;
new_root = parser->cur_node->children;
assert(new_root);
assert(CPARSER_NODE_ROOT == new_root->type);
parser->root[parser->root_level] = new_root;
snprintf(parser->prompt[parser->root_level],
sizeof(parser->prompt[parser->root_level]), "%s", prompt);
parser->context.cookie[parser->root_level] = cookie;
return CPARSER_OK;
}
cparser_result_t
cparser_submode_exit (cparser_t *parser)
{
if (!parser) {
return CPARSER_ERR_INVALID_PARAMS;
}
if (!parser->root_level) {
return CPARSER_NOT_OK;
}
parser->root_level--;
return CPARSER_OK;
}
cparser_result_t
cparser_load_cmd (cparser_t *parser, char *filename)
{
FILE *fp;
char buf[128];
size_t rsize, n;
int fd, indent = 0, last_indent = -1, new_line = 1, m, line_num = 0;
if (!VALID_PARSER(parser) || !filename) {
return CPARSER_ERR_INVALID_PARAMS;
}
fd = parser->cfg.fd;
parser->cfg.fd = -1;
fp = fopen(filename, "r");
if (!fp) {
return CPARSER_NOT_OK;
}
cparser_fsm_reset(parser);
while (!feof(fp)) {
rsize = fread(buf, 1, sizeof(buf), fp);
for (n = 0; n < rsize; n++) {
/* Examine the input characters to maintain indent level */
if ('\n' == buf[n]) {
cparser_result_t rc;
char buf[128];
line_num++;
indent = 0;
new_line = 1;
rc = cparser_execute_cmd(parser);
if (CPARSER_OK == rc) {
continue;
}
parser->cfg.fd = fd;
switch (rc) {
case CPARSER_ERR_PARSE_ERR:
snprintf(buf, sizeof(buf), "Line %d: Parse error.\n", line_num);
parser->cfg.prints(parser, buf);
break;
case CPARSER_ERR_INCOMP_CMD:
snprintf(buf, sizeof(buf), "Line %d: Incomplete command.\n", line_num);
parser->cfg.prints(parser, buf);
break;
default:
assert(0);
}
return CPARSER_NOT_OK;
} else if (' ' == buf[n]) {
if (new_line) {
indent++;
}
} else {
if (new_line) {
new_line = 0;
if (indent < last_indent) {
for (m = indent; m < last_indent; m++) {
if (CPARSER_OK != cparser_submode_exit(parser)) {
break;
}
cparser_fsm_reset(parser);
}
}
last_indent = indent;
}
}
(void)cparser_fsm_input(parser, buf[n]);
}
}
fclose(fp);
while (parser->root_level) {
(void)cparser_submode_exit(parser);
cparser_fsm_reset(parser);
}
parser->cfg.fd = fd;
return CPARSER_OK;
}
static cparser_result_t
cparser_walk_internal (cparser_t *parser, cparser_node_t *node,
cparser_walker_fn pre_fn, cparser_walker_fn post_fn,
void *cookie)
{
cparser_result_t rc;
cparser_node_t *cur_node;
if (pre_fn) {
rc = pre_fn(parser, node, cookie);
if (CPARSER_OK != rc) {
return rc;
}
}
if (CPARSER_NODE_END != node->type) {
cur_node = node->children;
while (cur_node) {
cparser_walk_internal(parser, cur_node, pre_fn, post_fn, cookie);
cur_node = cur_node->sibling;
}
}
if (post_fn) {
rc = post_fn(parser, node, cookie);
if (CPARSER_OK != rc) {
return rc;
}
}
return CPARSER_OK;
}
cparser_result_t
cparser_walk (cparser_t *parser, cparser_walker_fn pre_fn,
cparser_walker_fn post_fn, void *cookie)
{
if (!VALID_PARSER(parser) || (!pre_fn && !post_fn)) {
return CPARSER_ERR_INVALID_PARAMS;
}
return cparser_walk_internal(parser, parser->root[parser->root_level],
pre_fn, post_fn, cookie);
}
typedef struct help_stack_ {
char *filter;
int tos;
cparser_node_t *nodes[CPARSER_MAX_NUM_TOKENS+2];
} help_stack_t;
/**
* \brief Pre-order walker function used by cparser_help_cmd().
* \details Its main function is to push into the help stack when recurse into
* the next level.
*
* \param parser Pointer to the parser structure.
* \param node Pointer to the current parse tree node.
* \param cookie Pointer to the help stack.
*
* \return Return CPARSER_OK always.
*/
static cparser_result_t
cparser_help_pre_walker (cparser_t *parser, cparser_node_t *node, void *cookie)
{
help_stack_t *hs = (help_stack_t *)cookie;
assert(parser && node && hs);
hs->nodes[hs->tos] = node;
hs->tos++;
return CPARSER_OK;
}
/**
* \brief Post-order walker function used by cparser_help_cmd().
* \details Its main function is to print out a command description and to
* pop the help stack.
*
* \param parser Pointer to the parser structure.
* \param node Pointer to the current parse tree node.
* \param cookie Pointer to the help stack.
*
* \return Return CPARSER_OK always.
*/
static cparser_result_t
cparser_help_post_walker (cparser_t *parser, cparser_node_t *node, void *cookie)
{
help_stack_t *hs = (help_stack_t *)cookie;
int n, do_print;
assert(parser && node && hs);
if ((CPARSER_NODE_END == node->type) &&
(!(node->flags & CPARSER_NODE_FLAGS_OPT_PARTIAL))) {
do_print = 0;
if (hs->filter) {
/* We have a filter string. Check if it matches any keyword */
for (n = 0; n < hs->tos; n++) {
if (CPARSER_NODE_LIST == hs->nodes[n]->type) {
/* LIST node requires an extra walk of all keywords in the list */
cparser_list_node_t *lnode =
(cparser_list_node_t *)hs->nodes[n]->param;
assert(lnode);
while (lnode) {
if (strstr(lnode->keyword, hs->filter)) {
do_print = 1;
break;
}
lnode = lnode->next;
}
if (do_print) {
break;
}
}
if (CPARSER_NODE_KEYWORD != hs->nodes[n]->type) {
continue;
}
if (strstr(hs->nodes[n]->param, hs->filter)) {
do_print = 1; /* Yes, print it */
break;
}
}
if (!NODE_USABLE(parser, node)) {
do_print = 0; /* may match the filter but not usable */
}
} else if (NODE_USABLE(parser, node)) {
do_print = 1;
}
if (do_print) {
cparser_node_t *cur_node;
int m, num_braces = 0;
if (node->desc) {
parser->cfg.prints(parser, node->desc);
parser->cfg.prints(parser, "\r\n ");
} else {
parser->cfg.prints(parser, "\r ");
}
for (n = 0; n < hs->tos; n++) {
cur_node = hs->nodes[n];
if ((CPARSER_NODE_ROOT == cur_node->type) ||
(CPARSER_NODE_END == cur_node->type)) {
continue;
}
if (cur_node->flags & CPARSER_NODE_FLAGS_OPT_START) {
parser->cfg.prints(parser, "{ ");
num_braces++;
}
cparser_help_print_node(parser, cur_node, 0, 0);
parser->cfg.printc(parser, ' ');
if (cur_node->flags & CPARSER_NODE_FLAGS_OPT_END) {
for (m = 0; m < num_braces; m++) {
parser->cfg.prints(parser, "} ");
}
}
}
parser->cfg.prints(parser, "\r\n\n");
}
}
/* Pop the stack */
hs->tos--;
return CPARSER_OK;
}
cparser_result_t
cparser_help_cmd (cparser_t *parser, char *str)
{
help_stack_t help_stack;
assert(parser);
memset(&help_stack, 0, sizeof(help_stack));
help_stack.filter = str;
return cparser_walk(parser, cparser_help_pre_walker,
cparser_help_post_walker, &help_stack);
}
cparser_result_t
cparser_set_root_context (cparser_t *parser, void *context)
{
if (!parser) {
return CPARSER_ERR_INVALID_PARAMS;
}
parser->context.cookie[0] = context;
return CPARSER_OK;
}
cparser_result_t
cparser_get_root_context (cparser_t *parser, void **context)
{
if (!parser || !context) {
return CPARSER_ERR_INVALID_PARAMS;
}
*context = parser->context.cookie[0];
return CPARSER_OK;
}
cparser_result_t
cparser_set_privileged_mode (cparser_t *parser, int enable)
{
if (!parser) {
return CPARSER_ERR_INVALID_PARAMS;
}
parser->is_privileged_mode = (0 != enable);
return CPARSER_OK;
}
int
cparser_is_in_privileged_mode (const cparser_t *parser)
{
if (!parser) {
return 0;
}
return (parser->is_privileged_mode ? 1 : 0);
}
cparser_result_t
cparser_user_input (cparser_t *parser, const char *prompt, int do_echo,
char *buf, int buf_size, cparser_input_cb cb)
{
int tmp_do_echo;
if (!parser || !buf || !buf_size || !buf_size) {
return CPARSER_ERR_INVALID_PARAMS;
}
if (cparser_is_user_input(parser, &tmp_do_echo)) {
return CPARSER_NOT_OK; /* only one user input at a time */
}
/* Print the prompt */
if (prompt) {
parser->cfg.prints(parser, prompt);
}
/* Save the state */
parser->user_buf = buf;
parser->user_buf_size = buf_size;
parser->user_input_cb = cb;
parser->user_do_echo = do_echo;
assert(!parser->user_buf_count);
return CPARSER_OK;
}
cparser_result_t
cparser_abort_user_input (cparser_t *parser)
{
int do_echo;
if (!parser) {
return CPARSER_ERR_INVALID_PARAMS;
}
if (!cparser_is_user_input(parser, &do_echo)) {
return CPARSER_ERR_NOT_EXIST;
}
/* Force a callback immediately with an empty input */
parser->user_buf[0] = '\0';
parser->user_input_cb(parser, parser->user_buf, 0);
cparser_input_reset(parser);
cparser_print_prompt(parser);
return CPARSER_OK;
}
cparser_result_t
cparser_last_command (cparser_t *parser, char **cmd,
cparser_result_t *rc, int *is_priv)
{
if (!parser) {
return CPARSER_ERR_INVALID_PARAMS;
}
if (0 <= parser->last_line_idx) {
if (cmd) {
*cmd = parser->lines[parser->last_line_idx].buf;
}
if (rc) {
*rc = parser->last_rc;
}
if (is_priv) {
*is_priv = (!parser->last_end_node ? 0 :
(parser->last_end_node->flags &
CPARSER_NODE_FLAGS_HIDDEN ? 1 : 0));
}
} else {
assert((CPARSER_ERR_NOT_EXIST == parser->last_rc) &&
(!parser->last_end_node));
if (cmd) {
*cmd = NULL;
}
if (rc) {
*rc = parser->last_rc;
}
if (is_priv) {
*is_priv = 0;
}
}
return CPARSER_OK;
}
| 31.744 | 91 | 0.546567 |
ff601dbe843dfd3545f15b649a314ffeb730e68f | 3,862 | h | C | sdk/app/ultra_simple/RplidarClass.h | codenotes/rplidar | d24dae2848bc01c29e34bc9f46ec63d785bf61d5 | [
"BSD-2-Clause"
] | 1 | 2020-03-31T03:35:31.000Z | 2020-03-31T03:35:31.000Z | sdk/app/ultra_simple/RplidarClass.h | codenotes/rplidar | d24dae2848bc01c29e34bc9f46ec63d785bf61d5 | [
"BSD-2-Clause"
] | null | null | null | sdk/app/ultra_simple/RplidarClass.h | codenotes/rplidar | d24dae2848bc01c29e34bc9f46ec63d785bf61d5 | [
"BSD-2-Clause"
] | null | null | null | #pragma once
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include "rplidar.h" //RPLIDAR standard sdk, all-in-one header
#include "C:\usr\include\GregUtils\strguple.h"
#include <boost/circular_buffer.hpp>
#include <boost/thread/thread.hpp> //added /thread/ here, if there are problems look into this
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <fstream>
#include <boost/format.hpp>
//using namespace rp::standalone::rplidar;
//namespace rp {
// namespace standalone {
// namespace rplidar {
// struct RPlidarDriver;
// }
// }
//};
//
//namespace boost {
// struct thread;
//}
//
#include "C:/usr/include/rplidar/RPlidarNeedfullsForDLL.h"
struct RplidarReadingQueue {
//std::map<float, std::pair<_u16, rp::Clock::time_point> > storedRead;
std::map<float, rp::beam > storedRead;
static std::pair<float, float> GetLinearFit(std::vector<rp::point> pData)
{
float xSum = 0, ySum = 0, xxSum = 0, xySum = 0, slope, intercept;
// std::vector<float> xData;
/*for (long i = 0; i < pData.size(); i++)
{
xData.push_back(pData[i].x);
}*/
auto sz = pData.size();
for (long i = 0; i < sz; i++)
{
xSum += pData[i].x;
ySum += pData[i].y;
xxSum += pData[i].x * pData[i].x;
xySum += pData[i].x * pData[i].y;
}
slope = (sz * xySum - xSum * ySum) / (sz * xxSum - xSum * xSum);
intercept = (ySum - slope * xSum) / sz;
/*std::vector<float> res;
res.push_back(slope);
res.push_back(intercept);*/
return { slope,intercept };
}
//redeclared the rplidar sdk struct here so we don't have to bring in the rplidar sdk headers, etc.
float fromRadial;
float toRadial;
bool keepGoing = true;
bool useRangeFilter = false;
_u32 baud;
rp::standalone::rplidar::RPlidarDriver * drv = nullptr;
std::string opt_com_path;
static boost::thread * scanThread;
static boost::mutex qMutex;
static float tilt;
static std::string sweepTableName;
static std::atomic<rp::enumLidarStatus> lidarStatus;
boost::circular_buffer<rp::measure> * cb = nullptr;
RplidarReadingQueue(float fromRadial, float toRadial, int qSize, _u32 baud = 256000, const char * opt_com_path = "\\\\.\\com3");
RplidarReadingQueue(int size);
void setRange(int from, int to);
int getFromTo(rp::measure & m, int fromRadial, int toRadial);
int getFront(rp::measure & m);
bool isInRange(float theta);
bool push(rp::measure &m);
void getScan(rp::RplidarProxy::ScanVecType2 ** theScan, int msecExpiry=0);
~RplidarReadingQueue();
void stop();
rp::enumLidarStatus getLidarStatus();
bool initLidat();
bool run();
bool run2();
bool runThreaded();
void join();
void dumpScanToFile(std::string & fname, rp::RplidarProxy::ScanVecType2 * theScan, bool append);
static void savePresentScan(int id, std::string & database, rp::RplidarProxy::ScanVecType2 * theScan, const std::string & tblName);
bool sendSQL(std::string & path , std::shared_ptr<std::string> & sql);
void setTiltLidar(float tilt);
//returns next lowest id for sweep, pass in an id::none if you want latest and to start the chain backward LIFO
static int getScanFromDatabase(rp::RplidarProxy::ScanVecType2 ** psv, std::string & path, std::optional<int> & id, std::optional<std::string> & sweepTableName);
static int saveScanToDatabase(rp::RplidarProxy::ScanVecType2 * psv, std::string & path, std::optional<int> & id, std::optional<std::string> & sweepTableName);
static std::optional<int> getLastIDFromSweep(std::string & path, std::optional<std::string> & sweepTableName);
};
#define INIT_RPLIDAR boost::thread * RplidarReadingQueue::scanThread = nullptr; \
boost::mutex RplidarReadingQueue::qMutex; \
std::atomic<rp::enumLidarStatus> RplidarReadingQueue::lidarStatus=rp::STOPPED; \
float RplidarReadingQueue::tilt = 0.0f; \
std::string RplidarReadingQueue::sweepTableName;
| 25.576159 | 161 | 0.696271 |
ff604390461dc3d455d66fdc631d6cb62236d7d5 | 1,345 | h | C | third_party/WebKit/Source/core/paint/SubtreeRecorder.h | wenfeifei/miniblink49 | 2ed562ff70130485148d94b0e5f4c343da0c2ba4 | [
"Apache-2.0"
] | 5,964 | 2016-09-27T03:46:29.000Z | 2022-03-31T16:25:27.000Z | third_party/WebKit/Source/core/paint/SubtreeRecorder.h | w4454962/miniblink49 | b294b6eacb3333659bf7b94d670d96edeeba14c0 | [
"Apache-2.0"
] | 459 | 2016-09-29T00:51:38.000Z | 2022-03-07T14:37:46.000Z | third_party/WebKit/Source/core/paint/SubtreeRecorder.h | w4454962/miniblink49 | b294b6eacb3333659bf7b94d670d96edeeba14c0 | [
"Apache-2.0"
] | 1,006 | 2016-09-27T05:17:27.000Z | 2022-03-30T02:46:51.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.
#ifndef SubtreeRecorder_h
#define SubtreeRecorder_h
#include "core/paint/PaintPhase.h"
#include "wtf/PassOwnPtr.h"
namespace blink {
class DisplayItem;
class DisplayItemList;
class GraphicsContext;
class LayoutObject;
// Records subtree information during painting. The recorder's life span covers
// all painting operations executed during the root of the subtree's paint method
// for the paint phase.
class SubtreeRecorder {
public:
SubtreeRecorder(GraphicsContext&, const LayoutObject& root, PaintPhase);
~SubtreeRecorder();
// This method should be called before we actually paint the subtree, then we'll
// issue a pair of BeginSubtree/EndSubtree display items to enclose all display
// items when we paint the subtree.
// Omit this call if we skip painting of the whole subtree (when e.g. the subtree
// is out of the viewport, or the whole subtree is not invalidated), then we'll
// issue a SubtreeCached display item.
void begin();
private:
DisplayItemList* m_displayItemList;
const LayoutObject& m_subtreeRoot;
const PaintPhase m_paintPhase;
bool m_begun;
};
} // namespace blink
#endif // SubtreeRecorder_h
| 29.888889 | 85 | 0.751673 |
ff650d59151908f5dbb1526a0d04273d745ffeb1 | 340 | h | C | Empresa.h | ebnersilva/heranca_exercicio_ufpr | c247af1ad4cae519d14de8c32e36b7f0ac5ea2af | [
"MIT"
] | null | null | null | Empresa.h | ebnersilva/heranca_exercicio_ufpr | c247af1ad4cae519d14de8c32e36b7f0ac5ea2af | [
"MIT"
] | null | null | null | Empresa.h | ebnersilva/heranca_exercicio_ufpr | c247af1ad4cae519d14de8c32e36b7f0ac5ea2af | [
"MIT"
] | null | null | null | #ifndef EMPRESA_H
#define EMPRESA_H
#include <string>
using namespace std;
class Empresa
{
public:
Empresa();
Empresa(string nome, string endereco, string cidade, string estado, string CEP, string telefone);
protected:
string nome;
string endereco;
string cidade;
string estado;
string CEP;
string telefone;
};
#endif
| 14.782609 | 99 | 0.729412 |
ff65e2c4a3e90f9f6b281a3c565b05d6b2c349b1 | 1,988 | h | C | Ribbon.h | kenjinote/Ribbon | 9acc45e92ec9c3b8fc91c27437d57dff958ee1d2 | [
"MIT"
] | 1 | 2021-12-15T02:55:29.000Z | 2021-12-15T02:55:29.000Z | Ribbon.h | kenjinote/Ribbon | 9acc45e92ec9c3b8fc91c27437d57dff958ee1d2 | [
"MIT"
] | null | null | null | Ribbon.h | kenjinote/Ribbon | 9acc45e92ec9c3b8fc91c27437d57dff958ee1d2 | [
"MIT"
] | 1 | 2022-03-05T03:56:54.000Z | 2022-03-05T03:56:54.000Z | #pragma once
#include <UIRibbon.h>
#include <UIRibbonPropertyHelpers.h>
#include "ids.h"
/////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL InitializeFramework(HWND hWnd);
void DestroyFramework();
/////////////////////////////////////////////////////////////////////////////
class CCommandHandler
: public IUICommandHandler
{
public:
static HRESULT CreateInstance(IUICommandHandler **ppCommandHandler);
// IUnknown
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
STDMETHODIMP QueryInterface(REFIID iid, void** ppv);
// IUICommandHandler
STDMETHOD(UpdateProperty)(
UINT nCmdID,
REFPROPERTYKEY key,
const PROPVARIANT* ppropvarCurrentValue,
PROPVARIANT* ppropvarNewValue);
STDMETHOD(Execute)(
UINT nCmdID,
UI_EXECUTIONVERB verb,
const PROPERTYKEY* key,
const PROPVARIANT* ppropvarValue,
IUISimplePropertySet* pCommandExecutionProperties);
private:
CCommandHandler()
: m_cRef(1) {
}
LONG m_cRef;
};
/////////////////////////////////////////////////////////////////////////////
class CApplication
: public IUIApplication
{
public:
static HRESULT CreateInstance(IUIApplication **ppApplication);
// IUnknown
STDMETHOD_(ULONG, AddRef());
STDMETHOD_(ULONG, Release());
STDMETHOD(QueryInterface(REFIID iid, void** ppv));
// IUIApplication
STDMETHOD(OnCreateUICommand)(
UINT nCmdID,
UI_COMMANDTYPE typeID,
IUICommandHandler** ppCommandHandler);
STDMETHOD(OnViewChanged)(
UINT viewId,
UI_VIEWTYPE typeId,
IUnknown* pView,
UI_VIEWVERB verb,
INT uReasonCode);
STDMETHOD(OnDestroyUICommand)(
UINT32 commandId,
UI_COMMANDTYPE typeID,
IUICommandHandler* commandHandler);
private:
CApplication()
: m_cRef(1), m_pCommandHandler(NULL) {
}
~CApplication() {
if (m_pCommandHandler) {
m_pCommandHandler->Release();
m_pCommandHandler = NULL;
}
}
LONG m_cRef;
IUICommandHandler * m_pCommandHandler;
}; | 19.300971 | 77 | 0.663984 |
ff67d6a9ddd25510246f1ee494dfc568699b49bc | 736 | h | C | app/resource_util.h | drclue/WBEA | 3fe0426dcf6b3a65e16661f26a5e933fbbb15359 | [
"BSD-3-Clause"
] | 1 | 2021-06-19T09:09:43.000Z | 2021-06-19T09:09:43.000Z | app/resource_util.h | drclue/WBEA | 3fe0426dcf6b3a65e16661f26a5e933fbbb15359 | [
"BSD-3-Clause"
] | null | null | null | app/resource_util.h | drclue/WBEA | 3fe0426dcf6b3a65e16661f26a5e933fbbb15359 | [
"BSD-3-Clause"
] | 1 | 2019-11-30T20:08:45.000Z | 2019-11-30T20:08:45.000Z | // Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#ifndef _RESOURCE_UTIL
#define _RESOURCE_UTIL
#include "include/cef.h"
#ifdef _WIN32
// Load a resource of type BINARY
bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes);
#endif // _WIN32
// Returns the suggested mime type for the specified file extension.
std::string GetSuggestedMimeType(const std::string& fileExt);
// |out_bytes| must be freed by the caller.
bool Decrypt(const char* key, CefRefPtr<CefStreamReader> readStream,
unsigned char** out_bytes, size_t* out_bytes_size);
#endif // _RESOURCE_UTIL
| 29.44 | 76 | 0.756793 |
ff6a1cfe185db9ff822fb7730810f99cc7604faf | 649 | h | C | iOSOpenDev/frameworks/PhotoLibrary.framework/Headers/PLVideoEditingOverlayView.h | bzxy/cydia | f8c838cdbd86e49dddf15792e7aa56e2af80548d | [
"MIT"
] | 678 | 2017-11-17T08:33:19.000Z | 2022-03-26T10:40:20.000Z | iOSOpenDev/frameworks/PhotoLibrary.framework/Headers/PLVideoEditingOverlayView.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 22 | 2019-04-16T05:51:53.000Z | 2021-11-08T06:18:45.000Z | iOSOpenDev/frameworks/PhotoLibrary.framework/Headers/PLVideoEditingOverlayView.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 170 | 2018-06-10T07:59:20.000Z | 2022-03-22T16:19:33.000Z | /**
* This header is generated by class-dump-z 0.2b.
*
* Source: /System/Library/PrivateFrameworks/PhotoLibrary.framework/PhotoLibrary
*/
#import <PhotoLibrary/XXUnknownSuperclass.h>
#import <PhotoLibrary/PhotoLibrary-Structs.h>
@class UILabel, UIMovieScrubber;
@interface PLVideoEditingOverlayView : XXUnknownSuperclass {
UILabel *_titleLabel; // 48 = 0x30
UILabel *_bodyLabel; // 52 = 0x34
UIMovieScrubber *_scrubber; // 56 = 0x38
}
- (void)layoutSubviews; // 0x61ab9
- (void)setBody:(id)body; // 0x61a7d
- (void)setTitle:(id)title; // 0x61a41
- (void)drawRect:(CGRect)rect; // 0x618fd
- (id)initWithFrame:(CGRect)frame; // 0x6160d
@end
| 28.217391 | 80 | 0.736518 |
ff6b827cc8cf22bbd41bb5e7e1121f272ad7f6d1 | 3,970 | h | C | base/cluster/mgmt/cluscfg/basecluster/cexception.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | base/cluster/mgmt/cluscfg/basecluster/cexception.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | base/cluster/mgmt/cluscfg/basecluster/cexception.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | //////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2000 Microsoft Corporation
//
// Module Name:
// CException.h
//
// Description:
// This file contains the declarations of base class for all exception
// classes.
//
// Implementation File:
// None.
//
// Maintained By:
// Vij Vasu (Vvasu) 26-APR-2000
//
//////////////////////////////////////////////////////////////////////////////
// Make sure that this file is included only once per compile path.
#pragma once
//////////////////////////////////////////////////////////////////////////////
// Include Files
//////////////////////////////////////////////////////////////////////////////
// For HRESULT, WCHAR, etc.
#include <windef.h>
//////////////////////////////////////////////////////////////////////
// Macro Definitions
//////////////////////////////////////////////////////////////////////////////
//
// Shorthand for throwing different exceptions.
//
#define THROW_EXCEPTION( _hrErrorCode ) \
throw CException( _hrErrorCode, TEXT( __FILE__ ), __LINE__ )
//////////////////////////////////////////////////////////////////////////////
//++
//
// class CException
//
// Description:
// The CException is the base class for all exceptions thrown by
// functions defined in this library.
//
// An object of this class must have the m_hrErrorCode, m_pszFile and
// m_uiLineNumber members initialized.
//
//--
//////////////////////////////////////////////////////////////////////////////
class CException
{
public:
//////////////////////////////////////////////////////////////////////////
// Public constructors and destructors
//////////////////////////////////////////////////////////////////////////
// Constructor.
CException(
HRESULT hrErrorCodeIn
, const WCHAR * pszFileNameIn
, UINT uiLineNumberIn
) throw()
: m_hrErrorCode( hrErrorCodeIn )
, m_pszFileName( pszFileNameIn )
, m_uiLineNumber( uiLineNumberIn )
{
}
// Copy constructor.
CException( const CException & ceSrcIn ) throw()
: m_hrErrorCode( ceSrcIn.m_hrErrorCode )
, m_pszFileName( ceSrcIn.m_pszFileName )
, m_uiLineNumber( ceSrcIn.m_uiLineNumber )
{
}
// Default virtual destructor.
virtual
~CException() throw() {}
//////////////////////////////////////////////////////////////////////////
// Public Methods
//////////////////////////////////////////////////////////////////////////
// Assignment operator.
const CException &
operator =( const CException & ceSrcIn ) throw()
{
m_hrErrorCode = ceSrcIn.m_hrErrorCode;
m_pszFileName = ceSrcIn.m_pszFileName;
m_uiLineNumber = ceSrcIn.m_uiLineNumber;
return *this;
}
//
// Accessor methods.
//
HRESULT
HrGetErrorCode() const throw() { return m_hrErrorCode; }
void
SetErrorCode( HRESULT hrNewCode ) throw() { m_hrErrorCode = hrNewCode; }
const WCHAR *
PszGetThrowingFile() const throw() { return m_pszFileName; }
UINT
UiGetThrowingLine() const throw() { return m_uiLineNumber; }
private:
//////////////////////////////////////////////////////////////////////////
// Private members
//////////////////////////////////////////////////////////////////////////
// Default construction is not allowed.
CException();
//////////////////////////////////////////////////////////////////////////
// Private data
//////////////////////////////////////////////////////////////////////////
HRESULT m_hrErrorCode;
const WCHAR * m_pszFileName;
UINT m_uiLineNumber;
}; //*** class CException
| 28.561151 | 81 | 0.405793 |
ff6cea5ef94baec84e800c8c21ca35b68545f1ac | 96,313 | h | C | schemas/cpp/openconfig/openconfig_channel_monitor/openconfig_channel_monitor.pb.h | seilis/serialization-perf | 447cab4bfee66c8a86062b1b6169bddf81036a79 | [
"Apache-2.0"
] | null | null | null | schemas/cpp/openconfig/openconfig_channel_monitor/openconfig_channel_monitor.pb.h | seilis/serialization-perf | 447cab4bfee66c8a86062b1b6169bddf81036a79 | [
"Apache-2.0"
] | 2 | 2018-05-10T22:57:40.000Z | 2018-05-16T10:14:23.000Z | schemas/cpp/openconfig/openconfig_channel_monitor/openconfig_channel_monitor.pb.h | seilis/serialization-perf | 447cab4bfee66c8a86062b1b6169bddf81036a79 | [
"Apache-2.0"
] | 1 | 2018-05-09T03:03:01.000Z | 2018-05-09T03:03:01.000Z | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: openconfig/openconfig_channel_monitor/openconfig_channel_monitor.proto
#ifndef PROTOBUF_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto__INCLUDED
#define PROTOBUF_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto__INCLUDED
#include <string>
#include <google/protobuf/stubs/common.h>
#if GOOGLE_PROTOBUF_VERSION < 3005000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3005001 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/arenastring.h>
#include <google/protobuf/generated_message_table_driven.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/metadata.h>
#include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> // IWYU pragma: export
#include <google/protobuf/extension_set.h> // IWYU pragma: export
#include <google/protobuf/unknown_field_set.h>
#include "github.com/openconfig/ygot/proto/ywrapper/ywrapper.pb.h"
#include "github.com/openconfig/ygot/proto/yext/yext.pb.h"
// @@protoc_insertion_point(includes)
namespace protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto {
// Internal implementation detail -- do not use these members.
struct TableStruct {
static const ::google::protobuf::internal::ParseTableField entries[];
static const ::google::protobuf::internal::AuxillaryParseTableField aux[];
static const ::google::protobuf::internal::ParseTable schema[9];
static const ::google::protobuf::internal::FieldMetadata field_metadata[];
static const ::google::protobuf::internal::SerializationTable serialization_table[];
static const ::google::protobuf::uint32 offsets[];
};
void AddDescriptors();
void InitDefaultsChannelMonitors_ChannelMonitor_Channels_Channel_StateImpl();
void InitDefaultsChannelMonitors_ChannelMonitor_Channels_Channel_State();
void InitDefaultsChannelMonitors_ChannelMonitor_Channels_ChannelImpl();
void InitDefaultsChannelMonitors_ChannelMonitor_Channels_Channel();
void InitDefaultsChannelMonitors_ChannelMonitor_Channels_ChannelKeyImpl();
void InitDefaultsChannelMonitors_ChannelMonitor_Channels_ChannelKey();
void InitDefaultsChannelMonitors_ChannelMonitor_ChannelsImpl();
void InitDefaultsChannelMonitors_ChannelMonitor_Channels();
void InitDefaultsChannelMonitors_ChannelMonitor_ConfigImpl();
void InitDefaultsChannelMonitors_ChannelMonitor_Config();
void InitDefaultsChannelMonitors_ChannelMonitor_StateImpl();
void InitDefaultsChannelMonitors_ChannelMonitor_State();
void InitDefaultsChannelMonitors_ChannelMonitorImpl();
void InitDefaultsChannelMonitors_ChannelMonitor();
void InitDefaultsChannelMonitors_ChannelMonitorKeyImpl();
void InitDefaultsChannelMonitors_ChannelMonitorKey();
void InitDefaultsChannelMonitorsImpl();
void InitDefaultsChannelMonitors();
inline void InitDefaults() {
InitDefaultsChannelMonitors_ChannelMonitor_Channels_Channel_State();
InitDefaultsChannelMonitors_ChannelMonitor_Channels_Channel();
InitDefaultsChannelMonitors_ChannelMonitor_Channels_ChannelKey();
InitDefaultsChannelMonitors_ChannelMonitor_Channels();
InitDefaultsChannelMonitors_ChannelMonitor_Config();
InitDefaultsChannelMonitors_ChannelMonitor_State();
InitDefaultsChannelMonitors_ChannelMonitor();
InitDefaultsChannelMonitors_ChannelMonitorKey();
InitDefaultsChannelMonitors();
}
} // namespace protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto
namespace openconfig {
namespace openconfig_channel_monitor {
class ChannelMonitors;
class ChannelMonitorsDefaultTypeInternal;
extern ChannelMonitorsDefaultTypeInternal _ChannelMonitors_default_instance_;
class ChannelMonitors_ChannelMonitor;
class ChannelMonitors_ChannelMonitorDefaultTypeInternal;
extern ChannelMonitors_ChannelMonitorDefaultTypeInternal _ChannelMonitors_ChannelMonitor_default_instance_;
class ChannelMonitors_ChannelMonitorKey;
class ChannelMonitors_ChannelMonitorKeyDefaultTypeInternal;
extern ChannelMonitors_ChannelMonitorKeyDefaultTypeInternal _ChannelMonitors_ChannelMonitorKey_default_instance_;
class ChannelMonitors_ChannelMonitor_Channels;
class ChannelMonitors_ChannelMonitor_ChannelsDefaultTypeInternal;
extern ChannelMonitors_ChannelMonitor_ChannelsDefaultTypeInternal _ChannelMonitors_ChannelMonitor_Channels_default_instance_;
class ChannelMonitors_ChannelMonitor_Channels_Channel;
class ChannelMonitors_ChannelMonitor_Channels_ChannelDefaultTypeInternal;
extern ChannelMonitors_ChannelMonitor_Channels_ChannelDefaultTypeInternal _ChannelMonitors_ChannelMonitor_Channels_Channel_default_instance_;
class ChannelMonitors_ChannelMonitor_Channels_ChannelKey;
class ChannelMonitors_ChannelMonitor_Channels_ChannelKeyDefaultTypeInternal;
extern ChannelMonitors_ChannelMonitor_Channels_ChannelKeyDefaultTypeInternal _ChannelMonitors_ChannelMonitor_Channels_ChannelKey_default_instance_;
class ChannelMonitors_ChannelMonitor_Channels_Channel_State;
class ChannelMonitors_ChannelMonitor_Channels_Channel_StateDefaultTypeInternal;
extern ChannelMonitors_ChannelMonitor_Channels_Channel_StateDefaultTypeInternal _ChannelMonitors_ChannelMonitor_Channels_Channel_State_default_instance_;
class ChannelMonitors_ChannelMonitor_Config;
class ChannelMonitors_ChannelMonitor_ConfigDefaultTypeInternal;
extern ChannelMonitors_ChannelMonitor_ConfigDefaultTypeInternal _ChannelMonitors_ChannelMonitor_Config_default_instance_;
class ChannelMonitors_ChannelMonitor_State;
class ChannelMonitors_ChannelMonitor_StateDefaultTypeInternal;
extern ChannelMonitors_ChannelMonitor_StateDefaultTypeInternal _ChannelMonitors_ChannelMonitor_State_default_instance_;
} // namespace openconfig_channel_monitor
} // namespace openconfig
namespace openconfig {
namespace openconfig_channel_monitor {
// ===================================================================
class ChannelMonitors_ChannelMonitor_Channels_Channel_State : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State) */ {
public:
ChannelMonitors_ChannelMonitor_Channels_Channel_State();
virtual ~ChannelMonitors_ChannelMonitor_Channels_Channel_State();
ChannelMonitors_ChannelMonitor_Channels_Channel_State(const ChannelMonitors_ChannelMonitor_Channels_Channel_State& from);
inline ChannelMonitors_ChannelMonitor_Channels_Channel_State& operator=(const ChannelMonitors_ChannelMonitor_Channels_Channel_State& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
ChannelMonitors_ChannelMonitor_Channels_Channel_State(ChannelMonitors_ChannelMonitor_Channels_Channel_State&& from) noexcept
: ChannelMonitors_ChannelMonitor_Channels_Channel_State() {
*this = ::std::move(from);
}
inline ChannelMonitors_ChannelMonitor_Channels_Channel_State& operator=(ChannelMonitors_ChannelMonitor_Channels_Channel_State&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const ChannelMonitors_ChannelMonitor_Channels_Channel_State& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ChannelMonitors_ChannelMonitor_Channels_Channel_State* internal_default_instance() {
return reinterpret_cast<const ChannelMonitors_ChannelMonitor_Channels_Channel_State*>(
&_ChannelMonitors_ChannelMonitor_Channels_Channel_State_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
0;
void Swap(ChannelMonitors_ChannelMonitor_Channels_Channel_State* other);
friend void swap(ChannelMonitors_ChannelMonitor_Channels_Channel_State& a, ChannelMonitors_ChannelMonitor_Channels_Channel_State& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline ChannelMonitors_ChannelMonitor_Channels_Channel_State* New() const PROTOBUF_FINAL { return New(NULL); }
ChannelMonitors_ChannelMonitor_Channels_Channel_State* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ChannelMonitors_ChannelMonitor_Channels_Channel_State& from);
void MergeFrom(const ChannelMonitors_ChannelMonitor_Channels_Channel_State& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ChannelMonitors_ChannelMonitor_Channels_Channel_State* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// .ywrapper.BytesValue psd = 31486931 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/state/psd"];
bool has_psd() const;
void clear_psd();
static const int kPsdFieldNumber = 31486931;
const ::ywrapper::BytesValue& psd() const;
::ywrapper::BytesValue* release_psd();
::ywrapper::BytesValue* mutable_psd();
void set_allocated_psd(::ywrapper::BytesValue* psd);
// .ywrapper.UintValue upper_frequency = 354726687 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/state/upper-frequency"];
bool has_upper_frequency() const;
void clear_upper_frequency();
static const int kUpperFrequencyFieldNumber = 354726687;
const ::ywrapper::UintValue& upper_frequency() const;
::ywrapper::UintValue* release_upper_frequency();
::ywrapper::UintValue* mutable_upper_frequency();
void set_allocated_upper_frequency(::ywrapper::UintValue* upper_frequency);
// .ywrapper.UintValue lower_frequency = 403991936 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/state/lower-frequency"];
bool has_lower_frequency() const;
void clear_lower_frequency();
static const int kLowerFrequencyFieldNumber = 403991936;
const ::ywrapper::UintValue& lower_frequency() const;
::ywrapper::UintValue* release_lower_frequency();
::ywrapper::UintValue* mutable_lower_frequency();
void set_allocated_lower_frequency(::ywrapper::UintValue* lower_frequency);
// @@protoc_insertion_point(class_scope:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::ywrapper::BytesValue* psd_;
::ywrapper::UintValue* upper_frequency_;
::ywrapper::UintValue* lower_frequency_;
mutable int _cached_size_;
friend struct ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::TableStruct;
friend void ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::InitDefaultsChannelMonitors_ChannelMonitor_Channels_Channel_StateImpl();
};
// -------------------------------------------------------------------
class ChannelMonitors_ChannelMonitor_Channels_Channel : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel) */ {
public:
ChannelMonitors_ChannelMonitor_Channels_Channel();
virtual ~ChannelMonitors_ChannelMonitor_Channels_Channel();
ChannelMonitors_ChannelMonitor_Channels_Channel(const ChannelMonitors_ChannelMonitor_Channels_Channel& from);
inline ChannelMonitors_ChannelMonitor_Channels_Channel& operator=(const ChannelMonitors_ChannelMonitor_Channels_Channel& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
ChannelMonitors_ChannelMonitor_Channels_Channel(ChannelMonitors_ChannelMonitor_Channels_Channel&& from) noexcept
: ChannelMonitors_ChannelMonitor_Channels_Channel() {
*this = ::std::move(from);
}
inline ChannelMonitors_ChannelMonitor_Channels_Channel& operator=(ChannelMonitors_ChannelMonitor_Channels_Channel&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const ChannelMonitors_ChannelMonitor_Channels_Channel& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ChannelMonitors_ChannelMonitor_Channels_Channel* internal_default_instance() {
return reinterpret_cast<const ChannelMonitors_ChannelMonitor_Channels_Channel*>(
&_ChannelMonitors_ChannelMonitor_Channels_Channel_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
1;
void Swap(ChannelMonitors_ChannelMonitor_Channels_Channel* other);
friend void swap(ChannelMonitors_ChannelMonitor_Channels_Channel& a, ChannelMonitors_ChannelMonitor_Channels_Channel& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline ChannelMonitors_ChannelMonitor_Channels_Channel* New() const PROTOBUF_FINAL { return New(NULL); }
ChannelMonitors_ChannelMonitor_Channels_Channel* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ChannelMonitors_ChannelMonitor_Channels_Channel& from);
void MergeFrom(const ChannelMonitors_ChannelMonitor_Channels_Channel& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ChannelMonitors_ChannelMonitor_Channels_Channel* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
typedef ChannelMonitors_ChannelMonitor_Channels_Channel_State State;
// accessors -------------------------------------------------------
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State state = 216667371 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/state"];
bool has_state() const;
void clear_state();
static const int kStateFieldNumber = 216667371;
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State& state() const;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State* release_state();
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State* mutable_state();
void set_allocated_state(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State* state);
// @@protoc_insertion_point(class_scope:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State* state_;
mutable int _cached_size_;
friend struct ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::TableStruct;
friend void ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::InitDefaultsChannelMonitors_ChannelMonitor_Channels_ChannelImpl();
};
// -------------------------------------------------------------------
class ChannelMonitors_ChannelMonitor_Channels_ChannelKey : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey) */ {
public:
ChannelMonitors_ChannelMonitor_Channels_ChannelKey();
virtual ~ChannelMonitors_ChannelMonitor_Channels_ChannelKey();
ChannelMonitors_ChannelMonitor_Channels_ChannelKey(const ChannelMonitors_ChannelMonitor_Channels_ChannelKey& from);
inline ChannelMonitors_ChannelMonitor_Channels_ChannelKey& operator=(const ChannelMonitors_ChannelMonitor_Channels_ChannelKey& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
ChannelMonitors_ChannelMonitor_Channels_ChannelKey(ChannelMonitors_ChannelMonitor_Channels_ChannelKey&& from) noexcept
: ChannelMonitors_ChannelMonitor_Channels_ChannelKey() {
*this = ::std::move(from);
}
inline ChannelMonitors_ChannelMonitor_Channels_ChannelKey& operator=(ChannelMonitors_ChannelMonitor_Channels_ChannelKey&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const ChannelMonitors_ChannelMonitor_Channels_ChannelKey& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ChannelMonitors_ChannelMonitor_Channels_ChannelKey* internal_default_instance() {
return reinterpret_cast<const ChannelMonitors_ChannelMonitor_Channels_ChannelKey*>(
&_ChannelMonitors_ChannelMonitor_Channels_ChannelKey_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
2;
void Swap(ChannelMonitors_ChannelMonitor_Channels_ChannelKey* other);
friend void swap(ChannelMonitors_ChannelMonitor_Channels_ChannelKey& a, ChannelMonitors_ChannelMonitor_Channels_ChannelKey& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline ChannelMonitors_ChannelMonitor_Channels_ChannelKey* New() const PROTOBUF_FINAL { return New(NULL); }
ChannelMonitors_ChannelMonitor_Channels_ChannelKey* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ChannelMonitors_ChannelMonitor_Channels_ChannelKey& from);
void MergeFrom(const ChannelMonitors_ChannelMonitor_Channels_ChannelKey& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ChannelMonitors_ChannelMonitor_Channels_ChannelKey* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel channel = 3;
bool has_channel() const;
void clear_channel();
static const int kChannelFieldNumber = 3;
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel& channel() const;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel* release_channel();
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel* mutable_channel();
void set_allocated_channel(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel* channel);
// uint64 lower_frequency = 1 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/lower-frequency"];
void clear_lower_frequency();
static const int kLowerFrequencyFieldNumber = 1;
::google::protobuf::uint64 lower_frequency() const;
void set_lower_frequency(::google::protobuf::uint64 value);
// uint64 upper_frequency = 2 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/upper-frequency"];
void clear_upper_frequency();
static const int kUpperFrequencyFieldNumber = 2;
::google::protobuf::uint64 upper_frequency() const;
void set_upper_frequency(::google::protobuf::uint64 value);
// @@protoc_insertion_point(class_scope:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel* channel_;
::google::protobuf::uint64 lower_frequency_;
::google::protobuf::uint64 upper_frequency_;
mutable int _cached_size_;
friend struct ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::TableStruct;
friend void ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::InitDefaultsChannelMonitors_ChannelMonitor_Channels_ChannelKeyImpl();
};
// -------------------------------------------------------------------
class ChannelMonitors_ChannelMonitor_Channels : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels) */ {
public:
ChannelMonitors_ChannelMonitor_Channels();
virtual ~ChannelMonitors_ChannelMonitor_Channels();
ChannelMonitors_ChannelMonitor_Channels(const ChannelMonitors_ChannelMonitor_Channels& from);
inline ChannelMonitors_ChannelMonitor_Channels& operator=(const ChannelMonitors_ChannelMonitor_Channels& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
ChannelMonitors_ChannelMonitor_Channels(ChannelMonitors_ChannelMonitor_Channels&& from) noexcept
: ChannelMonitors_ChannelMonitor_Channels() {
*this = ::std::move(from);
}
inline ChannelMonitors_ChannelMonitor_Channels& operator=(ChannelMonitors_ChannelMonitor_Channels&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const ChannelMonitors_ChannelMonitor_Channels& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ChannelMonitors_ChannelMonitor_Channels* internal_default_instance() {
return reinterpret_cast<const ChannelMonitors_ChannelMonitor_Channels*>(
&_ChannelMonitors_ChannelMonitor_Channels_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
3;
void Swap(ChannelMonitors_ChannelMonitor_Channels* other);
friend void swap(ChannelMonitors_ChannelMonitor_Channels& a, ChannelMonitors_ChannelMonitor_Channels& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline ChannelMonitors_ChannelMonitor_Channels* New() const PROTOBUF_FINAL { return New(NULL); }
ChannelMonitors_ChannelMonitor_Channels* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ChannelMonitors_ChannelMonitor_Channels& from);
void MergeFrom(const ChannelMonitors_ChannelMonitor_Channels& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ChannelMonitors_ChannelMonitor_Channels* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
typedef ChannelMonitors_ChannelMonitor_Channels_Channel Channel;
typedef ChannelMonitors_ChannelMonitor_Channels_ChannelKey ChannelKey;
// accessors -------------------------------------------------------
// repeated .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey channel = 494547849 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel"];
int channel_size() const;
void clear_channel();
static const int kChannelFieldNumber = 494547849;
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey& channel(int index) const;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey* mutable_channel(int index);
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey* add_channel();
::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey >*
mutable_channel();
const ::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey >&
channel() const;
// @@protoc_insertion_point(class_scope:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey > channel_;
mutable int _cached_size_;
friend struct ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::TableStruct;
friend void ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::InitDefaultsChannelMonitors_ChannelMonitor_ChannelsImpl();
};
// -------------------------------------------------------------------
class ChannelMonitors_ChannelMonitor_Config : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config) */ {
public:
ChannelMonitors_ChannelMonitor_Config();
virtual ~ChannelMonitors_ChannelMonitor_Config();
ChannelMonitors_ChannelMonitor_Config(const ChannelMonitors_ChannelMonitor_Config& from);
inline ChannelMonitors_ChannelMonitor_Config& operator=(const ChannelMonitors_ChannelMonitor_Config& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
ChannelMonitors_ChannelMonitor_Config(ChannelMonitors_ChannelMonitor_Config&& from) noexcept
: ChannelMonitors_ChannelMonitor_Config() {
*this = ::std::move(from);
}
inline ChannelMonitors_ChannelMonitor_Config& operator=(ChannelMonitors_ChannelMonitor_Config&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const ChannelMonitors_ChannelMonitor_Config& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ChannelMonitors_ChannelMonitor_Config* internal_default_instance() {
return reinterpret_cast<const ChannelMonitors_ChannelMonitor_Config*>(
&_ChannelMonitors_ChannelMonitor_Config_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
4;
void Swap(ChannelMonitors_ChannelMonitor_Config* other);
friend void swap(ChannelMonitors_ChannelMonitor_Config& a, ChannelMonitors_ChannelMonitor_Config& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline ChannelMonitors_ChannelMonitor_Config* New() const PROTOBUF_FINAL { return New(NULL); }
ChannelMonitors_ChannelMonitor_Config* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ChannelMonitors_ChannelMonitor_Config& from);
void MergeFrom(const ChannelMonitors_ChannelMonitor_Config& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ChannelMonitors_ChannelMonitor_Config* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// .ywrapper.StringValue monitor_port = 92959424 [(.yext.schemapath) = "/channel-monitors/channel-monitor/config/monitor-port"];
bool has_monitor_port() const;
void clear_monitor_port();
static const int kMonitorPortFieldNumber = 92959424;
const ::ywrapper::StringValue& monitor_port() const;
::ywrapper::StringValue* release_monitor_port();
::ywrapper::StringValue* mutable_monitor_port();
void set_allocated_monitor_port(::ywrapper::StringValue* monitor_port);
// .ywrapper.StringValue name = 232841471 [(.yext.schemapath) = "/channel-monitors/channel-monitor/config/name"];
bool has_name() const;
void clear_name();
static const int kNameFieldNumber = 232841471;
const ::ywrapper::StringValue& name() const;
::ywrapper::StringValue* release_name();
::ywrapper::StringValue* mutable_name();
void set_allocated_name(::ywrapper::StringValue* name);
// @@protoc_insertion_point(class_scope:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::ywrapper::StringValue* monitor_port_;
::ywrapper::StringValue* name_;
mutable int _cached_size_;
friend struct ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::TableStruct;
friend void ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::InitDefaultsChannelMonitors_ChannelMonitor_ConfigImpl();
};
// -------------------------------------------------------------------
class ChannelMonitors_ChannelMonitor_State : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State) */ {
public:
ChannelMonitors_ChannelMonitor_State();
virtual ~ChannelMonitors_ChannelMonitor_State();
ChannelMonitors_ChannelMonitor_State(const ChannelMonitors_ChannelMonitor_State& from);
inline ChannelMonitors_ChannelMonitor_State& operator=(const ChannelMonitors_ChannelMonitor_State& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
ChannelMonitors_ChannelMonitor_State(ChannelMonitors_ChannelMonitor_State&& from) noexcept
: ChannelMonitors_ChannelMonitor_State() {
*this = ::std::move(from);
}
inline ChannelMonitors_ChannelMonitor_State& operator=(ChannelMonitors_ChannelMonitor_State&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const ChannelMonitors_ChannelMonitor_State& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ChannelMonitors_ChannelMonitor_State* internal_default_instance() {
return reinterpret_cast<const ChannelMonitors_ChannelMonitor_State*>(
&_ChannelMonitors_ChannelMonitor_State_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
5;
void Swap(ChannelMonitors_ChannelMonitor_State* other);
friend void swap(ChannelMonitors_ChannelMonitor_State& a, ChannelMonitors_ChannelMonitor_State& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline ChannelMonitors_ChannelMonitor_State* New() const PROTOBUF_FINAL { return New(NULL); }
ChannelMonitors_ChannelMonitor_State* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ChannelMonitors_ChannelMonitor_State& from);
void MergeFrom(const ChannelMonitors_ChannelMonitor_State& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ChannelMonitors_ChannelMonitor_State* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// .ywrapper.StringValue monitor_port = 183347389 [(.yext.schemapath) = "/channel-monitors/channel-monitor/state/monitor-port"];
bool has_monitor_port() const;
void clear_monitor_port();
static const int kMonitorPortFieldNumber = 183347389;
const ::ywrapper::StringValue& monitor_port() const;
::ywrapper::StringValue* release_monitor_port();
::ywrapper::StringValue* mutable_monitor_port();
void set_allocated_monitor_port(::ywrapper::StringValue* monitor_port);
// .ywrapper.StringValue name = 248662866 [(.yext.schemapath) = "/channel-monitors/channel-monitor/state/name"];
bool has_name() const;
void clear_name();
static const int kNameFieldNumber = 248662866;
const ::ywrapper::StringValue& name() const;
::ywrapper::StringValue* release_name();
::ywrapper::StringValue* mutable_name();
void set_allocated_name(::ywrapper::StringValue* name);
// @@protoc_insertion_point(class_scope:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::ywrapper::StringValue* monitor_port_;
::ywrapper::StringValue* name_;
mutable int _cached_size_;
friend struct ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::TableStruct;
friend void ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::InitDefaultsChannelMonitors_ChannelMonitor_StateImpl();
};
// -------------------------------------------------------------------
class ChannelMonitors_ChannelMonitor : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor) */ {
public:
ChannelMonitors_ChannelMonitor();
virtual ~ChannelMonitors_ChannelMonitor();
ChannelMonitors_ChannelMonitor(const ChannelMonitors_ChannelMonitor& from);
inline ChannelMonitors_ChannelMonitor& operator=(const ChannelMonitors_ChannelMonitor& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
ChannelMonitors_ChannelMonitor(ChannelMonitors_ChannelMonitor&& from) noexcept
: ChannelMonitors_ChannelMonitor() {
*this = ::std::move(from);
}
inline ChannelMonitors_ChannelMonitor& operator=(ChannelMonitors_ChannelMonitor&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const ChannelMonitors_ChannelMonitor& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ChannelMonitors_ChannelMonitor* internal_default_instance() {
return reinterpret_cast<const ChannelMonitors_ChannelMonitor*>(
&_ChannelMonitors_ChannelMonitor_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
6;
void Swap(ChannelMonitors_ChannelMonitor* other);
friend void swap(ChannelMonitors_ChannelMonitor& a, ChannelMonitors_ChannelMonitor& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline ChannelMonitors_ChannelMonitor* New() const PROTOBUF_FINAL { return New(NULL); }
ChannelMonitors_ChannelMonitor* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ChannelMonitors_ChannelMonitor& from);
void MergeFrom(const ChannelMonitors_ChannelMonitor& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ChannelMonitors_ChannelMonitor* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
typedef ChannelMonitors_ChannelMonitor_Channels Channels;
typedef ChannelMonitors_ChannelMonitor_Config Config;
typedef ChannelMonitors_ChannelMonitor_State State;
// accessors -------------------------------------------------------
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels channels = 29366261 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels"];
bool has_channels() const;
void clear_channels();
static const int kChannelsFieldNumber = 29366261;
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels& channels() const;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels* release_channels();
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels* mutable_channels();
void set_allocated_channels(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels* channels);
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config config = 381825399 [(.yext.schemapath) = "/channel-monitors/channel-monitor/config"];
bool has_config() const;
void clear_config();
static const int kConfigFieldNumber = 381825399;
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config& config() const;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config* release_config();
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config* mutable_config();
void set_allocated_config(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config* config);
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State state = 460661672 [(.yext.schemapath) = "/channel-monitors/channel-monitor/state"];
bool has_state() const;
void clear_state();
static const int kStateFieldNumber = 460661672;
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State& state() const;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State* release_state();
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State* mutable_state();
void set_allocated_state(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State* state);
// @@protoc_insertion_point(class_scope:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels* channels_;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config* config_;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State* state_;
mutable int _cached_size_;
friend struct ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::TableStruct;
friend void ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::InitDefaultsChannelMonitors_ChannelMonitorImpl();
};
// -------------------------------------------------------------------
class ChannelMonitors_ChannelMonitorKey : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey) */ {
public:
ChannelMonitors_ChannelMonitorKey();
virtual ~ChannelMonitors_ChannelMonitorKey();
ChannelMonitors_ChannelMonitorKey(const ChannelMonitors_ChannelMonitorKey& from);
inline ChannelMonitors_ChannelMonitorKey& operator=(const ChannelMonitors_ChannelMonitorKey& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
ChannelMonitors_ChannelMonitorKey(ChannelMonitors_ChannelMonitorKey&& from) noexcept
: ChannelMonitors_ChannelMonitorKey() {
*this = ::std::move(from);
}
inline ChannelMonitors_ChannelMonitorKey& operator=(ChannelMonitors_ChannelMonitorKey&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const ChannelMonitors_ChannelMonitorKey& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ChannelMonitors_ChannelMonitorKey* internal_default_instance() {
return reinterpret_cast<const ChannelMonitors_ChannelMonitorKey*>(
&_ChannelMonitors_ChannelMonitorKey_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
7;
void Swap(ChannelMonitors_ChannelMonitorKey* other);
friend void swap(ChannelMonitors_ChannelMonitorKey& a, ChannelMonitors_ChannelMonitorKey& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline ChannelMonitors_ChannelMonitorKey* New() const PROTOBUF_FINAL { return New(NULL); }
ChannelMonitors_ChannelMonitorKey* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ChannelMonitors_ChannelMonitorKey& from);
void MergeFrom(const ChannelMonitors_ChannelMonitorKey& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ChannelMonitors_ChannelMonitorKey* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// string name = 1 [(.yext.schemapath) = "/channel-monitors/channel-monitor/name"];
void clear_name();
static const int kNameFieldNumber = 1;
const ::std::string& name() const;
void set_name(const ::std::string& value);
#if LANG_CXX11
void set_name(::std::string&& value);
#endif
void set_name(const char* value);
void set_name(const char* value, size_t size);
::std::string* mutable_name();
::std::string* release_name();
void set_allocated_name(::std::string* name);
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor channel_monitor = 2;
bool has_channel_monitor() const;
void clear_channel_monitor();
static const int kChannelMonitorFieldNumber = 2;
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor& channel_monitor() const;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor* release_channel_monitor();
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor* mutable_channel_monitor();
void set_allocated_channel_monitor(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor* channel_monitor);
// @@protoc_insertion_point(class_scope:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::internal::ArenaStringPtr name_;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor* channel_monitor_;
mutable int _cached_size_;
friend struct ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::TableStruct;
friend void ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::InitDefaultsChannelMonitors_ChannelMonitorKeyImpl();
};
// -------------------------------------------------------------------
class ChannelMonitors : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:openconfig.openconfig_channel_monitor.ChannelMonitors) */ {
public:
ChannelMonitors();
virtual ~ChannelMonitors();
ChannelMonitors(const ChannelMonitors& from);
inline ChannelMonitors& operator=(const ChannelMonitors& from) {
CopyFrom(from);
return *this;
}
#if LANG_CXX11
ChannelMonitors(ChannelMonitors&& from) noexcept
: ChannelMonitors() {
*this = ::std::move(from);
}
inline ChannelMonitors& operator=(ChannelMonitors&& from) noexcept {
if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
if (this != &from) InternalSwap(&from);
} else {
CopyFrom(from);
}
return *this;
}
#endif
static const ::google::protobuf::Descriptor* descriptor();
static const ChannelMonitors& default_instance();
static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY
static inline const ChannelMonitors* internal_default_instance() {
return reinterpret_cast<const ChannelMonitors*>(
&_ChannelMonitors_default_instance_);
}
static PROTOBUF_CONSTEXPR int const kIndexInFileMessages =
8;
void Swap(ChannelMonitors* other);
friend void swap(ChannelMonitors& a, ChannelMonitors& b) {
a.Swap(&b);
}
// implements Message ----------------------------------------------
inline ChannelMonitors* New() const PROTOBUF_FINAL { return New(NULL); }
ChannelMonitors* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL;
void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL;
void CopyFrom(const ChannelMonitors& from);
void MergeFrom(const ChannelMonitors& from);
void Clear() PROTOBUF_FINAL;
bool IsInitialized() const PROTOBUF_FINAL;
size_t ByteSizeLong() const PROTOBUF_FINAL;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL;
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL;
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL;
int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const PROTOBUF_FINAL;
void InternalSwap(ChannelMonitors* other);
private:
inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
return NULL;
}
inline void* MaybeArenaPtr() const {
return NULL;
}
public:
::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL;
// nested types ----------------------------------------------------
typedef ChannelMonitors_ChannelMonitor ChannelMonitor;
typedef ChannelMonitors_ChannelMonitorKey ChannelMonitorKey;
// accessors -------------------------------------------------------
// repeated .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey channel_monitor = 228142614 [(.yext.schemapath) = "/channel-monitors/channel-monitor"];
int channel_monitor_size() const;
void clear_channel_monitor();
static const int kChannelMonitorFieldNumber = 228142614;
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey& channel_monitor(int index) const;
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey* mutable_channel_monitor(int index);
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey* add_channel_monitor();
::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey >*
mutable_channel_monitor();
const ::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey >&
channel_monitor() const;
// @@protoc_insertion_point(class_scope:openconfig.openconfig_channel_monitor.ChannelMonitors)
private:
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey > channel_monitor_;
mutable int _cached_size_;
friend struct ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::TableStruct;
friend void ::protobuf_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto::InitDefaultsChannelMonitorsImpl();
};
// ===================================================================
// ===================================================================
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif // __GNUC__
// ChannelMonitors_ChannelMonitor_Channels_Channel_State
// .ywrapper.UintValue lower_frequency = 403991936 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/state/lower-frequency"];
inline bool ChannelMonitors_ChannelMonitor_Channels_Channel_State::has_lower_frequency() const {
return this != internal_default_instance() && lower_frequency_ != NULL;
}
inline const ::ywrapper::UintValue& ChannelMonitors_ChannelMonitor_Channels_Channel_State::lower_frequency() const {
const ::ywrapper::UintValue* p = lower_frequency_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.lower_frequency)
return p != NULL ? *p : *reinterpret_cast<const ::ywrapper::UintValue*>(
&::ywrapper::_UintValue_default_instance_);
}
inline ::ywrapper::UintValue* ChannelMonitors_ChannelMonitor_Channels_Channel_State::release_lower_frequency() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.lower_frequency)
::ywrapper::UintValue* temp = lower_frequency_;
lower_frequency_ = NULL;
return temp;
}
inline ::ywrapper::UintValue* ChannelMonitors_ChannelMonitor_Channels_Channel_State::mutable_lower_frequency() {
if (lower_frequency_ == NULL) {
lower_frequency_ = new ::ywrapper::UintValue;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.lower_frequency)
return lower_frequency_;
}
inline void ChannelMonitors_ChannelMonitor_Channels_Channel_State::set_allocated_lower_frequency(::ywrapper::UintValue* lower_frequency) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete reinterpret_cast< ::google::protobuf::MessageLite*>(lower_frequency_);
}
if (lower_frequency) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
lower_frequency = ::google::protobuf::internal::GetOwnedMessage(
message_arena, lower_frequency, submessage_arena);
}
} else {
}
lower_frequency_ = lower_frequency;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.lower_frequency)
}
// .ywrapper.BytesValue psd = 31486931 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/state/psd"];
inline bool ChannelMonitors_ChannelMonitor_Channels_Channel_State::has_psd() const {
return this != internal_default_instance() && psd_ != NULL;
}
inline const ::ywrapper::BytesValue& ChannelMonitors_ChannelMonitor_Channels_Channel_State::psd() const {
const ::ywrapper::BytesValue* p = psd_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.psd)
return p != NULL ? *p : *reinterpret_cast<const ::ywrapper::BytesValue*>(
&::ywrapper::_BytesValue_default_instance_);
}
inline ::ywrapper::BytesValue* ChannelMonitors_ChannelMonitor_Channels_Channel_State::release_psd() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.psd)
::ywrapper::BytesValue* temp = psd_;
psd_ = NULL;
return temp;
}
inline ::ywrapper::BytesValue* ChannelMonitors_ChannelMonitor_Channels_Channel_State::mutable_psd() {
if (psd_ == NULL) {
psd_ = new ::ywrapper::BytesValue;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.psd)
return psd_;
}
inline void ChannelMonitors_ChannelMonitor_Channels_Channel_State::set_allocated_psd(::ywrapper::BytesValue* psd) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete reinterpret_cast< ::google::protobuf::MessageLite*>(psd_);
}
if (psd) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
psd = ::google::protobuf::internal::GetOwnedMessage(
message_arena, psd, submessage_arena);
}
} else {
}
psd_ = psd;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.psd)
}
// .ywrapper.UintValue upper_frequency = 354726687 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/state/upper-frequency"];
inline bool ChannelMonitors_ChannelMonitor_Channels_Channel_State::has_upper_frequency() const {
return this != internal_default_instance() && upper_frequency_ != NULL;
}
inline const ::ywrapper::UintValue& ChannelMonitors_ChannelMonitor_Channels_Channel_State::upper_frequency() const {
const ::ywrapper::UintValue* p = upper_frequency_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.upper_frequency)
return p != NULL ? *p : *reinterpret_cast<const ::ywrapper::UintValue*>(
&::ywrapper::_UintValue_default_instance_);
}
inline ::ywrapper::UintValue* ChannelMonitors_ChannelMonitor_Channels_Channel_State::release_upper_frequency() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.upper_frequency)
::ywrapper::UintValue* temp = upper_frequency_;
upper_frequency_ = NULL;
return temp;
}
inline ::ywrapper::UintValue* ChannelMonitors_ChannelMonitor_Channels_Channel_State::mutable_upper_frequency() {
if (upper_frequency_ == NULL) {
upper_frequency_ = new ::ywrapper::UintValue;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.upper_frequency)
return upper_frequency_;
}
inline void ChannelMonitors_ChannelMonitor_Channels_Channel_State::set_allocated_upper_frequency(::ywrapper::UintValue* upper_frequency) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete reinterpret_cast< ::google::protobuf::MessageLite*>(upper_frequency_);
}
if (upper_frequency) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
upper_frequency = ::google::protobuf::internal::GetOwnedMessage(
message_arena, upper_frequency, submessage_arena);
}
} else {
}
upper_frequency_ = upper_frequency;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State.upper_frequency)
}
// -------------------------------------------------------------------
// ChannelMonitors_ChannelMonitor_Channels_Channel
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.State state = 216667371 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/state"];
inline bool ChannelMonitors_ChannelMonitor_Channels_Channel::has_state() const {
return this != internal_default_instance() && state_ != NULL;
}
inline void ChannelMonitors_ChannelMonitor_Channels_Channel::clear_state() {
if (GetArenaNoVirtual() == NULL && state_ != NULL) {
delete state_;
}
state_ = NULL;
}
inline const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State& ChannelMonitors_ChannelMonitor_Channels_Channel::state() const {
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State* p = state_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.state)
return p != NULL ? *p : *reinterpret_cast<const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State*>(
&::openconfig::openconfig_channel_monitor::_ChannelMonitors_ChannelMonitor_Channels_Channel_State_default_instance_);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State* ChannelMonitors_ChannelMonitor_Channels_Channel::release_state() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.state)
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State* temp = state_;
state_ = NULL;
return temp;
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State* ChannelMonitors_ChannelMonitor_Channels_Channel::mutable_state() {
if (state_ == NULL) {
state_ = new ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.state)
return state_;
}
inline void ChannelMonitors_ChannelMonitor_Channels_Channel::set_allocated_state(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel_State* state) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete state_;
}
if (state) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
state = ::google::protobuf::internal::GetOwnedMessage(
message_arena, state, submessage_arena);
}
} else {
}
state_ = state;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel.state)
}
// -------------------------------------------------------------------
// ChannelMonitors_ChannelMonitor_Channels_ChannelKey
// uint64 lower_frequency = 1 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/lower-frequency"];
inline void ChannelMonitors_ChannelMonitor_Channels_ChannelKey::clear_lower_frequency() {
lower_frequency_ = GOOGLE_ULONGLONG(0);
}
inline ::google::protobuf::uint64 ChannelMonitors_ChannelMonitor_Channels_ChannelKey::lower_frequency() const {
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey.lower_frequency)
return lower_frequency_;
}
inline void ChannelMonitors_ChannelMonitor_Channels_ChannelKey::set_lower_frequency(::google::protobuf::uint64 value) {
lower_frequency_ = value;
// @@protoc_insertion_point(field_set:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey.lower_frequency)
}
// uint64 upper_frequency = 2 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel/upper-frequency"];
inline void ChannelMonitors_ChannelMonitor_Channels_ChannelKey::clear_upper_frequency() {
upper_frequency_ = GOOGLE_ULONGLONG(0);
}
inline ::google::protobuf::uint64 ChannelMonitors_ChannelMonitor_Channels_ChannelKey::upper_frequency() const {
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey.upper_frequency)
return upper_frequency_;
}
inline void ChannelMonitors_ChannelMonitor_Channels_ChannelKey::set_upper_frequency(::google::protobuf::uint64 value) {
upper_frequency_ = value;
// @@protoc_insertion_point(field_set:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey.upper_frequency)
}
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.Channel channel = 3;
inline bool ChannelMonitors_ChannelMonitor_Channels_ChannelKey::has_channel() const {
return this != internal_default_instance() && channel_ != NULL;
}
inline void ChannelMonitors_ChannelMonitor_Channels_ChannelKey::clear_channel() {
if (GetArenaNoVirtual() == NULL && channel_ != NULL) {
delete channel_;
}
channel_ = NULL;
}
inline const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel& ChannelMonitors_ChannelMonitor_Channels_ChannelKey::channel() const {
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel* p = channel_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey.channel)
return p != NULL ? *p : *reinterpret_cast<const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel*>(
&::openconfig::openconfig_channel_monitor::_ChannelMonitors_ChannelMonitor_Channels_Channel_default_instance_);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel* ChannelMonitors_ChannelMonitor_Channels_ChannelKey::release_channel() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey.channel)
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel* temp = channel_;
channel_ = NULL;
return temp;
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel* ChannelMonitors_ChannelMonitor_Channels_ChannelKey::mutable_channel() {
if (channel_ == NULL) {
channel_ = new ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey.channel)
return channel_;
}
inline void ChannelMonitors_ChannelMonitor_Channels_ChannelKey::set_allocated_channel(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_Channel* channel) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete channel_;
}
if (channel) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
channel = ::google::protobuf::internal::GetOwnedMessage(
message_arena, channel, submessage_arena);
}
} else {
}
channel_ = channel;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey.channel)
}
// -------------------------------------------------------------------
// ChannelMonitors_ChannelMonitor_Channels
// repeated .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.ChannelKey channel = 494547849 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels/channel"];
inline int ChannelMonitors_ChannelMonitor_Channels::channel_size() const {
return channel_.size();
}
inline void ChannelMonitors_ChannelMonitor_Channels::clear_channel() {
channel_.Clear();
}
inline const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey& ChannelMonitors_ChannelMonitor_Channels::channel(int index) const {
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.channel)
return channel_.Get(index);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey* ChannelMonitors_ChannelMonitor_Channels::mutable_channel(int index) {
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.channel)
return channel_.Mutable(index);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey* ChannelMonitors_ChannelMonitor_Channels::add_channel() {
// @@protoc_insertion_point(field_add:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.channel)
return channel_.Add();
}
inline ::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey >*
ChannelMonitors_ChannelMonitor_Channels::mutable_channel() {
// @@protoc_insertion_point(field_mutable_list:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.channel)
return &channel_;
}
inline const ::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels_ChannelKey >&
ChannelMonitors_ChannelMonitor_Channels::channel() const {
// @@protoc_insertion_point(field_list:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels.channel)
return channel_;
}
// -------------------------------------------------------------------
// ChannelMonitors_ChannelMonitor_Config
// .ywrapper.StringValue monitor_port = 92959424 [(.yext.schemapath) = "/channel-monitors/channel-monitor/config/monitor-port"];
inline bool ChannelMonitors_ChannelMonitor_Config::has_monitor_port() const {
return this != internal_default_instance() && monitor_port_ != NULL;
}
inline const ::ywrapper::StringValue& ChannelMonitors_ChannelMonitor_Config::monitor_port() const {
const ::ywrapper::StringValue* p = monitor_port_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config.monitor_port)
return p != NULL ? *p : *reinterpret_cast<const ::ywrapper::StringValue*>(
&::ywrapper::_StringValue_default_instance_);
}
inline ::ywrapper::StringValue* ChannelMonitors_ChannelMonitor_Config::release_monitor_port() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config.monitor_port)
::ywrapper::StringValue* temp = monitor_port_;
monitor_port_ = NULL;
return temp;
}
inline ::ywrapper::StringValue* ChannelMonitors_ChannelMonitor_Config::mutable_monitor_port() {
if (monitor_port_ == NULL) {
monitor_port_ = new ::ywrapper::StringValue;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config.monitor_port)
return monitor_port_;
}
inline void ChannelMonitors_ChannelMonitor_Config::set_allocated_monitor_port(::ywrapper::StringValue* monitor_port) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete reinterpret_cast< ::google::protobuf::MessageLite*>(monitor_port_);
}
if (monitor_port) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
monitor_port = ::google::protobuf::internal::GetOwnedMessage(
message_arena, monitor_port, submessage_arena);
}
} else {
}
monitor_port_ = monitor_port;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config.monitor_port)
}
// .ywrapper.StringValue name = 232841471 [(.yext.schemapath) = "/channel-monitors/channel-monitor/config/name"];
inline bool ChannelMonitors_ChannelMonitor_Config::has_name() const {
return this != internal_default_instance() && name_ != NULL;
}
inline const ::ywrapper::StringValue& ChannelMonitors_ChannelMonitor_Config::name() const {
const ::ywrapper::StringValue* p = name_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config.name)
return p != NULL ? *p : *reinterpret_cast<const ::ywrapper::StringValue*>(
&::ywrapper::_StringValue_default_instance_);
}
inline ::ywrapper::StringValue* ChannelMonitors_ChannelMonitor_Config::release_name() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config.name)
::ywrapper::StringValue* temp = name_;
name_ = NULL;
return temp;
}
inline ::ywrapper::StringValue* ChannelMonitors_ChannelMonitor_Config::mutable_name() {
if (name_ == NULL) {
name_ = new ::ywrapper::StringValue;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config.name)
return name_;
}
inline void ChannelMonitors_ChannelMonitor_Config::set_allocated_name(::ywrapper::StringValue* name) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete reinterpret_cast< ::google::protobuf::MessageLite*>(name_);
}
if (name) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
name = ::google::protobuf::internal::GetOwnedMessage(
message_arena, name, submessage_arena);
}
} else {
}
name_ = name;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config.name)
}
// -------------------------------------------------------------------
// ChannelMonitors_ChannelMonitor_State
// .ywrapper.StringValue monitor_port = 183347389 [(.yext.schemapath) = "/channel-monitors/channel-monitor/state/monitor-port"];
inline bool ChannelMonitors_ChannelMonitor_State::has_monitor_port() const {
return this != internal_default_instance() && monitor_port_ != NULL;
}
inline const ::ywrapper::StringValue& ChannelMonitors_ChannelMonitor_State::monitor_port() const {
const ::ywrapper::StringValue* p = monitor_port_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State.monitor_port)
return p != NULL ? *p : *reinterpret_cast<const ::ywrapper::StringValue*>(
&::ywrapper::_StringValue_default_instance_);
}
inline ::ywrapper::StringValue* ChannelMonitors_ChannelMonitor_State::release_monitor_port() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State.monitor_port)
::ywrapper::StringValue* temp = monitor_port_;
monitor_port_ = NULL;
return temp;
}
inline ::ywrapper::StringValue* ChannelMonitors_ChannelMonitor_State::mutable_monitor_port() {
if (monitor_port_ == NULL) {
monitor_port_ = new ::ywrapper::StringValue;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State.monitor_port)
return monitor_port_;
}
inline void ChannelMonitors_ChannelMonitor_State::set_allocated_monitor_port(::ywrapper::StringValue* monitor_port) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete reinterpret_cast< ::google::protobuf::MessageLite*>(monitor_port_);
}
if (monitor_port) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
monitor_port = ::google::protobuf::internal::GetOwnedMessage(
message_arena, monitor_port, submessage_arena);
}
} else {
}
monitor_port_ = monitor_port;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State.monitor_port)
}
// .ywrapper.StringValue name = 248662866 [(.yext.schemapath) = "/channel-monitors/channel-monitor/state/name"];
inline bool ChannelMonitors_ChannelMonitor_State::has_name() const {
return this != internal_default_instance() && name_ != NULL;
}
inline const ::ywrapper::StringValue& ChannelMonitors_ChannelMonitor_State::name() const {
const ::ywrapper::StringValue* p = name_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State.name)
return p != NULL ? *p : *reinterpret_cast<const ::ywrapper::StringValue*>(
&::ywrapper::_StringValue_default_instance_);
}
inline ::ywrapper::StringValue* ChannelMonitors_ChannelMonitor_State::release_name() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State.name)
::ywrapper::StringValue* temp = name_;
name_ = NULL;
return temp;
}
inline ::ywrapper::StringValue* ChannelMonitors_ChannelMonitor_State::mutable_name() {
if (name_ == NULL) {
name_ = new ::ywrapper::StringValue;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State.name)
return name_;
}
inline void ChannelMonitors_ChannelMonitor_State::set_allocated_name(::ywrapper::StringValue* name) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete reinterpret_cast< ::google::protobuf::MessageLite*>(name_);
}
if (name) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
name = ::google::protobuf::internal::GetOwnedMessage(
message_arena, name, submessage_arena);
}
} else {
}
name_ = name;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State.name)
}
// -------------------------------------------------------------------
// ChannelMonitors_ChannelMonitor
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Channels channels = 29366261 [(.yext.schemapath) = "/channel-monitors/channel-monitor/channels"];
inline bool ChannelMonitors_ChannelMonitor::has_channels() const {
return this != internal_default_instance() && channels_ != NULL;
}
inline void ChannelMonitors_ChannelMonitor::clear_channels() {
if (GetArenaNoVirtual() == NULL && channels_ != NULL) {
delete channels_;
}
channels_ = NULL;
}
inline const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels& ChannelMonitors_ChannelMonitor::channels() const {
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels* p = channels_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.channels)
return p != NULL ? *p : *reinterpret_cast<const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels*>(
&::openconfig::openconfig_channel_monitor::_ChannelMonitors_ChannelMonitor_Channels_default_instance_);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels* ChannelMonitors_ChannelMonitor::release_channels() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.channels)
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels* temp = channels_;
channels_ = NULL;
return temp;
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels* ChannelMonitors_ChannelMonitor::mutable_channels() {
if (channels_ == NULL) {
channels_ = new ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.channels)
return channels_;
}
inline void ChannelMonitors_ChannelMonitor::set_allocated_channels(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Channels* channels) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete channels_;
}
if (channels) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
channels = ::google::protobuf::internal::GetOwnedMessage(
message_arena, channels, submessage_arena);
}
} else {
}
channels_ = channels;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.channels)
}
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.Config config = 381825399 [(.yext.schemapath) = "/channel-monitors/channel-monitor/config"];
inline bool ChannelMonitors_ChannelMonitor::has_config() const {
return this != internal_default_instance() && config_ != NULL;
}
inline void ChannelMonitors_ChannelMonitor::clear_config() {
if (GetArenaNoVirtual() == NULL && config_ != NULL) {
delete config_;
}
config_ = NULL;
}
inline const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config& ChannelMonitors_ChannelMonitor::config() const {
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config* p = config_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.config)
return p != NULL ? *p : *reinterpret_cast<const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config*>(
&::openconfig::openconfig_channel_monitor::_ChannelMonitors_ChannelMonitor_Config_default_instance_);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config* ChannelMonitors_ChannelMonitor::release_config() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.config)
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config* temp = config_;
config_ = NULL;
return temp;
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config* ChannelMonitors_ChannelMonitor::mutable_config() {
if (config_ == NULL) {
config_ = new ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.config)
return config_;
}
inline void ChannelMonitors_ChannelMonitor::set_allocated_config(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_Config* config) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete config_;
}
if (config) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
config = ::google::protobuf::internal::GetOwnedMessage(
message_arena, config, submessage_arena);
}
} else {
}
config_ = config;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.config)
}
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.State state = 460661672 [(.yext.schemapath) = "/channel-monitors/channel-monitor/state"];
inline bool ChannelMonitors_ChannelMonitor::has_state() const {
return this != internal_default_instance() && state_ != NULL;
}
inline void ChannelMonitors_ChannelMonitor::clear_state() {
if (GetArenaNoVirtual() == NULL && state_ != NULL) {
delete state_;
}
state_ = NULL;
}
inline const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State& ChannelMonitors_ChannelMonitor::state() const {
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State* p = state_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.state)
return p != NULL ? *p : *reinterpret_cast<const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State*>(
&::openconfig::openconfig_channel_monitor::_ChannelMonitors_ChannelMonitor_State_default_instance_);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State* ChannelMonitors_ChannelMonitor::release_state() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.state)
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State* temp = state_;
state_ = NULL;
return temp;
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State* ChannelMonitors_ChannelMonitor::mutable_state() {
if (state_ == NULL) {
state_ = new ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.state)
return state_;
}
inline void ChannelMonitors_ChannelMonitor::set_allocated_state(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor_State* state) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete state_;
}
if (state) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
state = ::google::protobuf::internal::GetOwnedMessage(
message_arena, state, submessage_arena);
}
} else {
}
state_ = state;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor.state)
}
// -------------------------------------------------------------------
// ChannelMonitors_ChannelMonitorKey
// string name = 1 [(.yext.schemapath) = "/channel-monitors/channel-monitor/name"];
inline void ChannelMonitors_ChannelMonitorKey::clear_name() {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline const ::std::string& ChannelMonitors_ChannelMonitorKey::name() const {
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.name)
return name_.GetNoArena();
}
inline void ChannelMonitors_ChannelMonitorKey::set_name(const ::std::string& value) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
// @@protoc_insertion_point(field_set:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.name)
}
#if LANG_CXX11
inline void ChannelMonitors_ChannelMonitorKey::set_name(::std::string&& value) {
name_.SetNoArena(
&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
// @@protoc_insertion_point(field_set_rvalue:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.name)
}
#endif
inline void ChannelMonitors_ChannelMonitorKey::set_name(const char* value) {
GOOGLE_DCHECK(value != NULL);
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
// @@protoc_insertion_point(field_set_char:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.name)
}
inline void ChannelMonitors_ChannelMonitorKey::set_name(const char* value, size_t size) {
name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
::std::string(reinterpret_cast<const char*>(value), size));
// @@protoc_insertion_point(field_set_pointer:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.name)
}
inline ::std::string* ChannelMonitors_ChannelMonitorKey::mutable_name() {
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.name)
return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline ::std::string* ChannelMonitors_ChannelMonitorKey::release_name() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.name)
return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}
inline void ChannelMonitors_ChannelMonitorKey::set_allocated_name(::std::string* name) {
if (name != NULL) {
} else {
}
name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.name)
}
// .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitor channel_monitor = 2;
inline bool ChannelMonitors_ChannelMonitorKey::has_channel_monitor() const {
return this != internal_default_instance() && channel_monitor_ != NULL;
}
inline void ChannelMonitors_ChannelMonitorKey::clear_channel_monitor() {
if (GetArenaNoVirtual() == NULL && channel_monitor_ != NULL) {
delete channel_monitor_;
}
channel_monitor_ = NULL;
}
inline const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor& ChannelMonitors_ChannelMonitorKey::channel_monitor() const {
const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor* p = channel_monitor_;
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.channel_monitor)
return p != NULL ? *p : *reinterpret_cast<const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor*>(
&::openconfig::openconfig_channel_monitor::_ChannelMonitors_ChannelMonitor_default_instance_);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor* ChannelMonitors_ChannelMonitorKey::release_channel_monitor() {
// @@protoc_insertion_point(field_release:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.channel_monitor)
::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor* temp = channel_monitor_;
channel_monitor_ = NULL;
return temp;
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor* ChannelMonitors_ChannelMonitorKey::mutable_channel_monitor() {
if (channel_monitor_ == NULL) {
channel_monitor_ = new ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor;
}
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.channel_monitor)
return channel_monitor_;
}
inline void ChannelMonitors_ChannelMonitorKey::set_allocated_channel_monitor(::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitor* channel_monitor) {
::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
if (message_arena == NULL) {
delete channel_monitor_;
}
if (channel_monitor) {
::google::protobuf::Arena* submessage_arena = NULL;
if (message_arena != submessage_arena) {
channel_monitor = ::google::protobuf::internal::GetOwnedMessage(
message_arena, channel_monitor, submessage_arena);
}
} else {
}
channel_monitor_ = channel_monitor;
// @@protoc_insertion_point(field_set_allocated:openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey.channel_monitor)
}
// -------------------------------------------------------------------
// ChannelMonitors
// repeated .openconfig.openconfig_channel_monitor.ChannelMonitors.ChannelMonitorKey channel_monitor = 228142614 [(.yext.schemapath) = "/channel-monitors/channel-monitor"];
inline int ChannelMonitors::channel_monitor_size() const {
return channel_monitor_.size();
}
inline void ChannelMonitors::clear_channel_monitor() {
channel_monitor_.Clear();
}
inline const ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey& ChannelMonitors::channel_monitor(int index) const {
// @@protoc_insertion_point(field_get:openconfig.openconfig_channel_monitor.ChannelMonitors.channel_monitor)
return channel_monitor_.Get(index);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey* ChannelMonitors::mutable_channel_monitor(int index) {
// @@protoc_insertion_point(field_mutable:openconfig.openconfig_channel_monitor.ChannelMonitors.channel_monitor)
return channel_monitor_.Mutable(index);
}
inline ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey* ChannelMonitors::add_channel_monitor() {
// @@protoc_insertion_point(field_add:openconfig.openconfig_channel_monitor.ChannelMonitors.channel_monitor)
return channel_monitor_.Add();
}
inline ::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey >*
ChannelMonitors::mutable_channel_monitor() {
// @@protoc_insertion_point(field_mutable_list:openconfig.openconfig_channel_monitor.ChannelMonitors.channel_monitor)
return &channel_monitor_;
}
inline const ::google::protobuf::RepeatedPtrField< ::openconfig::openconfig_channel_monitor::ChannelMonitors_ChannelMonitorKey >&
ChannelMonitors::channel_monitor() const {
// @@protoc_insertion_point(field_list:openconfig.openconfig_channel_monitor.ChannelMonitors.channel_monitor)
return channel_monitor_;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // __GNUC__
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// -------------------------------------------------------------------
// @@protoc_insertion_point(namespace_scope)
} // namespace openconfig_channel_monitor
} // namespace openconfig
// @@protoc_insertion_point(global_scope)
#endif // PROTOBUF_openconfig_2fopenconfig_5fchannel_5fmonitor_2fopenconfig_5fchannel_5fmonitor_2eproto__INCLUDED
| 49.239775 | 239 | 0.775939 |
ff6d674d2e12786335163cd54806269f984cd83f | 2,321 | c | C | cmds/balloon.c | DentonGentry/gfiber-platform | 2ba5266103aad0b7b676555eebd3c2061ddb8333 | [
"Apache-2.0"
] | 8 | 2017-09-24T03:11:46.000Z | 2021-08-24T04:29:14.000Z | cmds/balloon.c | DentonGentry/gfiber-platform | 2ba5266103aad0b7b676555eebd3c2061ddb8333 | [
"Apache-2.0"
] | null | null | null | cmds/balloon.c | DentonGentry/gfiber-platform | 2ba5266103aad0b7b676555eebd3c2061ddb8333 | [
"Apache-2.0"
] | 1 | 2017-10-05T23:04:10.000Z | 2017-10-05T23:04:10.000Z | /*
* Copyright 2012-2014 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <memory.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#define BLOCKSIZE (8192 * 1024 - 32) // leave room for per-block overhead
// If you run this on your desktop without a memory limit like this, you're
// gonna have a bad time.
#define MAXBLOCKS ((int)(2048LL * 1024 * 1024 / BLOCKSIZE))
void *alloc_and_fill_block(void) {
char *block = malloc(BLOCKSIZE);
if (block) {
// make sure the kernel can't just use "zeroed" pages and not really
// give us the memory.
memset(block, 1, BLOCKSIZE);
}
return block;
}
void usage(char *progname) {
printf("%s: [-e] [-m N]\n", progname);
printf(" -e: exit after allocating memory.\n");
printf(" -m N: allocate at most N blocks (of %d bytes each)\n", BLOCKSIZE);
exit(1);
}
int main(int argc, char **argv) {
int opt;
int blocks = 0;
int exit_when_done = 0;
int maxblocks = MAXBLOCKS;
while ((opt = getopt(argc, argv, "em:")) != -1) {
switch (opt) {
case 'e':
exit_when_done = 1;
break;
case 'm':
maxblocks = atoi(optarg);
break;
default:
usage(argv[0]);
break;
}
}
for (blocks = 0; blocks < maxblocks; blocks++) {
if (alloc_and_fill_block() == NULL) {
break;
}
}
printf("%d blocks allocated (%lld bytes)\n",
blocks, ((long long)BLOCKSIZE) * blocks);
if (blocks >= MAXBLOCKS) {
printf("WARNING: maximum blocks allocated. Stopping for safety.\n");
}
if (exit_when_done) {
exit(0);
}
// just in case some memory becomes available
while (1) {
if (blocks < maxblocks && alloc_and_fill_block() != NULL) {
blocks++;
} else {
sleep(1);
}
}
}
| 26.078652 | 78 | 0.632055 |
ff6ddd92e8ba651f5fd6d10f6c510f6908ea2d84 | 271 | h | C | predictor/server/model_manager/framework/tf/tf_framework.h | algo-data-platform/PredictorService | a7da427617885546c5b5e07aa7740b3dee690337 | [
"Apache-2.0"
] | 2 | 2021-06-29T13:42:22.000Z | 2021-09-06T10:57:34.000Z | predictor/server/model_manager/framework/tf/tf_framework.h | algo-data-platform/PredictorService | a7da427617885546c5b5e07aa7740b3dee690337 | [
"Apache-2.0"
] | null | null | null | predictor/server/model_manager/framework/tf/tf_framework.h | algo-data-platform/PredictorService | a7da427617885546c5b5e07aa7740b3dee690337 | [
"Apache-2.0"
] | 5 | 2021-06-29T13:42:26.000Z | 2022-02-08T02:41:34.000Z | #pragma once
#include "predictor/server/model_manager/framework/model_framework.h"
#include "predictor/if/gen-cpp2/PredictorService.h"
namespace predictor {
class TFFramework : public ModelFramework {
public:
~TFFramework() = default;
};
} // namespace predictor
| 19.357143 | 69 | 0.767528 |
ff76d85b97854c03cc62ee2343bf0e7b8789ac26 | 5,068 | h | C | framework/postprocess.h | ohmaya/vulkan_best_practice_for_mobile_developers | 356cf5229687346adcde2ca08875aa77a8bf530a | [
"MIT"
] | null | null | null | framework/postprocess.h | ohmaya/vulkan_best_practice_for_mobile_developers | 356cf5229687346adcde2ca08875aa77a8bf530a | [
"MIT"
] | null | null | null | framework/postprocess.h | ohmaya/vulkan_best_practice_for_mobile_developers | 356cf5229687346adcde2ca08875aa77a8bf530a | [
"MIT"
] | null | null | null | /* Copyright (c) 2019, Arm Limited and Contributors
*
* SPDX-License-Identifier: MIT
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <map>
#include <vector>
#include "common/vk_common.h"
#include "core/Image.h"
#include "framework.h"
namespace vkb
{
/// @brief The description of a postprocess pass
struct PostProcessPass
{
/// The fragment shader to be used in the pass
std::string fragment_shader_path;
/// The output images for the pass, described with their format
std::vector<VkFormat> image_formats = {};
/// Relative Width of the output image(s) with respect to the swapchain
float relative_width = 1.0f;
/// Relative height of the output image(s) with respect to the swapchain
float relative_height = 1.0f;
};
/// @brief The set of input images for the postprocess chain
typedef std::vector<core::Image> ChainInputImages;
/// @brief Helper class to manage Vulkan objects related to postprocessing
class PostProcess
{
public:
/// @brief Constructs a PostProcess object
PostProcess(Context *context);
/// @brief Destroys the PostProcess object
~PostProcess();
/// @brief Tears down Vulkan objects used in postprocessing
void teardown_postprocess();
/// @brief Initializes the postprocess chain
/// @param input_images A vector containing the input images to be used for postprocessing.
/// The vector indices correspond to frame indices, the entries are vectors of input images
/// for the first pass in the chain. Input images must be transitioned to SHADER_READ_ONLY_OPTIMAL
/// layout before the first postprocess pass starts.
/// @param passes A description of the postprocess passes. The last pass will be used to draw to
/// the swapchain image, so it must have just one output.
/// @returns true if initialization succeeded, false otherwise
bool init(std::vector<ChainInputImages> input_images, std::vector<PostProcessPass> passes);
/// @brief Re-initializes framebuffers after the swapchain is recreated, passing the new set
/// of input images
/// @param input_images A vector containing the input images to be used for postprocessing.
/// The vector indices correspond to frame indices, the entries are vectors of input images
/// for the first pass in the chain. Input images must be transitioned to SHADER_READ_ONLY_OPTIMAL
/// layout before the first postprocess pass starts.
void on_resize(std::vector<ChainInputImages> input_images);
/// @brief Prepares and submits command buffers for postprocessing
/// @param swapchain_index The swapchain index for the image being rendered
void run(uint32_t swapchain_index);
private:
Context *context = nullptr;
/// @brief The Vulkan objects needed to run a postprocess pass
struct PostProcessPassResources
{
/// The postprocess pass description
PostProcessPass desc = {};
/// The images to be used in the pass.
std::vector<Image> images = {};
/// The descriptor set layout for this pass
VkDescriptorSetLayout desc_set_layout = VK_NULL_HANDLE;
/// The descriptor set holding the input images
VkDescriptorSet desc_set = VK_NULL_HANDLE;
/// The framebuffer to be used in the pass.
VkFramebuffer framebuffer = VK_NULL_HANDLE;
/// The render pass to be used in the pass.
VkRenderPass render_pass = VK_NULL_HANDLE;
/// The pipeline layout to be used in the pass.
VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
/// The pipeline to be used in the pass.
VkPipeline pipeline = VK_NULL_HANDLE;
};
/// @brief The Vulkan objects needed to run the postprocess chain
typedef std::vector<PostProcessPassResources> PostProcessChainResources;
/// @brief The Vulkan objects needed to run postprocessing on each swapchain image
typedef std::vector<PostProcessChainResources> PostProcessResources;
std::vector<PostProcessPass> passes;
std::vector<ChainInputImages> input_images;
PostProcessResources pp_resources;
VkDescriptorPool desc_pool = VK_NULL_HANDLE;
VkSampler sampler = VK_NULL_HANDLE;
};
} // namespace vkb
| 38.687023 | 129 | 0.756906 |
ff7737644b001c0edf8d136d5d5c5008890998c9 | 2,129 | h | C | qqtw/qqheaders7.2/QQDynamicPluginStateViewController.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 5 | 2018-02-20T14:24:17.000Z | 2020-08-06T09:31:21.000Z | qqtw/qqheaders7.2/QQDynamicPluginStateViewController.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 1 | 2020-06-10T07:49:16.000Z | 2020-06-12T02:08:35.000Z | qqtw/qqheaders7.2/QQDynamicPluginStateViewController.h | onezens/SmartQQ | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | null | null | null | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "QQViewController.h"
#import "QQDynamicPluginHeadViewDelegate.h"
#import "SimpleAlertViewDelegate.h"
#import "UIAlertViewDelegate.h"
#import "UITableViewDataSource.h"
#import "UITableViewDelegate.h"
@class NSString, PluginModel, QQDynamicPlugininHeadView, SimpleAlertView, UIButton, UITableView, UIView;
@interface QQDynamicPluginStateViewController : QQViewController <UITableViewDelegate, UITableViewDataSource, QQDynamicPluginHeadViewDelegate, UIAlertViewDelegate, SimpleAlertViewDelegate>
{
QQDynamicPlugininHeadView *_headerView;
UITableView *_tableView;
PluginModel *_pluginModel;
UIButton *_stateChangeBtn;
SimpleAlertView *_alertView;
UIView *_blackTipsView;
}
+ (id)dynamicPluginWebViewControllerByPluginID:(id)arg1;
- (void)CloseViewController;
- (void)QQDynamicPluginHeadViewCloseBtnClick:(id)arg1;
- (void)buttonClick:(id)arg1 atIndex:(int)arg2;
- (void)createStateChangeBtn;
- (void)dealloc;
- (id)getDefaultStyleForCellWithIdentifier:(id)arg1;
- (double)getRowsHeightInTable;
- (id)getTableFooterView:(id)arg1;
- (void)handleNavBarItemClick:(_Bool)arg1;
- (id)init;
- (id)initWithPluginConfigInfo:(id)arg1;
- (_Bool)loadData;
- (void)loadView;
@property(retain) PluginModel *pluginModel; // @synthesize pluginModel=_pluginModel;
- (void)pluginStateChange;
- (void)resetThemeOnDisappear;
- (void)scrollViewDidScroll:(id)arg1;
- (id)tableView:(id)arg1 cellForRichText:(id)arg2;
- (id)tableView:(id)arg1 cellForRowAtIndexPath:(id)arg2;
- (double)tableView:(id)arg1 heightForRowAtIndexPath:(id)arg2;
- (long long)tableView:(id)arg1 numberOfRowsInSection:(long long)arg2;
- (void)tableView:(id)arg1 willDisplayCell:(id)arg2 forRowAtIndexPath:(id)arg3;
- (void)viewWillAppear:(_Bool)arg1;
- (void)viewWillDisappear:(_Bool)arg1;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
| 34.901639 | 188 | 0.783936 |
ff79d09e0bf31eb1fac3a8d96835c2f7fadd060e | 1,814 | c | C | Assignment_4/ex_3/exercise_3.c | FilipHusnjak/GPU-Programming-Labs | ff1486e0a3e01d385aac7085838112518d467d63 | [
"Apache-2.0"
] | null | null | null | Assignment_4/ex_3/exercise_3.c | FilipHusnjak/GPU-Programming-Labs | ff1486e0a3e01d385aac7085838112518d467d63 | [
"Apache-2.0"
] | null | null | null | Assignment_4/ex_3/exercise_3.c | FilipHusnjak/GPU-Programming-Labs | ff1486e0a3e01d385aac7085838112518d467d63 | [
"Apache-2.0"
] | null | null | null | #include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <stdio.h>
#define N 100000000
#define EPSILON 0.00001
void saxpy_naive(float* y, const float* x, const float c, const int n){
for(int i=0; i<n; i++){
y[i] = c*x[i] + y[i];
}
}
void saxpy_acc(float* y, const float* x, const float c, const int n){
#pragma acc parallel loop independent
for(int i=0; i<n; i++){
y[i] = c*x[i] + y[i];
}
}
void initialize_rand(float* arr, int n){
for(int i=0; i<n; i++){
arr[i] = rand();
}
}
int main(){
float* y = malloc(N * sizeof(float));
float* x = malloc(N * sizeof(float));
float* y_naive = malloc(N * sizeof(float));
float* y_acc = malloc(N * sizeof(float));
srand(0);
initialize_rand(y, N);
initialize_rand(x, N);
float c = 1.5f;
clock_t t;
double elapsed;
int step = N / 100;
int start = 0;
printf("%d\n", N);
printf("%d\n", step);
printf("%d\n", start);
memcpy(y_naive, y, N * sizeof(float));
for(int i=start; i<N; i+=step){
t = clock();
saxpy_naive(y_naive, x, c, i);
elapsed = (clock() - t) * 1000 / CLOCKS_PER_SEC;
printf("%.4f\n", elapsed);
}
memcpy(y_acc, y, N * sizeof(float));
for(int i=start; i<N; i+=step) {
t = clock();
saxpy_acc(y_acc, x, c, i);
elapsed = (clock() - t) * 1000 / CLOCKS_PER_SEC;
printf("%.4f\n", elapsed);
}
memcpy(y_naive, y, N * sizeof(float));
memcpy(y_acc, y, N * sizeof(float));
saxpy_naive(y_naive, x, c, N);
saxpy_acc(y_acc, x, c, N);
for(int i=0; i<N; i++){
assert(fabsf(y_naive[i] - y_acc[i]) < EPSILON);
}
free(y);
free(x);
free(y_naive);
free(y_acc);
return 0;
} | 21.093023 | 71 | 0.535281 |
ff7b4f375a629bdc4bf52edb21ef28a425e2fa12 | 6,530 | c | C | pd_tcp.c | kayaklee/sockutil | cb0281eba717ff8b9702b7e9965122f748d5a9c5 | [
"Apache-2.0"
] | 10 | 2015-08-02T17:00:31.000Z | 2021-03-10T15:18:41.000Z | pd_tcp.c | kayaklee/sockutil | cb0281eba717ff8b9702b7e9965122f748d5a9c5 | [
"Apache-2.0"
] | null | null | null | pd_tcp.c | kayaklee/sockutil | cb0281eba717ff8b9702b7e9965122f748d5a9c5 | [
"Apache-2.0"
] | 1 | 2015-08-02T17:00:31.000Z | 2015-08-02T17:00:31.000Z | #include <string.h>
#include <errno.h>
#include "pd_tcp.h"
#include "pd_ringbuffer.h"
#include "pd_socket.h"
#include "pd_log.h"
#include "pd_ioc.h"
#include "pd_transport.h"
struct PdTcpIOComponent
{
struct PdIOComponent base_ioc;
struct PdRingBuffer recv_buf;
struct PdRingBuffer post_buf;
};
static int pd_tcp_read_stream(struct PdTcpIOComponent *tcp_ioc)
{
int ret = 0;
while (1)
{
char *buffer = pd_ringbuffer_get_producer_buffer(&tcp_ioc->recv_buf);
int length = pd_ringbuffer_get_producer_length(&tcp_ioc->recv_buf);
if (NULL == buffer
|| 0 >= length)
{
break;
}
int readlen = read(pd_socket_get_fd(tcp_ioc->base_ioc.sock), buffer, length);
if (-1 == readlen)
{
if (EINTR == errno)
{
continue;
}
else
{
break;
}
}
if (0 < readlen)
{
pd_ringbuffer_produce(&tcp_ioc->recv_buf, readlen);
PD_LOG(DEBUG, "read from peer=[%s], readlen=%d producer_length=%d",
pd_socket_str_peer(tcp_ioc->base_ioc.sock),
readlen,
pd_ringbuffer_get_producer_length(&tcp_ioc->recv_buf));
}
if (0 == readlen)
{
PD_LOG(DEBUG, "peer close tcp, peer=[%s]", pd_socket_str_peer(tcp_ioc->base_ioc.sock));
pd_tcp_on_error((struct PdIOComponent*)tcp_ioc);
ret = PD_ERR_IOC_DESTROY;
break;
}
}
return ret;
}
static int pd_tcp_write_stream(struct PdTcpIOComponent *tcp_ioc)
{
int ret = 0;
while (1)
{
char *buffer = pd_ringbuffer_get_consumer_buffer(&tcp_ioc->post_buf);
int length = pd_ringbuffer_get_consumer_length(&tcp_ioc->post_buf);
if (NULL == buffer
|| 0 >= length)
{
pd_transport_set_ioc(tcp_ioc->base_ioc.ts, (struct PdIOComponent*)tcp_ioc, 1, 0);
break;
}
int writelen = write(pd_socket_get_fd(tcp_ioc->base_ioc.sock), buffer, length);
if (-1 == writelen)
{
if (EINTR == errno)
{
continue;
}
else if (EPIPE == errno)
{
PD_LOG(DEBUG, "peer close tcp, peer=[%s]", pd_socket_str_peer(tcp_ioc->base_ioc.sock));
pd_tcp_on_error((struct PdIOComponent*)tcp_ioc);
ret = PD_ERR_IOC_DESTROY;
break;
}
else
{
break;
}
}
if (0 < writelen)
{
pd_ringbuffer_consume(&tcp_ioc->post_buf, writelen);
PD_LOG(DEBUG, "write to peer=[%s], writelen=%d consumer_length=%d",
pd_socket_str_peer(tcp_ioc->base_ioc.sock),
writelen,
pd_ringbuffer_get_producer_length(&tcp_ioc->post_buf));
}
}
return ret;
}
static void pd_tcp_handle_packet(struct PdTcpIOComponent *tcp_ioc)
{
while (1)
{
char *buffer = pd_ringbuffer_get_consumer_buffer(&tcp_ioc->recv_buf);
int length = pd_ringbuffer_get_consumer_length(&tcp_ioc->recv_buf);
if (NULL == buffer
|| 0 >= length)
{
break;
}
int handlelen = pd_transport_handle_packet(tcp_ioc->base_ioc.ts, tcp_ioc, buffer, length);
if (0 >= handlelen)
{
break;
}
pd_ringbuffer_consume(&tcp_ioc->recv_buf, handlelen);
}
}
int pd_tcp_on_readable(struct PdIOComponent *ioc)
{
int ret = 0;
if (NULL == ioc)
{
PD_LOG(WARN, "ioc null pointer");
}
else if (NULL == ioc->sock)
{
PD_LOG(WARN, "sock null pointer");
}
else
{
ret = pd_tcp_read_stream((struct PdTcpIOComponent*)ioc);
if (0 == ret)
{
pd_tcp_handle_packet((struct PdTcpIOComponent*)ioc);
}
}
return ret;
}
int pd_tcp_on_writeable(struct PdIOComponent *ioc)
{
int ret = 0;
if (NULL == ioc)
{
PD_LOG(WARN, "ioc null pointer");
}
else if (NULL == ioc->sock)
{
PD_LOG(WARN, "sock null pointer");
}
else
{
ret = pd_tcp_write_stream((struct PdTcpIOComponent*)ioc);
}
return ret;
}
void pd_tcp_on_error(struct PdIOComponent *ioc)
{
if (NULL == ioc)
{
PD_LOG(WARN, "ioc null pointer");
}
else if (NULL == ioc->sock)
{
PD_LOG(WARN, "sock null pointer");
}
else if (NULL == ioc->ts)
{
PD_LOG(WARN, "ts null pointer");
}
else if (0 != pd_transport_remove_ioc(ioc->ts, ioc))
{
PD_LOG(WARN, "pd_transport_remove_ioc fail, ioc=%p", ioc);
}
else
{
PD_LOG(DEBUG, "tcp fd error, will close, ioc=%p sock=%p", ioc, ioc->sock);
pd_socket_destroy(ioc->sock);
pd_tcp_ioc_free(ioc);
}
}
struct PdIOComponent *pd_tcp_ioc_alloc()
{
struct PdTcpIOComponent *tcp_ioc = (struct PdTcpIOComponent*)malloc(sizeof(struct PdTcpIOComponent));
if (NULL != tcp_ioc)
{
memset((void*)tcp_ioc, 0, sizeof(struct PdTcpIOComponent));
if (0 != pd_ringbuffer_init(&tcp_ioc->recv_buf)
|| 0 != pd_ringbuffer_init(&tcp_ioc->post_buf))
{
pd_tcp_ioc_free((struct PdIOComponent*)tcp_ioc);
tcp_ioc = NULL;
}
}
return (struct PdIOComponent*)tcp_ioc;
}
void pd_tcp_ioc_free(struct PdIOComponent *ioc)
{
struct PdTcpIOComponent *tcp_ioc = (struct PdTcpIOComponent*)ioc;
if (NULL != tcp_ioc)
{
pd_ringbuffer_destroy(&tcp_ioc->recv_buf);
pd_ringbuffer_destroy(&tcp_ioc->post_buf);
free(tcp_ioc);
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
int pd_tcp_post_packet(struct PdTcpIOComponent *tcp_ioc, const char *buffer, const int length)
{
int ret = 0;
if (NULL == tcp_ioc)
{
PD_LOG(WARN, "ioc null pointer");
ret = -1;
}
else if (NULL == buffer
|| 0 >= length)
{
PD_LOG(WARN, "invalid param, buffer=%p length=%d", buffer, length);
ret = -1;
}
else if (pd_ringbuffer_get_free(&tcp_ioc->post_buf) < length)
{
PD_LOG(WARN, "buffer not enough, length=%d free=%d", length, pd_ringbuffer_get_free(&tcp_ioc->post_buf));
ret = -1;
}
else
{
int64_t pos = 0;
while (pos < length)
{
char *post_buffer = pd_ringbuffer_get_producer_buffer(&tcp_ioc->post_buf);
int post_length = pd_ringbuffer_get_producer_length(&tcp_ioc->post_buf);
int copy_length = (post_length > (length - pos)) ? (length - pos) : post_length;
if (NULL == post_buffer
|| 0 >= post_length)
{
PD_LOG(WARN, "buffer null, post_buffer=%p post_length=%d", post_buffer, post_length);
ret = -1;
break;
}
memcpy(post_buffer, buffer + pos, copy_length);
pd_ringbuffer_produce(&tcp_ioc->post_buf, copy_length);
pos += copy_length;
}
if (0 == ret)
{
pd_transport_set_ioc(tcp_ioc->base_ioc.ts, (struct PdIOComponent*)tcp_ioc, 1, 1);
}
}
return ret;
}
| 24.641509 | 109 | 0.620368 |
ff7d2033320319b6f47fff4517ccfc1d8e46353b | 2,747 | c | C | Userland/SampleCodeModule/modules.c | shipupi/SO-TP2 | cbf02c621ca5b3e3a78a470efe5532e107b2b4cb | [
"BSD-3-Clause"
] | null | null | null | Userland/SampleCodeModule/modules.c | shipupi/SO-TP2 | cbf02c621ca5b3e3a78a470efe5532e107b2b4cb | [
"BSD-3-Clause"
] | null | null | null | Userland/SampleCodeModule/modules.c | shipupi/SO-TP2 | cbf02c621ca5b3e3a78a470efe5532e107b2b4cb | [
"BSD-3-Clause"
] | null | null | null | #include "include/modules.h"
#include "include/syscalls.h"
#include "include/stdio.h"
#include "include/vidio.h"
#include "include/extra.h"
#include "include/testInvalidOp.h"
void help() {
printf("\nHelp Manual for TPEG2");
printf("\nclear:");
printf("\n\tIt will clear the screen");
printf("\ntime:");
printf("\n\tIt will display on screen the current time in hh:mm:ss format");
printf("\ntestMemoryManager:");
printf("\n\tTests the memory manager");
printf("\nnumbers:");
printf("\n\tPrint numbers");
printf("\nprodCons:");
printf("\n\tsolution to the producers consumers problem");
printf("\ntrw:");
printf("\n\tCrea 4 IPC y los lista");
printf("\ntrw1:");
printf("\n\tEs un consumidor del IPC con id 'baj' (loop infinito) ");
printf("\ntrw2:");
printf("\n\tEs un productor del IPC con id 'baj' (solo una vez)");
printf("\nmut:");
printf("\n\tlist mutexes");
printf("\nmut1:");
printf("\n\tEs un consumidor del MUTEX con id 'test (loop infinito)'");
printf("\nmut2:");
printf("\n\tEs un productor del MUTEX con id 'test (solo una vez)'");
printf("\nps:");
printf("\n\tlist proccesses");
printf("\nlot:");
printf("\n\ttest the lottery scheduling with two processes of differnt priorities");
printf("\nipcs:");
printf("\n\tipcs");
printf("\nchpr:");
printf("\n\tChange the priority of a process chpr pid newPriority");
printf("\ndiph:");
printf("\n\tFisolofos");
}
void showTime() {
printf("\nCurrent time = ");
uint64_t * currTime = os_time(); //returns an array with the current hour, minutes, and seconds
char time[9]; //pass the array to a string to print
time[0] = currTime[0] + '0';
time[1] = currTime[1] + '0';
time[2] = ':';
time[3] = currTime[2] + '0';
time[4] = currTime[3] + '0';
time[5] = ':';
time[6] = currTime[4] + '0';
time[7] = currTime[5] + '0';
time[8] = 0;
printf(time);
}
int div(int n) {
return 10/n;
}
//Creado para conocer la cantidad de ticks por segundo para que aunque el timer tick sea
//distinto, el pong funcione con la misma velocidad. No logramos hacer que funcione bien por varias
//razones entonces vamos a tomar 18 ticks por segundo por como esta definido en el kernel space
int ticksPerSecond() {
return 18;
/*
int secondsTotal;
int ticksTotal;
double i = 0;
int ticksStart = os_ticks();
int secondStart = os_sec();
do {
while(i < 100000){ //HORRIBLE VER SI SE PUEDE HACER DE OTRA MANERA
i += 0.1;
}
while((secondsTotal = os_sec() - secondStart) == 0);
ticksTotal = os_ticks() - ticksStart;
return ticksTotal/secondsTotal;
*/
}
void exceptionDiv0() {
printf("\nDividing by zero");
div(0);
}
void exceptionInvalidOp() {
printf("\nAttempting a jmp 0x0");
invalidOpTest();
}
void clear() {
os_clear();
}
| 22.891667 | 100 | 0.659993 |
ff7f0f86836b9028cdf527a66e9e77e50c533267 | 5,345 | c | C | sdk-6.5.20/src/soc/dpp/ARAD/ARAD_PP/arad_pp_frwrd_extend_p2p.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/src/soc/dpp/ARAD/ARAD_PP/arad_pp_frwrd_extend_p2p.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/src/soc/dpp/ARAD/ARAD_PP/arad_pp_frwrd_extend_p2p.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | /*
* 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.
*/
#ifdef _ERR_MSG_MODULE_NAME
#error "_ERR_MSG_MODULE_NAME redefined"
#endif
#define _ERR_MSG_MODULE_NAME BSL_SOC_FORWARD
#include <shared/bsl.h>
#include <soc/dcmn/error.h>
#include <soc/dpp/SAND/Utils/sand_header.h>
#include <soc/dpp/SAND/Management/sand_general_macros.h>
#include <soc/dpp/SAND/Management/sand_error_code.h>
#include <soc/dpp/SAND/Utils/sand_os_interface.h>
#include <soc/dpp/SAND/SAND_FM/sand_pp_general.h>
#include <soc/dpp/ARAD/ARAD_PP/arad_pp_framework.h>
#include <soc/dpp/ARAD/ARAD_PP/arad_pp_frwrd_extend_p2p.h>
#include <soc/dpp/ARAD/ARAD_PP/arad_pp_general.h>
#include <soc/dpp/ARAD/ARAD_PP/arad_pp_lem_access.h>
#include <soc/dpp/ARAD/ARAD_PP/arad_pp_dbal.h>
#include <soc/dpp/PPC/ppc_api_fp.h>
void
arad_pp_frwrd_extend_p2p_lem_entry_qals_fill(int unit, SOC_PPC_FRWRD_MATCH_INFO *fwd_match_info, SOC_PPC_FP_QUAL_VAL * qual_vals)
{
SOCDNX_INIT_FUNC_DEFS;
DBAL_QUAL_VALS_CLEAR(qual_vals);
qual_vals[0].val.arr[0] = fwd_match_info->in_lif;
qual_vals[0].val.arr[1] = 0;
qual_vals[0].type = SOC_PPC_FP_QUAL_IRPP_IN_LIF;
qual_vals[1].val.arr[0] = fwd_match_info->outer_tag;
qual_vals[1].val.arr[1] = 0;
qual_vals[1].type = SOC_PPC_FP_QUAL_HDR_FWD_VLAN_TAG_ID;
if (fwd_match_info->nof_tags == 2) {
qual_vals[2].val.arr[0] = fwd_match_info->inner_tag;
qual_vals[2].val.arr[1] = 0;
qual_vals[2].type = SOC_PPC_FP_QUAL_HDR_FWD_VLAN_2ND_TAG_ID;
}
SOCDNX_FUNC_RETURN_VOID;
}
soc_error_t
arad_pp_frwrd_extend_p2p_lem_entry_add(int unit,
SOC_PPC_FRWRD_MATCH_INFO *fwd_match_info,
SOC_PPC_FRWRD_DECISION_INFO *frwrd_info)
{
int rv;
SOC_PPC_FP_QUAL_VAL qual_vals[SOC_PPC_FP_NOF_QUALS_PER_DB_MAX];
SOC_SAND_SUCCESS_FAILURE success;
ARAD_PP_LEM_ACCESS_PAYLOAD payload;
SOCDNX_INIT_FUNC_DEFS;
ARAD_PP_LEM_ACCESS_PAYLOAD_clear(&payload);
SOC_PPC_FP_QUAL_VAL_clear(qual_vals);
rv = arad_pp_fwd_decision_in_buffer_build(
unit,
ARAD_PP_FRWRD_DECISION_APPLICATION_TYPE_DFLT,
frwrd_info,
&payload.dest,
&payload.asd
);
SOCDNX_SAND_IF_ERR_EXIT(rv);
payload.flags = ARAD_PP_FWD_DECISION_PARSE_OUTLIF;
arad_pp_frwrd_extend_p2p_lem_entry_qals_fill(unit, fwd_match_info, qual_vals);
if (fwd_match_info->nof_tags == 1) {
rv = arad_pp_dbal_entry_add(unit, SOC_DPP_DBAL_SW_TABLE_ID_VPWS_TAGGED_SINGLE_TAG, qual_vals, 0, &payload, &success);
SOCDNX_SAND_IF_ERR_EXIT(rv);
} else {
rv = arad_pp_dbal_entry_add(unit, SOC_DPP_DBAL_SW_TABLE_ID_VPWS_TAGGED_DOUBLE_TAG, qual_vals, 0, &payload, &success);
SOCDNX_SAND_IF_ERR_EXIT(rv);
}
if (!SOC_SAND_SUCCESS2BOOL(success)) {
SOCDNX_EXIT_WITH_ERR(SOC_E_INTERNAL, (_BSL_SOCDNX_MSG("Failed updating entry\n")));
}
exit:
SOCDNX_FUNC_RETURN;
}
soc_error_t
arad_pp_frwrd_extend_p2p_lem_entry_remove(int unit,
SOC_PPC_FRWRD_MATCH_INFO *fwd_match_info)
{
int rv;
SOC_PPC_FP_QUAL_VAL qual_vals[SOC_PPC_FP_NOF_QUALS_PER_DB_MAX];
SOC_SAND_SUCCESS_FAILURE success;
SOCDNX_INIT_FUNC_DEFS;
arad_pp_frwrd_extend_p2p_lem_entry_qals_fill(unit, fwd_match_info, qual_vals);
if (fwd_match_info->nof_tags == 1) {
rv = arad_pp_dbal_entry_delete(unit, SOC_DPP_DBAL_SW_TABLE_ID_VPWS_TAGGED_SINGLE_TAG, qual_vals, &success);
SOCDNX_SAND_IF_ERR_EXIT(rv);
} else {
rv = arad_pp_dbal_entry_delete(unit, SOC_DPP_DBAL_SW_TABLE_ID_VPWS_TAGGED_DOUBLE_TAG, qual_vals, &success);
SOCDNX_SAND_IF_ERR_EXIT(rv);
}
if (!SOC_SAND_SUCCESS2BOOL(success)) {
SOCDNX_EXIT_WITH_ERR(SOC_E_INTERNAL, (_BSL_SOCDNX_MSG("Failed deleting entry\n")));
}
exit:
SOCDNX_FUNC_RETURN;
}
soc_error_t
arad_pp_frwrd_extend_p2p_lem_entry_get(int unit,
SOC_PPC_FRWRD_MATCH_INFO *fwd_match_info,
SOC_PPC_FRWRD_DECISION_INFO *frwrd_info,
uint8 * found)
{
int rv;
SOC_PPC_FP_QUAL_VAL qual_vals[SOC_PPC_FP_NOF_QUALS_PER_DB_MAX];
ARAD_PP_LEM_ACCESS_PAYLOAD payload;
SOCDNX_INIT_FUNC_DEFS;
SOC_PPC_FRWRD_DECISION_INFO_clear(frwrd_info);
ARAD_PP_LEM_ACCESS_PAYLOAD_clear(&payload);
arad_pp_frwrd_extend_p2p_lem_entry_qals_fill(unit, fwd_match_info, qual_vals);
if (fwd_match_info->nof_tags == 1) {
rv = arad_pp_dbal_entry_get(unit, SOC_DPP_DBAL_SW_TABLE_ID_VPWS_TAGGED_SINGLE_TAG, qual_vals, &payload, 0, 0, found);
SOCDNX_SAND_IF_ERR_EXIT(rv);
} else {
rv = arad_pp_dbal_entry_get(unit, SOC_DPP_DBAL_SW_TABLE_ID_VPWS_TAGGED_DOUBLE_TAG, qual_vals, &payload, 0, 0, found);
SOCDNX_SAND_IF_ERR_EXIT(rv);
}
rv = arad_pp_fwd_decision_in_buffer_parse(unit, payload.dest, payload.asd, ARAD_PP_FWD_DECISION_PARSE_DEST|ARAD_PP_FWD_DECISION_PARSE_OUTLIF, frwrd_info);
SOCDNX_SAND_IF_ERR_EXIT(rv);
exit:
SOCDNX_FUNC_RETURN;
}
#include <soc/dpp/SAND/Utils/sand_footer.h>
| 28.891892 | 158 | 0.721796 |
ff80f06612be1770e3e816bf37070676c6a5ceb5 | 305 | h | C | ProjectSummary/ProjectSummary/BOBFdKit/NSProcessInfo+BOBs.h | Sunshinealise/ProjectSummary | c1113a7a7e7aaa416596c262d4b3c775167a1638 | [
"MIT"
] | 3 | 2016-08-15T08:36:45.000Z | 2017-05-12T14:19:21.000Z | ProjectSummary/ProjectSummary/BOBFdKit/NSProcessInfo+BOBs.h | Sunshinealise/ProjectSummary | c1113a7a7e7aaa416596c262d4b3c775167a1638 | [
"MIT"
] | null | null | null | ProjectSummary/ProjectSummary/BOBFdKit/NSProcessInfo+BOBs.h | Sunshinealise/ProjectSummary | c1113a7a7e7aaa416596c262d4b3c775167a1638 | [
"MIT"
] | null | null | null | //
// NSProcessInfo+BOBs.h
// BOBUtils
//
// Created by beyondsoft-聂小波 on 16/8/15.
// Copyright © 2016年 NieXiaobo. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSProcessInfo (BOBs)
/**
* Return the CPU usage
*
* @return Return the CPU usage
*/
+ (float)cpuUsage;
@end
| 15.25 | 53 | 0.668852 |
ff8316241628dfb629e2f307cbd00f49c8117c5e | 3,533 | c | C | src/ps.c | bulldex/verified-runtime | fdbda347d4ca4deddf0e382d947e925e1afa23c2 | [
"Apache-2.0"
] | null | null | null | src/ps.c | bulldex/verified-runtime | fdbda347d4ca4deddf0e382d947e925e1afa23c2 | [
"Apache-2.0"
] | null | null | null | src/ps.c | bulldex/verified-runtime | fdbda347d4ca4deddf0e382d947e925e1afa23c2 | [
"Apache-2.0"
] | null | null | null | /*
* crun - OCI runtime written in C
*
* Copyright (C) 2017, 2018, 2019 Giuseppe Scrivano <giuseppe@scrivano.org>
* crun is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* crun is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with crun. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <argp.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "crun.h"
#include "libcrun/container.h"
#include "libcrun/utils.h"
#include "libcrun/cgroup.h"
#include "libcrun/status.h"
static char doc[] = "OCI runtime";
enum
{
OPTION_CONSOLE_SOCKET = 1000,
OPTION_PID_FILE,
OPTION_NO_SUBREAPER,
OPTION_NO_NEW_KEYRING,
OPTION_PRESERVE_FDS
};
struct ps_options_s
{
int format;
};
enum
{
PS_TABLE = 100,
PS_JSON,
};
static struct ps_options_s ps_options;
static struct argp_option options[] = { { "format", 'f', "FORMAT", 0, "select the output format", 0 },
{
0,
} };
static char args_doc[] = "ps";
static error_t
parse_opt (int key, char *arg, struct argp_state *state arg_unused)
{
switch (key)
{
case 'f':
if (strcmp (arg, "table") == 0)
ps_options.format = PS_TABLE;
else if (strcmp (arg, "json") == 0)
ps_options.format = PS_JSON;
else
error (EXIT_FAILURE, 0, "invalid format `%s`", arg);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp run_argp = { options, parse_opt, args_doc, doc, NULL, NULL, NULL };
int
crun_command_ps (struct crun_global_arguments *global_args, int argc, char **argv, libcrun_error_t *err)
{
int first_arg;
int ret;
libcrun_context_t crun_context = {
0,
};
libcrun_container_status_t status;
cleanup_free pid_t *pids = NULL;
size_t i;
ps_options.format = PS_TABLE;
argp_parse (&run_argp, argc, argv, ARGP_IN_ORDER, &first_arg, &ps_options);
crun_assert_n_args (argc - first_arg, 1, 1);
ret = init_libcrun_context (&crun_context, argv[first_arg], global_args, err);
if (UNLIKELY (ret < 0))
return ret;
ret = libcrun_read_container_status (&status, crun_context.state_root, argv[first_arg], err);
if (UNLIKELY (ret < 0))
{
libcrun_error_write_warning_and_release (stderr, &err);
return ret;
}
if (status.cgroup_path == NULL || status.cgroup_path[0] == '\0')
error (EXIT_FAILURE, 0, "the container is not using cgroups");
ret = libcrun_cgroup_read_pids (status.cgroup_path, true, &pids, err);
if (UNLIKELY (ret < 0))
{
libcrun_error_write_warning_and_release (stderr, &err);
return ret;
}
switch (ps_options.format)
{
case PS_JSON:
printf ("[\n");
for (i = 0; pids[i]; i++)
printf (" %d%s\n", pids[i], pids[i + 1] ? "," : "");
printf ("]\n");
break;
case PS_TABLE:
printf ("PID\n");
for (i = 0; pids[i]; i++)
printf ("%d\n", pids[i]);
break;
}
return 0;
}
| 24.706294 | 104 | 0.635437 |
ff85afacb54c76a92d2a10ed66822e7448772f0f | 296 | h | C | Search Sample/AppDelegate.h | RobertoMachorro/searchsample_ios | ded970369a1318ca67fd07d83475d08200822c67 | [
"MIT"
] | null | null | null | Search Sample/AppDelegate.h | RobertoMachorro/searchsample_ios | ded970369a1318ca67fd07d83475d08200822c67 | [
"MIT"
] | null | null | null | Search Sample/AppDelegate.h | RobertoMachorro/searchsample_ios | ded970369a1318ca67fd07d83475d08200822c67 | [
"MIT"
] | null | null | null | //
// AppDelegate.h
// Search Sample
//
// Created by Roberto Machorro on 12/13/17.
// Copyright © 2017 Unplugged Ideas, LLC. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
| 18.5 | 63 | 0.716216 |
ff8bc59f7a655722686daeddac2e693a1983021c | 373 | c | C | Code/huqingwei/study_jincheng/alarm.c | xiyoulinuxgroup-2019-summer/TeamC | 9fd7d691cd59d8c10d1492fead4c68cc2d852609 | [
"MIT"
] | 1 | 2021-01-07T12:21:49.000Z | 2021-01-07T12:21:49.000Z | Code/huqingwei/study_jincheng/alarm.c | xiyoulinuxgroup-2019-summer/TeamC | 9fd7d691cd59d8c10d1492fead4c68cc2d852609 | [
"MIT"
] | null | null | null | Code/huqingwei/study_jincheng/alarm.c | xiyoulinuxgroup-2019-summer/TeamC | 9fd7d691cd59d8c10d1492fead4c68cc2d852609 | [
"MIT"
] | 2 | 2019-07-23T00:07:30.000Z | 2019-08-19T08:51:44.000Z | #include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
int main()
{
int ret = alarm(5);
printf("ret = %d\n", ret);
sleep(2);
//重新设置定时器
ret = alarm(2);
printf("ret = %d\n", ret);
while(1){
printf("hello, world!\n");
sleep(1);
}
return 0;
}
| 14.346154 | 34 | 0.512064 |
ff8c89e00e9074f3ee8dd351fb53a4492dbfc418 | 11,389 | h | C | clicks/uartmux2/lib/include/uartmux2.h | StrahinjaJacimovic/mikrosdk_click_v2 | f8002047c96605f340957a0d3fdbde33706d02ac | [
"MIT"
] | 31 | 2020-10-02T14:15:14.000Z | 2022-03-24T08:33:21.000Z | clicks/uartmux2/lib/include/uartmux2.h | greghol/mikrosdk_click_v2 | 76e5dec265dce5fca72c4b93f77afd668dde5dfa | [
"MIT"
] | 4 | 2020-10-27T14:05:00.000Z | 2022-03-10T09:38:57.000Z | clicks/uartmux2/lib/include/uartmux2.h | greghol/mikrosdk_click_v2 | 76e5dec265dce5fca72c4b93f77afd668dde5dfa | [
"MIT"
] | 32 | 2020-11-28T07:56:42.000Z | 2022-03-14T19:42:29.000Z | /****************************************************************************
** Copyright (C) 2020 MikroElektronika d.o.o.
** Contact: https://www.mikroe.com/contact
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
** in the Software without restriction, including without limitation the rights
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
** copies of the Software, and to permit persons to whom the Software is
** furnished to do so, subject to the following conditions:
** The above copyright notice and this permission notice shall be
** included in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
** USE OR OTHER DEALINGS IN THE SOFTWARE.
****************************************************************************/
/*!
* @file uartmux2.h
* @brief This file contains API for UART MUX 2 Click Driver.
*/
#ifndef UARTMUX2_H
#define UARTMUX2_H
#ifdef __cplusplus
extern "C"{
#endif
#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_uart.h"
/*!
* @addtogroup uartmux2 UART MUX 2 Click Driver
* @brief API for configuring and manipulating UART MUX 2 Click driver.
* @{
*/
/**
* @defgroup uartmux2_reg UART MUX 2 Commands List
* @brief List of commands of UART MUX 2 Click driver.
*/
/**
* @addtogroup uartmux2_reg
* @{
*/
/**
* @brief UART MUX 2 description register.
* @details Specified register for description of UART MUX 2 Click driver.
*/
// TODO -- dodati makroe koji definisu adrese registara
/*! @} */ // uartmux2_reg
/**
* @defgroup uartmux2_set UART MUX 2 Device Settings
* @brief Settings for registers of UART MUX 2 Click driver.
*/
/**
* @addtogroup uartmux2_set
* @{
*/
/**
* @brief UART MUX 2 description setting.
* @details Specified setting for description of UART MUX 2 Click driver.
*/
/**
* @brief UART MUX 2 driver buffer size.
* @details Specified size of driver ring buffer.
* @note Increase buffer size if needed.
*/
#define DRV_BUFFER_SIZE 200
/*! @} */ // uartmux2_set
/**
* @addtogroup status
* @{
*/
/**
* @brief UART MUX 2 error status.
* @details Specified error status
* for description of UART MUX 2 Click driver.
*/
#define UARTMUX2_SUCCESS 0
#define UARTMUX2_ERROR -1
/*! @} */ // status
/**
* @addtogroup op_mode
* @{
*/
/**
* @brief UART MUX 2 operation mode.
* @details Specified operation mode selection
* for description of UART MUX 2 Click driver.
*/
#define UARTMUX2_OP_MODE_NORMAL 0x00
#define UARTMUX2_OP_MODE_POWER_DOWN 0x01
/*! @} */ // op_mode
/**
* @addtogroup mux_ch
* @{
*/
/**
* @brief UART MUX 2 select channel.
* @details Specified select uart mux channel
* of UART MUX 2 Click driver.
*/
#define UARTMUX2_CHANNEL_0 0
#define UARTMUX2_CHANNEL_1 1
#define UARTMUX2_CHANNEL_2 2
#define UARTMUX2_CHANNEL_3 3
/*! @} */ // mux_ch
/**
* @defgroup uartmux2_map UART MUX 2 MikroBUS Map
* @brief MikroBUS pin mapping of UART MUX 2 Click driver.
*/
/**
* @addtogroup uartmux2_map
* @{
*/
/**
* @brief MikroBUS pin mapping.
* @details Mapping pins of UART MUX 2 Click to the selected MikroBUS.
*/
#define UARTMUX2_MAP_MIKROBUS( cfg, mikrobus ) \
cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
cfg.off = MIKROBUS( mikrobus, MIKROBUS_AN ); \
cfg.a1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
cfg.a0 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
cfg.on = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
cfg.inv = MIKROBUS( mikrobus, MIKROBUS_INT );
/*! @} */ // uartmux2_map
/*! @} */ // uartmux2
/**
* @brief UART MUX 2 Click context object.
* @details Context object definition of UART MUX 2 Click driver.
*/
typedef struct
{
// Output pins
digital_out_t off; /**< Automatic OFF power-down control. */
digital_out_t a1; /**< Address channel selection. */
digital_out_t a0; /**< Address channel selection. */
digital_out_t on; /**< Automatic ON power-down control. */
// Input pins
digital_in_t inv; /**< Invalid status pin. */
// Modules
uart_t uart; /**< UART driver object. */
// Buffers
char uart_rx_buffer[ DRV_BUFFER_SIZE ]; /**< Buffer size. */
char uart_tx_buffer[ DRV_BUFFER_SIZE ]; /**< Buffer size. */
} uartmux2_t;
/**
* @brief UART MUX 2 Click configuration object.
* @details Configuration object definition of UART MUX 2 Click driver.
*/
typedef struct
{
// Communication gpio pins
pin_name_t rx_pin; /**< RX pin. */
pin_name_t tx_pin; /**< TX pin. */
// Additional gpio pins
pin_name_t off; /**< Automatic OFF power-down control. */
pin_name_t a1; /**< Address channel selection. */
pin_name_t a0; /**< Address channel selection. */
pin_name_t on; /**< Automatic ON power-down control. */
pin_name_t inv; /**< Invalid status pin. */
// Static variable
uint32_t baud_rate; /**< Clock speed. */
bool uart_blocking; /**< Wait for interrupt or not. */
uart_data_bits_t data_bit; /**< Data bits. */
uart_parity_t parity_bit; /**< Parity bit. */
uart_stop_bits_t stop_bit; /**< Stop bits. */
} uartmux2_cfg_t;
/*!
* @addtogroup uartmux2 UART MUX 2 Click Driver
* @brief API for configuring and manipulating UART MUX 2 Click driver.
* @{
*/
/**
* @brief UART MUX 2 configuration object setup function.
* @details This function initializes click configuration structure to initial
* values.
* @param[out] cfg : Click configuration structure.
* See #uartmux2_cfg_t object definition for detailed explanation.
* @return Nothing.
* @note The all used pins will be set to unconnected state.
*/
void uartmux2_cfg_setup ( uartmux2_cfg_t *cfg );
/**
* @brief UART MUX 2 initialization function.
* @details This function initializes all necessary pins and peripherals used
* for this click board.
* @param[out] ctx : Click context object.
* See #uartmux2_t object definition for detailed explanation.
* @param[in] cfg : Click configuration structure.
* See #uartmux2_cfg_t object definition for detailed explanation.
* @return @li @c 0 - Success,
* @li @c -1 - Error.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
err_t uartmux2_init ( uartmux2_t *ctx, uartmux2_cfg_t *cfg );
/**
* @brief UART MUX 2 default configuration function.
* @details This function executes a default configuration of UART MUX 2
* click board.
* @param[in] ctx : Click context object.
* See #uartmux2_t object definition for detailed explanation.
* @note This function can consist any necessary configuration or setting to put
* device into operating mode.
*/
void uartmux2_default_cfg ( uartmux2_t *ctx );
/**
* @brief UART MUX 2 data writing function.
* @details This function writes a desired number of data bytes by using UART serial interface.
* @param[in] ctx : Click context object.
* See #uartmux2_t object definition for detailed explanation.
* @param[in] data_buf : Data buffer for sending.
* @param[in] len : Number of bytes for sending.
* @return @li @c >=0 - Success,
* @li @c <0 - Error.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
err_t uartmux2_generic_write ( uartmux2_t *ctx, char *data_buf, uint16_t len );
/**
* @brief UART MUX 2 data reading function.
* @details This function reads a desired number of data bytes by using UART serial interface.
* @param[in] ctx : Click context object.
* See #uartmux2_t object definition for detailed explanation.
* @param[out] data_buf : Output read data.
* @param[in] max_len : Number of bytes to be read.
* @return @li @c >0 - Number of data bytes read,
* @li @c <=0 - Error/Empty Ring buffer.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
err_t uartmux2_generic_read ( uartmux2_t *ctx, char *data_buf, uint16_t max_len );
/**
* @brief UART MUX 2 set operation mode function.
* @details This function set a desired operation mode of the
* UART MUX 2 click board.
* @param[in] ctx : Click context object.
* See #uartmux2_t object definition for detailed explanation.
* @param[in] op_mode : Operation mode
* @li @c 0x00 ( UARTMUX2_OP_MODE_NORMAL ) - Normal operation with automatic power down disabled,
* @li @c 0x01 ( UARTMUX2_OP_MODE_POWER_DOWN ) - Normal operation with automatic power down enabled.
* @return @li @c 0 - Success,
* @li @c -1 - Error.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
err_t uartmux2_set_operation_mode ( uartmux2_t *ctx, uint8_t op_mode );
/**
* @brief UART MUX 2 set channel function.
* @details This function set a desired channel f the
* UART MUX 2 click board.
* @param[in] ctx : Click context object.
* See #uartmux2_t object definition for detailed explanation.
* @param[in] mux_ch : Selected channel
* @li @c 0 ( UARTMUX2_CHANNEL_0 ) - UART0, Channel 0,
* @li @c 1 ( UARTMUX2_CHANNEL_1 ) - UART1, Channel 1,
* @li @c 2 ( UARTMUX2_CHANNEL_2 ) - UART2, Channel 2,
* @li @c 3 ( UARTMUX2_CHANNEL_3 ) - UART3, Channel 3.
* @return @li @c 0 - Success,
* @li @c -1 - Error.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
err_t uartmux2_set_channel ( uartmux2_t *ctx, uint8_t mux_ch );
/**
* @brief UART MUX 2 data writing function.
* @details This function writes a desired number of data bytes by using UART serial interface.
* @param[in] ctx : Click context object.
* See #uartmux2_t object definition for detailed explanation.
* @param[in] tx_data : Data buffer for sending.
* @return @li @c >=0 - Success,
* @li @c <0 - Error.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
err_t uartmux2_send_data ( uartmux2_t *ctx, char *tx_data );
/**
* @brief UART MUX 2 get INV pin status function.
* @details This function get INV pin status ( RS232 status ) of the
* UART MUX 2 click board.
* @param[in] ctx : Click context object.
* See #uartmux2_t object definition for detailed explanation.
* @return @li @c 0 - RS232 receiver input are unpowered,
* @li @c 1 - RS232 receiver input are powered.
*
* See #err_t definition for detailed explanation.
* @note None.
*/
uint8_t uartmux2_get_inv_status ( uartmux2_t *ctx );
#ifdef __cplusplus
}
#endif
#endif // UARTMUX2_H
/*! @} */ // uartmux2
// ------------------------------------------------------------------------ END
| 31.032698 | 109 | 0.649399 |
ff900b7a85dd6d4bc4d1db2170461714e797ae50 | 1,091 | c | C | src/phong.c | RugnarLodbrok/ray_tracing | 9fbbb7c1d0afa9ffab38cab4d1ab552fecb3b551 | [
"MIT"
] | null | null | null | src/phong.c | RugnarLodbrok/ray_tracing | 9fbbb7c1d0afa9ffab38cab4d1ab552fecb3b551 | [
"MIT"
] | null | null | null | src/phong.c | RugnarLodbrok/ray_tracing | 9fbbb7c1d0afa9ffab38cab4d1ab552fecb3b551 | [
"MIT"
] | null | null | null | #include "rtx.h"
#include <math.h>
uint phong_color(t_material *m, double diff, double spec, double i)
{
uint r;
uint g;
uint b;
double spec_v;
spec_v = pow(spec, m->spec_exp) * m->spec_v;
r = (uint)((diff * (m->diff & 0xFF) + spec_v) * i
+ (m->amb & 0xFF) + .5);
g = (uint)((diff * ((m->diff & 0xFF00) >> 8) + spec_v) * i
+ ((m->amb & 0xFF00) >> 8) + .5);
b = (uint)((diff * ((m->diff & 0xFF0000) >> 16) + spec_v) * i
+ ((m->amb & 0xFF0000) >> 16) + .5);
if (g > 255 && b > 255)
r = r;
return (r > 255 ? 255 : r) +
0x100 * (g > 255 ? 255 : g) +
0x10000 * (b > 255 ? 255 : b);
}
uint phong(t_material *m,
t_vec *normale, //normalized
t_vec *light, //normalized
double light_intencity,
t_vec *view) //normalized
{
double diff;
double spec;
t_vec refl;
diff = -t_vec_dot(*normale, *light);
spec = 0;
if (diff < 0)
diff = 0;
else
{
refl = t_vec_mul(*normale, 2 * t_vec_dot(*normale, *view));
refl = t_vec_sub(refl, *view);
spec = t_vec_dot(*light, refl);
}
return phong_color(m, diff, spec > 0 ? spec : 0, 1);
}
| 23.212766 | 67 | 0.549954 |