text
stringlengths 4
6.14k
|
|---|
/*
* libopenemv - a library to work with EMV family of smart cards
* Copyright (C) 2015 Dmitry Eremin-Solenikov
*
* 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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "openemv/dump.h"
#include <stdio.h>
void dump_buffer_simple(const unsigned char *ptr, size_t len, FILE *f)
{
int i;
if (!f)
f = stdout;
for (i = 0; i < len; i ++)
fprintf(f, "%s%02hhX", i ? " " : "", ptr[i]);
}
void dump_buffer(const unsigned char *ptr, size_t len, FILE *f)
{
int i, j;
if (!f)
f = stdout;
for (i = 0; i < len; i += 16) {
fprintf(f, "\t%02x:", i);
for (j = 0; j < 16; j++) {
if (i + j < len)
fprintf(f, " %02hhx", ptr[i + j]);
else
fprintf(f, " ");
}
fprintf(f, " |");
for (j = 0; j < 16 && i + j < len; j++) {
fprintf(f, "%c", (ptr[i+j] >= 0x20 && ptr[i+j] < 0x7f) ? ptr[i+j] : '.' );
}
fprintf(f, "\n");
}
}
|
/*
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/evp.h>
#include <openssl/objects.h>
#include <openssl/x509.h>
int X509_certificate_type(const X509 *x, const EVP_PKEY *pkey)
{
const EVP_PKEY *pk;
int ret = 0, i;
if (x == NULL)
return 0;
if (pkey == NULL)
pk = X509_get0_pubkey(x);
else
pk = pkey;
if (pk == NULL)
return 0;
switch (EVP_PKEY_id(pk)) {
case EVP_PKEY_RSA:
ret = EVP_PK_RSA | EVP_PKT_SIGN;
/* if (!sign only extension) */
ret |= EVP_PKT_ENC;
break;
case EVP_PKEY_RSA_PSS:
ret = EVP_PK_RSA | EVP_PKT_SIGN;
break;
case EVP_PKEY_DSA:
ret = EVP_PK_DSA | EVP_PKT_SIGN;
break;
case EVP_PKEY_EC:
ret = EVP_PK_EC | EVP_PKT_SIGN | EVP_PKT_EXCH;
break;
case EVP_PKEY_ED448:
case EVP_PKEY_ED25519:
ret = EVP_PKT_SIGN;
break;
case EVP_PKEY_DH:
ret = EVP_PK_DH | EVP_PKT_EXCH;
break;
case NID_id_GostR3410_2001:
case NID_id_GostR3410_2012_256:
case NID_id_GostR3410_2012_512:
ret = EVP_PKT_EXCH | EVP_PKT_SIGN;
break;
default:
break;
}
i = X509_get_signature_nid(x);
if (i && OBJ_find_sigid_algs(i, NULL, &i)) {
switch (i) {
case NID_rsaEncryption:
case NID_rsa:
ret |= EVP_PKS_RSA;
break;
case NID_dsa:
case NID_dsa_2:
ret |= EVP_PKS_DSA;
break;
case NID_X9_62_id_ecPublicKey:
ret |= EVP_PKS_EC;
break;
default:
break;
}
}
return ret;
}
|
#include "../../../../../src/location/maps/qgeomapdata_p.h"
|
/*
Copyright (C) 2014 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include "mag.h"
int main()
{
slong iter;
flint_rand_t state;
flint_printf("bin_ui....");
fflush(stdout);
flint_randinit(state);
for (iter = 0; iter < 2000 * arb_test_multiplier(); iter++)
{
fmpr_t x, y;
fmpz_t f;
mag_t xb;
ulong n, k;
fmpr_init(x);
fmpr_init(y);
fmpz_init(f);
mag_init(xb);
mag_randtest_special(xb, state, 80);
n = n_randtest(state) % 10000;
k = n_randtest(state) % 10000;
mag_bin_uiui(xb, n, k);
fmpz_bin_uiui(f, n, k);
fmpr_set_fmpz(x, f);
mag_get_fmpr(y, xb);
MAG_CHECK_BITS(xb)
if (!(fmpr_cmpabs(y, x) >= 0))
{
flint_printf("FAIL\n\n");
flint_printf("n = %wu\n\n", n);
flint_printf("x = "); fmpr_print(x); flint_printf("\n\n");
flint_printf("y = "); fmpr_print(y); flint_printf("\n\n");
flint_abort();
}
fmpr_clear(x);
fmpr_clear(y);
fmpz_clear(f);
mag_clear(xb);
}
flint_randclear(state);
flint_cleanup();
flint_printf("PASS\n");
return EXIT_SUCCESS;
}
|
/*
* Copyright (C) 2012 Colin Walters <[email protected]>
*
* SPDX-License-Identifier: LGPL-2.0+
*
* 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 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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: Colin Walters <[email protected]>
*/
#include "config.h"
#include "ot-main.h"
#include "ot-admin-builtins.h"
#include "ot-admin-functions.h"
#include "otutil.h"
#include <glib/gi18n.h>
static GOptionEntry options[] = {
{ NULL }
};
gboolean
ot_admin_builtin_os_init (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
{
g_autoptr(GOptionContext) context = NULL;
g_autoptr(OstreeSysroot) sysroot = NULL;
gboolean ret = FALSE;
const char *osname = NULL;
context = g_option_context_new ("OSNAME");
if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
invocation, &sysroot, cancellable, error))
goto out;
if (!ostree_sysroot_ensure_initialized (sysroot, cancellable, error))
goto out;
if (argc < 2)
{
ot_util_usage_error (context, "OSNAME must be specified", error);
goto out;
}
osname = argv[1];
if (!ostree_sysroot_init_osname (sysroot, osname, cancellable, error))
goto out;
g_print ("ostree/deploy/%s initialized as OSTree root\n", osname);
ret = TRUE;
out:
return ret;
}
|
/*
* Copyright (C) 2006, 2007 OpenedHand Ltd.
*
* Author: Jorn Baayen <[email protected]>
*
* 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.
*/
#ifndef __GUPNP_SERVICE_INFO_H__
#define __GUPNP_SERVICE_INFO_H__
#include <glib-object.h>
#include <libxml/tree.h>
#include <libsoup/soup-uri.h>
#include "gupnp-context.h"
#include "gupnp-service-introspection.h"
G_BEGIN_DECLS
GType
gupnp_service_info_get_type (void) G_GNUC_CONST;
#define GUPNP_TYPE_SERVICE_INFO \
(gupnp_service_info_get_type ())
#define GUPNP_SERVICE_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
GUPNP_TYPE_SERVICE_INFO, \
GUPnPServiceInfo))
#define GUPNP_SERVICE_INFO_CLASS(obj) \
(G_TYPE_CHECK_CLASS_CAST ((obj), \
GUPNP_TYPE_SERVICE_INFO, \
GUPnPServiceInfoClass))
#define GUPNP_IS_SERVICE_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
GUPNP_TYPE_SERVICE_INFO))
#define GUPNP_IS_SERVICE_INFO_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE ((obj), \
GUPNP_TYPE_SERVICE_INFO))
#define GUPNP_SERVICE_INFO_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
GUPNP_TYPE_SERVICE_INFO, \
GUPnPServiceInfoClass))
typedef struct _GUPnPServiceInfoPrivate GUPnPServiceInfoPrivate;
/**
* GUPnPServiceInfo:
*
* This struct contains private data only, and should be accessed using the
* functions below.
*/
typedef struct {
GObject parent;
GUPnPServiceInfoPrivate *priv;
} GUPnPServiceInfo;
typedef struct {
GObjectClass parent_class;
/* future padding */
void (* _gupnp_reserved1) (void);
void (* _gupnp_reserved2) (void);
void (* _gupnp_reserved3) (void);
void (* _gupnp_reserved4) (void);
} GUPnPServiceInfoClass;
/**
* GUPnPServiceIntrospectionCallback
* @info: The #GUPnPServiceInfo introspection was requested for
* @introspection: The new #GUPnPServiceIntrospection object, or NULL
* @error: The #GError that occurred, or NULL
* @user_data: User data
*
* Callback notifying that @introspection for @info has been obtained.
**/
typedef void (* GUPnPServiceIntrospectionCallback) (
GUPnPServiceInfo *info,
GUPnPServiceIntrospection *introspection,
const GError *error,
gpointer user_data);
GUPnPContext *
gupnp_service_info_get_context (GUPnPServiceInfo *info);
const char *
gupnp_service_info_get_location (GUPnPServiceInfo *info);
const SoupURI *
gupnp_service_info_get_url_base (GUPnPServiceInfo *info);
const char *
gupnp_service_info_get_udn (GUPnPServiceInfo *info);
const char *
gupnp_service_info_get_service_type (GUPnPServiceInfo *info);
char *
gupnp_service_info_get_id (GUPnPServiceInfo *info);
char *
gupnp_service_info_get_scpd_url (GUPnPServiceInfo *info);
char *
gupnp_service_info_get_control_url (GUPnPServiceInfo *info);
char *
gupnp_service_info_get_event_subscription_url (GUPnPServiceInfo *info);
GUPnPServiceIntrospection *
gupnp_service_info_get_introspection (GUPnPServiceInfo *info,
GError **error);
void
gupnp_service_info_get_introspection_async
(GUPnPServiceInfo *info,
GUPnPServiceIntrospectionCallback callback,
gpointer user_data);
G_END_DECLS
#endif /* __GUPNP_SERVICE_INFO_H__ */
|
/*
Copyright (C) 2010 Sebastian Pancratz
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <http://www.gnu.org/licenses/>.
*/
#include <gmp.h>
#include "flint.h"
#include "fmpz.h"
#include "fmpz_vec.h"
#include "fmpz_poly.h"
#include "fmpq_poly.h"
void
_fmpq_poly_rescale(fmpz * res, fmpz_t denr,
const fmpz * poly, const fmpz_t den, slong len,
const fmpz_t xnum, const fmpz_t xden)
{
if (len < WORD(2))
{
if (res != poly)
{
_fmpz_vec_set(res, poly, len);
fmpz_set(denr, den);
}
}
else
{
slong i;
fmpz_t t;
fmpz_init(t);
fmpz_one(t);
fmpz_set(res, poly);
for (i = WORD(1); i < len; i++)
{
fmpz_mul(t, t, xnum);
fmpz_mul(res + i, poly + i, t);
}
fmpz_one(t);
for (i = len - WORD(2); i >= WORD(0); i--)
{
fmpz_mul(t, t, xden);
fmpz_mul(res + i, res + i, t);
}
fmpz_mul(denr, den, t);
fmpz_clear(t);
_fmpq_poly_canonicalise(res, denr, len);
}
}
void fmpq_poly_rescale(fmpq_poly_t res, const fmpq_poly_t poly, const fmpq_t x)
{
if (fmpq_is_zero(x))
{
fmpq_poly_zero(res);
}
else if (poly->length < WORD(2))
{
fmpq_poly_set(res, poly);
}
else
{
fmpq_poly_fit_length(res, poly->length);
_fmpq_poly_rescale(res->coeffs, res->den,
poly->coeffs, poly->den, poly->length,
fmpq_numref(x), fmpq_denref(x));
_fmpq_poly_set_length(res, poly->length);
}
}
|
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the qmake spec of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QPLATFORMDEFS_H
#define QPLATFORMDEFS_H
// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
#define _XOPEN_SOURCE 500
#define __EXTENSIONS__
// Get Qt defines/settings
#include "qglobal.h"
#include <unistd.h>
// We are hot - unistd.h should have turned on the specific APIs we requested
#include <pthread.h>
#include <dirent.h>
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <signal.h>
#include <dlfcn.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/filio.h>
#include <sys/ipc.h>
#include <sys/time.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <netinet/in.h>
#ifndef QT_NO_IPV6IFNAME
#include <net/if.h>
#endif
// On 64-bit platforms sockets use socklen_t
#define QT_SOCKLEN_T socklen_t
// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED
static inline int qt_socket_connect(int s, struct sockaddr *addr, QT_SOCKLEN_T addrlen)
{ return ::connect(s, addr, addrlen); }
#ifdef QT_LARGEFILE_SUPPORT
#define QT_STATBUF struct stat64
#define QT_STATBUF4TSTAT struct stat64
#define QT_STAT ::stat64
#define QT_FSTAT ::fstat64
#define QT_LSTAT ::lstat64
#define QT_OPEN ::open64
#define QT_TRUNCATE ::truncate64
#define QT_FTRUNCATE ::ftruncate64
#define QT_LSEEK ::lseek64
#else
#define QT_STATBUF struct stat
#define QT_STATBUF4TSTAT struct stat
#define QT_STAT ::stat
#define QT_FSTAT ::fstat
#define QT_LSTAT ::lstat
#define QT_OPEN ::open
#define QT_TRUNCATE ::truncate
#define QT_FTRUNCATE ::ftruncate
#define QT_LSEEK ::lseek
#endif
#ifdef QT_LARGEFILE_SUPPORT
#define QT_FOPEN ::fopen64
#define QT_FSEEK ::fseeko64
#define QT_FTELL ::ftello64
#define QT_FGETPOS ::fgetpos64
#define QT_FSETPOS ::fsetpos64
#define QT_FPOS_T fpos64_t
#define QT_OFF_T off64_t
#else
#define QT_FOPEN ::fopen
#define QT_FSEEK ::fseek
#define QT_FTELL ::ftell
#define QT_FGETPOS ::fgetpos
#define QT_FSETPOS ::fsetpos
#define QT_FPOS_T fpos_t
#define QT_OFF_T long
#endif
#define QT_STAT_REG S_IFREG
#define QT_STAT_DIR S_IFDIR
#define QT_STAT_MASK S_IFMT
#define QT_STAT_LNK S_IFLNK
#define QT_SOCKET_CONNECT qt_socket_connect
#define QT_SOCKET_BIND ::bind
#define QT_FILENO fileno
#define QT_CLOSE ::close
#define QT_READ ::read
#define QT_WRITE ::write
#define QT_ACCESS ::access
#define QT_GETCWD ::getcwd
#define QT_CHDIR ::chdir
#define QT_MKDIR ::mkdir
#define QT_RMDIR ::rmdir
#define QT_OPEN_LARGEFILE O_LARGEFILE
#define QT_OPEN_RDONLY O_RDONLY
#define QT_OPEN_WRONLY O_WRONLY
#define QT_OPEN_RDWR O_RDWR
#define QT_OPEN_CREAT O_CREAT
#define QT_OPEN_TRUNC O_TRUNC
#define QT_OPEN_APPEND O_APPEND
#define QT_SIGNAL_RETTYPE void
#define QT_SIGNAL_ARGS int
#define QT_SIGNAL_IGNORE SIG_IGN
// Only Solaris 7 and better support 64-bit
#define QT_SNPRINTF ::snprintf
#define QT_VSNPRINTF ::vsnprintf
#ifdef connect
#undef connect
#endif
#endif // QPLATFORMDEFS_H
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-signed--multipart.h : class for a signed-multipart
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
* 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.
*
* 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, see <http://www.gnu.org/licenses/>.
*
* Authors: Michael Zucchi <[email protected]>
*/
/* Should this be a subclass of multipart?
* No, because we dont have different parts?
* I'm not really sure yet ... ? */
#if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
#error "Only <camel/camel.h> can be included directly."
#endif
#ifndef CAMEL_MULTIPART_SIGNED_H
#define CAMEL_MULTIPART_SIGNED_H
#include <camel/camel-multipart.h>
/* Standard GObject macros */
#define CAMEL_TYPE_MULTIPART_SIGNED \
(camel_multipart_signed_get_type ())
#define CAMEL_MULTIPART_SIGNED(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), CAMEL_TYPE_MULTIPART_SIGNED, CamelMultipartSigned))
#define CAMEL_MULTIPART_SIGNED_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
((cls), CAMEL_TYPE_MULTIPART_SIGNED, CamelMultipartSignedClass))
#define CAMEL_IS_MULTIPART_SIGNED(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), CAMEL_TYPE_MULTIPART_SIGNED))
#define CAMEL_IS_MULTIPART_SIGNED_CLASS(cls) \
(G_TYPE_CHECK_CLASS_TYPE \
((cls), CAMEL_TYPE_MULTIPART_SIGNED))
#define CAMEL_MULTIPART_SIGNED_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_MULTIPART_SIGNED, CamelMultipartSignedClass))
G_BEGIN_DECLS
/* 'handy' enums for getting the internal parts of the multipart */
enum {
CAMEL_MULTIPART_SIGNED_CONTENT,
CAMEL_MULTIPART_SIGNED_SIGNATURE
};
typedef struct _CamelMultipartSigned CamelMultipartSigned;
typedef struct _CamelMultipartSignedClass CamelMultipartSignedClass;
typedef struct _CamelMultipartSignedPrivate CamelMultipartSignedPrivate;
struct _CamelMultipartSigned {
CamelMultipart parent;
CamelMultipartSignedPrivate *priv;
};
struct _CamelMultipartSignedClass {
CamelMultipartClass parent_class;
};
GType camel_multipart_signed_get_type (void) G_GNUC_CONST;
CamelMultipartSigned *
camel_multipart_signed_new (void);
CamelStream * camel_multipart_signed_get_content_stream
(CamelMultipartSigned *mps,
GError **error);
void camel_multipart_signed_set_content_stream
(CamelMultipartSigned *mps,
CamelStream *content_stream);
void camel_multipart_signed_set_signature
(CamelMultipartSigned *mps,
CamelMimePart *signature);
G_END_DECLS
#endif /* CAMEL_MULTIPART_SIGNED_H */
|
/*
Copyright (C) 2016-2017 Alexander Borisov
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
Author: [email protected] (Alexander Borisov)
*/
#ifndef MODEST_RENDER_BINDING_H
#define MODEST_RENDER_BINDING_H
#pragma once
#include <modest/myosi.h>
#include <modest/modest.h>
#include <modest/node/node.h>
#include <modest/render/tree.h>
#include <modest/render/tree_node.h>
#include <modest/declaration.h>
#include <myhtml/tree.h>
#ifdef __cplusplus
extern "C" {
#endif
modest_render_tree_node_t * modest_render_binding(modest_t* modest, modest_render_tree_t* render_tree, myhtml_tree_t* html_tree);
modest_render_tree_node_t * modest_layer_binding_node(modest_t* modest, modest_render_tree_t* render_tree,
modest_render_tree_node_t* render_root, myhtml_tree_node_t* html_node);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* MODEST_RENDER_BINDING_H */
|
/*
* Copyright (C) 2009, 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
*
* 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 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 DumpRenderTreeBlackBerry_h
#define DumpRenderTreeBlackBerry_h
#include "BlackBerryGlobal.h"
#include "DumpRenderTreeClient.h"
#include "PlatformString.h"
#include "Timer.h"
#include <BlackBerryPlatformLayoutTest.h>
#include <FindOptions.h>
#include <wtf/Vector.h>
namespace WebCore {
class Credential;
class DOMWrapperWorld;
class Frame;
class Range;
}
extern WebCore::Frame* mainFrame;
extern WebCore::Frame* topLoadingFrame;
extern bool waitForPolicy;
class AccessibilityController;
class GCController;
namespace BlackBerry {
namespace WebKit {
class WebPage;
class DumpRenderTree : public BlackBerry::WebKit::DumpRenderTreeClient, public BlackBerry::Platform::LayoutTestClient {
public:
DumpRenderTree(WebPage*);
virtual ~DumpRenderTree();
static DumpRenderTree* currentInstance() { return s_currentInstance; }
void dump();
void setWaitToDumpWatchdog(double interval);
WebPage* page() { return m_page; }
bool loadFinished() const { return m_loadFinished; }
// FrameLoaderClient delegates
void didStartProvisionalLoadForFrame(WebCore::Frame*);
void didCommitLoadForFrame(WebCore::Frame*);
void didFailProvisionalLoadForFrame(WebCore::Frame*);
void didFailLoadForFrame(WebCore::Frame*);
void didFinishLoadForFrame(WebCore::Frame*);
void didFinishDocumentLoadForFrame(WebCore::Frame*);
void didClearWindowObjectInWorld(WebCore::DOMWrapperWorld*, JSGlobalContextRef, JSObjectRef windowObject);
void didReceiveTitleForFrame(const String& title, WebCore::Frame*);
void didDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&);
void didDispatchWillPerformClientRedirect();
void didHandleOnloadEventsForFrame(WebCore::Frame*);
void didReceiveResponseForFrame(WebCore::Frame*, const WebCore::ResourceResponse&);
// ChromeClient delegates
void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID);
void runJavaScriptAlert(const String& message);
bool runJavaScriptConfirm(const String& message);
String runJavaScriptPrompt(const String& message, const String& defaultValue);
bool runBeforeUnloadConfirmPanel(const String& message);
void setStatusText(const String&);
void exceededDatabaseQuota(WebCore::SecurityOrigin*, const String& name);
bool allowsOpeningWindow();
void windowCreated(WebPage*);
// EditorClient delegates
void setAcceptsEditing(bool acceptsEditing) { m_acceptsEditing = acceptsEditing; }
void didBeginEditing();
void didEndEditing();
void didChange();
void didChangeSelection();
bool findString(const String&, WebCore::FindOptions);
bool shouldBeginEditingInDOMRange(WebCore::Range*);
bool shouldEndEditingInDOMRange(WebCore::Range*);
bool shouldDeleteDOMRange(WebCore::Range*);
bool shouldChangeSelectedDOMRangeToDOMRangeAffinityStillSelecting(WebCore::Range* fromRange, WebCore::Range* toRange, int affinity, bool stillSelecting);
bool shouldInsertNode(WebCore::Node*, WebCore::Range*, int insertAction);
bool shouldInsertText(const String&, WebCore::Range*, int insertAction);
bool isSelectTrailingWhitespaceEnabled() const { return s_selectTrailingWhitespaceEnabled; }
void setSelectTrailingWhitespaceEnabled(bool enabled) { s_selectTrailingWhitespaceEnabled = enabled; }
bool didReceiveAuthenticationChallenge(WebCore::Credential&);
// BlackBerry::Platform::BlackBerryPlatformLayoutTestClient method
virtual void addTest(const char* testFile);
private:
void runTest(const String& url);
void runTests();
void runCurrentTest();
void processWork(WebCore::Timer<DumpRenderTree>*);
private:
static DumpRenderTree* s_currentInstance;
String dumpFramesAsText(WebCore::Frame*);
void locationChangeForFrame(WebCore::Frame*);
void doneDrt();
bool isHTTPTest(const String& test);
String renderTreeDump() const;
void resetToConsistentStateBeforeTesting();
void runRemainingTests();
void invalidateAnyPreviousWaitToDumpWatchdog();
void waitToDumpWatchdogTimerFired(WebCore::Timer<DumpRenderTree>*);
Vector<String> m_tests;
Vector<String>::iterator m_currentTest;
Vector<String> m_bufferedTests;
String m_resultsDir;
String m_doneFile;
String m_currentHttpTest;
String m_currentTestFile;
GCController* m_gcController;
AccessibilityController* m_accessibilityController;
WebPage* m_page;
bool m_dumpPixels;
WebCore::Timer<DumpRenderTree> m_waitToDumpWatchdogTimer;
WebCore::Timer<DumpRenderTree> m_workTimer;
bool m_acceptsEditing;
bool m_loadFinished;
static bool s_selectTrailingWhitespaceEnabled;
};
}
}
#endif // DumpRenderTreeBlackBerry_h
|
/*
* Copyright (C) 2014 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup boards_stm32f4discovery
* @{
*
* @file
* @name Peripheral MCU configuration for the STM32F4discovery board
*
* @author Hauke Petersen <[email protected]>
* @author Peter Kietzmann <[email protected]>
*/
#ifndef PERIPH_CONF_H
#define PERIPH_CONF_H
#include "periph_cpu.h"
#include "f4/cfg_clock_168_8_0.h"
#include "cfg_spi_divtable.h"
#include "cfg_usb_otg_fs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Timer configuration
* @{
*/
static const timer_conf_t timer_config[] = {
{
.dev = TIM2,
.max = 0xffffffff,
.rcc_mask = RCC_APB1ENR_TIM2EN,
.bus = APB1,
.irqn = TIM2_IRQn
},
{
.dev = TIM5,
.max = 0xffffffff,
.rcc_mask = RCC_APB1ENR_TIM5EN,
.bus = APB1,
.irqn = TIM5_IRQn
}
};
#define TIMER_0_ISR isr_tim2
#define TIMER_1_ISR isr_tim5
#define TIMER_NUMOF ARRAY_SIZE(timer_config)
/** @} */
/**
* @name UART configuration
* @{
*/
static const uart_conf_t uart_config[] = {
{
.dev = USART2,
.rcc_mask = RCC_APB1ENR_USART2EN,
.rx_pin = GPIO_PIN(PORT_A, 3),
.tx_pin = GPIO_PIN(PORT_A, 2),
.rx_af = GPIO_AF7,
.tx_af = GPIO_AF7,
.bus = APB1,
.irqn = USART2_IRQn,
#ifdef UART_USE_DMA
.dma_stream = 6,
.dma_chan = 4
#endif
},
{
.dev = USART3,
.rcc_mask = RCC_APB1ENR_USART3EN,
.rx_pin = GPIO_PIN(PORT_D, 9),
.tx_pin = GPIO_PIN(PORT_D, 8),
.rx_af = GPIO_AF7,
.tx_af = GPIO_AF7,
.bus = APB1,
.irqn = USART3_IRQn,
#ifdef UART_USE_DMA
.dma_stream = 3,
.dma_chan = 4
#endif
}
};
#define UART_0_ISR (isr_usart2)
#define UART_0_DMA_ISR (isr_dma1_stream6)
#define UART_1_ISR (isr_usart3)
#define UART_1_DMA_ISR (isr_dma1_stream3)
#define UART_NUMOF ARRAY_SIZE(uart_config)
/** @} */
/**
* @name ADC configuration
*
* We need to define the following fields:
* PIN, device (ADCx), channel
* @{
*/
#define ADC_CONFIG { \
{GPIO_PIN(PORT_A, 1), 0, 1}, \
{GPIO_PIN(PORT_A, 4), 0, 4}, \
{GPIO_PIN(PORT_C, 1), 1, 11}, \
{GPIO_PIN(PORT_C, 2), 1, 12} \
}
#define ADC_NUMOF (4)
/** @} */
/**
* @name DAC configuration
* @{
*/
static const dac_conf_t dac_config[] = {
{ .pin = GPIO_PIN(PORT_A, 4), .chan = 0 },
{ .pin = GPIO_PIN(PORT_A, 5), .chan = 1 }
};
#define DAC_NUMOF ARRAY_SIZE(dac_config)
/** @} */
/**
* @name PWM configuration
* @{
*/
static const pwm_conf_t pwm_config[] = {
{
.dev = TIM1,
.rcc_mask = RCC_APB2ENR_TIM1EN,
.chan = { { .pin = GPIO_PIN(PORT_E, 9), .cc_chan = 0 },
{ .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 1 },
{ .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 2 },
{ .pin = GPIO_PIN(PORT_E, 14), .cc_chan = 3 } },
.af = GPIO_AF1,
.bus = APB2
},
{
.dev = TIM3,
.rcc_mask = RCC_APB1ENR_TIM3EN,
.chan = { { .pin = GPIO_PIN(PORT_B, 4), .cc_chan = 0 },
{ .pin = GPIO_PIN(PORT_B, 5), .cc_chan = 1 },
{ .pin = GPIO_PIN(PORT_B, 0), .cc_chan = 2 },
{ .pin = GPIO_PIN(PORT_B, 1), .cc_chan = 3 } },
.af = GPIO_AF2,
.bus = APB1
}
};
#define PWM_NUMOF ARRAY_SIZE(pwm_config)
/** @} */
/**
* @name SPI configuration
* @{
*/
static const spi_conf_t spi_config[] = {
{
.dev = SPI1,
.mosi_pin = GPIO_PIN(PORT_A, 7),
.miso_pin = GPIO_PIN(PORT_A, 6),
.sclk_pin = GPIO_PIN(PORT_A, 5),
.cs_pin = GPIO_PIN(PORT_A, 4),
.mosi_af = GPIO_AF5,
.miso_af = GPIO_AF5,
.sclk_af = GPIO_AF5,
.cs_af = GPIO_AF5,
.rccmask = RCC_APB2ENR_SPI1EN,
.apbbus = APB2
},
{
.dev = SPI2,
.mosi_pin = GPIO_PIN(PORT_B, 15),
.miso_pin = GPIO_PIN(PORT_B, 14),
.sclk_pin = GPIO_PIN(PORT_B, 13),
.cs_pin = GPIO_PIN(PORT_B, 12),
.mosi_af = GPIO_AF5,
.miso_af = GPIO_AF5,
.sclk_af = GPIO_AF5,
.cs_af = GPIO_AF5,
.rccmask = RCC_APB1ENR_SPI2EN,
.apbbus = APB1
}
};
#define SPI_NUMOF ARRAY_SIZE(spi_config)
/** @} */
/**
* @name I2C configuration
* @{
*/
static const i2c_conf_t i2c_config[] = {
{
.dev = I2C1,
.speed = I2C_SPEED_NORMAL,
.scl_pin = GPIO_PIN(PORT_B, 6),
.sda_pin = GPIO_PIN(PORT_B, 7),
.scl_af = GPIO_AF4,
.sda_af = GPIO_AF4,
.bus = APB1,
.rcc_mask = RCC_APB1ENR_I2C1EN,
.clk = CLOCK_APB1,
.irqn = I2C1_EV_IRQn
}
};
#define I2C_0_ISR isr_i2c1_ev
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CONF_H */
/** @} */
|
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QRFCOMMSERVER_P_H
#define QRFCOMMSERVER_P_H
#include <QtGlobal>
#include <QList>
#include <qbluetoothsocket.h>
#ifdef QTM_SYMBIAN_BLUETOOTH
#include <es_sock.h>
#include <bt_sock.h>
#endif
#ifdef QTM_BLUEZ_BLUETOOTH
QT_FORWARD_DECLARE_CLASS(QSocketNotifier)
#endif
QT_BEGIN_HEADER
QTM_BEGIN_NAMESPACE
class QBluetoothAddress;
class QBluetoothSocket;
#ifdef QTM_SYMBIAN_BLUETOOTH
class QBluetoothSocketPrivate;
#endif
class QRfcommServer;
class QRfcommServerPrivate
{
Q_DECLARE_PUBLIC(QRfcommServer)
public:
QRfcommServerPrivate();
~QRfcommServerPrivate();
#ifdef QTM_SYMBIAN_BLUETOOTH
// private slots
void _q_connected();
void _q_socketError(QBluetoothSocket::SocketError err);
void _q_disconnected();
#endif //QTM_SYMBIAN_BLUETOOTH
#ifdef QTM_BLUEZ_BLUETOOTH
void _q_newConnection();
#endif
public:
QBluetoothSocket *socket;
#ifdef QTM_SYMBIAN_BLUETOOTH
mutable QList<QBluetoothSocket *> activeSockets;
QBluetoothSocketPrivate *ds;
#endif
int maxPendingConnections;
QBluetooth::SecurityFlags securityFlags;
protected:
QRfcommServer *q_ptr;
private:
#ifdef QTM_BLUEZ_BLUETOOTH
QSocketNotifier *socketNotifier;
#endif
};
QTM_END_NAMESPACE
QT_END_HEADER
#endif
|
/*
kopetelviprops.h
Kopete Contactlist Properties GUI for Groups and MetaContacts
Copyright (c) 2002-2003 by Stefan Gehn <[email protected]>
Kopete (c) 2002-2003 by the Kopete developers <[email protected]>
*************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
*************************************************************************
*/
#ifndef KOPETELVIPROPS_H
#define KOPETELVIPROPS_H
#include <kdialog.h>
#include <kabc/sound.h>
#include "kopetemetacontact.h"
#include "ui_kopetemetalvipropswidget.h"
#include "ui_kopetegvipropswidget.h"
class AddressBookLinkWidget;
class CustomNotificationProps;
class KopeteAddressBookExport;
class KUrlRequester;
namespace KABC { class Addressee; }
namespace Kopete {
class Contact;
class Group;
}
class KopeteGVIProps: public KDialog
{
Q_OBJECT
public:
KopeteGVIProps(Kopete::Group *group, QWidget *parent);
~KopeteGVIProps();
private:
CustomNotificationProps * mNotificationProps;
QWidget *mainWidget;
Ui::KopeteGVIPropsWidget *ui_mainWidget;
Kopete::Group *mGroup;
bool m_dirty;
private slots:
void slotOkClicked();
void slotUseCustomIconsToggled(bool on);
void slotIconChanged();
};
class KopeteMetaLVIProps: public KDialog
{
Q_OBJECT
public:
KopeteMetaLVIProps(Kopete::MetaContact *metaContact, QWidget *parent);
~KopeteMetaLVIProps();
private:
CustomNotificationProps * mNotificationProps;
QPushButton *mFromKABC;
QWidget* mainWidget;
Ui::KopeteMetaLVIPropsWidget *ui_mainWidget;
AddressBookLinkWidget *linkWidget;
Kopete::MetaContact *mMetaContact;
KopeteAddressBookExport *mExport;
KABC::Sound mSound;
int m_countPhotoCapable;
QMap<int, Kopete::Contact *> m_withPhotoContacts;
QString mAddressBookUid; // the currently selected addressbook UID
QString m_photoPath;
void setContactsNameTypes();
Kopete::MetaContact::PropertySource selectedNameSource() const;
Kopete::MetaContact::PropertySource selectedPhotoSource() const;
Kopete::Contact* selectedNameSourceContact() const;
Kopete::Contact* selectedPhotoSourceContact() const;
private slots:
void slotOkClicked();
void slotUseCustomIconsToggled( bool on );
void slotClearPhotoClicked();
void slotAddresseeChanged( const KABC::Addressee & );
void slotExportClicked();
void slotImportClicked();
void slotFromKABCClicked();
void slotOpenSoundDialog( KUrlRequester *requester );
void slotLoadNameSources();
void slotLoadPhotoSources();
void slotSelectPhoto();
void slotEnableAndDisableWidgets();
};
#endif
|
#include <stdlib.h>
#include <check.h>
#include "../src/money.h"
START_TEST (test_money_create)
{
Money *m;
m = money_create (5, "USD");
ck_assert_int_eq (money_amount (m), 5);
ck_assert_str_eq (money_currency (m), "USD");
money_free (m);
}
END_TEST
Suite *
money_suite (void)
{
Suite *s = suite_create ("Money");
/* Core test case */
TCase *tc_core = tcase_create ("Core");
tcase_add_test (tc_core, test_money_create);
suite_add_tcase (s, tc_core);
return s;
}
int
main (void)
{
int number_failed;
Suite *s = money_suite ();
SRunner *sr = srunner_create (s);
srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
|
/*
* SALSA-Lib - Small ALSA Library
*
* Copyright (c) 2007-2012 by Takashi Iwai <[email protected]>
*
* 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 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __ASOUNDLIB_H
#define __ASOUNDLIB_H
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <assert.h>
#include <endian.h>
#include <sys/poll.h>
#include <errno.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "recipe.h"
#include "asoundef.h"
#include "version.h"
#include "global.h"
#include "input.h"
#include "output.h"
#include "error.h"
#include "control.h"
|
/*
* Purpose: Test check dbcolinfo/dbtableinfo informations
* Functions: dbresults dbsqlexec dbtablecolinfo
*/
#include "common.h"
static int failed = 0;
static void
check_is(const char *value, const char *expected)
{
if (strcmp(value, expected) == 0)
return;
failed = 1;
fprintf(stderr, "Wrong value, got \"%s\" expected \"%s\"\n", value, expected);
}
static void
check_contains(const char *value, const char *expected)
{
if (strstr(value, expected) != NULL)
return;
failed = 1;
fprintf(stderr, "Wrong value, got \"%s\" expected to contains \"%s\"\n", value, expected);
}
int
main(int argc, char **argv)
{
LOGINREC *login;
DBPROCESS *dbproc;
int n_col;
DBCOL2 col2;
set_malloc_options();
read_login_info(argc, argv);
printf("Starting %s\n", argv[0]);
dbinit();
dberrhandle(syb_err_handler);
dbmsghandle(syb_msg_handler);
printf("About to logon\n");
login = dblogin();
DBSETLPWD(login, PASSWORD);
DBSETLUSER(login, USER);
DBSETLAPP(login, "colinfo");
printf("About to open\n");
dbproc = dbopen(login, SERVER);
if (strlen(DATABASE))
dbuse(dbproc, DATABASE);
dbloginfree(login);
printf("creating tables\n");
sql_cmd(dbproc);
dbsqlexec(dbproc);
while (dbresults(dbproc) != NO_MORE_RESULTS) {
/* nop */
}
sql_cmd(dbproc); /* select */
dbsqlexec(dbproc);
if (dbresults(dbproc) != SUCCEED) {
printf("Was expecting a result set.");
exit(1);
}
for (n_col = 1; n_col <= 3; ++n_col) {
col2.SizeOfStruct = sizeof(col2);
if (dbtablecolinfo(dbproc, n_col, (DBCOL *) &col2) != SUCCEED) {
fprintf(stderr, "dbtablecolinfo failed for col %d\n", n_col);
failed = 1;
continue;
}
if (n_col == 1) {
check_is(col2.Name, "number");
check_contains(col2.TableName, "#colinfo_table");
} else if (n_col == 2) {
check_is(col2.Name, "is_a_string");
check_contains(col2.TableName, "#colinfo_table");
} else if (n_col == 3) {
check_is(col2.Name, "dollars");
check_contains(col2.TableName, "#test_table");
}
}
dbexit();
printf("%s %s\n", __FILE__, (failed ? "failed!" : "OK"));
return failed ? 1 : 0;
}
|
/* This file is part of GEGL.
*
* 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 3 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 GEGL; if not, see <https://www.gnu.org/licenses/>.
*
* Copyright 2006 Øyvind Kolås <[email protected]>
*/
#ifndef __GEGL_TILE_BACKEND_RAM_H__
#define __GEGL_TILE_BACKEND_RAM_H__
#include "gegl-tile-backend.h"
/***
* GeglTileBackendRam is a GeglTileBackend that store tiles in RAM.
*/
G_BEGIN_DECLS
#define GEGL_TYPE_TILE_BACKEND_RAM (gegl_tile_backend_ram_get_type ())
#define GEGL_TILE_BACKEND_RAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_TILE_BACKEND_RAM, GeglTileBackendRam))
#define GEGL_TILE_BACKEND_RAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEGL_TYPE_TILE_BACKEND_RAM, GeglTileBackendRamClass))
#define GEGL_IS_TILE_BACKEND_RAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_TILE_BACKEND_RAM))
#define GEGL_IS_TILE_BACKEND_RAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEGL_TYPE_TILE_BACKEND_RAM))
#define GEGL_TILE_BACKEND_RAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEGL_TYPE_TILE_BACKEND_RAM, GeglTileBackendRamClass))
typedef struct _GeglTileBackendRam GeglTileBackendRam;
typedef struct _GeglTileBackendRamClass GeglTileBackendRamClass;
struct _GeglTileBackendRam
{
GeglTileBackend parent_instance;
GHashTable *entries;
};
struct _GeglTileBackendRamClass
{
GeglTileBackendClass parent_class;
};
GType gegl_tile_backend_ram_get_type (void) G_GNUC_CONST;
void gegl_tile_backend_ram_stats (void);
G_END_DECLS
#endif
|
/*
* Copyright (C) 2016 Hedede <[email protected]>
*
* License LGPLv3 or later:
* GNU Lesser GPL version 3 <http://gnu.org/licenses/lgpl-3.0.html>
* This is free software: you are free to change and redistribute it.
* There is NO WARRANTY, to the extent permitted by law.
*/
#ifndef aw_utility_result_h
#define aw_utility_result_h
#include <cassert>
#include <aw/types/types.h>
#include <aw/utility/storage.h>
namespace aw {
inline namespace utility {
/*
namespace _impl {
template<typename T>
struct error {
error(T const& value) : value(value) {}
error(T&& value) : value(std::move(value)) {}
T value;
};
template<typename T>
struct result {
result(T const& value) : value(value) {}
result(T&& value) : value(std::move(value)) {}
T value;
};
} // namespace _impl*/
struct error_tag {};
struct value_tag {};
/*!
* Simple helper, which can hold either a value, or an error.
*/
template <typename T, typename E>
struct result {
using value_type = T;
using error_type = E;
/*!
* Construct result from copy of \a value.
*
* \note
* Pass `value_tag{}` as argument to disambiguate
* between error type and value type (if both
* can be constructed from same value).
*/
result(T const& value, value_tag = value_tag{})
: is_error(false)
{
construct_value(value);
}
/*!
* Construct error.
*/
result(E const& error, error_tag = error_tag{})
: is_error(true)
{
construct_error(error);
}
/*!
* Move-construct result from \a value.
*/
result(T&& value, value_tag = value_tag{})
: is_error(false)
{
construct_value(std::move(value));
}
/*!
* Move-construct error.
*/
result(E&& error, error_tag = error_tag{})
: is_error(true)
{
construct_error(std::move(error));
}
template<typename...Args>
result(value_tag, Args&&... args)
: is_error(false)
{
construct_value(std::forward<Args>(args)...);
}
template<typename...Args>
result(error_tag, Args&&... args)
: is_error(true)
{
construct_error(std::forward<Args>(args)...);
}
template<typename OtherT, typename OtherE>
result(result<OtherT,OtherE> const& other)
: is_error(other.is_error)
{
if (!is_error)
construct_value(other.value());
else
construct_error(other.error());
}
template<typename OtherT, typename OtherE>
result(result<OtherT,OtherE>&& other)
: is_error(other.is_error)
{
if (!is_error)
construct_value(std::move(other.value()));
else
construct_error(std::move(other.error()));
}
~result()
{
destroy();
}
template<typename OtherT, typename OtherE>
result& operator=(result<OtherT,OtherE> const& other)
{
destroy();
is_error = other.is_error;
if (!is_error)
construct_value(other.value());
else
construct_error(other.error());
}
template<typename OtherT, typename OtherE>
result& operator=(result<OtherT,OtherE>&& other)
{
destroy();
is_error = other.is_error;
if (!is_error)
construct_value(std::move(other.value()));
else
construct_error(std::move(other.error()));
}
bool has_error() const
{
return is_error;
}
/*!
* Check if result holds a value.
* \return
* `true` if result holds a value,
* `false` if result holds an error.
*/
explicit operator bool() const
{
return !is_error;
}
/*!
* Get value from result.
*
* Behaviour is undefined if result holds an error.
*/
T& value() &
{
return *get_value();
}
T const& value() const&
{
return *get_value();
}
T&& value() &&
{
return std::move(*get_value());
}
T const&& value() const&&
{
return std::move(*get_value());
}
/*!
* Get error from result.
*
* Behaviour is undefined if result holds a value.
*/
E& error() &
{
return *get_error();
}
E const& error() const&
{
return *get_error();
}
E&& error() &&
{
return std::move(*get_error());
}
E const&& error() const&&
{
return std::move(*get_error());
}
private:
void destroy()
{
if (!is_error)
storage_.template destroy<value_type>();
else
storage_.template destroy<error_type>();
}
template <typename... Args>
void construct_value(Args&&...args)
{
storage_.template construct<T>(std::forward<Args>(args)...);
}
template <typename... Args>
void construct_error(Args&&...args)
{
storage_.template construct<E>(std::forward<Args>(args)...);
}
T* get_value()
{
assert(!is_error);
return storage_.template get<T>();
}
T const* get_value() const
{
assert(!is_error);
return storage_.template get<T>();
}
E* get_error()
{
assert(is_error);
return storage_.template get<E>();
}
E const* get_error() const
{
assert(is_error);
return storage_.template get<E>();
}
storage<T, E> storage_;
bool is_error;
};
template<class T, class E, typename... Args>
result<T,E> make_result(Args&&... args)
{
return {value_tag{}, std::forward<Args>(args)...};
}
template<class T, class E, typename... Args>
result<T,E> make_error(Args&&... args)
{
return {error_tag{}, std::forward<Args>(args)...};
}
} // namespace utility
} // namespace aw
#endif//aw_utility_result_h
|
#ifndef SOCIOTWITTER_H
#define SOCIOTWITTER_H
#include <widgetinterface.h>
#include <widgetplugin.h>
#include "sociotwitterinterface.h"
class VISIBLE_SYM SocioTwitter : public PlexyDesk::WidgetPlugin {
Q_OBJECT
public:
SocioTwitter(QObject *object = 0);
virtual ~SocioTwitter();
QGraphicsItem *item();
};
#endif
|
/* This provides unification of code over STM32 subfamilies */
/*
* This file is part of the libopencm3 project.
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include <libopencm3/cm3/common.h>
#include <libopencm3/stm32/memorymap.h>
#if defined(STM32F0)
# include <libopencm3/stm32/f0/pwr.h>
#elif defined(STM32F1)
# include <libopencm3/stm32/f1/pwr.h>
#elif defined(STM32F2)
# include <libopencm3/stm32/f2/pwr.h>
#elif defined(STM32F3)
# include <libopencm3/stm32/f3/pwr.h>
#elif defined(STM32F4)
# include <libopencm3/stm32/f4/pwr.h>
#elif defined(STM32F7)
# include <libopencm3/stm32/f7/pwr.h>
#elif defined(STM32L1)
# include <libopencm3/stm32/l1/pwr.h>
#elif defined(STM32L0)
# include <libopencm3/stm32/l0/pwr.h>
#elif defined(STM32L4)
# include <libopencm3/stm32/l4/pwr.h>
#elif defined(STM32G0)
# include <libopencm3/stm32/g0/pwr.h>
#elif defined(STM32G4)
# include <libopencm3/stm32/g4/pwr.h>
#elif defined(STM32H7)
# include <libopencm3/stm32/h7/pwr.h>
#else
# error "stm32 family not defined."
#endif
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Header: TextTree.h
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef TextTree_H
#define TextTree_H
#include "CMRmisc.h"
using namespace std;
struct TextTree {
TextTree() : tid(-1), vNumber(0), vLabel(0), firstChild(0), nextSibling(0), parent(0)
{
}
TextTree(int t) : tid(t), vNumber(0), vLabel(0), firstChild(0), nextSibling(0), parent(0)
{
}
TextTree(int t, short v) : tid(t), vNumber(v),
vLabel(v,-1), firstChild(v,-1), nextSibling(v,-1), parent(v,-1)
{
}
~TextTree()
{
}
//assuming the copy constructor and operator= have default definition
int tid;
short vNumber; // number of nodes in the tree
vector<short> vLabel;
vector<short> firstChild;
vector<short> nextSibling;
vector<short> parent;
};
istream& operator>>(istream& in, TextTree& rhs);
ostream& operator<<(ostream& out, const TextTree& rhs);
#endif //TextTree_H
|
/*************************************************************************\
* Copyright (C) Michael Kerrisk, 2014. *
* *
* This program is free software. You may use, modify, and redistribute it *
* under the terms of the GNU Affero General Public License as published *
* by the Free Software Foundation, either version 3 or (at your option) *
* any later version. This program is distributed without any warranty. *
* See the file COPYING.agpl-v3 for details. *
\*************************************************************************/
/* Listing 26-3 */
#include <sys/wait.h>
#include "print_wait_status.h" /* Declares printWaitStatus() */
#include "tlpi_hdr.h"
int
main(int argc, char *argv[])
{
int status;
pid_t childPid;
if (argc > 1 && strcmp(argv[1], "--help") == 0)
usageErr("%s [exit-status]\n", argv[0]);
switch (fork()) {
case -1: errExit("fork");
case 0: /* Child: either exits immediately with given
status or loops waiting for signals */
printf("Child started with PID = %ld\n", (long) getpid());
if (argc > 1) /* Status supplied on command line? */
exit(getInt(argv[1], 0, "exit-status"));
else /* Otherwise, wait for signals */
for (;;)
pause();
exit(EXIT_FAILURE); /* Not reached, but good practice */
default: /* Parent: repeatedly wait on child until it
either exits or is terminated by a signal */
for (;;) {
childPid = waitpid(-1, &status, WUNTRACED
#ifdef WCONTINUED /* Not present on older versions of Linux */
| WCONTINUED
#endif
);
if (childPid == -1)
errExit("waitpid");
/* Print status in hex, and as separate decimal bytes */
printf("waitpid() returned: PID=%ld; status=0x%04x (%d,%d)\n",
(long) childPid,
(unsigned int) status, status >> 8, status & 0xff);
printWaitStatus(NULL, status);
if (WIFEXITED(status) || WIFSIGNALED(status))
exit(EXIT_SUCCESS);
}
}
}
|
/**
* @defgroup Icon Icon
* @ingroup Elementary
*
* @image html icon_inheritance_tree.png
* @image latex icon_inheritance_tree.eps
*
* @image html img/widget/icon/preview-00.png
* @image latex img/widget/icon/preview-00.eps
*
* An icon object is used to display standard icon images ("delete",
* "edit", "arrows", etc.) or images coming from a custom file (PNG,
* JPG, EDJE, etc.), on icon contexts.
*
* The icon image requested can be in the Elementary theme in use, or
* in the @c freedesktop.org theme paths. It's possible to set the
* order of preference from where an image will be fetched.
*
* This widget inherits from the @ref Image one, so that all the
* functions acting on it also work for icon objects.
*
* You should be using an icon, instead of an image, whenever one of
* the following apply:
* - you need a @b thumbnail version of an original image
* - you need freedesktop.org provided icon images
* - you need theme provided icon images (Edje groups)
*
* Various calls on the icon's API are marked as @b deprecated, as
* they just wrap the image counterpart functions. Use the ones we
* point you to, for each case of deprecation here, instead --
* eventually the deprecated ones will be discarded (next major
* release).
*
* Default images provided by Elementary's default theme are described
* below.
*
* These are names for icons that were first intended to be used in
* toolbars, but can be used in many other places too:
* @li @c "home"
* @li @c "close"
* @li @c "apps"
* @li @c "arrow_up"
* @li @c "arrow_down"
* @li @c "arrow_left"
* @li @c "arrow_right"
* @li @c "chat"
* @li @c "clock"
* @li @c "delete"
* @li @c "edit"
* @li @c "refresh"
* @li @c "folder"
* @li @c "file"
*
* These are names for icons that were designed to be used in menus
* (but again, you can use them anywhere else):
* @li @c "menu/home"
* @li @c "menu/close"
* @li @c "menu/apps"
* @li @c "menu/arrow_up"
* @li @c "menu/arrow_down"
* @li @c "menu/arrow_left"
* @li @c "menu/arrow_right"
* @li @c "menu/chat"
* @li @c "menu/clock"
* @li @c "menu/delete"
* @li @c "menu/edit"
* @li @c "menu/refresh"
* @li @c "menu/folder"
* @li @c "menu/file"
*
* And these are names for some media player specific icons:
* @li @c "media_player/forward"
* @li @c "media_player/info"
* @li @c "media_player/next"
* @li @c "media_player/pause"
* @li @c "media_player/play"
* @li @c "media_player/prev"
* @li @c "media_player/rewind"
* @li @c "media_player/stop"
*
* This widget emits the following signals, besides the ones sent from
* @ref Image:
* - @c "thumb,done" - elm_icon_thumb_set() has completed with success
* (since 1.7)
* - @c "thumb,error" - elm_icon_thumb_set() has failed (since 1.7)
*
* Elementary icon objects support the following API calls:
* @li elm_object_signal_emit()
* @li elm_object_signal_callback_add()
* @li elm_object_signal_callback_del()
* for emmiting and listening to signals on the object, when the
* internal image comes from an Edje object. This behavior was added
* unintentionally, though, and is @b deprecated. Expect it to be
* dropped on future releases.
*
* An example of usage for this API follows:
* @li @ref tutorial_icon
*/
#include "elm_icon_common.h"
#ifdef EFL_EO_API_SUPPORT
#include "elm_icon_eo.h"
#endif
#ifndef EFL_NOLEGACY_API_SUPPORT
#include "elm_icon_legacy.h"
#endif
/**
* @}
*/
|
/* Workaround build system bug that will put objects in source dir */
#include "../../../common/ieee802154_settings.c"
|
/* ------------------------------------------------
Copyright 2014 AT&T Intellectual Property
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.
------------------------------------------- */
/* gscpmsgq.h defines the interface to a socket based message
* queue implementation for MacOSX which does not provide
* a System V message queueu but shared memory.
*/
#ifndef GSCPMSGQ_H
#define GSCPMSGQ_H
#ifdef NOMSGQ
#include <sys/types.h>
#include <sys/ipc.h>
struct gscp_msgbuf {
long mtype; /* message type, must be > 0 */
char mtext[1]; /* message data */
};
int gscp_msgget(key_t key, int msgflg);
ssize_t gscp_msgrcv(int msqid, struct gscp_msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg);
int gscp_msgsnd(int msqid, struct gscp_msgbuf *msgp, size_t msgsz, int msgflg);
#endif
#endif
|
/* uconsole.c
*
* Copyright 2011 Brian Swetland <[email protected]>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <stdint.h>
#include "usb.h"
int main(int argc, char **argv) {
int r, once;
usb_handle *usb;
char buf[64];
once = 1;
for (;;) {
usb = usb_open(0x18d1, 0xdb05, 0);
if (usb == 0) {
usb = usb_open(0x18d1, 0xdb04, 1);
}
if (usb == 0) {
if (once) {
fprintf(stderr,"waiting for device...\n");
once = 0;
}
} else {
break;
}
}
fprintf(stderr,"connected\n");
for (;;) {
r = usb_read(usb, buf, 64);
if (r < 0)
break;
if (write(1, buf, r)) { /* do nothing */ }
}
return 0;
}
|
//
// BMKViewController.h
// lianxi
//
// Created by 张丽明 on 2017/4/24.
// Copyright © 2017年 张丽明. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface BMKViewController : UIViewController
@end
|
/**
******************************************************************************
* @file stm324xg_eval_sd.h
* @author MCD Application Team
* @version V2.0.5
* @date 02-March-2015
* @brief This file contains the common defines and functions prototypes for
* the stm324xg_eval_sd.c driver.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. 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.
* 3. Neither the name of STMicroelectronics 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 HOLDER 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM324xG_EVAL_SD_H
#define __STM324xG_EVAL_SD_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM324xG_EVAL
* @{
*/
/** @defgroup STM324xG_EVAL_SD
* @{
*/
/** @defgroup STM324xG_EVAL_SD_Exported_Types
* @{
*/
/**
* @brief SD Card information structure
*/
#define SD_CardInfo HAL_SD_CardInfoTypedef
/**
* @brief SD status structure definition
*/
#define MSD_OK 0x00
#define MSD_ERROR 0x01
/** @defgroup STM324xG_EVAL_SD_Exported_Constants
* @{
*/
#define SD_DETECT_PIN GPIO_PIN_13
#define SD_DETECT_GPIO_PORT GPIOH
#define __SD_DETECT_GPIO_CLK_ENABLE() __GPIOH_CLK_ENABLE()
#define SD_DETECT_IRQn EXTI15_10_IRQn
#define SD_DATATIMEOUT ((uint32_t)100000000)
#define SD_PRESENT ((uint8_t)0x01)
#define SD_NOT_PRESENT ((uint8_t)0x00)
/* DMA definitions for SD DMA transfer */
#define __DMAx_TxRx_CLK_ENABLE __DMA2_CLK_ENABLE
#define SD_DMAx_Tx_CHANNEL DMA_CHANNEL_4
#define SD_DMAx_Rx_CHANNEL DMA_CHANNEL_4
#define SD_DMAx_Tx_STREAM DMA2_Stream6
#define SD_DMAx_Rx_STREAM DMA2_Stream3
#define SD_DMAx_Tx_IRQn DMA2_Stream6_IRQn
#define SD_DMAx_Rx_IRQn DMA2_Stream3_IRQn
#define SD_DMAx_Tx_IRQHandler DMA2_Stream6_IRQHandler
#define SD_DMAx_Rx_IRQHandler DMA2_Stream3_IRQHandler
#define SD_DetectIRQHandler() HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13)
/**
* @}
*/
/** @defgroup STM324xG_EVAL_SD_Exported_Macro
* @{
*/
/** @defgroup STM324xG_EVAL_SD_Exported_Functions
* @{
*/
uint8_t BSP_SD_Init(void);
uint8_t BSP_SD_ITConfig(void);
void BSP_SD_DetectIT(void);
void BSP_SD_DetectCallback(void);
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);
void BSP_SD_IRQHandler(void);
void BSP_SD_DMA_Tx_IRQHandler(void);
void BSP_SD_DMA_Rx_IRQHandler(void);
HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void);
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
uint8_t BSP_SD_IsDetected(void);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __STM324xG_EVAL_SD_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
#ifndef VIDEO_H
#define VIDEO_H
#include <linux/videodev2.h>
struct buf
{
void *start;
size_t length;
};
struct buffer
{
struct v4l2_requestbuffers req; // ÇëÇó
struct v4l2_buffer query; // »ñÈ¡
struct buf *buf; // »º³å
};
struct video
{
int fd;
struct v4l2_format format; // ÊÓÆµÖ¡¸ñʽ
struct buffer buffer; // ÊÓÆµ»º³å
};
void video_init();
void video_quit();
void buffer_enqueue(int index);
void buffer_dequeue(int index);
void buffer_mmap(int index);
#endif
|
/* System library. */
#include "StdAfx.h"
#ifndef ACL_PREPARE_COMPILE
#include "stdlib/acl_define.h"
#ifdef ACL_BCB_COMPILER
#pragma hdrstop
#endif
#endif
#ifdef ACL_UNIX
#include <errno.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
/* Utility library. */
#include "posix_signals.h"
#include "stdlib/acl_msg.h"
#include "stdlib/unix/acl_timed_wait.h"
/* Application-specific. */
static int timed_wait_expired;
/* timed_wait_alarm - timeout handler */
static void timed_wait_alarm(int unused_sig acl_unused)
{
/*
* WARNING WARNING WARNING.
*
* This code runs at unpredictable moments, as a signal handler.
* This code is here only so that we can break out of waitpid().
* Don't put any code here other than for setting a global flag.
*/
timed_wait_expired = 1;
}
/* timed_waitpid - waitpid with time limit */
int acl_timed_waitpid(pid_t pid, ACL_WAIT_STATUS_T *statusp, int options,
int time_limit)
{
const char *myname = "timed_waitpid";
struct sigaction action;
struct sigaction old_action;
int time_left;
int wpid;
char tbuf[256];
/*
* Sanity checks.
*/
if (time_limit <= 0)
acl_msg_panic("%s: bad time limit: %d", myname, time_limit);
/*
* Set up a timer.
*/
sigemptyset(&action.sa_mask);
action.sa_flags = 0;
action.sa_handler = timed_wait_alarm;
if (sigaction(SIGALRM, &action, &old_action) < 0)
acl_msg_fatal("%s: sigaction(SIGALRM): %s", myname,
acl_last_strerror(tbuf, sizeof(tbuf)));
timed_wait_expired = 0;
time_left = alarm(time_limit);
/*
* Wait for only a limited amount of time.
*/
if ((wpid = waitpid(pid, statusp, options)) < 0 && timed_wait_expired)
acl_set_error(ETIMEDOUT);
/*
* Cleanup.
*/
alarm(0);
if (sigaction(SIGALRM, &old_action, (struct sigaction *) 0) < 0)
acl_msg_fatal("%s: sigaction(SIGALRM): %s", myname,
acl_last_strerror(tbuf, sizeof(tbuf)));
if (time_left)
alarm(time_left);
return (wpid);
}
#endif /* ACL_UNIX */
|
#ifndef __RDMURMUR2___H__
#define __RDMURMUR2___H__
uint32_t rd_murmur2 (const void *key, size_t len);
int unittest_murmur2 (void);
#endif // __RDMURMUR2___H__
|
/*
* Copyright (c) 2017 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <led_strip.h>
#include <errno.h>
#include <string.h>
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_LED_STRIP_LEVEL
#include <logging/sys_log.h>
#include <zephyr.h>
#include <device.h>
#include <spi.h>
#include <misc/util.h>
/*
* LPD880X SPI master configuration:
*
* - mode 0 (the default), 8 bit, MSB first, one-line SPI
* - no shenanigans (no CS hold, release device lock, not an EEPROM)
*/
#define LPD880X_SPI_OPERATION (SPI_OP_MODE_MASTER | \
SPI_TRANSFER_MSB | \
SPI_WORD_SET(8) | \
SPI_LINES_SINGLE)
struct lpd880x_data {
struct spi_config config;
};
static int lpd880x_update(struct device *dev, void *data, size_t size)
{
struct lpd880x_data *drv_data = dev->driver_data;
/*
* Per the AdaFruit reverse engineering notes on the protocol,
* a zero byte propagates through at most 32 LED driver ICs.
* The LPD8803 is the worst case, at 3 output channels per IC.
*/
u8_t reset_size = ceiling_fraction(ceiling_fraction(size, 3), 32);
u8_t reset_buf[reset_size];
u8_t last = 0x00;
struct spi_buf bufs[3];
size_t rc;
/* Prepares the strip to shift in new data values. */
memset(reset_buf, 0x00, reset_size);
bufs[0].buf = reset_buf;
bufs[0].len = reset_size;
/* Displays the serialized pixel data. */
bufs[1].buf = data;
bufs[1].len = size;
/* Ensures the last byte of pixel data is displayed. */
bufs[2].buf = &last;
bufs[2].len = sizeof(last);
rc = spi_write(&drv_data->config, bufs, ARRAY_SIZE(bufs));
if (rc) {
SYS_LOG_ERR("can't update strip: %d", rc);
}
return rc;
}
static int lpd880x_strip_update_rgb(struct device *dev,
struct led_rgb *pixels,
size_t num_pixels)
{
u8_t *px = (u8_t *)pixels;
u8_t r, g, b;
size_t i;
/*
* Overwrite a prefix of the pixels array with its on-wire
* representation, eliminating padding/scratch garbage, if any.
*/
for (i = 0; i < num_pixels; i++) {
r = 0x80 | (pixels[i].r >> 1);
g = 0x80 | (pixels[i].g >> 1);
b = 0x80 | (pixels[i].b >> 1);
/*
* GRB is the ordering used by commonly available
* LPD880x strips.
*/
*px++ = g;
*px++ = r;
*px++ = b;
}
return lpd880x_update(dev, pixels, 3 * num_pixels);
}
static int lpd880x_strip_update_channels(struct device *dev, u8_t *channels,
size_t num_channels)
{
size_t i;
for (i = 0; i < num_channels; i++) {
channels[i] = 0x80 | (channels[i] >> 1);
}
return lpd880x_update(dev, channels, num_channels);
}
static int lpd880x_strip_init(struct device *dev)
{
struct lpd880x_data *data = dev->driver_data;
struct spi_config *config = &data->config;
struct device *spi;
spi = device_get_binding(CONFIG_LPD880X_STRIP_SPI_DEV_NAME);
if (!spi) {
SYS_LOG_ERR("SPI device %s not found",
CONFIG_LPD880X_STRIP_SPI_DEV_NAME);
return -ENODEV;
}
config->dev = spi;
config->frequency = CONFIG_LPD880X_STRIP_SPI_BAUD_RATE;
config->operation = LPD880X_SPI_OPERATION;
config->slave = 0; /* MOSI/CLK only; CS is not supported. */
config->cs = NULL;
return 0;
}
static struct lpd880x_data lpd880x_strip_data;
static const struct led_strip_driver_api lpd880x_strip_api = {
.update_rgb = lpd880x_strip_update_rgb,
.update_channels = lpd880x_strip_update_channels,
};
DEVICE_AND_API_INIT(lpd880x_strip, CONFIG_LPD880X_STRIP_NAME,
lpd880x_strip_init, &lpd880x_strip_data,
NULL, POST_KERNEL, CONFIG_LED_STRIP_INIT_PRIORITY,
&lpd880x_strip_api);
|
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include<winapifamily.h>
#define ANG_NO_RUNTIME_ERRORS
#define ANGSYS_DYNAMIC_LIBRARY
#include <angsys.hpp>
#include <ang/platform/angwin/angwin.hpp>
#include <ang/graphics/angraph.hpp>
#pragma comment(lib, "angsys.lib")
#pragma comment(lib, "angraph.lib")
#pragma comment(lib, "angsys.platform.lib")
// TODO: reference additional headers your program requires here
#define _USE_MATH_DEFINES
#include <math.h>
//#define VK_NO_PROTOTYPES
//#include <vulkan\vulkan.h>
|
/* Copyright JS Foundation and other contributors, http://js.foundation
*
* 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 RE_COMPILER_H
#define RE_COMPILER_H
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
#include "ecma-globals.h"
#include "re-bytecode.h"
#include "re-parser.h"
/** \addtogroup parser Parser
* @{
*
* \addtogroup regexparser Regular expression
* @{
*
* \addtogroup regexparser_compiler Compiler
* @{
*/
/**
* Context of RegExp compiler
*/
typedef struct
{
uint16_t flags; /**< RegExp flags */
uint32_t num_of_captures; /**< number of capture groups */
uint32_t num_of_non_captures; /**< number of non-capture groups */
uint32_t highest_backref; /**< highest backreference */
re_bytecode_ctx_t *bytecode_ctx_p; /**< pointer of RegExp bytecode context */
re_token_t current_token; /**< current token */
re_parser_ctx_t *parser_ctx_p; /**< pointer of RegExp parser context */
} re_compiler_ctx_t;
ecma_value_t
re_compile_bytecode (const re_compiled_code_t **out_bytecode_p, ecma_string_t *pattern_str_p, uint16_t flags);
void re_cache_gc_run ();
/**
* @}
* @}
* @}
*/
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
#endif /* !RE_COMPILER_H */
|
// Copyright 2019-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "MDCTextControl.h"
/**
A base implementation of MDCTextControlStyle. This is only used for base text controls, i.e.
ones that are not filled or outlined.
*/
@interface MDCTextControlStyleBase : NSObject <MDCTextControlStyle>
@end
|
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#define TESTLUCY_USE_SHORT_NAMES
#include "Lucy/Util/ToolSet.h"
#include "Clownfish/Blob.h"
#include "Clownfish/Boolean.h"
#include "Clownfish/Num.h"
#include "Clownfish/TestHarness/TestBatchRunner.h"
#include "Clownfish/TestHarness/TestUtils.h"
#include "Lucy/Test/Util/TestFreezer.h"
#include "Lucy/Store/InStream.h"
#include "Lucy/Store/OutStream.h"
#include "Lucy/Store/RAMFile.h"
#include "Lucy/Util/Freezer.h"
TestFreezer*
TestFreezer_new() {
return (TestFreezer*)Class_Make_Obj(TESTFREEZER);
}
// Return the result of round-tripping the object through FREEZE and THAW.
static Obj*
S_freeze_thaw(Obj *object) {
if (object) {
RAMFile *ram_file = RAMFile_new(NULL, false);
OutStream *outstream = OutStream_open((Obj*)ram_file);
FREEZE(object, outstream);
OutStream_Close(outstream);
DECREF(outstream);
InStream *instream = InStream_open((Obj*)ram_file);
Obj *retval = THAW(instream);
DECREF(instream);
DECREF(ram_file);
return retval;
}
else {
return NULL;
}
}
// Return the result of round-tripping the object through dump() and load().
static Obj*
S_dump_load(Obj *object) {
if (object) {
Obj *dump = Freezer_dump(object);
Obj *loaded = Freezer_load(dump);
DECREF(dump);
return loaded;
}
else {
return NULL;
}
}
static void
test_blob(TestBatchRunner *runner) {
Blob *wanted = Blob_new("foobar", 6);
Blob *got = (Blob*)S_freeze_thaw((Obj*)wanted);
TEST_TRUE(runner, got && Blob_Equals(wanted, (Obj*)got),
"Serialization round trip");
DECREF(wanted);
DECREF(got);
}
static void
test_string(TestBatchRunner *runner) {
String *wanted = TestUtils_get_str("foo");
String *got = (String*)S_freeze_thaw((Obj*)wanted);
TEST_TRUE(runner, got && Str_Equals(wanted, (Obj*)got),
"Round trip through FREEZE/THAW");
DECREF(got);
DECREF(wanted);
}
static void
test_hash(TestBatchRunner *runner) {
Hash *wanted = Hash_new(0);
for (uint32_t i = 0; i < 10; i++) {
String *str = TestUtils_random_string(rand() % 1200);
Integer *num = Int_new(i);
Hash_Store(wanted, str, (Obj*)num);
DECREF(str);
}
{
Hash *got = (Hash*)S_freeze_thaw((Obj*)wanted);
TEST_TRUE(runner, got && Hash_Equals(wanted, (Obj*)got),
"Round trip through serialization.");
DECREF(got);
}
{
Obj *got = S_dump_load((Obj*)wanted);
TEST_TRUE(runner, Hash_Equals(wanted, got),
"Dump => Load round trip");
DECREF(got);
}
DECREF(wanted);
}
static void
test_num(TestBatchRunner *runner) {
Float *f64 = Float_new(1.33);
Integer *i64 = Int_new(-1);
Float *f64_thaw = (Float*)S_freeze_thaw((Obj*)f64);
Integer *i64_thaw = (Integer*)S_freeze_thaw((Obj*)i64);
TEST_TRUE(runner, Float_Equals(f64, (Obj*)f64_thaw),
"Float freeze/thaw");
TEST_TRUE(runner, Int_Equals(i64, (Obj*)i64_thaw),
"Integer freeze/thaw");
#ifdef LUCY_VALGRIND
SKIP(runner, 1, "known leaks");
#else
Boolean *true_thaw = (Boolean*)S_freeze_thaw((Obj*)CFISH_TRUE);
TEST_TRUE(runner, Bool_Equals(CFISH_TRUE, (Obj*)true_thaw),
"Boolean freeze/thaw");
#endif
DECREF(i64_thaw);
DECREF(f64_thaw);
DECREF(i64);
DECREF(f64);
}
static void
test_varray(TestBatchRunner *runner) {
Vector *array = Vec_new(0);
Vec_Store(array, 1, (Obj*)Str_newf("foo"));
Vec_Store(array, 3, (Obj*)Str_newf("bar"));
{
Obj *got = S_freeze_thaw((Obj*)array);
TEST_TRUE(runner, got && Vec_Equals(array, got),
"Round trip through FREEZE/THAW");
DECREF(got);
}
{
Obj *got = S_dump_load((Obj*)array);
TEST_TRUE(runner, got && Vec_Equals(array, got),
"Dump => Load round trip");
DECREF(got);
}
DECREF(array);
}
void
TestFreezer_Run_IMP(TestFreezer *self, TestBatchRunner *runner) {
TestBatchRunner_Plan(runner, (TestBatch*)self, 9);
test_blob(runner);
test_string(runner);
test_hash(runner);
test_num(runner);
test_varray(runner);
}
|
/*
This file is a part of libcds - Concurrent Data Structures library
(C) Copyright Maxim Khizhinsky ([email protected]) 2006-2016
Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
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.
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 HOLDER 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 CDSLIB_THREADING_DETAILS_WINTLS_H
#define CDSLIB_THREADING_DETAILS_WINTLS_H
#include <stdio.h>
#include <cds/threading/details/wintls_manager.h>
#ifndef CDS_CXX11_INLINE_NAMESPACE_SUPPORT
namespace cds { namespace threading {
using wintls::Manager;
}} // namespace cds::threading
#endif
#endif // #ifndef CDSLIB_THREADING_DETAILS_WINTLS_H
|
/*
** $Id: ldo.h,v 2.43 2018/02/17 19:29:29 roberto Exp $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
#ifndef ldo_h
#define ldo_h
#include "lobject.h"
#include "lstate.h"
#include "lzio.h"
/*
** Macro to check stack size and grow stack if needed. Parameters
** 'pre'/'pos' allow the macro to preserve a pointer into the
** stack across reallocations, doing the work only when needed.
** 'condmovestack' is used in heavy tests to force a stack reallocation
** at every check.
*/
#define luaD_checkstackaux(L,n,pre,pos) \
if (L->stack_last - L->top <= (n)) \
{ pre; luaD_growstack(L, n, 1); pos; } \
else { condmovestack(L,pre,pos); }
/* In general, 'pre'/'pos' are empty (nothing to save) */
#define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0)
#define savestack(L,p) ((char *)(p) - (char *)L->stack)
#define restorestack(L,n) ((StkId)((char *)L->stack + (n)))
/* macro to check stack size, preserving 'p' */
#define checkstackp(L,n,p) \
luaD_checkstackaux(L, n, \
ptrdiff_t t__ = savestack(L, p); /* save 'p' */ \
luaC_checkGC(L), /* stack grow uses memory */ \
p = restorestack(L, t__)) /* 'pos' part: restore 'p' */
/* macro to check stack size and GC */
#define checkstackGC(L,fsize) \
luaD_checkstackaux(L, (fsize), (void)0, luaC_checkGC(L))
/* type of protected functions, to be ran by 'runprotected' */
typedef void (*Pfunc) (lua_State *L, void *ud);
LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
const char *mode);
LUAI_FUNC void luaD_hook (lua_State *L, int event, int line,
int fTransfer, int nTransfer);
LUAI_FUNC void luaD_hookcall (lua_State *L, CallInfo *ci);
LUAI_FUNC void luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func, int n);
LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
LUAI_FUNC void luaD_tryfuncTM (lua_State *L, StkId func);
LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
ptrdiff_t oldtop, ptrdiff_t ef);
LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult,
int nres);
LUAI_FUNC int luaD_reallocstack (lua_State *L, int newsize, int raiseerror);
LUAI_FUNC int luaD_growstack (lua_State *L, int n, int raiseerror);
LUAI_FUNC void luaD_shrinkstack (lua_State *L);
LUAI_FUNC void luaD_inctop (lua_State *L);
LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
#endif
|
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* T.125 Multipoint Communication Service (MCS) Protocol
*
* Copyright 2011 Marc-Andre Moreau <[email protected]>
* Copyright 2015 Thincast Technologies GmbH
* Copyright 2015 DI (FH) Martin Haimberger <[email protected]>
*
* 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 FREERDP_LIB_CORE_MCS_H
#define FREERDP_LIB_CORE_MCS_H
typedef struct rdp_mcs rdpMcs;
#include "transport.h"
#include <freerdp/crypto/ber.h>
#include <freerdp/api.h>
#include <freerdp/types.h>
#include <winpr/stream.h>
#include <winpr/wtsapi.h>
#define MCS_BASE_CHANNEL_ID 1001
#define MCS_GLOBAL_CHANNEL_ID 1003
enum MCS_Result
{
MCS_Result_successful = 0,
MCS_Result_domain_merging = 1,
MCS_Result_domain_not_hierarchical = 2,
MCS_Result_no_such_channel = 3,
MCS_Result_no_such_domain = 4,
MCS_Result_no_such_user = 5,
MCS_Result_not_admitted = 6,
MCS_Result_other_user_id = 7,
MCS_Result_parameters_unacceptable = 8,
MCS_Result_token_not_available = 9,
MCS_Result_token_not_possessed = 10,
MCS_Result_too_many_channels = 11,
MCS_Result_too_many_tokens = 12,
MCS_Result_too_many_users = 13,
MCS_Result_unspecified_failure = 14,
MCS_Result_user_rejected = 15,
MCS_Result_enum_length = 16
};
enum DomainMCSPDU
{
DomainMCSPDU_PlumbDomainIndication = 0,
DomainMCSPDU_ErectDomainRequest = 1,
DomainMCSPDU_MergeChannelsRequest = 2,
DomainMCSPDU_MergeChannelsConfirm = 3,
DomainMCSPDU_PurgeChannelsIndication = 4,
DomainMCSPDU_MergeTokensRequest = 5,
DomainMCSPDU_MergeTokensConfirm = 6,
DomainMCSPDU_PurgeTokensIndication = 7,
DomainMCSPDU_DisconnectProviderUltimatum = 8,
DomainMCSPDU_RejectMCSPDUUltimatum = 9,
DomainMCSPDU_AttachUserRequest = 10,
DomainMCSPDU_AttachUserConfirm = 11,
DomainMCSPDU_DetachUserRequest = 12,
DomainMCSPDU_DetachUserIndication = 13,
DomainMCSPDU_ChannelJoinRequest = 14,
DomainMCSPDU_ChannelJoinConfirm = 15,
DomainMCSPDU_ChannelLeaveRequest = 16,
DomainMCSPDU_ChannelConveneRequest = 17,
DomainMCSPDU_ChannelConveneConfirm = 18,
DomainMCSPDU_ChannelDisbandRequest = 19,
DomainMCSPDU_ChannelDisbandIndication = 20,
DomainMCSPDU_ChannelAdmitRequest = 21,
DomainMCSPDU_ChannelAdmitIndication = 22,
DomainMCSPDU_ChannelExpelRequest = 23,
DomainMCSPDU_ChannelExpelIndication = 24,
DomainMCSPDU_SendDataRequest = 25,
DomainMCSPDU_SendDataIndication = 26,
DomainMCSPDU_UniformSendDataRequest = 27,
DomainMCSPDU_UniformSendDataIndication = 28,
DomainMCSPDU_TokenGrabRequest = 29,
DomainMCSPDU_TokenGrabConfirm = 30,
DomainMCSPDU_TokenInhibitRequest = 31,
DomainMCSPDU_TokenInhibitConfirm = 32,
DomainMCSPDU_TokenGiveRequest = 33,
DomainMCSPDU_TokenGiveIndication = 34,
DomainMCSPDU_TokenGiveResponse = 35,
DomainMCSPDU_TokenGiveConfirm = 36,
DomainMCSPDU_TokenPleaseRequest = 37,
DomainMCSPDU_TokenPleaseConfirm = 38,
DomainMCSPDU_TokenReleaseRequest = 39,
DomainMCSPDU_TokenReleaseConfirm = 40,
DomainMCSPDU_TokenTestRequest = 41,
DomainMCSPDU_TokenTestConfirm = 42,
DomainMCSPDU_enum_length = 43
};
typedef struct
{
UINT32 maxChannelIds;
UINT32 maxUserIds;
UINT32 maxTokenIds;
UINT32 numPriorities;
UINT32 minThroughput;
UINT32 maxHeight;
UINT32 maxMCSPDUsize;
UINT32 protocolVersion;
} DomainParameters;
struct rdp_mcs_channel
{
char Name[CHANNEL_NAME_LEN + 1];
UINT32 options;
int ChannelId;
BOOL joined;
void* handle;
};
typedef struct rdp_mcs_channel rdpMcsChannel;
struct rdp_mcs
{
rdpTransport* transport;
UINT16 userId;
UINT16 baseChannelId;
UINT16 messageChannelId;
DomainParameters domainParameters;
DomainParameters targetParameters;
DomainParameters minimumParameters;
DomainParameters maximumParameters;
BOOL userChannelJoined;
BOOL globalChannelJoined;
BOOL messageChannelJoined;
UINT32 channelCount;
UINT32 channelMaxCount;
rdpMcsChannel* channels;
};
#define MCS_SEND_DATA_HEADER_MAX_LENGTH 8
#define MCS_TYPE_CONNECT_INITIAL 0x65
#define MCS_TYPE_CONNECT_RESPONSE 0x66
FREERDP_LOCAL BOOL mcs_recv_connect_initial(rdpMcs* mcs, wStream* s);
FREERDP_LOCAL BOOL mcs_send_connect_initial(rdpMcs* mcs);
FREERDP_LOCAL BOOL mcs_recv_connect_response(rdpMcs* mcs, wStream* s);
FREERDP_LOCAL BOOL mcs_send_connect_response(rdpMcs* mcs);
FREERDP_LOCAL BOOL mcs_recv_erect_domain_request(rdpMcs* mcs, wStream* s);
FREERDP_LOCAL BOOL mcs_send_erect_domain_request(rdpMcs* mcs);
FREERDP_LOCAL BOOL mcs_recv_attach_user_request(rdpMcs* mcs, wStream* s);
FREERDP_LOCAL BOOL mcs_send_attach_user_request(rdpMcs* mcs);
FREERDP_LOCAL BOOL mcs_recv_attach_user_confirm(rdpMcs* mcs, wStream* s);
FREERDP_LOCAL BOOL mcs_send_attach_user_confirm(rdpMcs* mcs);
FREERDP_LOCAL BOOL mcs_recv_channel_join_request(rdpMcs* mcs, wStream* s, UINT16* channelId);
FREERDP_LOCAL BOOL mcs_send_channel_join_request(rdpMcs* mcs, UINT16 channelId);
FREERDP_LOCAL BOOL mcs_recv_channel_join_confirm(rdpMcs* mcs, wStream* s, UINT16* channelId);
FREERDP_LOCAL BOOL mcs_send_channel_join_confirm(rdpMcs* mcs, UINT16 channelId);
FREERDP_LOCAL BOOL mcs_recv_disconnect_provider_ultimatum(rdpMcs* mcs, wStream* s, int* reason);
FREERDP_LOCAL BOOL mcs_send_disconnect_provider_ultimatum(rdpMcs* mcs);
FREERDP_LOCAL void mcs_write_domain_mcspdu_header(wStream* s, enum DomainMCSPDU domainMCSPDU,
UINT16 length, BYTE options);
FREERDP_LOCAL BOOL mcs_client_begin(rdpMcs* mcs);
FREERDP_LOCAL rdpMcs* mcs_new(rdpTransport* transport);
FREERDP_LOCAL void mcs_free(rdpMcs* mcs);
#endif /* FREERDP_LIB_CORE_MCS_H */
|
// Copyright (C) 2006 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#undef DLIB_MEMORY_MANAGER_STATELESs_ABSTRACT_
#ifdef DLIB_MEMORY_MANAGER_STATELESs_ABSTRACT_
#include "../algs.h"
namespace dlib
{
template <
typename T
>
class memory_manager_stateless
{
/*!
REQUIREMENTS ON T
T must have a default constructor.
WHAT THIS OBJECT REPRESENTS
This object represents some kind of stateless memory manager or memory pool.
Stateless means that all instances (instances of the same kernel implementation that is)
of this object are identical and can be used interchangeably. Note that
implementations are allowed to have some shared global state such as a
global memory pool.
THREAD SAFETY
This object is thread safe. You may access it from any thread at any time
without synchronizing access.
!*/
public:
typedef T type;
const static bool is_stateless = true;
template <typename U>
struct rebind {
typedef memory_manager_stateless<U> other;
};
memory_manager_stateless(
);
/*!
ensures
- #*this is properly initialized
throws
- std::bad_alloc
!*/
virtual ~memory_manager_stateless(
);
/*!
ensures
- frees any resources used by *this but has no effect on any shared global
resources used by the implementation.
!*/
T* allocate (
);
/*!
ensures
- allocates a new object of type T and returns a pointer to it.
throws
- std::bad_alloc or any exception thrown by T's constructor.
If this exception is thrown then the call to allocate()
has no effect on #*this.
!*/
void deallocate (
T* item
);
/*!
requires
- item == is a pointer to memory that was obtained from a call to
allocate(). (i.e. The pointer you are deallocating must have
come from the same implementation of memory_manager_stateless
that is trying to deallocate it.)
- the memory pointed to by item hasn't already been deallocated.
ensures
- deallocates the object pointed to by item
!*/
T* allocate_array (
unsigned long size
);
/*!
ensures
- allocates a new array of size objects of type T and returns a
pointer to it.
throws
- std::bad_alloc or any exception thrown by T's constructor.
If this exception is thrown then the call to allocate()
has no effect on #*this.
!*/
void deallocate_array (
T* item
);
/*!
requires
- item == is a pointer to memory that was obtained from a call to
allocate_array(). (i.e. The pointer you are deallocating must have
come from the same implementation of memory_manager_stateless
that is trying to deallocate it.)
- the memory pointed to by item hasn't already been deallocated.
ensures
- deallocates the array pointed to by item
!*/
void swap (
memory_manager_stateless& item
);
/*!
ensures
- this function has no effect on *this or item. It is just provided
to make this object's interface more compatable with the other
memory managers.
!*/
private:
// restricted functions
memory_manager_stateless(memory_manager_stateless&); // copy constructor
memory_manager_stateless& operator=(memory_manager_stateless&); // assignment operator
};
template <
typename T
>
inline void swap (
memory_manager_stateless<T>& a,
memory_manager_stateless<T>& b
) { a.swap(b); }
/*!
provides a global swap function
!*/
}
#endif // DLIB_MEMORY_MANAGER_STATELESs_ABSTRACT_
|
/*
*------------------------------------------------------------------
* Copyright (c) 2018 Cisco and/or its affiliates.
* 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 _AF_XDP_H_
#define _AF_XDP_H_
#include <vlib/log.h>
#include <vnet/interface.h>
#include <bpf/xsk.h>
#define AF_XDP_NUM_RX_QUEUES_ALL ((u16)-1)
#define af_xdp_log(lvl, dev, f, ...) \
vlib_log(lvl, af_xdp_main.log_class, "%v: " f, (dev)->name, ##__VA_ARGS__)
#define foreach_af_xdp_device_flags \
_ (0, INITIALIZED, "initialized") \
_ (1, ERROR, "error") \
_ (2, ADMIN_UP, "admin-up") \
_ (3, LINK_UP, "link-up") \
_ (4, ZEROCOPY, "zero-copy") \
_ (5, SYSCALL_LOCK, "syscall-lock")
enum
{
#define _(a, b, c) AF_XDP_DEVICE_F_##b = (1 << a),
foreach_af_xdp_device_flags
#undef _
};
#define af_xdp_device_error(dev, fmt, ...) \
if (!(dev)->error) \
{ \
clib_error_t *err_ = clib_error_return_unix (0, fmt, ## __VA_ARGS__); \
if (!clib_atomic_bool_cmp_and_swap (&(dev)->error, 0, err_)) \
clib_error_free(err_); \
}
typedef enum
{
AF_XDP_RXQ_MODE_UNKNOWN,
AF_XDP_RXQ_MODE_POLLING,
AF_XDP_RXQ_MODE_INTERRUPT,
} __clib_packed af_xdp_rxq_mode_t;
typedef struct
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
/* fields below are accessed in data-plane (hot) */
clib_spinlock_t syscall_lock;
struct xsk_ring_cons rx;
struct xsk_ring_prod fq;
int xsk_fd;
/* fields below are accessed in control-plane only (cold) */
uword file_index;
u32 queue_index;
af_xdp_rxq_mode_t mode;
} af_xdp_rxq_t;
typedef struct
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
/* fields below are accessed in data-plane (hot) */
clib_spinlock_t lock;
clib_spinlock_t syscall_lock;
struct xsk_ring_prod tx;
struct xsk_ring_cons cq;
int xsk_fd;
/* fields below are accessed in control-plane only (cold) */
u32 queue_index;
} af_xdp_txq_t;
typedef struct
{
CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
/* fields below are accessed in data-plane (hot) */
af_xdp_rxq_t *rxqs;
af_xdp_txq_t *txqs;
vlib_buffer_t *buffer_template;
u32 per_interface_next_index;
u32 sw_if_index;
u32 hw_if_index;
u32 flags;
u8 pool; /* buffer pool index */
u8 txq_num;
/* fields below are accessed in control-plane only (cold) */
char *name;
char *linux_ifname;
u32 dev_instance;
u8 hwaddr[6];
u8 rxq_num;
char *netns;
struct xsk_umem **umem;
struct xsk_socket **xsk;
struct bpf_object *bpf_obj;
unsigned linux_ifindex;
/* error */
clib_error_t *error;
} af_xdp_device_t;
typedef struct
{
af_xdp_device_t *devices;
vlib_log_class_t log_class;
u16 msg_id_base;
} af_xdp_main_t;
extern af_xdp_main_t af_xdp_main;
typedef enum
{
AF_XDP_MODE_AUTO = 0,
AF_XDP_MODE_COPY = 1,
AF_XDP_MODE_ZERO_COPY = 2,
} af_xdp_mode_t;
typedef enum
{
AF_XDP_CREATE_FLAGS_NO_SYSCALL_LOCK = 1,
} af_xdp_create_flag_t;
typedef struct
{
char *linux_ifname;
char *name;
char *prog;
char *netns;
af_xdp_mode_t mode;
af_xdp_create_flag_t flags;
u32 rxq_size;
u32 txq_size;
u32 rxq_num;
/* return */
int rv;
u32 sw_if_index;
clib_error_t *error;
} af_xdp_create_if_args_t;
void af_xdp_create_if (vlib_main_t * vm, af_xdp_create_if_args_t * args);
void af_xdp_delete_if (vlib_main_t * vm, af_xdp_device_t * ad);
void af_xdp_device_input_refill (af_xdp_device_t *ad);
extern vlib_node_registration_t af_xdp_input_node;
extern vnet_device_class_t af_xdp_device_class;
/* format.c */
format_function_t format_af_xdp_device;
format_function_t format_af_xdp_device_name;
format_function_t format_af_xdp_input_trace;
/* unformat.c */
unformat_function_t unformat_af_xdp_create_if_args;
typedef struct
{
u32 next_index;
u32 hw_if_index;
} af_xdp_input_trace_t;
#define foreach_af_xdp_tx_func_error \
_ (NO_FREE_SLOTS, "no free tx slots") \
_ (SYSCALL_REQUIRED, "syscall required") \
_ (SYSCALL_FAILURES, "syscall failures")
typedef enum
{
#define _(f,s) AF_XDP_TX_ERROR_##f,
foreach_af_xdp_tx_func_error
#undef _
AF_XDP_TX_N_ERROR,
} af_xdp_tx_func_error_t;
#endif /* _AF_XDP_H_ */
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
|
/* $NetBSD: hex_quote.h,v 1.1.1.1 2009/06/23 10:09:00 tron Exp $ */
#ifndef _HEX_QUOTE_H_INCLUDED_
#define _HEX_QUOTE_H_INCLUDED_
/*++
/* NAME
/* hex_quote 3h
/* SUMMARY
/* quote/unquote text, HTTP style.
/* SYNOPSIS
/* #include <hex_quote.h>
/* DESCRIPTION
/* .nf
/*
* Utility library.
*/
#include <vstring.h>
/*
* External interface.
*/
extern VSTRING *hex_quote(VSTRING *, const char *);
extern VSTRING *hex_unquote(VSTRING *, const char *);
/* LICENSE
/* .ad
/* .fi
/* The Secure Mailer license must be distributed with this software.
/* AUTHOR(S)
/* Wietse Venema
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
/*--*/
#endif
|
//
// TableVisualTestViewController.h
// Beautify
//
// Created by Chris Grant on 10/09/2013.
// Copyright (c) 2013 Colin Eberhardt. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface TableVisualTestViewController : UITableViewController
@end
|
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_melloware_jintellitype_JIntellitype */
#ifndef _Included_com_melloware_jintellitype_JIntellitype
#define _Included_com_melloware_jintellitype_JIntellitype
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_melloware_jintellitype_JIntellitype
* Method: initializeLibrary
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_initializeLibrary
(JNIEnv *, jobject);
/*
* Class: com_melloware_jintellitype_JIntellitype
* Method: regHotKey
* Signature: (III)V
*/
JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_regHotKey
(JNIEnv *, jobject, jint, jint, jint);
/*
* Class: com_melloware_jintellitype_JIntellitype
* Method: terminate
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_terminate
(JNIEnv *, jobject);
/*
* Class: com_melloware_jintellitype_JIntellitype
* Method: unregHotKey
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_unregHotKey
(JNIEnv *, jobject, jint);
/*
* Class: com_melloware_jintellitype_JIntellitype
* Method: isRunning
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_com_melloware_jintellitype_JIntellitype_isRunning
(JNIEnv *, jclass, jstring);
#ifdef __cplusplus
}
#endif
#endif
|
/*
Copyright 2016 Richard Bernardino
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.
*/
#pragma once
#include "Renderable.h"
#include "..\Common\DeviceResources.h"
#include "Wireframe.h"
class Renderable3D : public Renderable
{
public:
Renderable3D(
const shared_ptr<DeviceResources>& deviceResources,
Wireframe * pWireframe)
: Renderable(deviceResources, pWireframe)
{
}
//Renderable3D()
//{
// m_pfBounds = new float[3];
//}
protected:
private:
};
|
#ifndef _NTIFS_
#include <ntifs.h>
#endif
#include "..\Driver\ProtectedEntry.h"
extern NTSTATUS PtAddEntry(__in PRTL_GENERIC_TABLE pGenericTable, __in PAP_PROTECTED_ENTRY pEntry)
{
NTSTATUS status;
BOOLEAN IsInserted = FALSE;
PAP_PROTECTED_ENTRY pInsertedEntry = NULL;
if(NULL == pGenericTable)
return STATUS_INVALID_PARAMETER_1;
if(NULL == pEntry)
return STATUS_INVALID_PARAMETER_2;
pInsertedEntry = RtlInsertElementGenericTable(pGenericTable,
pEntry,
sizeof(AP_PROTECTED_ENTRY),
&IsInserted);
if(IsInserted == TRUE && pInsertedEntry != NULL)// Entry inserted.
status = STATUS_SUCCESS;
else if(IsInserted == FALSE && pInsertedEntry != NULL)// Entry not inserted, but already exists.
status = STATUS_OBJECTID_EXISTS;
else
status = STATUS_INTERNAL_ERROR; // Internal error occurred.
return status;
}
|
//---------------------------------------------------------------------------
// Camera.h
//---------------------------------------------------------------------------
/**
@file Camera.h
Contiene la declaración de la clase que maneja la cámara.
@see Graphics::CCamera
@author David Llansó
@date Julio, 2010
*/
#ifndef __Graphics_Camera_H
#define __Graphics_Camera_H
#include "BaseSubsystems/Math.h"
// Predeclaración de clases para ahorrar tiempo de compilación
namespace Ogre
{
class Camera;
class SceneNode;
class CompositorManager;
}
namespace Graphics
{
class CScene;
class CServer;
}
namespace Graphics
{
/**
Clase de la cámara extendida basada en Ogre. Para simplificar su uso
La cámara extendida consta de dos nodos, uno es el propio de la
cámara, que contiene la cámara real de Ogre y otro es el nodo
objetivo, que representa la posición a la que la cámara debe mirar.
@ingroup graphicsGroup
@author David Llansó
@date Julio, 2010
*/
class CCamera
{
public:
/**
Constructor de la clase.
@param name Nombre de la cámara.
@param sceneMgr Gestor de la escena de Ogre a la que pertenece.
*/
CCamera(const std::string &name, CScene *scene);
/**
Destructor de la aplicación.
*/
virtual ~CCamera();
/**
Devuelve la posición de la cámara.
@return Referencia a la posición del nodo que contiene la cámara de Ogre.
*/
const Vector3 &getCameraPosition();
/**
Devuelve la posición a la que apunta la cámara.
@return Referencia a la posición del nodo _targetCamera.
*/
const Vector3 &getTargetCameraPosition();
/**
Devuelve la orientación de la cámara.
@return Referencia al quaternion del nodo que contiene la cámara de Ogre.
*/
const Quaternion &getCameraOrientation();
/**
Cambia la posición de la cámara.
@param newPosition Nueva posición para el nodo que contiene la cámara
de Ogre.
*/
void setCameraPosition(const Vector3 &newPosition);
/**
Cambia la posición de la posición a la que apunta la cámara.
@param newPosition Nueva posición para el _targetNode.
*/
void setTargetCameraPosition(const Vector3 &newPosition);
/**
Configura la Dimensión-Y de Field of View(FOV) del frustum CON RADIANES.
FOV es el angulo entre la posicion del frustum y los "bordes" de la pantalla, en los cuales la escena es proyectada.
Valores altos (+90 grados) da un resultado a una vista "ojo de pez". Valores bajos (-30 grados) en una vista "telescopica".
Los valores usuales son 45 o 60 grados.
@param rads Este parametro indica el FOV vertical, el horizontal se calcula a partir de este.
*/
void setFOVyInRadians(float rads);
/**
Configura la Dimensión-Y de Field of View(FOV) del frustum CON GRADOS.
FOV es el angulo entre la posicion del frustum y los "bordes" de la pantalla, en los cuales la escena es proyectada.
Valores altos (+90 grados) da un resultado a una vista "ojo de pez". Valores bajos (-30 grados) en una vista "telescopica".
Los valores usuales son 45 o 60 grados.
@param degrees Este parametro indica el FOV vertical, el horizontal se calcula a partir de este.
*/
void setFOVyInDegrees(float degrees);
/*
Configura el Near Clip del frustum. Es decir el plano más cercano a la cámara a partir del cual se pintan los objetos
@param distance Distancia de dicho plano a la cámara
*/
void setNearClipDistance(float distance);
/*
Configura el Far Clip del frustum. Es decir el plano más lejano a la cámara a partir del cual se pintan los objetos
@param distance Distancia de dicho plano a la cámara
*/
void setFarClipDistance(float distance);
void setCompositorEffect(const std::string &effect, bool activate);
float getAspectRatio() const;
Ogre::Radian getFovyY() const;
Matrix4 getViewMatrix() const;
Matrix4 getProjectionMatrix() const;
Vector2 getScreenCoord(const Vector3 &positionWorld);
protected:
/**
Clase amiga. Solo la escena tiene acceso a la cámara de Ogre para
poder crear el viewport.
*/
friend class CScene;
friend class CServer;
/**
Devuelve la cámara de Ogre.
@return puntero a la cámara de Ogre.
*/
Ogre::Camera *getCamera() {return _camera;}
/**
Nodo que contiene la cámara.
*/
Ogre::SceneNode *_cameraNode;
/**
Nodo que representa el punto a donde debe mirar la cámara.
*/
Ogre::SceneNode *_targetNode;
/**
La cámara de Ogre.
*/
Ogre::Camera *_camera;
/**
Controla todos los elementos de una escena. Su equivalente
en la lógica del juego sería el mapa o nivel.
*/
CScene *_scene;
/**
Nombre de la cámara.
*/
std::string _name;
Ogre::CompositorManager* _compositorManager;
std::string _actualCameraEffect;
}; // class CCamera
} // namespace Graphics
#endif // __Graphics_Camera_H
|
/* Copyright (c) 2016 PaddlePaddle Authors. 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. */
#pragma once
#include <stdlib.h>
#include <mutex>
#include "hl_gpu.h"
#include "paddle/utils/Logging.h"
namespace paddle {
/**
* @brief Allocator base class.
*
* This is the base class of all Allocator class.
*/
class Allocator {
public:
virtual ~Allocator() {}
virtual void* alloc(size_t size) = 0;
virtual void free(void* ptr) = 0;
virtual std::string getName() = 0;
};
/**
* @brief CPU allocator implementation.
*/
class CpuAllocator : public Allocator {
public:
~CpuAllocator() {}
/**
* @brief Aligned allocation on CPU.
* @param size Size to be allocated.
* @return Pointer to the allocated memory
*/
virtual void* alloc(size_t size) {
void* ptr;
#ifdef PADDLE_WITH_MKLDNN
// refer to https://github.com/01org/mkl-dnn/blob/master/include/mkldnn.hpp
// memory alignment
CHECK_EQ(posix_memalign(&ptr, 4096ul, size), 0);
#else
CHECK_EQ(posix_memalign(&ptr, 32ul, size), 0);
#endif
CHECK(ptr) << "Fail to allocate CPU memory: size=" << size;
return ptr;
}
/**
* @brief Free the memory space.
* @param ptr Pointer to be free.
*/
virtual void free(void* ptr) {
if (ptr) {
::free(ptr);
}
}
virtual std::string getName() { return "cpu_alloc"; }
};
/**
* @brief GPU allocator implementation.
*/
class GpuAllocator : public Allocator {
public:
~GpuAllocator() {}
/**
* @brief Allocate GPU memory.
* @param size Size to be allocated.
* @return Pointer to the allocated memory
*/
virtual void* alloc(size_t size) {
void* ptr = hl_malloc_device(size);
CHECK(ptr) << "Fail to allocate GPU memory " << size << " bytes";
return ptr;
}
/**
* @brief Free the GPU memory.
* @param ptr Pointer to be free.
*/
virtual void free(void* ptr) {
if (ptr) {
hl_free_mem_device(ptr);
}
}
virtual std::string getName() { return "gpu_alloc"; }
};
/**
* @brief CPU pinned memory allocator implementation.
*/
class CudaHostAllocator : public Allocator {
public:
~CudaHostAllocator() {}
/**
* @brief Allocate pinned memory.
* @param size Size to be allocated.
* @return Pointer to the allocated memory
*/
virtual void* alloc(size_t size) {
void* ptr = hl_malloc_host(size);
CHECK(ptr) << "Fail to allocate pinned memory " << size << " bytes";
return ptr;
}
/**
* @brief Free the pinned memory.
* @param ptr Pointer to be free.
*/
virtual void free(void* ptr) {
if (ptr) {
hl_free_mem_host(ptr);
}
}
virtual std::string getName() { return "cuda_host_alloc"; }
};
} // namespace paddle
|
/*=========================================================================
Library: CTK
Copyright (c) Kitware Inc.
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.txt
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 __ctkTransferFunctionItem_h
#define __ctkTransferFunctionItem_h
/// Qt includes
#include <QGraphicsObject>
/// CTK includes
#include "ctkWidgetsExport.h"
#include "ctkPimpl.h"
#include "ctkTransferFunction.h"
struct ctkControlPoint;
class ctkTransferFunctionItemPrivate;
/// \ingroup Widgets
///
/// TODO: should probably derive from QGraphicsItem or QAbstractGraphicsShapeItem
class CTK_WIDGETS_EXPORT ctkTransferFunctionItem: public QGraphicsObject
{
Q_OBJECT
Q_PROPERTY(QRectF rect READ rect WRITE setRect)
public:
ctkTransferFunctionItem(QGraphicsItem* parent = 0);
ctkTransferFunctionItem(ctkTransferFunction* transferFunction,
QGraphicsItem* parent = 0);
virtual ~ctkTransferFunctionItem();
Q_INVOKABLE void setTransferFunction(ctkTransferFunction* transferFunction);
Q_INVOKABLE ctkTransferFunction* transferFunction()const;
inline void setRect(qreal x, qreal y, qreal width, qreal height);
void setRect(const QRectF& rectangle);
QRectF rect()const;
/*
qreal rangeXDiff();
qreal rangeXOffSet();
qreal rangeYDiff();
qreal rangeYOffSet();
QPointF transferFunction2ScreenCoordinates( qreal x, qreal y);
QPointF screen2TransferFunctionCoordinates( qreal x, qreal y);
*/
virtual QRectF boundingRect()const;
protected:
//qreal y(const QVariant& value)const;
//inline qreal y(const ctkPoint& point)const;
QColor color(const QVariant& value)const;
inline QColor color(const ctkPoint& point)const;
//QList<ctkPoint> bezierParams(ctkControlPoint* start, ctkControlPoint* end)const;
//QList<ctkPoint> nonLinearPoints(ctkControlPoint* start, ctkControlPoint* end)const;
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value);
protected:
QScopedPointer<ctkTransferFunctionItemPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(ctkTransferFunctionItem);
Q_DISABLE_COPY(ctkTransferFunctionItem);
};
//-----------------------------------------------------------------------------
void ctkTransferFunctionItem::setRect(qreal x, qreal y, qreal width, qreal height)
{
this->setRect(QRectF(x,y,width,height));
}
/*
//-----------------------------------------------------------------------------
qreal ctkTransferFunctionItem::y(const ctkPoint& p)const
{
return this->y(p.Value);
}
//-----------------------------------------------------------------------------
QColor ctkTransferFunctionItem::color(const ctkPoint& p)const
{
return this->color(p.Value);
}
*/
#endif
|
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2011 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <[email protected]>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "vcc_compile.h"
/*--------------------------------------------------------------------*/
void v_matchproto_(sym_wildcard_t)
vcc_Var_Wildcard(struct vcc *tl, struct symbol *parent, struct symbol *sym)
{
struct vsb *vsb;
assert(parent->type == HEADER);
if (strlen(sym->name) >= 127) {
VSB_printf(tl->sb, "HTTP header (%.20s..) is too long.\n",
sym->name);
tl->err = 1;
return;
}
AN(sym);
sym->noref = 1;
sym->kind = SYM_VAR;
sym->type = parent->type;
sym->eval = vcc_Eval_Var;
sym->r_methods = parent->r_methods;
sym->w_methods = parent->w_methods;
sym->u_methods = parent->u_methods;
/* Create a C-name version of the header name */
vsb = VSB_new_auto();
AN(vsb);
VSB_printf(vsb, "&VGC_%s_", parent->rname);
VCC_PrintCName(vsb, sym->name, NULL);
AZ(VSB_finish(vsb));
/* Create the static identifier */
Fh(tl, 0, "static const struct gethdr_s %s =\n", VSB_data(vsb) + 1);
Fh(tl, 0, " { %s, \"\\%03o%s:\"};\n",
parent->rname, (unsigned int)strlen(sym->name) + 1, sym->name);
/* Create the symbol r/l values */
sym->rname = TlDup(tl, VSB_data(vsb));
VSB_clear(vsb);
VSB_printf(vsb, "VRT_SetHdr(ctx, %s,", sym->rname);
AZ(VSB_finish(vsb));
sym->lname = TlDup(tl, VSB_data(vsb));
VSB_clear(vsb);
VSB_printf(vsb, "VRT_SetHdr(ctx, %s, vrt_magic_string_unset)",
sym->rname);
AZ(VSB_finish(vsb));
sym->uname = TlDup(tl, VSB_data(vsb));
VSB_destroy(&vsb);
}
|
/*
pbrt source code is Copyright(c) 1998-2016
Matt Pharr, Greg Humphreys, and Wenzel Jakob.
This file is part of pbrt.
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.
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
HOLDER 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.
*/
#if defined(_MSC_VER)
#define NOMINMAX
#pragma once
#endif
#ifndef PBRT_ACCELERATORS_BVH_H
#define PBRT_ACCELERATORS_BVH_H
// accelerators/bvh.h*
#include "pbrt.h"
#include "primitive.h"
#include <atomic>
namespace pbrt {
struct BVHBuildNode;
// BVHAccel Forward Declarations
struct BVHPrimitiveInfo;
struct MortonPrimitive;
struct LinearBVHNode;
// BVHAccel Declarations
class BVHAccel : public Aggregate {
public:
// BVHAccel Public Types
enum class SplitMethod { SAH, HLBVH, Middle, EqualCounts };
// BVHAccel Public Methods
BVHAccel(const std::vector<std::shared_ptr<Primitive>> &p,
int maxPrimsInNode = 1,
SplitMethod splitMethod = SplitMethod::SAH);
Bounds3f WorldBound() const;
~BVHAccel();
bool Intersect(const Ray &ray, SurfaceInteraction *isect) const;
bool IntersectP(const Ray &ray) const;
private:
// BVHAccel Private Methods
BVHBuildNode *recursiveBuild(
MemoryArena &arena, std::vector<BVHPrimitiveInfo> &primitiveInfo,
int start, int end, int *totalNodes,
std::vector<std::shared_ptr<Primitive>> &orderedPrims);
BVHBuildNode *HLBVHBuild(
MemoryArena &arena, const std::vector<BVHPrimitiveInfo> &primitiveInfo,
int *totalNodes,
std::vector<std::shared_ptr<Primitive>> &orderedPrims) const;
BVHBuildNode *emitLBVH(
BVHBuildNode *&buildNodes,
const std::vector<BVHPrimitiveInfo> &primitiveInfo,
MortonPrimitive *mortonPrims, int nPrimitives, int *totalNodes,
std::vector<std::shared_ptr<Primitive>> &orderedPrims,
std::atomic<int> *orderedPrimsOffset, int bitIndex) const;
BVHBuildNode *buildUpperSAH(MemoryArena &arena,
std::vector<BVHBuildNode *> &treeletRoots,
int start, int end, int *totalNodes) const;
int flattenBVHTree(BVHBuildNode *node, int *offset);
// BVHAccel Private Data
const int maxPrimsInNode;
const SplitMethod splitMethod;
std::vector<std::shared_ptr<Primitive>> primitives;
LinearBVHNode *nodes = nullptr;
};
std::shared_ptr<BVHAccel> CreateBVHAccelerator(
const std::vector<std::shared_ptr<Primitive>> &prims, const ParamSet &ps);
} // namespace pbrt
#endif // PBRT_ACCELERATORS_BVH_H
|
//
// VJJSONPreferencesWindowController.h
// VisualJSON
//
// Created by Jeong YunWon on 13. 7. 27..
// Copyright (c) 2013 youknowone.org. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface VJJSONPreferencesWindowController : NSWindowController
@property(nonatomic,strong) IBOutlet NSButton *showBriefCheckBox;
@property(nonatomic,strong) IBOutlet NSButton *allowInvalidSSLCheckBox;
- (IBAction)showBriefChanged:(id)sender;
- (IBAction)setAllowsInvalidSSLCertificates:(id)sender;
@end
|
/*-
* Copyright (c) 2003 Ryuichiro Imura
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: soc2013/dpl/head/sys/fs/msdosfs/msdosfs_iconv.c 171796 2007-08-07 02:25:56Z bde $");
#include <sys/param.h>
#include <sys/iconv.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/mount.h>
VFS_DECLARE_ICONV(msdosfs);
|
#include <types.h>
#include "pexpert/platform.h"
#include "vm/vm.h"
#include "scheduler/scheduler.h"
// Linker defines
extern uint32_t BUILD_NUMBER;
const char KERNEL_VERSION[] = "0.1";
/*
* Kernel entry point
*/
void kmain(void) {
// initialise the platform
pexpert_init();
// Initialise paging and VM subsystem
vm_init();
// print some info
KINFO("PMK %s (build %u): Copyright 2014 Tristan Seifert <[email protected]>. All rights reserved.\n", KERNEL_VERSION, (unsigned int) &BUILD_NUMBER);
KDEBUG("Loading IO services from RAM disk...\n");
// Load any additional drivers from RAM disk
// Initialise scheduler
scheduler_init();
// Start driver and initialisation processes
// Run scheduler
}
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkAssemblyPaths.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkAssemblyPaths - a list of lists of props representing an assembly hierarchy
// .SECTION Description
// vtkAssemblyPaths represents an assembly hierarchy as a list of
// vtkAssemblyPath. Each path represents the complete path from the
// top level assembly (if any) down to the leaf prop.
// .SECTION see also
// vtkAssemblyPath vtkAssemblyNode vtkPicker vtkAssembly vtkProp
#ifndef __vtkAssemblyPaths_h
#define __vtkAssemblyPaths_h
#include "vtkRenderingCoreModule.h" // For export macro
#include "vtkCollection.h"
#include "vtkAssemblyPath.h" // Needed for inline methods
class vtkProp;
class VTKRENDERINGCORE_EXPORT vtkAssemblyPaths : public vtkCollection
{
public:
static vtkAssemblyPaths *New();
vtkTypeMacro(vtkAssemblyPaths,vtkCollection);
// Description:
// Add a path to the list.
void AddItem(vtkAssemblyPath *p);
// Description:
// Remove a path from the list.
void RemoveItem(vtkAssemblyPath *p);
// Description:
// Determine whether a particular path is present. Returns its position
// in the list.
int IsItemPresent(vtkAssemblyPath *p);
// Description:
// Get the next path in the list.
vtkAssemblyPath *GetNextItem();
// Description:
// Override the standard GetMTime() to check for the modified times
// of the paths.
virtual unsigned long GetMTime();
//BTX
// Description:
// Reentrant safe way to get an object in a collection. Just pass the
// same cookie back and forth.
vtkAssemblyPath *GetNextPath(vtkCollectionSimpleIterator &cookie) {
return static_cast<vtkAssemblyPath *>(this->GetNextItemAsObject(cookie));};
//ETX
protected:
vtkAssemblyPaths() {};
~vtkAssemblyPaths() {};
private:
// hide the standard AddItem from the user and the compiler.
void AddItem(vtkObject *o) { this->vtkCollection::AddItem(o); };
void RemoveItem(vtkObject *o) { this->vtkCollection::RemoveItem(o); };
void RemoveItem(int i) { this->vtkCollection::RemoveItem(i); };
int IsItemPresent(vtkObject *o)
{ return this->vtkCollection::IsItemPresent(o);};
private:
vtkAssemblyPaths(const vtkAssemblyPaths&); // Not implemented.
void operator=(const vtkAssemblyPaths&); // Not implemented.
};
inline void vtkAssemblyPaths::AddItem(vtkAssemblyPath *p)
{
this->vtkCollection::AddItem(p);
}
inline void vtkAssemblyPaths::RemoveItem(vtkAssemblyPath *p)
{
this->vtkCollection::RemoveItem(p);
}
inline int vtkAssemblyPaths::IsItemPresent(vtkAssemblyPath *p)
{
return this->vtkCollection::IsItemPresent(p);
}
inline vtkAssemblyPath *vtkAssemblyPaths::GetNextItem()
{
return static_cast<vtkAssemblyPath *>(this->GetNextItemAsObject());
}
#endif
// VTK-HeaderTest-Exclude: vtkAssemblyPaths.h
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WebRemoteFrameClient_h
#define WebRemoteFrameClient_h
#include "public/platform/WebSecurityOrigin.h"
#include "public/web/WebDOMMessageEvent.h"
namespace blink {
class WebInputEvent;
class WebLocalFrame;
class WebRemoteFrame;
struct WebRect;
class WebRemoteFrameClient {
public:
// Specifies the reason for the detachment.
enum class DetachType { Remove, Swap };
// Notify the embedder that it should remove this frame from the frame tree
// and release any resources associated with it.
virtual void frameDetached(DetachType) { }
// Notifies the embedder that a postMessage was issued to a remote frame.
virtual void postMessageEvent(
WebLocalFrame* sourceFrame,
WebRemoteFrame* targetFrame,
WebSecurityOrigin targetOrigin,
WebDOMMessageEvent) { }
// Send initial drawing parameters to a child frame that is being rendered
// out of process.
virtual void initializeChildFrame(
const WebRect& frameRect,
float scaleFactor) { }
// A remote frame was asked to start a navigation.
virtual void navigate(const WebURLRequest& request, bool shouldReplaceCurrentEntry) { }
virtual void reload(bool ignoreCache, bool isClientRedirect) { }
// FIXME: Remove this method once we have input routing in the browser
// process. See http://crbug.com/339659.
virtual void forwardInputEvent(const WebInputEvent*) { }
virtual void frameRectsChanged(const WebRect&) { }
// This frame updated its opener to another frame.
virtual void didChangeOpener(WebFrame* opener) { }
};
} // namespace blink
#endif // WebRemoteFrameClient_h
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE427_Uncontrolled_Search_Path_Element__wchar_t_connect_socket_51b.c
Label Definition File: CWE427_Uncontrolled_Search_Path_Element.label.xml
Template File: sources-sink-51b.tmpl.c
*/
/*
* @description
* CWE: 427 Uncontrolled Search Path Element
* BadSource: connect_socket Read data using a connect socket (client side)
* GoodSource: Use a hardcoded path
* Sink:
* BadSink : Set the environment variable
* Flow Variant: 51 Data flow: data passed as an argument from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define NEW_PATH L"%SystemRoot%\\system32"
#define PUTENV _wputenv
#else
#define NEW_PATH L"/bin"
#define PUTENV putenv
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else /* NOT _WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define IP_ADDRESS "127.0.0.1"
/* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
#ifndef OMITBAD
void CWE427_Uncontrolled_Search_Path_Element__wchar_t_connect_socket_51b_badSink(wchar_t * data)
{
/* POTENTIAL FLAW: Set a new environment variable with a path that is possibly insecure */
PUTENV(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE427_Uncontrolled_Search_Path_Element__wchar_t_connect_socket_51b_goodG2BSink(wchar_t * data)
{
/* POTENTIAL FLAW: Set a new environment variable with a path that is possibly insecure */
PUTENV(data);
}
#endif /* OMITGOOD */
|
/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004 Xilinx, Inc. All rights reserved.
//
// Xilinx, Inc.
//
// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
// COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
// ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
// STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
// IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
// FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
// XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
// THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
// ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
// FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE.
/////////////////////////////////////////////////////////////////////////////
#include "fat.h"
#include "directory.h"
#include "util.h"
UINT32 get_fat16_sector_for_cluster(UINT32 cluster, PartitionInfo *pi)
{
/* Each FAT entry takes 2 bytes in FAT 16 */
return ((cluster * 2) / SECTORSIZE) + pi->FatSector;
}
UINT32 get_fat16_offset_for_cluster(UINT32 cluster, PartitionInfo *pi)
{
/* Each FAT entry takes 2 bytes in FAT 16 */
return ((cluster * 2) % SECTORSIZE);
}
UINT32 get_next_cluster_fat16(BYTE *fat_entry, PartitionInfo *pi)
{
return (UINT32)(0xffff & make_UINT16(*(fat_entry + 1), *(fat_entry)));
}
void set_next_cluster_fat16(BYTE *fat_entry, UINT32 next_cluster, PartitionInfo *pi)
{
write_UINT16(fat_entry, next_cluster);
}
int is_eoc_fat16(UINT32 cluster, PartitionInfo *pi)
{
return (cluster >= FAT16_EOC);
}
int is_valid_cluster_fat16(UINT32 cluster, PartitionInfo *pi)
{
return (cluster < MAX_FAT16_CLUSTERS);
}
fat_ops fat16_ops = {
get_fat16_sector_for_cluster,
get_fat16_offset_for_cluster,
get_next_cluster_fat16,
set_next_cluster_fat16,
is_eoc_fat16,
is_valid_cluster_fat16,
next_cluster_generic,
free_cluster_chain_generic,
allocate_one_cluster_generic,
link_cluster_generic,
};
|
// file: cvmat_serialization.h
#ifndef _CV_MAT_SERIALIZER
#define _CV_MAT_SERIALIZER
#include <opencv2/opencv.hpp>
#include <boost/serialization/split_free.hpp>
#include <boost/serialization/vector.hpp>
BOOST_SERIALIZATION_SPLIT_FREE(::cv::Mat)
namespace boost {
namespace serialization {
/** Serialization support for cv::Mat */
template <class Archive>
void save(Archive & ar, const cv::Mat& m, const unsigned int version)
{
size_t elem_size = m.elemSize();
size_t elem_type = m.type();
ar & m.cols;
ar & m.rows;
ar & elem_size;
ar & elem_type;
const size_t data_size = m.cols * m.rows * elem_size;
ar & boost::serialization::make_array(m.ptr(), data_size);
}
/** Serialization support for cv::Mat */
template <class Archive>
void load(Archive & ar, cv::Mat& m, const unsigned int version)
{
int cols, rows;
size_t elem_size, elem_type;
ar & cols;
ar & rows;
ar & elem_size;
ar & elem_type;
m.create(rows, cols, elem_type);
size_t data_size = m.cols * m.rows * elem_size;
ar & boost::serialization::make_array(m.ptr(), data_size);
}
}
}
BOOST_SERIALIZATION_SPLIT_FREE(cv::KeyPoint)
namespace boost{
namespace serialization {
template <class Archive>
void save (Archive &ar, const cv::KeyPoint &kp, const unsigned int version)
{
float kx = kp.pt.x,
ky = kp.pt.y;
ar & kx;
ar & ky;
ar & kp.size;
ar & kp.angle;
ar & kp.response;
ar & kp.octave;
ar & kp.class_id;
}
template <class Archive>
void load (Archive &ar, cv::KeyPoint &kp, const unsigned int version)
{
float kx, ky;
ar & kx;
ar & ky;
ar & kp.size;
ar & kp.angle;
ar & kp.response;
ar & kp.octave;
ar & kp.class_id;
kp.pt.x = kx;
kp.pt.y = ky;
}
}
}
#endif // _CV_MAT_SERIALIZER
|
/*============================================================================
Library: CppMicroServices
Copyright (c) German Cancer Research Center (DKFZ)
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 USSERVICEREGISTRATION_H
#define USSERVICEREGISTRATION_H
#include "usServiceRegistrationBase.h"
US_BEGIN_NAMESPACE
/**
* \ingroup MicroServices
*
* A registered service.
*
* <p>
* The framework returns a <code>ServiceRegistration</code> object when a
* <code>ModuleContext#RegisterService()</code> method invocation is successful.
* The <code>ServiceRegistration</code> object is for the private use of the
* registering module and should not be shared with other modules.
* <p>
* The <code>ServiceRegistration</code> object may be used to update the
* properties of the service or to unregister the service.
*
* @tparam S Class tyoe of the service interface
* @see ModuleContext#RegisterService()
* @remarks This class is thread safe.
*/
template<class I1, class I2 = void, class I3 = void>
class ServiceRegistration : public ServiceRegistrationBase
{
public:
/**
* Creates an invalid ServiceRegistration object. You can use
* this object in boolean expressions and it will evaluate to
* <code>false</code>.
*/
ServiceRegistration() : ServiceRegistrationBase()
{
}
///@{
/**
* Returns a <code>ServiceReference</code> object for a service being
* registered.
* <p>
* The <code>ServiceReference</code> object may be shared with other
* modules.
*
* @throws std::logic_error If this
* <code>ServiceRegistration</code> object has already been
* unregistered or if it is invalid.
* @return <code>ServiceReference</code> object.
*/
ServiceReference<I1> GetReference(InterfaceType<I1>) const
{
return this->ServiceRegistrationBase::GetReference(us_service_interface_iid<I1>());
}
ServiceReference<I2> GetReference(InterfaceType<I2>) const
{
return this->ServiceRegistrationBase::GetReference(us_service_interface_iid<I2>());
}
ServiceReference<I3> GetReference(InterfaceType<I3>) const
{
return this->ServiceRegistrationBase::GetReference(us_service_interface_iid<I3>());
}
///@}
using ServiceRegistrationBase::operator=;
private:
friend class ModuleContext;
ServiceRegistration(const ServiceRegistrationBase& base)
: ServiceRegistrationBase(base)
{
}
};
/// \cond
template<class I1, class I2>
class ServiceRegistration<I1, I2, void> : public ServiceRegistrationBase
{
public:
ServiceRegistration() : ServiceRegistrationBase()
{
}
ServiceReference<I1> GetReference(InterfaceType<I1>) const
{
return ServiceReference<I1>(this->ServiceRegistrationBase::GetReference(us_service_interface_iid<I1>()));
}
ServiceReference<I2> GetReference(InterfaceType<I2>) const
{
return ServiceReference<I2>(this->ServiceRegistrationBase::GetReference(us_service_interface_iid<I2>()));
}
using ServiceRegistrationBase::operator=;
private:
friend class ModuleContext;
ServiceRegistration(const ServiceRegistrationBase& base)
: ServiceRegistrationBase(base)
{
}
};
template<class I1>
class ServiceRegistration<I1, void, void> : public ServiceRegistrationBase
{
public:
ServiceRegistration() : ServiceRegistrationBase()
{
}
ServiceReference<I1> GetReference() const
{
return this->GetReference(InterfaceType<I1>());
}
ServiceReference<I1> GetReference(InterfaceType<I1>) const
{
return ServiceReference<I1>(this->ServiceRegistrationBase::GetReference(us_service_interface_iid<I1>()));
}
using ServiceRegistrationBase::operator=;
private:
friend class ModuleContext;
ServiceRegistration(const ServiceRegistrationBase& base)
: ServiceRegistrationBase(base)
{
}
};
template<>
class ServiceRegistration<void, void, void> : public ServiceRegistrationBase
{
public:
/**
* Creates an invalid ServiceReference object. You can use
* this object in boolean expressions and it will evaluate to
* <code>false</code>.
*/
ServiceRegistration() : ServiceRegistrationBase()
{
}
ServiceRegistration(const ServiceRegistrationBase& base)
: ServiceRegistrationBase(base)
{
}
using ServiceRegistrationBase::operator=;
};
/// \endcond
/**
* \ingroup MicroServices
*
* A service registration object of unknown type.
*/
typedef ServiceRegistration<void> ServiceRegistrationU;
US_END_NAMESPACE
#endif // USSERVICEREGISTRATION_H
|
/*-
* Copyright (c) 2010 Doug Rabson
* Copyright (c) 2011 Andriy Gapon
* Copyright (c) 2011 Pawel Jakub Dawidek <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
/* $FreeBSD$ */
#include <sys/param.h>
#include <sys/queue.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <md5.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
#define NBBY 8
void
pager_output(const char *line)
{
fprintf(stderr, "%s", line);
}
#define ZFS_TEST
#define printf(...) fprintf(stderr, __VA_ARGS__)
#include "libzfs.h"
#include "zfsimpl.c"
#undef printf
static int
vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
{
int fd = *(int *)priv;
if (pread(fd, buf, bytes, off) != bytes)
return (-1);
return (0);
}
static int
zfs_read(spa_t *spa, dnode_phys_t *dn, void *buf, size_t size, off_t off)
{
const znode_phys_t *zp = (const znode_phys_t *) dn->dn_bonus;
size_t n;
int rc;
n = size;
if (off + n > zp->zp_size)
n = zp->zp_size - off;
rc = dnode_read(spa, dn, off, buf, n);
if (rc != 0)
return (-rc);
return (n);
}
int
main(int argc, char** argv)
{
char buf[512], hash[33];
MD5_CTX ctx;
struct stat sb;
struct zfsmount zfsmnt;
dnode_phys_t dn;
#if 0
uint64_t rootobj;
#endif
spa_t *spa;
off_t off;
ssize_t n;
int i, failures, *fd;
zfs_init();
if (argc == 1) {
static char *av[] = {
"zfsboottest",
"/dev/gpt/system0",
"/dev/gpt/system1",
"-",
"/boot/zfsloader",
"/boot/support.4th",
"/boot/kernel/kernel",
NULL,
};
argc = sizeof(av) / sizeof(av[0]) - 1;
argv = av;
}
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-") == 0)
break;
}
fd = malloc(sizeof(fd[0]) * (i - 1));
if (fd == NULL)
errx(1, "Unable to allocate memory.");
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-") == 0)
break;
fd[i - 1] = open(argv[i], O_RDONLY);
if (fd[i - 1] == -1) {
warn("open(%s) failed", argv[i]);
continue;
}
if (vdev_probe(vdev_read, &fd[i - 1], NULL) != 0) {
warnx("vdev_probe(%s) failed", argv[i]);
close(fd[i - 1]);
}
}
spa = STAILQ_FIRST(&zfs_pools);
if (spa == NULL) {
fprintf(stderr, "no pools\n");
exit(1);
}
if (zfs_spa_init(spa)) {
fprintf(stderr, "can't init pool\n");
exit(1);
}
spa_all_status();
#if 0
uint64_t rootobj;
if (zfs_get_root(spa, &rootobj)) {
fprintf(stderr, "can't get root\n");
exit(1);
}
if (zfs_mount(spa, rootobj, &zfsmnt)) {
#else
if (zfs_mount(spa, 0, &zfsmnt)) {
fprintf(stderr, "can't mount\n");
exit(1);
#endif
}
printf("\n");
for (++i, failures = 0; i < argc; i++) {
if (zfs_lookup(&zfsmnt, argv[i], &dn)) {
fprintf(stderr, "%s: can't lookup\n", argv[i]);
failures++;
continue;
}
if (zfs_dnode_stat(spa, &dn, &sb)) {
fprintf(stderr, "%s: can't stat\n", argv[i]);
failures++;
continue;
}
off = 0;
MD5Init(&ctx);
do {
n = sb.st_size - off;
n = n > sizeof(buf) ? sizeof(buf) : n;
n = zfs_read(spa, &dn, buf, n, off);
if (n < 0) {
fprintf(stderr, "%s: zfs_read failed\n",
argv[i]);
failures++;
break;
}
MD5Update(&ctx, buf, n);
off += n;
} while (off < sb.st_size);
if (off < sb.st_size)
continue;
MD5End(&ctx, hash);
printf("%s %s\n", hash, argv[i]);
}
return (failures == 0 ? 0 : 1);
}
|
// Copyright (c) 2012 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 NET_HTTP_HTTP_PIPELINED_STREAM_H_
#define NET_HTTP_HTTP_PIPELINED_STREAM_H_
#include <string>
#include "base/basictypes.h"
#include "net/base/net_log.h"
#include "net/http/http_stream.h"
#include "net/socket/ssl_client_socket.h"
namespace net {
class BoundNetLog;
class HttpPipelinedConnectionImpl;
class HttpResponseInfo;
class HttpRequestHeaders;
struct HttpRequestInfo;
class IOBuffer;
class ProxyInfo;
struct SSLConfig;
// HttpPipelinedStream is the pipelined implementation of HttpStream. It has
// very little code in it. Instead, it serves as the client's interface to the
// pipelined connection, where all the work happens.
//
// In the case of pipelining failures, these functions may return
// ERR_PIPELINE_EVICTION. In that case, the client should retry the HTTP
// request without pipelining.
class HttpPipelinedStream : public HttpStream {
public:
HttpPipelinedStream(HttpPipelinedConnectionImpl* pipeline,
int pipeline_id);
virtual ~HttpPipelinedStream();
// HttpStream methods:
virtual int InitializeStream(const HttpRequestInfo* request_info,
RequestPriority priority,
const BoundNetLog& net_log,
const CompletionCallback& callback) OVERRIDE;
virtual int SendRequest(const HttpRequestHeaders& headers,
HttpResponseInfo* response,
const CompletionCallback& callback) OVERRIDE;
virtual UploadProgress GetUploadProgress() const OVERRIDE;
virtual int ReadResponseHeaders(const CompletionCallback& callback) OVERRIDE;
virtual const HttpResponseInfo* GetResponseInfo() const OVERRIDE;
virtual int ReadResponseBody(IOBuffer* buf, int buf_len,
const CompletionCallback& callback) OVERRIDE;
virtual void Close(bool not_reusable) OVERRIDE;
virtual HttpStream* RenewStreamForAuth() OVERRIDE;
virtual bool IsResponseBodyComplete() const OVERRIDE;
virtual bool CanFindEndOfResponse() const OVERRIDE;
virtual bool IsConnectionReused() const OVERRIDE;
virtual void SetConnectionReused() OVERRIDE;
virtual bool IsConnectionReusable() const OVERRIDE;
virtual bool GetLoadTimingInfo(
LoadTimingInfo* load_timing_info) const OVERRIDE;
virtual void GetSSLInfo(SSLInfo* ssl_info) OVERRIDE;
virtual void GetSSLCertRequestInfo(
SSLCertRequestInfo* cert_request_info) OVERRIDE;
virtual bool IsSpdyHttpStream() const OVERRIDE;
virtual void Drain(HttpNetworkSession* session) OVERRIDE;
virtual void SetPriority(RequestPriority priority) OVERRIDE;
// The SSLConfig used to establish this stream's pipeline.
const SSLConfig& used_ssl_config() const;
// The ProxyInfo used to establish this this stream's pipeline.
const ProxyInfo& used_proxy_info() const;
// The BoundNetLog of this stream's pipelined connection.
const BoundNetLog& net_log() const;
// True if this stream's pipeline was NPN negotiated.
bool was_npn_negotiated() const;
// Protocol negotiated with the server.
NextProto protocol_negotiated() const;
private:
HttpPipelinedConnectionImpl* pipeline_;
int pipeline_id_;
const HttpRequestInfo* request_info_;
DISALLOW_COPY_AND_ASSIGN(HttpPipelinedStream);
};
} // namespace net
#endif // NET_HTTP_HTTP_PIPELINED_STREAM_H_
|
// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
#pragma once
class MemFile
{
MemFile(const MemFile&);
MemFile& operator=(const MemFile&);
public:
MemFile();
~MemFile();
HRESULT Open(const wchar_t*);
HRESULT Close();
bool IsOpen() const;
HRESULT GetView(const BYTE*&, LONGLONG&) const;
private:
HANDLE m_hFile;
HANDLE m_hMap;
void* m_pView;
LONGLONG m_size;
};
|
/* LibMemcached
* Copyright (C) 2010 Brian Aker, Trond Norbye
* All rights reserved.
*
* Use and distribution licensed under the BSD license. See
* the COPYING file in the parent directory for full text.
*
* Summary: "Implementation" of the function we don't have on windows
* to avoid a bunch of ifdefs in the rest of the code
*
*/
#ifndef WIN32_WRAPPERS_H
#define WIN32_WRAPPERS_H 1
#include <inttypes.h>
/*
* One of the Windows headers define interface as a macro, but that
* is causing problems with the member named "interface" in some of the
* structs.
*/
#undef interface
#undef malloc
#undef realloc
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
#define PRIu64 "I64u"
#define poll(a,b,c) WSAPoll(a,b,c)
#define gettimeofday(a, b) win_gettimeofday(a)
extern int win_gettimeofday(struct timeval *t);
#define strdup(a) _strdup(a)
#define strtoull(a, b, c) _strtoui64(a, b, c)
#define strtoll(a, b, c) _strtoi64(a, b, c)
#define getsockopt(a, b, c, d, e) win_getsockopt(a, b, c, d, e)
extern int win_getsockopt(SOCKET s, int level, int optname, void *value, socklen_t *option_len);
#define setsockopt(a, b, c, d, e) win_setsockopt(a, b, c, d, e)
extern int win_setsockopt(SOCKET s, int level, int optname, const void *value, socklen_t option_len);
#if 0
/*
* WinSock use a separate range for error codes. Let's just map to the
* WinSock ones.
*/
#define EADDRINUSE WSAEADDRINUSE
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define EALREADY WSAEALREADY
#define EISCONN WSAEISCONN
#define ENOTCONN WSAENOTCONN
#define ENOBUFS WSAENOBUFS
#define SHUT_RDWR SD_BOTH
#endif
/* EAI_SYSTEM isn't defined anywhere... just set it to... 11? */
#define EAI_SYSTEM 11
/* Best effort mapping of functions to alternative functions */
#define index(a,b) strchr(a,b)
#define rindex(a,b) strrchr(a,b)
#define random() rand()
#define kill(a, b) while (false) {}
#define fork() (-1)
#define waitpid(a,b,c) (-1)
#define fnmatch(a,b,c) (-1)
#define sleep(a) Sleep(a*1000)
#endif /* WIN32_WRAPPERS_H */
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This is the base class for an object that send frames to a receiver.
// TODO(hclam): Refactor such that there is no separate AudioSender vs.
// VideoSender, and the functionality of both is rolled into this class.
#ifndef MEDIA_CAST_SENDER_FRAME_SENDER_H_
#define MEDIA_CAST_SENDER_FRAME_SENDER_H_
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "media/cast/cast_environment.h"
#include "media/cast/net/rtcp/rtcp.h"
#include "media/cast/sender/rtp_timestamp_helper.h"
namespace media {
namespace cast {
class FrameSender {
public:
FrameSender(scoped_refptr<CastEnvironment> cast_environment,
CastTransportSender* const transport_sender,
base::TimeDelta rtcp_interval,
int frequency,
uint32 ssrc,
double max_frame_rate,
base::TimeDelta playout_delay);
virtual ~FrameSender();
// Calling this function is only valid if the receiver supports the
// "extra_playout_delay", rtp extension.
void SetTargetPlayoutDelay(base::TimeDelta new_target_playout_delay);
base::TimeDelta GetTargetPlayoutDelay() const {
return target_playout_delay_;
}
protected:
// Schedule and execute periodic sending of RTCP report.
void ScheduleNextRtcpReport();
void SendRtcpReport(bool schedule_future_reports);
void OnReceivedRtt(base::TimeDelta rtt,
base::TimeDelta avg_rtt,
base::TimeDelta min_rtt,
base::TimeDelta max_rtt);
bool is_rtt_available() const { return rtt_available_; }
const scoped_refptr<CastEnvironment> cast_environment_;
// Sends encoded frames over the configured transport (e.g., UDP). In
// Chromium, this could be a proxy that first sends the frames from a renderer
// process to the browser process over IPC, with the browser process being
// responsible for "packetizing" the frames and pushing packets into the
// network layer.
CastTransportSender* const transport_sender_;
const uint32 ssrc_;
// Records lip-sync (i.e., mapping of RTP <--> NTP timestamps), and
// extrapolates this mapping to any other point in time.
RtpTimestampHelper rtp_timestamp_helper_;
// RTT information from RTCP.
bool rtt_available_;
base::TimeDelta rtt_;
base::TimeDelta avg_rtt_;
base::TimeDelta min_rtt_;
base::TimeDelta max_rtt_;
protected:
const base::TimeDelta rtcp_interval_;
// The total amount of time between a frame's capture/recording on the sender
// and its playback on the receiver (i.e., shown to a user). This is fixed as
// a value large enough to give the system sufficient time to encode,
// transmit/retransmit, receive, decode, and render; given its run-time
// environment (sender/receiver hardware performance, network conditions,
// etc.).
base::TimeDelta target_playout_delay_;
// If true, we transmit the target playout delay to the receiver.
bool send_target_playout_delay_;
// Max encoded frames generated per second.
double max_frame_rate_;
// Maximum number of outstanding frames before the encoding and sending of
// new frames shall halt.
int max_unacked_frames_;
private:
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<FrameSender> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(FrameSender);
};
} // namespace cast
} // namespace media
#endif // MEDIA_CAST_SENDER_FRAME_SENDER_H_
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE369_Divide_by_Zero__float_fgets_83.h
Label Definition File: CWE369_Divide_by_Zero__float.label.xml
Template File: sources-sinks-83.tmpl.h
*/
/*
* @description
* CWE: 369 Divide by Zero
* BadSource: fgets Read data from the console using fgets()
* GoodSource: A hardcoded non-zero number (two)
* Sinks:
* GoodSink: Check value of or near zero before dividing
* BadSink : Divide a constant by data
* Flow Variant: 83 Data flow: data passed to class constructor and destructor by declaring the class object on the stack
*
* */
#include "std_testcase.h"
#include <math.h>
namespace CWE369_Divide_by_Zero__float_fgets_83
{
#ifndef OMITBAD
class CWE369_Divide_by_Zero__float_fgets_83_bad
{
public:
CWE369_Divide_by_Zero__float_fgets_83_bad(float dataCopy);
~CWE369_Divide_by_Zero__float_fgets_83_bad();
private:
float data;
};
#endif /* OMITBAD */
#ifndef OMITGOOD
class CWE369_Divide_by_Zero__float_fgets_83_goodG2B
{
public:
CWE369_Divide_by_Zero__float_fgets_83_goodG2B(float dataCopy);
~CWE369_Divide_by_Zero__float_fgets_83_goodG2B();
private:
float data;
};
class CWE369_Divide_by_Zero__float_fgets_83_goodB2G
{
public:
CWE369_Divide_by_Zero__float_fgets_83_goodB2G(float dataCopy);
~CWE369_Divide_by_Zero__float_fgets_83_goodB2G();
private:
float data;
};
#endif /* OMITGOOD */
}
|
/* -*- coding: utf-8 -*-
* ----------------------------------------------------------------------
* Copyright © 2013, libcork authors
* All rights reserved.
*
* Please see the COPYING file in this distribution for license details.
* ----------------------------------------------------------------------
*/
#ifndef LIBCORK_CONFIG_BSD_H
#define LIBCORK_CONFIG_BSD_H
/*-----------------------------------------------------------------------
* Endianness
*/
#include <sys/endian.h>
#if BYTE_ORDER == BIG_ENDIAN
#define CORK_CONFIG_IS_BIG_ENDIAN 1
#define CORK_CONFIG_IS_LITTLE_ENDIAN 0
#elif BYTE_ORDER == LITTLE_ENDIAN
#define CORK_CONFIG_IS_BIG_ENDIAN 0
#define CORK_CONFIG_IS_LITTLE_ENDIAN 1
#else
#error "Cannot determine system endianness"
#endif
#define CORK_HAVE_REALLOCF 1
#define CORK_HAVE_PTHREADS 1
#endif /* LIBCORK_CONFIG_BSD_H */
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_memmove_10.c
Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE193.label.xml
Template File: sources-sink-10.tmpl.c
*/
/*
* @description
* CWE: 121 Stack Based Buffer Overflow
* BadSource: Point data to a buffer that does not have space for a NULL terminator
* GoodSource: Point data to a buffer that includes space for a NULL terminator
* Sink: memmove
* BadSink : Copy string to data using memmove()
* Flow Variant: 10 Control flow: if(globalTrue) and if(globalFalse)
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
/* MAINTENANCE NOTE: The length of this string should equal the 10 */
#define SRC_STRING L"AAAAAAAAAA"
#ifndef OMITBAD
void CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_memmove_10_bad()
{
wchar_t * data;
wchar_t * dataBadBuffer = (wchar_t *)ALLOCA((10)*sizeof(wchar_t));
wchar_t * dataGoodBuffer = (wchar_t *)ALLOCA((10+1)*sizeof(wchar_t));
if(globalTrue)
{
/* FLAW: Set a pointer to a buffer that does not leave room for a NULL terminator when performing
* string copies in the sinks */
data = dataBadBuffer;
data[0] = L'\0'; /* null terminate */
}
{
wchar_t source[10+1] = SRC_STRING;
/* Copy length + 1 to include NUL terminator from source */
/* POTENTIAL FLAW: data may not have enough space to hold source */
memmove(data, source, (wcslen(source) + 1) * sizeof(wchar_t));
printWLine(data);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the globalTrue to globalFalse */
static void goodG2B1()
{
wchar_t * data;
wchar_t * dataBadBuffer = (wchar_t *)ALLOCA((10)*sizeof(wchar_t));
wchar_t * dataGoodBuffer = (wchar_t *)ALLOCA((10+1)*sizeof(wchar_t));
if(globalFalse)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Set a pointer to a buffer that leaves room for a NULL terminator when performing
* string copies in the sinks */
data = dataGoodBuffer;
data[0] = L'\0'; /* null terminate */
}
{
wchar_t source[10+1] = SRC_STRING;
/* Copy length + 1 to include NUL terminator from source */
/* POTENTIAL FLAW: data may not have enough space to hold source */
memmove(data, source, (wcslen(source) + 1) * sizeof(wchar_t));
printWLine(data);
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */
static void goodG2B2()
{
wchar_t * data;
wchar_t * dataBadBuffer = (wchar_t *)ALLOCA((10)*sizeof(wchar_t));
wchar_t * dataGoodBuffer = (wchar_t *)ALLOCA((10+1)*sizeof(wchar_t));
if(globalTrue)
{
/* FIX: Set a pointer to a buffer that leaves room for a NULL terminator when performing
* string copies in the sinks */
data = dataGoodBuffer;
data[0] = L'\0'; /* null terminate */
}
{
wchar_t source[10+1] = SRC_STRING;
/* Copy length + 1 to include NUL terminator from source */
/* POTENTIAL FLAW: data may not have enough space to hold source */
memmove(data, source, (wcslen(source) + 1) * sizeof(wchar_t));
printWLine(data);
}
}
void CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_memmove_10_good()
{
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_memmove_10_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_memmove_10_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
// $Id: tos.h,v 1.1.1.1 2007/11/05 19:11:37 jpolastre Exp $
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
* Copyright (c) 2002-2003 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/*
*
* Authors: Jason Hill, David Gay, Philip Levis, Nelson Lee
* Date last modified: 6/25/02
*
*/
/**
* @author Jason Hill
* @author David Gay
* @author Philip Levis
* @author Nelson Lee
*/
#if !defined(__CYGWIN__)
#if defined(__MSP430__)
#include <sys/inttypes.h>
#else
#include <inttypes.h>
#endif
#else //__CYGWIN
// Must be PLATFORM_PC...
#include <unistd.h>
#include <stdio.h>
// Earlier cygwins do not define uint8_t & co
#ifndef _STDINT_H
#ifndef __uint8_t_defined
#define __uint8_t_defined
typedef u_int8_t uint8_t;
#endif
#ifndef __uint16_t_defined
#define __uint16_t_defined
typedef u_int16_t uint16_t;
#endif
#ifndef __uint32_t_defined
#define __uint32_t_defined
typedef u_int32_t uint32_t;
#endif
#endif
#endif //__CYGWIN
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stddef.h>
#include <ctype.h>
#ifndef GENERICCOMM
# define GENERICCOMM GenericComm //the name of the default generic comm component
#endif
#ifndef GENERICCOMMPROMISCUOUS
# define GENERICCOMMPROMISCUOUS GenericCommPromiscuous //the name of the default promiscuous generic comm component
#endif
typedef unsigned char bool;
#ifdef FALSE //if FALSE is defined, undefine it, for the enum below
#undef FALSE
#endif
#ifdef TRUE //if TRUE is defined, undefine it, for the enum below
#undef TRUE
#endif
enum {
FALSE = 0,
TRUE = 1
};
uint16_t TOS_LOCAL_ADDRESS = 1;
enum { /* standard codes for result_t */
FAIL = 0,
SUCCESS = 1
};
// for wiring checks
struct @atmostonce { };
struct @atleastonce { };
struct @exactlyonce { };
#if NESC >= 110
uint8_t rcombine(uint8_t r1, uint8_t r2); // keep 1.1alpha1 happy
typedef uint8_t result_t __attribute__((combine(rcombine)));
#else
typedef uint8_t result_t;
#define atomic
#define async
#define norace
#endif
result_t rcombine(result_t r1, result_t r2)
/* Returns: FAIL if r1 or r2 == FAIL , r2 otherwise. This is the standard
combining rule for results
*/
{
return r1 == FAIL ? FAIL : r2;
}
result_t rcombine3(result_t r1, result_t r2, result_t r3)
{
return rcombine(r1, rcombine(r2, r3));
}
result_t rcombine4(result_t r1, result_t r2, result_t r3,
result_t r4)
{
return rcombine(r1, rcombine(r2, rcombine(r3, r4)));
}
#undef NULL
enum {
NULL = 0x0
};
#include <hardware.h>
#include <dbg.h>
#include <sched.c>
// buggy in avr-gcc 3.1
void *nmemcpy(void *to, const void *from, size_t n)
{
char *cto = to;
const char *cfrom = from;
while (n--) *cto++ = *cfrom++;
return to;
}
void *nmemset(void *to, int val, size_t n)
{
char *cto = to;
while (n--) *cto++ = val;
return to;
}
#if 0 /* to be turned by David Gay later */
int strcasecmp(const char *s1, const char *s2)
{
while (*s1 && *s2)
{
int c1 = tolower(*s1++), c2 = tolower(*s2++);
if (c1 != c2)
return c1 - c2;
}
if (*s1)
return 1;
else if (*s2)
return -1;
else
return 0;
}
#endif
#define memcpy nmemcpy
#define memset nmemset
#include "Ident.h" //added by css
/* avr-gcc lib 3.3 for 128s defines an output() macro.
* This is clearly a bad idea.
* But we have to live with it. The problem is that
* the IntOutput interface has a command, output; if we don't
* undef gcc's output. the compiler tosses an error at you.
* -pal, 6/2/03
*/
#ifdef output
#undef output
#endif
|
/* Copyright 2021 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* Volteer family-specific CBI functions, shared with Zephyr */
#ifndef __CROS_EC_BASEBOARD_CBI_H
#define __CROS_EC_BASEBOARD_CBI_H
unsigned char get_board_id(void);
/**
* Configure run-time data structures and operation based on CBI data. This
* typically includes customization for changes in the BOARD_VERSION and
* FW_CONFIG fields in CBI. This routine is called from the baseboard after
* the CBI data has been initialized.
*/
__override_proto void board_cbi_init(void);
#endif /* __CROS_EC_BASEBOARD_CBI_H */
|
/*
* This file is part of the Soletta Project
*
* Copyright (C) 2015 Intel Corporation. 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 Intel Corporation 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.
*/
#include <errno.h>
#include <stdlib.h>
// Riot includes
#include <periph/gpio.h>
#define SOL_LOG_DOMAIN &_log_domain
#include "sol-log-internal.h"
#include "sol-gpio.h"
#include "sol-mainloop.h"
#include "sol-util.h"
#include "sol-interrupt_scheduler_riot.h"
SOL_LOG_INTERNAL_DECLARE_STATIC(_log_domain, "gpio");
struct sol_gpio {
int pin;
bool active_low;
struct {
void (*cb)(void *data, struct sol_gpio *gpio);
const void *data;
void *int_handler;
} irq;
};
static void
gpio_process_cb(void *data)
{
struct sol_gpio *gpio = data;
gpio->irq.cb((void *)gpio->irq.data, gpio);
}
SOL_API struct sol_gpio *
sol_gpio_open_raw(int pin, const struct sol_gpio_config *config)
{
struct sol_gpio *gpio;
gpio_pp_t pull;
const unsigned int drive_table[] = {
[SOL_GPIO_DRIVE_NONE] = GPIO_NOPULL,
[SOL_GPIO_DRIVE_PULL_UP] = GPIO_PULLUP,
[SOL_GPIO_DRIVE_PULL_DOWN] = GPIO_PULLDOWN
};
SOL_LOG_INTERNAL_INIT_ONCE;
#ifndef SOL_NO_API_VERSION
if (unlikely(config->api_version != SOL_GPIO_CONFIG_API_VERSION)) {
SOL_WRN("Couldn't open gpio that has unsupported version '%u', "
"expected version is '%u'",
config->api_version, SOL_GPIO_CONFIG_API_VERSION);
return NULL;
}
#endif
gpio = malloc(sizeof(struct sol_gpio));
SOL_NULL_CHECK(gpio, NULL);
gpio->pin = pin;
gpio->active_low = config->active_low;
gpio->irq.int_handler = NULL;
pull = drive_table[config->drive_mode];
if (config->dir == SOL_GPIO_DIR_OUT) {
if (gpio_init(gpio->pin, GPIO_DIR_OUT, pull) < 0)
goto error;
sol_gpio_write(gpio, config->out.value);
} else {
if (config->in.trigger_mode == SOL_GPIO_EDGE_NONE) {
if (gpio_init(gpio->pin, GPIO_DIR_IN, pull) < 0)
goto error;
} else {
gpio_flank_t flank;
const unsigned int trigger_table[] = {
[SOL_GPIO_EDGE_RISING] = GPIO_RISING,
[SOL_GPIO_EDGE_FALLING] = GPIO_FALLING,
[SOL_GPIO_EDGE_BOTH] = GPIO_BOTH
};
flank = trigger_table[config->in.trigger_mode];
gpio->irq.cb = config->in.cb;
gpio->irq.data = config->in.user_data;
if (sol_interrupt_scheduler_gpio_init_int(gpio->pin, pull, flank,
gpio_process_cb, gpio,
&gpio->irq.int_handler) < 0)
goto error;
}
}
return gpio;
error:
free(gpio);
return NULL;
}
SOL_API void
sol_gpio_close(struct sol_gpio *gpio)
{
SOL_NULL_CHECK(gpio);
if (gpio->irq.int_handler != NULL) {
sol_interrupt_scheduler_gpio_stop(gpio->pin, gpio->irq.int_handler);
}
free(gpio);
}
SOL_API bool
sol_gpio_write(struct sol_gpio *gpio, bool value)
{
SOL_NULL_CHECK(gpio, false);
gpio_write(gpio->pin, gpio->active_low ^ value);
return true;
}
SOL_API int
sol_gpio_read(struct sol_gpio *gpio)
{
SOL_NULL_CHECK(gpio, -EINVAL);
return gpio->active_low ^ !!gpio_read(gpio->pin);
}
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE191_Integer_Underflow__int_listen_socket_sub_61a.c
Label Definition File: CWE191_Integer_Underflow__int.label.xml
Template File: sources-sinks-61a.tmpl.c
*/
/*
* @description
* CWE: 191 Integer Underflow
* BadSource: listen_socket Read data using a listen socket (server side)
* GoodSource: Set data to a small, non-zero number (negative two)
* Sinks: sub
* GoodSink: Ensure there will not be an underflow before subtracting 1 from data
* BadSink : Subtract 1 from data, which can cause an Underflow
* Flow Variant: 61 Data flow: data returned from one function to another in different source files
*
* */
#include "std_testcase.h"
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define LISTEN_BACKLOG 5
#define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2)
#ifndef OMITBAD
/* bad function declaration */
int CWE191_Integer_Underflow__int_listen_socket_sub_61b_badSource(int data);
void CWE191_Integer_Underflow__int_listen_socket_sub_61_bad()
{
int data;
/* Initialize data */
data = 0;
data = CWE191_Integer_Underflow__int_listen_socket_sub_61b_badSource(data);
{
/* POTENTIAL FLAW: Subtracting 1 from data could cause an underflow */
int result = data - 1;
printIntLine(result);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
int CWE191_Integer_Underflow__int_listen_socket_sub_61b_goodG2BSource(int data);
static void goodG2B()
{
int data;
/* Initialize data */
data = 0;
data = CWE191_Integer_Underflow__int_listen_socket_sub_61b_goodG2BSource(data);
{
/* POTENTIAL FLAW: Subtracting 1 from data could cause an underflow */
int result = data - 1;
printIntLine(result);
}
}
/* goodB2G uses the BadSource with the GoodSink */
int CWE191_Integer_Underflow__int_listen_socket_sub_61b_goodB2GSource(int data);
static void goodB2G()
{
int data;
/* Initialize data */
data = 0;
data = CWE191_Integer_Underflow__int_listen_socket_sub_61b_goodB2GSource(data);
/* FIX: Add a check to prevent an underflow from occurring */
if (data > INT_MIN)
{
int result = data - 1;
printIntLine(result);
}
else
{
printLine("data value is too large to perform subtraction.");
}
}
void CWE191_Integer_Underflow__int_listen_socket_sub_61_good()
{
goodG2B();
goodB2G();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE191_Integer_Underflow__int_listen_socket_sub_61_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE191_Integer_Underflow__int_listen_socket_sub_61_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE197_Numeric_Truncation_Error__int_rand_to_short_45.c
Label Definition File: CWE197_Numeric_Truncation_Error__int.label.xml
Template File: sources-sink-45.tmpl.c
*/
/*
* @description
* CWE: 197 Numeric Truncation Error
* BadSource: rand Set data to result of rand(), which may be zero
* GoodSource: Less than CHAR_MAX
* Sinks: to_short
* BadSink : Convert data to a short
* Flow Variant: 45 Data flow: data passed as a static global variable from one function to another in the same source file
*
* */
#include "std_testcase.h"
static int CWE197_Numeric_Truncation_Error__int_rand_to_short_45_badData;
static int CWE197_Numeric_Truncation_Error__int_rand_to_short_45_goodG2BData;
#ifndef OMITBAD
static void badSink()
{
int data = CWE197_Numeric_Truncation_Error__int_rand_to_short_45_badData;
{
/* POTENTIAL FLAW: Convert data to a short, possibly causing a truncation error */
short shortData = (short)data;
printShortLine(shortData);
}
}
void CWE197_Numeric_Truncation_Error__int_rand_to_short_45_bad()
{
int data;
/* Initialize data */
data = -1;
/* POTENTIAL FLAW: Set data to a random value */
data = RAND32();
CWE197_Numeric_Truncation_Error__int_rand_to_short_45_badData = data;
badSink();
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() uses the GoodSource with the BadSink */
static void goodG2BSink()
{
int data = CWE197_Numeric_Truncation_Error__int_rand_to_short_45_goodG2BData;
{
/* POTENTIAL FLAW: Convert data to a short, possibly causing a truncation error */
short shortData = (short)data;
printShortLine(shortData);
}
}
static void goodG2B()
{
int data;
/* Initialize data */
data = -1;
/* FIX: Use a positive integer less than CHAR_MAX*/
data = CHAR_MAX-5;
CWE197_Numeric_Truncation_Error__int_rand_to_short_45_goodG2BData = data;
goodG2BSink();
}
void CWE197_Numeric_Truncation_Error__int_rand_to_short_45_good()
{
goodG2B();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE197_Numeric_Truncation_Error__int_rand_to_short_45_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE197_Numeric_Truncation_Error__int_rand_to_short_45_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
// 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 EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
#define EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
#include <stddef.h>
#include <string>
#include "base/macros.h"
#include "base/synchronization/lock.h"
#include "extensions/common/activation_sequence.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_set.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
class GURL;
namespace extensions {
// Thread safe container for all loaded extensions in this process,
// essentially the renderer counterpart to ExtensionRegistry.
class RendererExtensionRegistry {
public:
RendererExtensionRegistry();
RendererExtensionRegistry(const RendererExtensionRegistry&) = delete;
RendererExtensionRegistry& operator=(const RendererExtensionRegistry&) =
delete;
~RendererExtensionRegistry();
static RendererExtensionRegistry* Get();
// Returns the ExtensionSet that underlies this RenderExtensionRegistry.
//
// This is not thread-safe and must only be called on the RenderThread, but
// even so, it's not thread safe because other threads may decide to
// modify this. Don't persist a reference to this.
//
// TODO(annekao): remove or make thread-safe and callback-based.
const ExtensionSet* GetMainThreadExtensionSet() const;
size_t size() const;
bool is_empty() const;
// Forwards to the ExtensionSet methods by the same name.
bool Contains(const std::string& id) const;
bool Insert(const scoped_refptr<const Extension>& extension);
bool Remove(const std::string& id);
std::string GetExtensionOrAppIDByURL(const GURL& url) const;
const Extension* GetExtensionOrAppByURL(const GURL& url) const;
const Extension* GetHostedAppByURL(const GURL& url) const;
const Extension* GetByID(const std::string& id) const;
ExtensionIdSet GetIDs() const;
bool ExtensionBindingsAllowed(const GURL& url) const;
// ActivationSequence related methods.
//
// Sets ActivationSequence for a Service Worker based |extension|.
void SetWorkerActivationSequence(
const scoped_refptr<const Extension>& extension,
ActivationSequence worker_activation_sequence);
// Returns the current activation sequence for worker based extension with
// |extension_id|. Returns absl::nullopt otherwise.
absl::optional<ActivationSequence> GetWorkerActivationSequence(
const ExtensionId& extension_id) const;
private:
ExtensionSet extensions_;
// Maps extension id to ActivationSequence, for worker based extensions.
std::map<ExtensionId, ActivationSequence> worker_activation_sequences_;
mutable base::Lock lock_;
};
} // namespace extensions
#endif // EXTENSIONS_RENDERER_RENDERER_EXTENSION_REGISTRY_H_
|
// Copyright 2016 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 CHROME_BROWSER_EXTENSIONS_DEVICE_PERMISSIONS_DIALOG_CONTROLLER_H_
#define CHROME_BROWSER_EXTENSIONS_DEVICE_PERMISSIONS_DIALOG_CONTROLLER_H_
#include <unordered_map>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/chooser_controller/chooser_controller.h"
#include "extensions/browser/api/device_permissions_prompt.h"
class DevicePermissionsDialogController
: public ChooserController,
public extensions::DevicePermissionsPrompt::Prompt::Observer {
public:
DevicePermissionsDialogController(
content::RenderFrameHost* owner,
scoped_refptr<extensions::DevicePermissionsPrompt::Prompt> prompt);
~DevicePermissionsDialogController() override;
// ChooserController:
bool ShouldShowHelpButton() const override;
bool AllowMultipleSelection() const override;
base::string16 GetNoOptionsText() const override;
base::string16 GetOkButtonLabel() const override;
size_t NumOptions() const override;
base::string16 GetOption(size_t index) const override;
void Select(const std::vector<size_t>& indices) override;
void Cancel() override;
void Close() override;
void OpenHelpCenterUrl() const override;
// extensions::DevicePermissionsPrompt::Prompt::Observer:
void OnDeviceAdded(size_t index, const base::string16& device_name) override;
void OnDeviceRemoved(size_t index,
const base::string16& device_name) override;
private:
scoped_refptr<extensions::DevicePermissionsPrompt::Prompt> prompt_;
// Maps from device name to number of devices.
std::unordered_map<base::string16, int> device_name_map_;
DISALLOW_COPY_AND_ASSIGN(DevicePermissionsDialogController);
};
#endif // CHROME_BROWSER_EXTENSIONS_DEVICE_PERMISSIONS_DIALOG_CONTROLLER_H_
|
#include "jsonsl.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <errno.h>
#include "all-tests.h"
static int WantFail = 0;
static jsonsl_error_t WantError = 0;
void fmt_level(const char *buf, size_t nbuf, int levels)
{
const char *c = buf;
int ii;
for (ii = 0; ii < levels; ii++) {
putchar('\t');
}
while (nbuf && *c) {
putchar(*c);
if (*c == '\n') {
for (ii = 0; ii < levels; ii++) {
putchar(' ');
}
}
c++;
nbuf--;
}
putchar('\n');
}
void state_callback(jsonsl_t jsn,
jsonsl_action_t action,
struct jsonsl_state_st *state,
const char *buf)
{
/* We are called here with the jsn object, the state (PUSH or POP),
* the 'state' object, which contains information about the level of
* nesting we are descending into/ascending from, and a pointer to the
* start position of the detectin of this nesting
*/
/*
printf("@%-5lu L%d %c%s\n",
jsn->pos,
state->level,
action,
jsonsl_strtype(state->type));
*/
/*
if (action == JSONSL_ACTION_POP) {
size_t state_len = jsn->pos - state->pos_begin;
}
*/
}
int error_callback(jsonsl_t jsn,
jsonsl_error_t err,
struct jsonsl_state_st *state,
char *errat)
{
/* Error callback. In theory, this can return a true value
* and maybe 'correct' and seek ahead of the buffer, and try to
* do some correction.
*/
if (WantFail) {
printf("Got error %s (PASS)\n", jsonsl_strerror(err));
WantError = err;
return 0;
}
fprintf(stderr, "Got parse error at '%c', pos %lu\n", *errat, jsn->pos);
fprintf(stderr, "Error is %s\n", jsonsl_strerror(err));
fprintf(stderr, "Remaining text: %s\n", errat);
abort();
return 0;
}
void parse_single_file(const char *path)
{
char *buf, *bufp;
long fsize;
size_t nread = 0;
FILE *fh;
jsonsl_t jsn;
struct stat sb = { 0 };
WantError = 0;
/* open our file */
if (stat(path, &sb) == -1) {
perror(path);
return;
}
if (S_ISDIR(sb.st_mode)) {
fprintf(stderr, "Skipping directory '%s'\n", path);
return;
}
fh = fopen(path, "r");
if (fh == NULL) {
perror(path);
return;
}
/* Declare that we will support up to 512 nesting levels.
* Each level of nesting requires about ~40 bytes (allocated at initialization)
* to maintain state information.
*/
jsn = jsonsl_new(0x2000);
/* Set up our error callbacks (to be called when an error occurs)
* and a nest callback (when a level changes in 'nesting')
*/
jsn->error_callback = error_callback;
jsn->action_callback = state_callback;
/* Declare that we're intertested in receiving callbacks about
* json 'Object' and 'List' types.
*/
jsonsl_enable_all_callbacks(jsn);
/* read into the buffer */
/**
* To avoid recomputing offsets and relative positioning,
* we will maintain the buffer, but this is not strictly required.
*/
fseek(fh, 0, SEEK_END);
fsize = ftell(fh);
if (fsize == -1) {
perror(path);
fclose(fh);
return;
}
assert(fsize < 0x1000000);
buf = malloc(fsize);
bufp = buf;
fseek(fh, 0, SEEK_SET);
while ( (nread = fread(bufp, 1, 4096, fh)) ) {
jsonsl_feed(jsn, bufp, nread);
bufp += nread;
}
if (WantFail && WantError == 0) {
fprintf(stderr, "Expected error but didn't find any!\n");
abort();
}
jsonsl_destroy(jsn);
fclose(fh);
free(buf);
}
JSONSL_TEST_JSON_FUNC
{
int ii;
if (getenv("JSONSL_QUIET_TESTS")) {
freopen(DEVNULL, "w", stdout);
}
#ifdef JSONSL_FAILURE_TESTS
WantFail = 1;
#else
if (getenv("JSONSL_FAIL_TESTS")) {
printf("Want Fail..\n");
WantFail = 1;
}
#endif
if (argc < 2) {
fprintf(stderr, "Usage: %s FILES..\n", argv[0]);
exit(EXIT_FAILURE);
}
for (ii = 1; ii < argc && argv[ii]; ii++) {
int rv;
struct stat sb = { 0 };
rv = stat(argv[ii], &sb);
if (rv == -1) {
fprintf(stderr, "Couldn't stat '%s': %s\n",
argv[ii], strerror(errno));
return EXIT_FAILURE;
}
if (S_ISDIR(sb.st_mode)) {
fprintf(stderr, "Skipping directory '%s'\n", argv[ii]);
continue;
}
fprintf(stderr, "==== %-40s ====\n", argv[ii]);
parse_single_file(argv[ii]);
}
return 0;
}
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2022 Intel Corporation
*/
#ifndef _QAT_ASYM_H_
#define _QAT_ASYM_H_
#include <cryptodev_pmd.h>
#include <rte_crypto_asym.h>
#include "icp_qat_fw_pke.h"
#include "qat_device.h"
#include "qat_crypto.h"
#include "icp_qat_fw.h"
/** Intel(R) QAT Asymmetric Crypto PMD driver name */
#define CRYPTODEV_NAME_QAT_ASYM_PMD crypto_qat_asym
typedef uint64_t large_int_ptr;
#define MAX_PKE_PARAMS 8
#define QAT_PKE_MAX_LN_SIZE 512
#define _PKE_ALIGN_ __rte_aligned(8)
#define QAT_ASYM_MAX_PARAMS 8
#define QAT_ASYM_MODINV_NUM_IN_PARAMS 2
#define QAT_ASYM_MODINV_NUM_OUT_PARAMS 1
#define QAT_ASYM_MODEXP_NUM_IN_PARAMS 3
#define QAT_ASYM_MODEXP_NUM_OUT_PARAMS 1
#define QAT_ASYM_RSA_NUM_IN_PARAMS 3
#define QAT_ASYM_RSA_NUM_OUT_PARAMS 1
#define QAT_ASYM_RSA_QT_NUM_IN_PARAMS 6
#define QAT_ASYM_ECDSA_RS_SIGN_IN_PARAMS 1
#define QAT_ASYM_ECDSA_RS_SIGN_OUT_PARAMS 2
#define QAT_ASYM_ECDSA_RS_VERIFY_IN_PARAMS 1
#define QAT_ASYM_ECDSA_RS_VERIFY_OUT_PARAMS 0
#define QAT_ASYM_ECPM_IN_PARAMS 7
#define QAT_ASYM_ECPM_OUT_PARAMS 2
/**
* helper function to add an asym capability
* <name> <op type> <modlen (min, max, increment)>
**/
#define QAT_ASYM_CAP(n, o, l, r, i) \
{ \
.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC, \
{.asym = { \
.xform_capa = { \
.xform_type = RTE_CRYPTO_ASYM_XFORM_##n,\
.op_types = o, \
{ \
.modlen = { \
.min = l, \
.max = r, \
.increment = i \
}, } \
} \
}, \
} \
}
struct qat_asym_op_cookie {
size_t alg_bytesize;
uint64_t error;
rte_iova_t input_addr;
rte_iova_t output_addr;
large_int_ptr input_params_ptrs[MAX_PKE_PARAMS] _PKE_ALIGN_;
large_int_ptr output_params_ptrs[MAX_PKE_PARAMS] _PKE_ALIGN_;
union {
uint8_t input_array[MAX_PKE_PARAMS][QAT_PKE_MAX_LN_SIZE];
uint8_t input_buffer[MAX_PKE_PARAMS * QAT_PKE_MAX_LN_SIZE];
} _PKE_ALIGN_;
uint8_t output_array[MAX_PKE_PARAMS][QAT_PKE_MAX_LN_SIZE] _PKE_ALIGN_;
} _PKE_ALIGN_;
struct qat_asym_session {
struct icp_qat_fw_pke_request req_tmpl;
struct rte_crypto_asym_xform xform;
};
static inline void
qat_fill_req_tmpl(struct icp_qat_fw_pke_request *qat_req)
{
memset(qat_req, 0, sizeof(*qat_req));
qat_req->pke_hdr.service_type = ICP_QAT_FW_COMN_REQ_CPM_FW_PKE;
qat_req->pke_hdr.hdr_flags =
ICP_QAT_FW_COMN_HDR_FLAGS_BUILD
(ICP_QAT_FW_COMN_REQ_FLAG_SET);
}
static inline void
qat_asym_build_req_tmpl(void *sess_private_data)
{
struct icp_qat_fw_pke_request *qat_req;
struct qat_asym_session *session = sess_private_data;
qat_req = &session->req_tmpl;
qat_fill_req_tmpl(qat_req);
}
int
qat_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
struct rte_crypto_asym_xform *xform,
struct rte_cryptodev_asym_session *sess);
unsigned int
qat_asym_session_get_private_size(struct rte_cryptodev *dev);
void
qat_asym_session_clear(struct rte_cryptodev *dev,
struct rte_cryptodev_asym_session *sess);
void
qat_asym_init_op_cookie(void *cookie);
#endif /* _QAT_ASYM_H_ */
|
// Copyright (C) 2011-2012 by Tapjoy Inc.
//
// This file is part of the Tapjoy SDK.
//
// By using the Tapjoy SDK in your software, you agree to the terms of the Tapjoy SDK License Agreement.
//
// The Tapjoy SDK is bound by the Tapjoy SDK License Agreement and can be found here: https://www.tapjoy.com/sdk/license
#import <Foundation/Foundation.h>
#import "TJCCoreFetcherHandler.h"
/*! \interface TJCVideoRequestHandler
* \brief The Tapjoy Connect Video Request Handler Class.
*
*/
@interface TJCVideoRequestHandler : TJCCoreFetcherHandler<TJCWebFetcherDelegate>
{
BOOL clickSuccessful_;
}
@property (assign) BOOL clickSuccessful;
- (id)initRequestWithDelegate:(id<TJCFetchResponseDelegate>) aDelegate andRequestTag:(int)aTag;
// Video request methods.
// Requests video data.
- (void)requestVideoData;
// Request video click.
- (void)recordVideoClickWithURL:(NSString*)URLString;
// Request video complete.
- (void)requestVideoCompleteWithOfferID:(NSString*)offerID;
// Server callback methods.
// Video data received, which includes video URL, Offer ID, and other data. Caching should begin here.
- (void)videoDataReceived:(TJCCoreFetcher*)myFetcher;
// Video click received, this indicates that the server has received the video has begun playing message.
- (void)videoClickReceived:(TJCCoreFetcher*)myFetcher;
// Video complete callback, this indicates that the server has received the video complete message.
- (void)videoCompleteReceived:(TJCCoreFetcher*)myFetcher;
@end
|
/*
* Copyright (C) 1989 by Kenneth Almquist. All rights reserved.
* This file is part of ash, which is distributed under the terms specified
* by the Ash General Public License. See the file named LICENSE.
*/
#include <stdio.h>
char *commandname;
void
#ifdef __STDC__
error(char *msg, ...) {
#else
error(msg)
char *msg;
{
#endif
fprintf(stderr, "%s: %s\n", commandname, msg);
exit(2);
}
|
#ifndef XPathTest_h
#define XPathTest_h
#include "framework.h"
class XPathTest : public test_fixture
{
public:
TEST_SUITE(XPathTest);
TEST(XPathTest::TestConstructor);
TEST(XPathTest::TestCopyConstructor);
TEST(XPathTest::TestAssignmentOperator);
TEST(XPathTest::TestOpenPath);
TEST(XPathTest::TestIsPath);
TEST(XPathTest::TestIsReg);
TEST(XPathTest::TestExists);
TEST(XPathTest::TestClear);
TEST(XPathTest::TestIter);
TEST(XPathTest::TestFileSize);
TEST_SUITE_END();
virtual ~XPathTest() throw()
{}
void setup();
void teardown();
protected:
void TestConstructor();
void TestCopyConstructor();
void TestAssignmentOperator();
void TestOpenPath();
void TestIsPath();
void TestIsReg();
void TestExists();
void TestClear();
void TestIter();
void TestFileSize();
private:
};
#endif
|
#include "lib9.h"
#include <sys/types.h>
#include <fcntl.h>
vlong
seek(int fd, vlong where, int from)
{
return lseek(fd, where, from);
}
|
/**
******************************************************************************
* @file usbd_dfu_media_template.c
* @author MCD Application Team
* @version V2.4.0
* @date 28-February-2015
* @brief Memory management layer
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usbd_dfu_media_template.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Extern function prototypes ------------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
uint16_t MEM_If_Init(void);
uint16_t MEM_If_Erase (uint32_t Add);
uint16_t MEM_If_Write (uint8_t *src, uint8_t *dest, uint32_t Len);
uint8_t *MEM_If_Read (uint8_t *src, uint8_t *dest, uint32_t Len);
uint16_t MEM_If_DeInit(void);
uint16_t MEM_If_GetStatus (uint32_t Add, uint8_t Cmd, uint8_t *buffer);
USBD_DFU_MediaTypeDef USBD_DFU_MEDIA_Template_fops =
{
(uint8_t *)"DFU MEDIA",
MEM_If_Init,
MEM_If_DeInit,
MEM_If_Erase,
MEM_If_Write,
MEM_If_Read,
MEM_If_GetStatus,
};
/**
* @brief MEM_If_Init
* Memory initialization routine.
* @param None
* @retval 0 if operation is successful, MAL_FAIL else.
*/
uint16_t MEM_If_Init(void)
{
return 0;
}
/**
* @brief MEM_If_DeInit
* Memory deinitialization routine.
* @param None
* @retval 0 if operation is successful, MAL_FAIL else.
*/
uint16_t MEM_If_DeInit(void)
{
return 0;
}
/**
* @brief MEM_If_Erase
* Erase sector.
* @param Add: Address of sector to be erased.
* @retval 0 if operation is successful, MAL_FAIL else.
*/
uint16_t MEM_If_Erase(uint32_t Add)
{
return 0;
}
/**
* @brief MEM_If_Write
* Memory write routine.
* @param Add: Address to be written to.
* @param Len: Number of data to be written (in bytes).
* @retval 0 if operation is successful, MAL_FAIL else.
*/
uint16_t MEM_If_Write(uint8_t *src, uint8_t *dest, uint32_t Len)
{
return 0;
}
/**
* @brief MEM_If_Read
* Memory read routine.
* @param Add: Address to be read from.
* @param Len: Number of data to be read (in bytes).
* @retval Pointer to the physical address where data should be read.
*/
uint8_t *MEM_If_Read (uint8_t *src, uint8_t *dest, uint32_t Len)
{
/* Return a valid address to avoid HardFault */
return (uint8_t*)(0);
}
/**
* @brief Flash_If_GetStatus
* Memory read routine.
* @param Add: Address to be read from.
* @param cmd: Number of data to be read (in bytes).
* @retval Pointer to the physical address where data should be read.
*/
uint16_t MEM_If_GetStatus (uint32_t Add, uint8_t Cmd, uint8_t *buffer)
{
switch (Cmd)
{
case DFU_MEDIA_PROGRAM:
break;
case DFU_MEDIA_ERASE:
default:
break;
}
return (0);
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/*
* Copyright 2017 Google
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#import <Foundation/Foundation.h>
#import "FIRFirestoreSwiftNameSupport.h"
@class FIRApp;
@class FIRCollectionReference;
@class FIRDocumentReference;
@class FIRFirestoreSettings;
@class FIRTransaction;
@class FIRWriteBatch;
NS_ASSUME_NONNULL_BEGIN
/**
* `FIRFirestore` represents a Firestore Database and is the entry point for all Firestore
* operations.
*/
FIR_SWIFT_NAME(Firestore)
@interface FIRFirestore : NSObject
#pragma mark - Initializing
/** */
- (instancetype)init __attribute__((unavailable("Use a static constructor method.")));
/**
* Creates, caches, and returns a `FIRFirestore` using the default `FIRApp`. Each subsequent
* invocation returns the same `FIRFirestore` object.
*
* @return The `FIRFirestore` instance.
*/
+ (instancetype)firestore FIR_SWIFT_NAME(firestore());
/**
* Creates, caches, and returns a `FIRFirestore` object for the specified _app_. Each subsequent
* invocation returns the same `FIRFirestore` object.
*
* @param app The `FIRApp` instance to use for authentication and as a source of the Google Cloud
* Project ID for your Firestore Database. If you want the default instance, you should explicitly
* set it to `[FIRApp defaultApp]`.
*
* @return The `FIRFirestore` instance.
*/
+ (instancetype)firestoreForApp:(FIRApp *)app FIR_SWIFT_NAME(firestore(app:));
/**
* Custom settings used to configure this `FIRFirestore` object.
*/
@property(nonatomic, copy) FIRFirestoreSettings *settings;
/**
* The Firebase App associated with this Firestore instance.
*/
@property(strong, nonatomic, readonly) FIRApp *app;
#pragma mark - Collections and Documents
/**
* Gets a `FIRCollectionReference` referring to the collection at the specified path within the
* database.
*
* @param collectionPath The slash-separated path of the collection for which to get a
* `FIRCollectionReference`.
*
* @return The `FIRCollectionReference` at the specified _collectionPath_.
*/
- (FIRCollectionReference *)collectionWithPath:(NSString *)collectionPath
FIR_SWIFT_NAME(collection(_:));
/**
* Gets a `FIRDocumentReference` referring to the document at the specified path within the
* database.
*
* @param documentPath The slash-separated path of the document for which to get a
* `FIRDocumentReference`.
*
* @return The `FIRDocumentReference` for the specified _documentPath_.
*/
- (FIRDocumentReference *)documentWithPath:(NSString *)documentPath FIR_SWIFT_NAME(document(_:));
#pragma mark - Transactions and Write Batches
/**
* Executes the given updateBlock and then attempts to commit the changes applied within an atomic
* transaction.
*
* In the updateBlock, a set of reads and writes can be performed atomically using the
* `FIRTransaction` object passed to the block. After the updateBlock is run, Firestore will attempt
* to apply the changes to the server. If any of the data read has been modified outside of this
* transaction since being read, then the transaction will be retried by executing the updateBlock
* again. If the transaction still fails after 5 retries, then the transaction will fail.
*
* Since the updateBlock may be executed multiple times, it should avoiding doing anything that
* would cause side effects.
*
* Any value maybe be returned from the updateBlock. If the transaction is successfully committed,
* then the completion block will be passed that value. The updateBlock also has an `NSError` out
* parameter. If this is set, then the transaction will not attempt to commit, and the given error
* will be passed to the completion block.
*
* The `FIRTransaction` object passed to the updateBlock contains methods for accessing documents
* and collections. Unlike other firestore access, data accessed with the transaction will not
* reflect local changes that have not been committed. For this reason, it is required that all
* reads are performed before any writes. Transactions must be performed while online. Otherwise,
* reads will fail, and the final commit will fail.
*
* @param updateBlock The block to execute within the transaction context.
* @param completion The block to call with the result or error of the transaction.
*/
- (void)runTransactionWithBlock:(id _Nullable (^)(FIRTransaction *, NSError **))updateBlock
completion:(void (^)(id _Nullable result, NSError *_Nullable error))completion;
/**
* Creates a write batch, used for performing multiple writes as a single
* atomic operation.
*
* Unlike transactions, write batches are persisted offline and therefore are preferable when you
* don't need to condition your writes on read data.
*/
- (FIRWriteBatch *)batch;
#pragma mark - Logging
/** Enables or disables logging from the Firestore client. */
+ (void)enableLogging:(BOOL)logging
DEPRECATED_MSG_ATTRIBUTE("Use FIRSetLoggerLevel(FIRLoggerLevelDebug) to enable logging");
@end
NS_ASSUME_NONNULL_END
|
#ifndef XInternalListTest_h
#define XInternalListTest_h
#include "framework.h"
//XInternalListTest obviously requires XInternalList
#define STDUTILS_REQUIRES_INTERNAL
class XInternalListTest : public test_fixture
{
public:
TEST_SUITE(XInternalListTest);
TEST(XInternalListTest::TestIterationExternal);
TEST(XInternalListTest::TestIterationInternal);
TEST(XInternalListTest::TestNonPODAndMethodOrdersExternal);
TEST(XInternalListTest::TestNonPODAndMethodOrdersInternal);
TEST(XInternalListTest::TestAppendAndGet);
TEST(XInternalListTest::TestPrependAndGet);
TEST(XInternalListTest::TestAppendListAndSubList);
TEST(XInternalListTest::TestListInsertion);
TEST(XInternalListTest::TestInsertBeforeIterExternal);
TEST(XInternalListTest::TestInsertBeforeIterInternal);
TEST(XInternalListTest::TestPop);
TEST(XInternalListTest::TestContains);
TEST(XInternalListTest::TestRemove);
TEST(XInternalListTest::TestRemoveAtIterExternal);
TEST(XInternalListTest::TestRemoveAtIterInternal);
TEST(XInternalListTest::TestCtorForIterAndBadIter);
TEST(XInternalListTest::TestAllowedOperations);
TEST(XInternalListTest::TestIsSorted);
TEST(XInternalListTest::TestBackwardIterPermissionsExternal);
TEST(XInternalListTest::TestBackwardIterPermissionsInternal);
TEST_SUITE_END();
virtual ~XInternalListTest() throw()
{}
void setup();
void teardown();
protected:
void TestIterationExternal();
void TestIterationInternal();
void TestNonPODAndMethodOrdersExternal();
void TestNonPODAndMethodOrdersInternal();
void TestAppendAndGet();
void TestPrependAndGet();
void TestAppendListAndSubList();
void TestListInsertion();
void TestInsertBeforeIterExternal();
void TestInsertBeforeIterInternal();
void TestInsertSortedAndGet();
void TestPop();
void TestContains();
void TestRemove();
void TestRemoveAtIterExternal();
void TestRemoveAtIterInternal();
void TestCtorForIterAndBadIter();
void TestAllowedOperations();
void TestIsSorted();
void TestBackwardIterPermissionsExternal();
void TestBackwardIterPermissionsInternal();
};
class foo
{
public:
foo(int d = 0)
{
data = d;
}
foo(const foo& obj)
{
copy(obj);
}
virtual ~foo()
{
}
foo& operator =(const foo& obj)
{
return copy(obj);
}
bool operator ==(const foo& obj) const
{
return(obj.data == data) ? true : false;
}
int get() const
{
return data;
}
private:
foo& copy(const foo& obj)
{
data = obj.data; return *this;
}
int data;
};
#endif
|
/*
* Copyright (c) 2017 Fastly, Kazuho Oku
*
* 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.
*/
#include "quicly/maxsender.h"
#include "test.h"
static void test_basic(void)
{
quicly_maxsender_t m;
quicly_maxsender_sent_t ackargs;
quicly_maxsender_init(&m, 100);
/* basic checks */
ok(!quicly_maxsender_should_send_max(&m, 0, 100, 512));
ok(quicly_maxsender_should_send_max(&m, 0, 100, 1024));
ok(!quicly_maxsender_should_send_max(&m, 99, 100, 0));
ok(quicly_maxsender_should_send_max(&m, 100, 100, 0));
/* scenario */
ok(!quicly_maxsender_should_send_max(&m, 24, 100, 768));
ok(quicly_maxsender_should_send_max(&m, 25, 100, 768));
quicly_maxsender_record(&m, 125, &ackargs);
ok(!quicly_maxsender_should_send_max(&m, 49, 100, 768));
ok(quicly_maxsender_should_send_max(&m, 50, 100, 768));
quicly_maxsender_acked(&m, &ackargs);
ok(!quicly_maxsender_should_send_max(&m, 49, 100, 768));
ok(quicly_maxsender_should_send_max(&m, 50, 100, 768));
quicly_maxsender_record(&m, 150, &ackargs);
ok(!quicly_maxsender_should_send_max(&m, 74, 100, 768));
quicly_maxsender_lost(&m, &ackargs);
ok(quicly_maxsender_should_send_max(&m, 74, 100, 768));
}
void test_maxsender(void)
{
subtest("basic", test_basic);
}
|
//
// FirestackDatabase.h
// Firestack
//
// Created by Ari Lerner on 8/23/16.
// Copyright © 2016 Facebook. All rights reserved.
//
#ifndef FirestackDatabase_h
#define FirestackDatabase_h
#import "Firebase.h"
#import "RCTEventEmitter.h"
#import "RCTBridgeModule.h"
@interface FirestackDatabase : RCTEventEmitter <RCTBridgeModule> {
}
@property (nonatomic) NSDictionary *_DBHandles;
@property (nonatomic, weak) FIRDatabaseReference *ref;
@end
#endif
|
// Copyright (c) 2013 Richard Long & HexBeerium
//
// Released under the MIT license ( http://opensource.org/licenses/MIT )
//
#import <SenTestingKit/SenTestingKit.h>
@interface HLMediaTypeUnitTest : SenTestCase {
}
@end
|
// This file was generated based on 'C:\ProgramData\Uno\Packages\Fuse.Animations\0.18.8\$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.Object.h>
namespace g{namespace Fuse{namespace Animations{struct PlayerPart;}}}
namespace g{
namespace Fuse{
namespace Animations{
// internal sealed class PlayerPart :1991
// {
uType* PlayerPart_typeof();
void PlayerPart__ctor__fn(PlayerPart* __this, double* currentProgress);
void PlayerPart__AlterDuration_fn(PlayerPart* __this, double* t, double* timeMult);
void PlayerPart__MarkSource_fn(PlayerPart* __this, bool* isAnimating);
void PlayerPart__New1_fn(double* currentProgress, PlayerPart** __retval);
void PlayerPart__PlayToEnd_fn(PlayerPart* __this);
void PlayerPart__PlayToProgress_fn(PlayerPart* __this, double* progress);
void PlayerPart__PlayToStart_fn(PlayerPart* __this);
void PlayerPart__get_Progress_fn(PlayerPart* __this, double* __retval);
void PlayerPart__SeekProgress_fn(PlayerPart* __this, double* p);
void PlayerPart__Step_fn(PlayerPart* __this, bool* __retval);
void PlayerPart__get_TimeMultiplier_fn(PlayerPart* __this, double* __retval);
struct PlayerPart : uObject
{
double _stepTime;
double _timeMultiplier;
bool Animate;
double Current;
double Duration;
bool IsProgress;
double Source;
double SourceTime;
double Target;
void ctor_(double currentProgress);
void AlterDuration(double t, double timeMult);
void MarkSource(bool isAnimating);
void PlayToEnd();
void PlayToProgress(double progress);
void PlayToStart();
double Progress();
void SeekProgress(double p);
bool Step();
double TimeMultiplier();
static PlayerPart* New1(double currentProgress);
};
// }
}}} // ::g::Fuse::Animations
|
//
// ImojiSDKUI
//
// Created by Nima Khoshini
// Copyright (C) 2015 Imoji
//
// 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.
//
#import <Foundation/Foundation.h>
#import <ImojiSDKUI/IMCollectionViewStatusCell.h>
@interface IMSuggestionLoadingViewCell : IMCollectionViewStatusCell
@end
|
#pragma once
/*
* Copyright (C) 2010-2013 Team XBMC
* http://xbmc.org
*
* 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, 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 XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#import <Cocoa/Cocoa.h>
@interface OSXGLView : NSOpenGLView
{
NSOpenGLContext *m_glcontext;
NSOpenGLPixelFormat *m_pixFmt;
NSTrackingArea *m_trackingArea;
}
- (id)initWithFrame: (NSRect)frameRect;
- (void)dealloc;
- (BOOL)preservesContentDuringLiveResize;
- (NSOpenGLContext *)getGLContext;
@end
|
#ifndef __MT_EMI_MPU_H
#define __MT_EMI_MPU_H
#define EMI_MPUA (EMI_BASE+0x0160)
#define EMI_MPUB (EMI_BASE+0x0168)
#define EMI_MPUC (EMI_BASE+0x0170)
#define EMI_MPUD (EMI_BASE+0x0178)
#define EMI_MPUE (EMI_BASE+0x0180)
#define EMI_MPUF (EMI_BASE+0x0188)
#define EMI_MPUG (EMI_BASE+0x0190)
#define EMI_MPUH (EMI_BASE+0x0198)
#define EMI_MPUI (EMI_BASE+0x01A0)
#define EMI_MPUJ (EMI_BASE+0x01A8)
#define EMI_MPUK (EMI_BASE+0x01B0)
#define EMI_MPUL (EMI_BASE+0x01B8)
#define EMI_MPUM (EMI_BASE+0x01C0)
#define EMI_MPUN (EMI_BASE+0x01C8)
#define EMI_MPUP (EMI_BASE+0x01D8)
#define EMI_MPUQ (EMI_BASE+0x01E0)
#define EMI_MPUS (EMI_BASE+0x01F0)
#define EMI_MPUT (EMI_BASE+0x01F8)
#define EMI_MKEY (EMI_BASE+0x0650)
#define EMI_MPSW (EMI_BASE+0x0658)
#define EMI_MLST (EMI_BASE+0x0660)
#define EMI_DRVA (EMI_BASE+0x0318)
#define EMI_DRVB (EMI_BASE+0x0320)
#define REGION_0_KEY 0x12345678
#define REGION_1_KEY 0x23456788
#define REGION_2_KEY 0x34567898
#define REGION_3_KEY 0x45678908
#define REGION_4_KEY 0x56789018
#define REGION_5_KEY 0x67890128
#define REGION_6_KEY 0x78901238
#define REGION_7_KEY 0x89012348
#define NO_PROTECTION 0
#define SEC_RW 1
#define SEC_RW_NSEC_R 2
#define SEC_RW_NSEC_W 3
#define SEC_R_NSEC_R 4
#define FORBIDDEN 5
#define EN_MPU_STR "ON"
#define DIS_MPU_STR "OFF"
#define TEST_STR "TEST"
/*EMI memory protection align 32K*/
#define EMI_MPU_ALIGNMENT 0x8000
//#define OOR_VIO 0x00000200
#define EMI_PHY_OFFSET 0x80000000
enum
{
/* apmcu */
MST_ID_APMCU_0,
/* periSys */
MST_ID_PERI_0, MST_ID_PERI_1, MST_ID_PERI_2,
/* Modem MCU*/
MST_ID_MDMCU_0, MST_ID_MDMCU_1, MST_ID_MDMCU_2,
/* Modem HW (2G/3G) */
MST_ID_MDHW_0, MST_ID_MDHW_1, MST_ID_MDHW_2, MST_ID_MDHW_3, MST_ID_MDHW_4, MST_ID_MDHW_5, MST_ID_MDHW_6,
/* ConnSYS */
MST_ID_CONNSYS_0,
/* MM */
MST_ID_MM_0, MST_ID_MM_1, MST_ID_MM_2, MST_ID_MM_3,
MST_INVALID,
NR_MST,
};
typedef void (*emi_mpu_notifier)(u32 addr, int wr_vio);
#define SET_ACCESS_PERMISSON(d3, d2, d1, d0) (((d3) << 9) | ((d2) << 6) | ((d1) << 3) | (d0))
extern int emi_mpu_set_region_protection(unsigned int start_addr, unsigned int end_addr, int region, unsigned int access_permission);
extern int emi_mpu_notifier_register(int master, emi_mpu_notifier notifider);
#endif /* !__MT_EMI_MPU_H */
|
/*
* smdk_wm8994.c
*
* 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.
*/
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/io.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <mach/regs-clock.h>
#include "i2s.h"
#include "s3c-i2s-v2.h"
#include "../codecs/wm8994.h"
/*
* Default CFG switch settings to use this driver:
* SMDKV310: CFG5-1000, CFG7-111111
*/
/*
* Configure audio route as :-
* $ amixer sset 'DAC1' on,on
* $ amixer sset 'Right Headphone Mux' 'DAC'
* $ amixer sset 'Left Headphone Mux' 'DAC'
* $ amixer sset 'DAC1R Mixer AIF1.1' on
* $ amixer sset 'DAC1L Mixer AIF1.1' on
* $ amixer sset 'IN2L' on
* $ amixer sset 'IN2L PGA IN2LN' on
* $ amixer sset 'MIXINL IN2L' on
* $ amixer sset 'AIF1ADC1L Mixer ADC/DMIC' on
* $ amixer sset 'IN2R' on
* $ amixer sset 'IN2R PGA IN2RN' on
* $ amixer sset 'MIXINR IN2R' on
* $ amixer sset 'AIF1ADC1R Mixer ADC/DMIC' on
*/
/* SMDK has a 16.934MHZ crystal attached to WM8994 */
#define DEBUG 1
#if DEBUG
#define wm8978_dbg(fmt,arg...) printk("[wm8978:]"fmt"\n",##arg)
#else
#define wm8978_dbg(fmt,arg...)
#endif
static int set_epll_rate(unsigned long rate)
{
struct clk *fout_epll;
wm8978_dbg("%s",__FUNCTION__);
fout_epll = clk_get(NULL, "fout_epll");
if (IS_ERR(fout_epll)) {
printk(KERN_ERR "%s: failed to get fout_epll\n", __func__);
return PTR_ERR(fout_epll);
}
if (rate == clk_get_rate(fout_epll))
goto out;
clk_set_rate(fout_epll, rate);
out:
clk_put(fout_epll);
return 0;
}
static int smdk_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int bfs, psr, rfs, ret;
unsigned long rclk;
wm8978_dbg("%s",__FUNCTION__);
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_U24:
case SNDRV_PCM_FORMAT_S24:
bfs = 48;
break;
case SNDRV_PCM_FORMAT_U16_LE:
case SNDRV_PCM_FORMAT_S16_LE:
bfs = 32;
break;
default:
return -EINVAL;
}
switch (params_rate(params)) {
case 16000:
case 22050:
case 24000:
case 32000:
case 44100:
case 48000:
case 88200:
case 96000:
if (bfs == 48)
rfs = 384;
else
rfs = 256;
break;
case 64000:
rfs = 384;
break;
case 8000:
case 11025:
case 12000:
if (bfs == 48)
rfs = 768;
else
rfs = 512;
break;
default:
return -EINVAL;
}
rclk = params_rate(params) * rfs;
switch (rclk) {
case 4096000:
case 5644800:
case 6144000:
case 8467200:
case 9216000:
psr = 8;
break;
case 8192000:
case 11289600:
case 12288000:
case 16934400:
case 18432000:
psr = 4;
break;
case 22579200:
case 24576000:
case 33868800:
case 36864000:
psr = 2;
break;
case 67737600:
case 73728000:
psr = 1;
break;
default:
printk("Not yet supported!\n");
return -EINVAL;
}
set_epll_rate(rclk * psr);
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBS_CFS);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBS_CFS);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1,
rclk, SND_SOC_CLOCK_IN);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_CDCLK,
0, SND_SOC_CLOCK_OUT);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_clkdiv(cpu_dai, SAMSUNG_I2S_DIV_BCLK, bfs);
if (ret < 0)
return ret;
return 0;
}
/*
* SMDK WM8978 DAI operations.
*/
static struct snd_soc_ops smdk_ops = {
.hw_params = smdk_hw_params,
};
static struct snd_soc_dai_link smdk_dai[] = {
{ /* Primary DAI i/f */
.name = "WM8978 PAIF TX",
.stream_name = "HiFi_Playback",
// .stream_name = "Capture",
.cpu_dai_name = "samsung-i2s.0",
.codec_dai_name = "wm8978_codec",
.platform_name = "samsung-audio",
.codec_name = "wm8978.4-001a",
.ops = &smdk_ops,
},
{ /* Primary DAI i/f */
.name = "WM8978 PAIF RX",
.stream_name = "HiFi_Capture",
// .stream_name = "Capture",
.cpu_dai_name = "samsung-i2s.0",
.codec_dai_name = "wm8978_codec",
.platform_name = "samsung-audio",
.codec_name = "wm8978.4-001a",
.ops = &smdk_ops,
}
};
static struct snd_soc_card smdk = {
.name = "SMDK-I2S",
.dai_link = smdk_dai,
/* If you want to use sec_fifo device,
* changes the num_link = 2 or ARRAY_SIZE(smdk_dai). */
.num_links = ARRAY_SIZE(smdk_dai),
};
static struct platform_device *smdk_snd_device;
static int __init smdk_audio_init(void)
{
int ret;
smdk_snd_device = platform_device_alloc("soc-audio", -1);
if (!smdk_snd_device)
return -ENOMEM;
platform_set_drvdata(smdk_snd_device, &smdk);
wm8978_dbg("%s",__FUNCTION__);
ret = platform_device_add(smdk_snd_device);
if (ret)
platform_device_put(smdk_snd_device);
return ret;
}
module_init(smdk_audio_init);
static void __exit smdk_audio_exit(void)
{
platform_device_unregister(smdk_snd_device);
}
module_exit(smdk_audio_exit);
MODULE_DESCRIPTION("ALSA SoC SMDK WM8994");
MODULE_LICENSE("GPL");
|
/***************************************************************************
* Copyright (C) 2006 by Massimiliano Torromeo *
* [email protected] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef FILELISTER_H
#define FILELISTER_H
#include <string>
#include <vector>
class FileLister {
private:
std::string path, filter;
bool showDirectories, showFiles;
std::vector<std::string> directories, files, excludes;
public:
FileLister(const std::string &startPath = "/boot/local", bool showDirectories = true, bool showFiles = true);
void browse(bool clean = true);
unsigned int size();
unsigned int dirCount();
unsigned int fileCount();
std::string operator[](unsigned int);
std::string at(unsigned int);
bool isFile(unsigned int);
bool isDirectory(unsigned int);
const std::string &getPath();
void setPath(const std::string &path, bool doBrowse=true);
const std::string &getFilter();
void setFilter(const std::string &filter);
const std::vector<std::string> &getDirectories() { return directories; }
const std::vector<std::string> &getFiles() { return files; }
void insertFile(const std::string &file);
void addExclude(const std::string &exclude);
};
#endif // FILELISTER_H
|
///////////////////////////////////////////////////////////////////////////
//
// FILE: textbuf.h
// TextBuffer class
//
// Part of: Scid (Shane's Chess Information Database)
// Version: 2.7
//
// Notice: Copyright (c) 1999-2001 Shane Hudson. All rights reserved.
//
// Author: Shane Hudson ([email protected])
//
///////////////////////////////////////////////////////////////////////////
#ifndef SCID_TEXTBUF_H
#define SCID_TEXTBUF_H
#include "common.h"
#include "error.h"
class TextBuffer
{
private:
//----------------------------------
// TextBuffer: Data Structures
uint Column;
uint IndentColumn;
uint WrapColumn;
uint LineIsEmpty; // true if current line is empty.
uint LineCount;
uint ByteCount;
uint BufferSize;
bool ConvertNewlines; // If true, convert newlines to spaces.
char * Buffer;
char * Current;
bool PausedTranslations;
bool HasTranslations;
const char * Translation [256];
inline void AddChar (char ch);
//----------------------------------
// TextBuffer: Public Functions
public:
TextBuffer() { Init(); }
~TextBuffer() { Free(); }
void Init ();
void Free ();
void Empty ();
void SetBufferSize (uint length);
uint GetBufferSize() { return BufferSize; }
uint GetByteCount() { return ByteCount; }
uint GetLineCount() { return LineCount; }
uint GetColumn() { return Column; }
uint GetWrapColumn () { return WrapColumn; }
void SetWrapColumn (uint column) { WrapColumn = column; }
uint GetIndent () { return IndentColumn; }
void SetIndent (uint column) { IndentColumn = column; }
char * GetBuffer () { return Buffer; }
void NewlinesToSpaces (bool b) { ConvertNewlines = b; }
void AddTranslation (char ch, const char * str);
// void ClearTranslation (char ch) { Translation[ch] = NULL; }
// Changed ch to int, to avoid compiler warnings.
void ClearTranslation (int ch) { Translation[ch] = NULL; }
void ClearTranslations () { HasTranslations = false; }
void PauseTranslations () { PausedTranslations = true; }
void ResumeTranslations () { PausedTranslations = false; }
errorT NewLine();
errorT Indent();
errorT PrintLine (const char * str);
errorT PrintWord (const char * str);
errorT PrintString (const char * str);
errorT PrintSpace ();
errorT PrintChar (char b);
errorT DumpToFile (FILE * fp);
errorT PrintInt (uint i, const char * str);
inline errorT PrintInt (uint i) { return PrintInt (i, ""); }
};
inline void
TextBuffer::AddChar (char ch)
{
if (HasTranslations && !PausedTranslations) {
byte b = (byte) ch;
const char * str = Translation[b];
if (str != NULL) {
const char * s = str;
while (*s) {
*Current++ = *s++;
ByteCount++;
}
return;
}
}
*Current = ch;
Current++;
ByteCount++;
}
#endif // SCID_TEXTBUF_H
///////////////////////////////////////////////////////////////////////////
// EOF: textbuf.h
///////////////////////////////////////////////////////////////////////////
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2007 William Jon McCann <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include "gnome-settings-plugin.h"
#include "gsd-clipboard-plugin.h"
#include "gsd-clipboard-manager.h"
struct GsdClipboardPluginPrivate {
GsdClipboardManager *manager;
};
#define GSD_CLIPBOARD_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_CLIPBOARD_PLUGIN, GsdClipboardPluginPrivate))
GNOME_SETTINGS_PLUGIN_REGISTER (GsdClipboardPlugin, gsd_clipboard_plugin)
static void
gsd_clipboard_plugin_init (GsdClipboardPlugin *plugin)
{
plugin->priv = GSD_CLIPBOARD_PLUGIN_GET_PRIVATE (plugin);
g_debug ("GsdClipboardPlugin initializing");
plugin->priv->manager = gsd_clipboard_manager_new ();
}
static void
gsd_clipboard_plugin_finalize (GObject *object)
{
GsdClipboardPlugin *plugin;
g_return_if_fail (object != NULL);
g_return_if_fail (GSD_IS_CLIPBOARD_PLUGIN (object));
g_debug ("GsdClipboardPlugin finalizing");
plugin = GSD_CLIPBOARD_PLUGIN (object);
g_return_if_fail (plugin->priv != NULL);
if (plugin->priv->manager != NULL) {
g_object_unref (plugin->priv->manager);
}
G_OBJECT_CLASS (gsd_clipboard_plugin_parent_class)->finalize (object);
}
static void
impl_activate (GnomeSettingsPlugin *plugin)
{
gboolean res;
GError *error;
g_debug ("Activating clipboard plugin");
error = NULL;
res = gsd_clipboard_manager_start (GSD_CLIPBOARD_PLUGIN (plugin)->priv->manager, &error);
if (! res) {
g_warning ("Unable to start clipboard manager: %s", error->message);
g_error_free (error);
}
}
static void
impl_deactivate (GnomeSettingsPlugin *plugin)
{
g_debug ("Deactivating clipboard plugin");
gsd_clipboard_manager_stop (GSD_CLIPBOARD_PLUGIN (plugin)->priv->manager);
}
static void
gsd_clipboard_plugin_class_init (GsdClipboardPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
object_class->finalize = gsd_clipboard_plugin_finalize;
plugin_class->activate = impl_activate;
plugin_class->deactivate = impl_deactivate;
g_type_class_add_private (klass, sizeof (GsdClipboardPluginPrivate));
}
|
#ifndef _UMLBASEEXITPOINTPSEUDOSTATE_H
#define _UMLBASEEXITPOINTPSEUDOSTATE_H
#include "UmlPseudoState.h"
#include "anItemKind.h"
#include <q3cstring.h>
class UmlExitPointPseudoState;
class UmlItem;
class UmlBaseExitPointPseudoState : public UmlPseudoState {
public:
// returns a new exit point pseudo state named 's' created under 'parent'
//
// In case it cannot be created (the name is already used or
// invalid, 'parent' cannot contain it etc ...) return 0 in C++
// and produce a RuntimeException in Java
static UmlExitPointPseudoState * create(UmlItem * parent, const char * s);
// returns the kind of the item
virtual anItemKind kind();
// return the the referenced sub machine state or 0/null
// if the state is not a sub machine state reference
UmlExitPointPseudoState * reference();
// set the referenced sub machine state (may be 0/null)
//
// On error return FALSE in C++, produce a RuntimeException in Java
bool set_Reference(UmlExitPointPseudoState * v);
protected:
// the constructor, do not call it yourself !!!!!!!!!!
UmlBaseExitPointPseudoState(void * id, const Q3CString & s) : UmlPseudoState(id, s) {
}
private:
UmlExitPointPseudoState * _reference;
protected:
virtual void read_uml_();
};
#endif
|
/* Copyright (C) 2014 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU 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 General Public License
* version 2 along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* \file
*
* \author Victor Julien <[email protected]>
*/
#ifndef __UTIL_LUA_H__
#define __UTIL_LUA_H__
#ifdef HAVE_LUA
typedef struct LuaStreamingBuffer_ {
const uint8_t *data;
uint32_t data_len;
uint8_t flags;
} LuaStreamingBuffer;
/* gets */
/** \brief get tv pointer from the lua state */
ThreadVars *LuaStateGetThreadVars(lua_State *luastate);
Packet *LuaStateGetPacket(lua_State *luastate);
void *LuaStateGetTX(lua_State *luastate);
/** \brief get flow pointer from lua state
*
* \retval f flow poiner or NULL if it was not set
*/
Flow *LuaStateGetFlow(lua_State *luastate);
PacketAlert *LuaStateGetPacketAlert(lua_State *luastate);
/** \brief get file pointer from the lua state */
File *LuaStateGetFile(lua_State *luastate);
LuaStreamingBuffer *LuaStateGetStreamingBuffer(lua_State *luastate);
int LuaStateGetDirection(lua_State *luastate);
/* sets */
void LuaStateSetPacket(lua_State *luastate, Packet *p);
void LuaStateSetTX(lua_State *luastate, void *tx);
/** \brief set a flow pointer in the lua state
*
* \param f flow pointer
*/
void LuaStateSetFlow(lua_State *luastate, Flow *f);
void LuaStateSetPacketAlert(lua_State *luastate, PacketAlert *pa);
void LuaStateSetFile(lua_State *luastate, File *file);
void LuaStateSetThreadVars(lua_State *luastate, ThreadVars *tv);
void LuaStateSetStreamingBuffer(lua_State *luastate, LuaStreamingBuffer *b);
void LuaStateSetDirection(lua_State *luastate, int direction);
void LuaPrintStack(lua_State *state);
int LuaPushStringBuffer(lua_State *luastate, const uint8_t *input, size_t input_len);
int LuaPushInteger(lua_State *luastate, lua_Integer n);
#endif /* HAVE_LUA */
#endif /* __UTIL_LUA_H__ */
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <xtables.h>
#include <linux/netfilter_ipv6/ip6t_opts.h>
enum {
O_HBH_LEN = 0,
O_HBH_OPTS,
};
static void hbh_help(void)
{
printf(
"hbh match options:\n"
"[!] --hbh-len length total length of this header\n"
" --hbh-opts TYPE[:LEN][,TYPE[:LEN]...] \n"
" Options and its length (list, max: %d)\n",
IP6T_OPTS_OPTSNR);
}
static const struct xt_option_entry hbh_opts[] = {
{.name = "hbh-len", .id = O_HBH_LEN, .type = XTTYPE_UINT32,
.flags = XTOPT_INVERT | XTOPT_PUT,
XTOPT_POINTER(struct ip6t_opts, hdrlen)},
{.name = "hbh-opts", .id = O_HBH_OPTS, .type = XTTYPE_STRING},
XTOPT_TABLEEND,
};
static uint32_t
parse_opts_num(const char *idstr, const char *typestr)
{
unsigned long int id;
char* ep;
id = strtoul(idstr,&ep,0) ;
if ( idstr == ep ) {
xtables_error(PARAMETER_PROBLEM,
"hbh: no valid digits in %s `%s'", typestr, idstr);
}
if ( id == ULONG_MAX && errno == ERANGE ) {
xtables_error(PARAMETER_PROBLEM,
"%s `%s' specified too big: would overflow",
typestr, idstr);
}
if ( *idstr != '\0' && *ep != '\0' ) {
xtables_error(PARAMETER_PROBLEM,
"hbh: error parsing %s `%s'", typestr, idstr);
}
return id;
}
static int
parse_options(const char *optsstr, uint16_t *opts)
{
char *buffer, *cp, *next, *range;
unsigned int i;
buffer = strdup(optsstr);
if (!buffer) xtables_error(OTHER_PROBLEM, "strdup failed");
for (cp=buffer, i=0; cp && i<IP6T_OPTS_OPTSNR; cp=next,i++)
{
next=strchr(cp, ',');
if (next) *next++='\0';
range = strchr(cp, ':');
if (range) {
if (i == IP6T_OPTS_OPTSNR-1)
xtables_error(PARAMETER_PROBLEM,
"too many ports specified");
*range++ = '\0';
}
opts[i] = (parse_opts_num(cp, "opt") & 0xFF) << 8;
if (range) {
if (opts[i] == 0)
xtables_error(PARAMETER_PROBLEM, "PAD0 has not got length");
opts[i] |= parse_opts_num(range, "length") & 0xFF;
} else {
opts[i] |= (0x00FF);
}
#ifdef DEBUG
printf("opts str: %s %s\n", cp, range);
printf("opts opt: %04X\n", opts[i]);
#endif
}
if (cp) xtables_error(PARAMETER_PROBLEM, "too many addresses specified");
free(buffer);
#ifdef DEBUG
printf("addr nr: %d\n", i);
#endif
return i;
}
static void hbh_parse(struct xt_option_call *cb)
{
struct ip6t_opts *optinfo = cb->data;
xtables_option_parse(cb);
switch (cb->entry->id) {
case O_HBH_LEN:
if (cb->invert)
optinfo->invflags |= IP6T_OPTS_INV_LEN;
optinfo->flags |= IP6T_OPTS_LEN;
break;
case O_HBH_OPTS:
optinfo->optsnr = parse_options(cb->arg, optinfo->opts);
optinfo->flags |= IP6T_OPTS_OPTS;
break;
}
}
static void
print_options(unsigned int optsnr, uint16_t *optsp)
{
unsigned int i;
for(i=0; i<optsnr; i++){
printf("%c", (i==0)?' ':',');
printf("%d", (optsp[i] & 0xFF00)>>8);
if ((optsp[i] & 0x00FF) != 0x00FF){
printf(":%d", (optsp[i] & 0x00FF));
}
}
}
static void hbh_print(const void *ip, const struct xt_entry_match *match,
int numeric)
{
const struct ip6t_opts *optinfo = (struct ip6t_opts *)match->data;
printf(" hbh");
if (optinfo->flags & IP6T_OPTS_LEN) {
printf(" length");
printf(":%s", optinfo->invflags & IP6T_OPTS_INV_LEN ? "!" : "");
printf("%u", optinfo->hdrlen);
}
if (optinfo->flags & IP6T_OPTS_OPTS) printf(" opts");
print_options(optinfo->optsnr, (uint16_t *)optinfo->opts);
if (optinfo->invflags & ~IP6T_OPTS_INV_MASK)
printf(" Unknown invflags: 0x%X",
optinfo->invflags & ~IP6T_OPTS_INV_MASK);
}
static void hbh_save(const void *ip, const struct xt_entry_match *match)
{
const struct ip6t_opts *optinfo = (struct ip6t_opts *)match->data;
if (optinfo->flags & IP6T_OPTS_LEN) {
printf("%s --hbh-len %u",
(optinfo->invflags & IP6T_OPTS_INV_LEN) ? " !" : "",
optinfo->hdrlen);
}
if (optinfo->flags & IP6T_OPTS_OPTS)
printf(" --hbh-opts");
print_options(optinfo->optsnr, (uint16_t *)optinfo->opts);
}
static int hbh_xlate(struct xt_xlate *xl,
const struct xt_xlate_mt_params *params)
{
const struct ip6t_opts *optinfo =
(struct ip6t_opts *)params->match->data;
if (!(optinfo->flags & IP6T_OPTS_LEN) ||
(optinfo->flags & IP6T_OPTS_OPTS))
return 0;
xt_xlate_add(xl, "hbh hdrlength %s%u",
(optinfo->invflags & IP6T_OPTS_INV_LEN) ? "!= " : "",
optinfo->hdrlen);
return 1;
}
static struct xtables_match hbh_mt6_reg = {
.name = "hbh",
.version = XTABLES_VERSION,
.family = NFPROTO_IPV6,
.size = XT_ALIGN(sizeof(struct ip6t_opts)),
.userspacesize = XT_ALIGN(sizeof(struct ip6t_opts)),
.help = hbh_help,
.print = hbh_print,
.save = hbh_save,
.x6_parse = hbh_parse,
.x6_options = hbh_opts,
.xlate = hbh_xlate,
};
void
_init(void)
{
xtables_register_match(&hbh_mt6_reg);
}
|
/* PR middle-end/46534 */
extern int printf (const char *, ...);
#define S1 " "
#define S2 S1 S1 S1 S1 S1 S1 S1 S1 S1 S1
#define S3 S2 S2 S2 S2 S2 S2 S2 S2 S2 S2
#define S4 S3 S3 S3 S3 S3 S3 S3 S3 S3 S3
#define S5 S4 S4 S4 S4 S4 S4 S4 S4 S4 S4
#define S6 S5 S5 S5 S5 S5 S5 S5 S5 S5 S5
#define S7 S6 S6 S6 S6 S6 S6 S6 S6 S6 S6
void
foo (void)
{
printf (S7 "\n");
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.