url
stringlengths
12
221
text
stringlengths
176
1.03M
encoding
stringclasses
16 values
confidence
float64
0.7
1
license
stringlengths
0
347
copyright
stringlengths
3
31.8k
gamin-0.1.10/python/gamin.c
/* * gamin.c: glue to the gamin library for access from Python * * See Copyright for the status of this software. * * veillard@redhat.com */ #include <Python.h> #include <fam.h> #include "config.h" #ifdef GAMIN_DEBUG_API int FAMDebug(FAMConnection *fc, const char *filename, FAMRequest * fr, void *userData); #endif void init_gamin(void); static FAMConnection **connections = NULL; static int nb_connections = 0; static int max_connections = 0; static FAMRequest **requests = NULL; static int nb_requests = 0; static int max_requests = 0; static int get_connection(void) { int i; if (connections == NULL) { max_connections = 10; connections = (FAMConnection **) malloc(max_connections * sizeof(FAMConnection *)); if (connections == NULL) { max_connections = 0; return(-1); } memset(connections, 0, max_connections * sizeof(FAMConnection *)); } for (i = 0;i < max_connections;i++) if (connections[i] == NULL) break; if (i >= max_connections) { FAMConnection **tmp; tmp = (FAMConnection **) realloc(connections, max_connections * 2 * sizeof(FAMConnection *)); if (tmp == NULL) return(-1); memset(&tmp[max_connections], 0, max_connections * sizeof(FAMConnection *)); max_connections *= 2; connections = tmp; } connections[i] = (FAMConnection *) malloc(sizeof(FAMConnection)); if (connections[i] == NULL) return(-1); nb_connections++; return(i); } static int release_connection(int no) { if ((no < 0) || (no >= max_connections)) return(-1); if (connections[no] == NULL) return(-1); free(connections[no]); connections[no] = NULL; nb_connections--; return(0); } static FAMConnection * check_connection(int no) { if ((no < 0) || (no >= max_connections)) return(NULL); return(connections[no]); } static int get_request(void) { int i; if (requests == NULL) { max_requests = 10; requests = (FAMRequest **) malloc(max_requests * sizeof(FAMRequest *)); if (requests == NULL) { max_requests = 0; return(-1); } memset(requests, 0, max_requests * sizeof(FAMRequest *)); } for (i = 0;i < max_requests;i++) if (requests[i] == NULL) break; if (i >= max_requests) { FAMRequest **tmp; tmp = (FAMRequest **) realloc(requests, max_requests * 2 * sizeof(FAMRequest *)); if (tmp == NULL) return(-1); memset(&tmp[max_requests], 0, max_requests * sizeof(FAMRequest *)); max_requests *= 2; requests = tmp; } requests[i] = (FAMRequest *) malloc(sizeof(FAMRequest)); if (requests[i] == NULL) return(-1); nb_requests++; return(i); } static int release_request(int no) { if ((no < 0) || (no >= max_requests)) return(-1); if (requests[no] == NULL) return(-1); free(requests[no]); requests[no] = NULL; nb_requests--; return(0); } static FAMRequest * check_request(int no) { if ((no < 0) || (no >= max_requests)) return(NULL); return(requests[no]); } static int fam_connect(void) { int ret; int no = get_connection(); FAMConnection *conn; if (no < 0) return(-1); conn = connections[no]; if (conn == NULL) return(-1); ret = FAMOpen2(conn, "gamin-python"); if (ret < 0) { release_connection(no); return(ret); } return(no); } static int call_internal_callback(PyObject *self, const char *filename, FAMCodes event) { PyObject *ret; if ((self == NULL) || (filename == NULL)) return(-1); /* fprintf(stderr, "call_internal_callback(%p)\n", self); */ ret = PyEval_CallMethod(self, (char *) "_internal_callback", (char *) "(zi)", filename, (int) event); if (ret != NULL) { Py_DECREF(ret); #if 0 } else { fprintf(stderr, "call_internal_callback() failed\n"); #endif } return(0); } static PyObject * gamin_Errno(PyObject *self, PyObject * args) { return(PyInt_FromLong(FAMErrno)); } static PyObject * gamin_MonitorConnect(PyObject *self, PyObject * args) { int ret; ret = fam_connect(); if (ret < 0) { return(PyInt_FromLong(-1)); } return(PyInt_FromLong(ret)); } static PyObject * gamin_GetFd(PyObject *self, PyObject * args) { int no; FAMConnection *conn; if (!PyArg_ParseTuple(args, (char *)"i:GetFd", &no)) return(NULL); conn = check_connection(no); if (conn == NULL) { return(PyInt_FromLong(-1)); } return(PyInt_FromLong(FAMCONNECTION_GETFD(conn))); } static PyObject * gamin_MonitorClose(PyObject *self, PyObject * args) { int no; int ret; if (!PyArg_ParseTuple(args, (char *)"i:MonitorClose", &no)) return(NULL); ret = release_connection(no); return(PyInt_FromLong(ret)); } static PyObject * gamin_ProcessOneEvent(PyObject *self, PyObject * args) { int ret; FAMEvent fe; int no; FAMConnection *conn; if (!PyArg_ParseTuple(args, (char *)"i:ProcessOneEvent", &no)) return(NULL); conn = check_connection(no); if (conn == NULL) { return(PyInt_FromLong(-1)); } ret = FAMNextEvent(conn, &fe); if (ret < 0) { return(PyInt_FromLong(-1)); } call_internal_callback(fe.userdata, &fe.filename[0], fe.code); return(PyInt_FromLong(ret)); } static PyObject * gamin_ProcessEvents(PyObject *self, PyObject * args) { int ret; int nb = 0; FAMEvent fe; int no; FAMConnection *conn; if (!PyArg_ParseTuple(args, (char *)"i:ProcessOneEvent", &no)) return(NULL); conn = check_connection(no); if (conn == NULL) { return(PyInt_FromLong(-1)); } do { ret = FAMPending(conn); if (ret < 0) return(PyInt_FromLong(-1)); if (ret == 0) break; ret = FAMNextEvent(conn, &fe); if (ret < 0) return(PyInt_FromLong(-1)); call_internal_callback(fe.userdata, &fe.filename[0], fe.code); nb++; } while (ret >= 0); return(PyInt_FromLong(nb)); } static PyObject * gamin_EventPending(PyObject *self, PyObject * args) { int no; FAMConnection *conn; if (!PyArg_ParseTuple(args, (char *)"i:ProcessOneEvent", &no)) return(NULL); conn = check_connection(no); if (conn == NULL) { return(PyInt_FromLong(-1)); } return(PyInt_FromLong(FAMPending(conn))); } static PyObject * gamin_MonitorNoExists(PyObject *self, PyObject * args) { int no; FAMConnection *conn; if (!PyArg_ParseTuple(args, (char *)"i:MonitorNoExists", &no)) return(NULL); conn = check_connection(no); if (conn == NULL) { return(PyInt_FromLong(-1)); } return(PyInt_FromLong(FAMNoExists(conn))); } static PyObject * gamin_MonitorDirectory(PyObject *self, PyObject * args) { PyObject *userdata; char * filename; int ret; int noreq; int no; FAMConnection *conn; FAMRequest *request; if (!PyArg_ParseTuple(args, (char *)"izO:MonitorDirectory", &no, &filename, &userdata)) return(NULL); conn = check_connection(no); if (conn == NULL) { return(PyInt_FromLong(-1)); } noreq = get_request(); if (noreq < 0) { return(PyInt_FromLong(-1)); } request = check_request(noreq); ret = FAMMonitorDirectory(conn, filename, request, userdata); if (ret < 0) { release_request(noreq); return(PyInt_FromLong(-1)); } return(PyInt_FromLong(noreq)); } static PyObject * gamin_MonitorFile(PyObject *self, PyObject * args) { PyObject *userdata; char * filename; int ret; int noreq; int no; FAMConnection *conn; FAMRequest *request; if (!PyArg_ParseTuple(args, (char *)"izO:MonitorFile", &no, &filename, &userdata)) return(NULL); conn = check_connection(no); if (conn == NULL) { return(PyInt_FromLong(-1)); } noreq = get_request(); if (noreq < 0) { return(PyInt_FromLong(-1)); } request = check_request(noreq); ret = FAMMonitorFile(conn, filename, request, userdata); if (ret < 0) { release_request(noreq); return(PyInt_FromLong(-1)); } return(PyInt_FromLong(noreq)); } static PyObject * gamin_MonitorCancel(PyObject *self, PyObject * args) { int ret; int noreq; int no; FAMConnection *conn; FAMRequest *request; if (!PyArg_ParseTuple(args, (char *)"ii:MonitorCancel", &no, &noreq)) return(NULL); conn = check_connection(no); if (conn == NULL) { return(PyInt_FromLong(-1)); } request = check_request(noreq); if (request == NULL) { return(PyInt_FromLong(-1)); } ret = FAMCancelMonitor(conn, request); if (ret < 0) { release_request(noreq); return(PyInt_FromLong(-1)); } return(PyInt_FromLong(ret)); } #ifdef GAMIN_DEBUG_API static PyObject * gamin_MonitorDebug(PyObject *self, PyObject * args) { PyObject *userdata; char * filename; int ret; int noreq; int no; FAMConnection *conn; FAMRequest *request; if (!PyArg_ParseTuple(args, (char *)"izO:MonitorDebug", &no, &filename, &userdata)) return(NULL); conn = check_connection(no); if (conn == NULL) { return(PyInt_FromLong(-1)); } noreq = get_request(); if (noreq < 0) { return(PyInt_FromLong(-1)); } request = check_request(noreq); ret = FAMDebug(conn, filename, request, userdata); if (ret < 0) { release_request(noreq); return(PyInt_FromLong(-1)); } return(PyInt_FromLong(noreq)); } #endif static PyMethodDef gaminMethods[] = { {(char *)"MonitorConnect", gamin_MonitorConnect, METH_VARARGS, NULL}, {(char *)"MonitorDirectory", gamin_MonitorDirectory, METH_VARARGS, NULL}, {(char *)"MonitorFile", gamin_MonitorFile, METH_VARARGS, NULL}, {(char *)"MonitorCancel", gamin_MonitorCancel, METH_VARARGS, NULL}, {(char *)"MonitorNoExists", gamin_MonitorNoExists, METH_VARARGS, NULL}, {(char *)"EventPending", gamin_EventPending, METH_VARARGS, NULL}, {(char *)"ProcessOneEvent", gamin_ProcessOneEvent, METH_VARARGS, NULL}, {(char *)"ProcessEvents", gamin_ProcessEvents, METH_VARARGS, NULL}, {(char *)"MonitorClose", gamin_MonitorClose, METH_VARARGS, NULL}, {(char *)"GetFd", gamin_GetFd, METH_VARARGS, NULL}, {(char *)"Errno", gamin_Errno, METH_VARARGS, NULL}, #ifdef GAMIN_DEBUG_API {(char *)"MonitorDebug", gamin_MonitorDebug, METH_VARARGS, NULL}, #endif {NULL, NULL, 0, NULL} }; void init_gamin(void) { static int initialized = 0; if (initialized != 0) return; /* intialize the python extension module */ Py_InitModule((char *) "_gamin", gaminMethods); initialized = 1; }
utf-8
1
unknown
unknown
pgbackrest-2.37/src/command/backup/common.h
/*********************************************************************************************************************************** Common Functions and Definitions for Backup and Expire Commands ***********************************************************************************************************************************/ #ifndef COMMAND_BACKUP_COMMON_H #define COMMAND_BACKUP_COMMON_H #include <stdbool.h> #include <time.h> #include "common/type/string.h" #include "info/infoBackup.h" /*********************************************************************************************************************************** Backup constants ***********************************************************************************************************************************/ #define BACKUP_PATH_HISTORY "backup.history" /*********************************************************************************************************************************** Functions ***********************************************************************************************************************************/ // Format a backup label from a type and timestamp with an optional prior label String *backupLabelFormat(BackupType type, const String *backupLabelPrior, time_t timestamp); // Returns an anchored regex string for filtering backups based on the type (at least one type is required to be true) typedef struct BackupRegExpParam { bool full; bool differential; bool incremental; bool noAnchorEnd; } BackupRegExpParam; #define backupRegExpP(...) \ backupRegExp((BackupRegExpParam){__VA_ARGS__}) String *backupRegExp(BackupRegExpParam param); // Create a symlink to the specified backup (if symlinks are supported) void backupLinkLatest(const String *backupLabel, unsigned int repoIdx); #endif
utf-8
1
MIT
2015-2020 The PostgreSQL Global Development Group 2013-2020 David Steele
linux-5.16.7/drivers/media/usb/gspca/m5602/m5602_ov7660.h
/* SPDX-License-Identifier: GPL-2.0-only */ /* * Driver for the ov7660 sensor * * Copyright (C) 2009 Erik Andrén * Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project. * Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br> * * Portions of code to USB interface and ALi driver software, * Copyright (c) 2006 Willem Duinker * v4l2 interface modeled after the V4L2 driver * for SN9C10x PC Camera Controllers */ #ifndef M5602_OV7660_H_ #define M5602_OV7660_H_ #include "m5602_sensor.h" #define OV7660_GAIN 0x00 #define OV7660_BLUE_GAIN 0x01 #define OV7660_RED_GAIN 0x02 #define OV7660_VREF 0x03 #define OV7660_COM1 0x04 #define OV7660_BAVE 0x05 #define OV7660_GEAVE 0x06 #define OV7660_AECHH 0x07 #define OV7660_RAVE 0x08 #define OV7660_COM2 0x09 #define OV7660_PID 0x0a #define OV7660_VER 0x0b #define OV7660_COM3 0x0c #define OV7660_COM4 0x0d #define OV7660_COM5 0x0e #define OV7660_COM6 0x0f #define OV7660_AECH 0x10 #define OV7660_CLKRC 0x11 #define OV7660_COM7 0x12 #define OV7660_COM8 0x13 #define OV7660_COM9 0x14 #define OV7660_COM10 0x15 #define OV7660_RSVD16 0x16 #define OV7660_HSTART 0x17 #define OV7660_HSTOP 0x18 #define OV7660_VSTART 0x19 #define OV7660_VSTOP 0x1a #define OV7660_PSHFT 0x1b #define OV7660_MIDH 0x1c #define OV7660_MIDL 0x1d #define OV7660_MVFP 0x1e #define OV7660_LAEC 0x1f #define OV7660_BOS 0x20 #define OV7660_GBOS 0x21 #define OV7660_GROS 0x22 #define OV7660_ROS 0x23 #define OV7660_AEW 0x24 #define OV7660_AEB 0x25 #define OV7660_VPT 0x26 #define OV7660_BBIAS 0x27 #define OV7660_GbBIAS 0x28 #define OV7660_RSVD29 0x29 #define OV7660_RBIAS 0x2c #define OV7660_HREF 0x32 #define OV7660_ADC 0x37 #define OV7660_OFON 0x39 #define OV7660_TSLB 0x3a #define OV7660_COM12 0x3c #define OV7660_COM13 0x3d #define OV7660_LCC1 0x62 #define OV7660_LCC2 0x63 #define OV7660_LCC3 0x64 #define OV7660_LCC4 0x65 #define OV7660_LCC5 0x66 #define OV7660_HV 0x69 #define OV7660_RSVDA1 0xa1 #define OV7660_DEFAULT_GAIN 0x0e #define OV7660_DEFAULT_RED_GAIN 0x80 #define OV7660_DEFAULT_BLUE_GAIN 0x80 #define OV7660_DEFAULT_SATURATION 0x00 #define OV7660_DEFAULT_EXPOSURE 0x20 /* Kernel module parameters */ extern int force_sensor; extern bool dump_sensor; int ov7660_probe(struct sd *sd); int ov7660_init(struct sd *sd); int ov7660_init_controls(struct sd *sd); int ov7660_start(struct sd *sd); int ov7660_stop(struct sd *sd); void ov7660_disconnect(struct sd *sd); static const struct m5602_sensor ov7660 = { .name = "ov7660", .i2c_slave_id = 0x42, .i2c_regW = 1, .probe = ov7660_probe, .init = ov7660_init, .init_controls = ov7660_init_controls, .start = ov7660_start, .stop = ov7660_stop, .disconnect = ov7660_disconnect, }; #endif
utf-8
1
GPL-2
1991-2012 Linus Torvalds and many others
barrier-2.4.0+dfsg/src/lib/platform/synwinhk.h
/* * barrier -- mouse and keyboard sharing utility * Copyright (C) 2018 Debauchee Open Source Group * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2002 Chris Schoeneman * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file LICENSE that should have accompanied this file. * * This package is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include "base/EventTypes.h" #define WIN32_LEAN_AND_MEAN #include <Windows.h> #if defined(synwinhk_EXPORTS) #define CBARRIERHOOK_API __declspec(dllexport) #else #define CBARRIERHOOK_API __declspec(dllimport) #endif #define BARRIER_MSG_MARK WM_APP + 0x0011 // mark id; <unused> #define BARRIER_MSG_KEY WM_APP + 0x0012 // vk code; key data #define BARRIER_MSG_MOUSE_BUTTON WM_APP + 0x0013 // button msg; <unused> #define BARRIER_MSG_MOUSE_WHEEL WM_APP + 0x0014 // delta; <unused> #define BARRIER_MSG_MOUSE_MOVE WM_APP + 0x0015 // x; y #define BARRIER_MSG_POST_WARP WM_APP + 0x0016 // <unused>; <unused> #define BARRIER_MSG_PRE_WARP WM_APP + 0x0017 // x; y #define BARRIER_MSG_SCREEN_SAVER WM_APP + 0x0018 // activated; <unused> #define BARRIER_MSG_DEBUG WM_APP + 0x0019 // data, data #define BARRIER_MSG_INPUT_FIRST BARRIER_MSG_KEY #define BARRIER_MSG_INPUT_LAST BARRIER_MSG_PRE_WARP #define BARRIER_HOOK_LAST_MSG BARRIER_MSG_DEBUG #define BARRIER_HOOK_FAKE_INPUT_VIRTUAL_KEY VK_CANCEL #define BARRIER_HOOK_FAKE_INPUT_SCANCODE 0 extern "C" { enum EHookMode { kHOOK_DISABLE, kHOOK_WATCH_JUMP_ZONE, kHOOK_RELAY_EVENTS }; /* REMOVED ImmuneKeys for migration of synwinhk out of DLL typedef void (*SetImmuneKeysFunc)(const DWORD*, std::size_t); // do not call setImmuneKeys() while the hooks are active! CBARRIERHOOK_API void setImmuneKeys(const DWORD *list, std::size_t size); */ }
utf-8
1
GPL-2 with OpenSSL exception
2002-2014 Chris Schoeneman <crs23@users.sourceforge.net> 2008-2014 Nick Bolton <nick@symless.com> 2012-2016 Symless Ltd. 2018-2021 Debauchee Open Source Group 2021 Povilas Kanapickas <povilas@radix.lt>
linux-5.16.7/arch/arm/mach-davinci/devices-da8xx.c
// SPDX-License-Identifier: GPL-2.0-or-later /* * DA8XX/OMAP L1XX platform device data * * Copyright (c) 2007-2009, MontaVista Software, Inc. <source@mvista.com> * Derived from code that was: * Copyright (C) 2006 Komal Shah <komal_shah802003@yahoo.com> */ #include <linux/ahci_platform.h> #include <linux/clk-provider.h> #include <linux/clk.h> #include <linux/clkdev.h> #include <linux/dma-map-ops.h> #include <linux/dmaengine.h> #include <linux/init.h> #include <linux/io.h> #include <linux/platform_device.h> #include <linux/reboot.h> #include <linux/serial_8250.h> #include <mach/common.h> #include <mach/cputype.h> #include <mach/da8xx.h> #include "asp.h" #include "cpuidle.h" #include "irqs.h" #include "sram.h" #define DA8XX_TPCC_BASE 0x01c00000 #define DA8XX_TPTC0_BASE 0x01c08000 #define DA8XX_TPTC1_BASE 0x01c08400 #define DA8XX_WDOG_BASE 0x01c21000 /* DA8XX_TIMER64P1_BASE */ #define DA8XX_I2C0_BASE 0x01c22000 #define DA8XX_RTC_BASE 0x01c23000 #define DA8XX_PRUSS_MEM_BASE 0x01c30000 #define DA8XX_MMCSD0_BASE 0x01c40000 #define DA8XX_SPI0_BASE 0x01c41000 #define DA830_SPI1_BASE 0x01e12000 #define DA8XX_LCD_CNTRL_BASE 0x01e13000 #define DA850_SATA_BASE 0x01e18000 #define DA850_MMCSD1_BASE 0x01e1b000 #define DA8XX_EMAC_CPPI_PORT_BASE 0x01e20000 #define DA8XX_EMAC_CPGMACSS_BASE 0x01e22000 #define DA8XX_EMAC_CPGMAC_BASE 0x01e23000 #define DA8XX_EMAC_MDIO_BASE 0x01e24000 #define DA8XX_I2C1_BASE 0x01e28000 #define DA850_TPCC1_BASE 0x01e30000 #define DA850_TPTC2_BASE 0x01e38000 #define DA850_SPI1_BASE 0x01f0e000 #define DA8XX_DDR2_CTL_BASE 0xb0000000 #define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000 #define DA8XX_EMAC_MOD_REG_OFFSET 0x2000 #define DA8XX_EMAC_RAM_OFFSET 0x0000 #define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K void __iomem *da8xx_syscfg0_base; void __iomem *da8xx_syscfg1_base; static struct plat_serial8250_port da8xx_serial0_pdata[] = { { .mapbase = DA8XX_UART0_BASE, .irq = DAVINCI_INTC_IRQ(IRQ_DA8XX_UARTINT0), .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, .iotype = UPIO_MEM, .regshift = 2, }, { .flags = 0, } }; static struct plat_serial8250_port da8xx_serial1_pdata[] = { { .mapbase = DA8XX_UART1_BASE, .irq = DAVINCI_INTC_IRQ(IRQ_DA8XX_UARTINT1), .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, .iotype = UPIO_MEM, .regshift = 2, }, { .flags = 0, } }; static struct plat_serial8250_port da8xx_serial2_pdata[] = { { .mapbase = DA8XX_UART2_BASE, .irq = DAVINCI_INTC_IRQ(IRQ_DA8XX_UARTINT2), .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, .iotype = UPIO_MEM, .regshift = 2, }, { .flags = 0, } }; struct platform_device da8xx_serial_device[] = { { .name = "serial8250", .id = PLAT8250_DEV_PLATFORM, .dev = { .platform_data = da8xx_serial0_pdata, } }, { .name = "serial8250", .id = PLAT8250_DEV_PLATFORM1, .dev = { .platform_data = da8xx_serial1_pdata, } }, { .name = "serial8250", .id = PLAT8250_DEV_PLATFORM2, .dev = { .platform_data = da8xx_serial2_pdata, } }, { } }; static s8 da8xx_queue_priority_mapping[][2] = { /* {event queue no, Priority} */ {0, 3}, {1, 7}, {-1, -1} }; static s8 da850_queue_priority_mapping[][2] = { /* {event queue no, Priority} */ {0, 3}, {-1, -1} }; static struct edma_soc_info da8xx_edma0_pdata = { .queue_priority_mapping = da8xx_queue_priority_mapping, .default_queue = EVENTQ_1, }; static struct edma_soc_info da850_edma1_pdata = { .queue_priority_mapping = da850_queue_priority_mapping, .default_queue = EVENTQ_0, }; static struct resource da8xx_edma0_resources[] = { { .name = "edma3_cc", .start = DA8XX_TPCC_BASE, .end = DA8XX_TPCC_BASE + SZ_32K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma3_tc0", .start = DA8XX_TPTC0_BASE, .end = DA8XX_TPTC0_BASE + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma3_tc1", .start = DA8XX_TPTC1_BASE, .end = DA8XX_TPTC1_BASE + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma3_ccint", .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_CCINT0), .flags = IORESOURCE_IRQ, }, { .name = "edma3_ccerrint", .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_CCERRINT), .flags = IORESOURCE_IRQ, }, }; static struct resource da850_edma1_resources[] = { { .name = "edma3_cc", .start = DA850_TPCC1_BASE, .end = DA850_TPCC1_BASE + SZ_32K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma3_tc0", .start = DA850_TPTC2_BASE, .end = DA850_TPTC2_BASE + SZ_1K - 1, .flags = IORESOURCE_MEM, }, { .name = "edma3_ccint", .start = DAVINCI_INTC_IRQ(IRQ_DA850_CCINT1), .flags = IORESOURCE_IRQ, }, { .name = "edma3_ccerrint", .start = DAVINCI_INTC_IRQ(IRQ_DA850_CCERRINT1), .flags = IORESOURCE_IRQ, }, }; static const struct platform_device_info da8xx_edma0_device __initconst = { .name = "edma", .id = 0, .dma_mask = DMA_BIT_MASK(32), .res = da8xx_edma0_resources, .num_res = ARRAY_SIZE(da8xx_edma0_resources), .data = &da8xx_edma0_pdata, .size_data = sizeof(da8xx_edma0_pdata), }; static const struct platform_device_info da850_edma1_device __initconst = { .name = "edma", .id = 1, .dma_mask = DMA_BIT_MASK(32), .res = da850_edma1_resources, .num_res = ARRAY_SIZE(da850_edma1_resources), .data = &da850_edma1_pdata, .size_data = sizeof(da850_edma1_pdata), }; static const struct dma_slave_map da830_edma_map[] = { { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 0) }, { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 1) }, { "davinci-mcasp.1", "rx", EDMA_FILTER_PARAM(0, 2) }, { "davinci-mcasp.1", "tx", EDMA_FILTER_PARAM(0, 3) }, { "davinci-mcasp.2", "rx", EDMA_FILTER_PARAM(0, 4) }, { "davinci-mcasp.2", "tx", EDMA_FILTER_PARAM(0, 5) }, { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 14) }, { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 15) }, { "da830-mmc.0", "rx", EDMA_FILTER_PARAM(0, 16) }, { "da830-mmc.0", "tx", EDMA_FILTER_PARAM(0, 17) }, { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 18) }, { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 19) }, }; int __init da830_register_edma(struct edma_rsv_info *rsv) { struct platform_device *edma_pdev; da8xx_edma0_pdata.rsv = rsv; da8xx_edma0_pdata.slave_map = da830_edma_map; da8xx_edma0_pdata.slavecnt = ARRAY_SIZE(da830_edma_map); edma_pdev = platform_device_register_full(&da8xx_edma0_device); return PTR_ERR_OR_ZERO(edma_pdev); } static const struct dma_slave_map da850_edma0_map[] = { { "davinci-mcasp.0", "rx", EDMA_FILTER_PARAM(0, 0) }, { "davinci-mcasp.0", "tx", EDMA_FILTER_PARAM(0, 1) }, { "davinci-mcbsp.0", "rx", EDMA_FILTER_PARAM(0, 2) }, { "davinci-mcbsp.0", "tx", EDMA_FILTER_PARAM(0, 3) }, { "davinci-mcbsp.1", "rx", EDMA_FILTER_PARAM(0, 4) }, { "davinci-mcbsp.1", "tx", EDMA_FILTER_PARAM(0, 5) }, { "spi_davinci.0", "rx", EDMA_FILTER_PARAM(0, 14) }, { "spi_davinci.0", "tx", EDMA_FILTER_PARAM(0, 15) }, { "da830-mmc.0", "rx", EDMA_FILTER_PARAM(0, 16) }, { "da830-mmc.0", "tx", EDMA_FILTER_PARAM(0, 17) }, { "spi_davinci.1", "rx", EDMA_FILTER_PARAM(0, 18) }, { "spi_davinci.1", "tx", EDMA_FILTER_PARAM(0, 19) }, }; static const struct dma_slave_map da850_edma1_map[] = { { "da830-mmc.1", "rx", EDMA_FILTER_PARAM(1, 28) }, { "da830-mmc.1", "tx", EDMA_FILTER_PARAM(1, 29) }, }; int __init da850_register_edma(struct edma_rsv_info *rsv[2]) { struct platform_device *edma_pdev; if (rsv) { da8xx_edma0_pdata.rsv = rsv[0]; da850_edma1_pdata.rsv = rsv[1]; } da8xx_edma0_pdata.slave_map = da850_edma0_map; da8xx_edma0_pdata.slavecnt = ARRAY_SIZE(da850_edma0_map); edma_pdev = platform_device_register_full(&da8xx_edma0_device); if (IS_ERR(edma_pdev)) { pr_warn("%s: Failed to register eDMA0\n", __func__); return PTR_ERR(edma_pdev); } da850_edma1_pdata.slave_map = da850_edma1_map; da850_edma1_pdata.slavecnt = ARRAY_SIZE(da850_edma1_map); edma_pdev = platform_device_register_full(&da850_edma1_device); return PTR_ERR_OR_ZERO(edma_pdev); } static struct resource da8xx_i2c_resources0[] = { { .start = DA8XX_I2C0_BASE, .end = DA8XX_I2C0_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT0), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT0), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da8xx_i2c_device0 = { .name = "i2c_davinci", .id = 1, .num_resources = ARRAY_SIZE(da8xx_i2c_resources0), .resource = da8xx_i2c_resources0, }; static struct resource da8xx_i2c_resources1[] = { { .start = DA8XX_I2C1_BASE, .end = DA8XX_I2C1_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT1), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_I2CINT1), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da8xx_i2c_device1 = { .name = "i2c_davinci", .id = 2, .num_resources = ARRAY_SIZE(da8xx_i2c_resources1), .resource = da8xx_i2c_resources1, }; int __init da8xx_register_i2c(int instance, struct davinci_i2c_platform_data *pdata) { struct platform_device *pdev; if (instance == 0) pdev = &da8xx_i2c_device0; else if (instance == 1) pdev = &da8xx_i2c_device1; else return -EINVAL; pdev->dev.platform_data = pdata; return platform_device_register(pdev); } static struct resource da8xx_watchdog_resources[] = { { .start = DA8XX_WDOG_BASE, .end = DA8XX_WDOG_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, }; static struct platform_device da8xx_wdt_device = { .name = "davinci-wdt", .id = -1, .num_resources = ARRAY_SIZE(da8xx_watchdog_resources), .resource = da8xx_watchdog_resources, }; int __init da8xx_register_watchdog(void) { return platform_device_register(&da8xx_wdt_device); } static struct resource da8xx_emac_resources[] = { { .start = DA8XX_EMAC_CPPI_PORT_BASE, .end = DA8XX_EMAC_CPPI_PORT_BASE + SZ_16K - 1, .flags = IORESOURCE_MEM, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_THRESH_PULSE), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_THRESH_PULSE), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_PULSE), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_RX_PULSE), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_TX_PULSE), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_TX_PULSE), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_MISC_PULSE), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_C0_MISC_PULSE), .flags = IORESOURCE_IRQ, }, }; struct emac_platform_data da8xx_emac_pdata = { .ctrl_reg_offset = DA8XX_EMAC_CTRL_REG_OFFSET, .ctrl_mod_reg_offset = DA8XX_EMAC_MOD_REG_OFFSET, .ctrl_ram_offset = DA8XX_EMAC_RAM_OFFSET, .ctrl_ram_size = DA8XX_EMAC_CTRL_RAM_SIZE, .version = EMAC_VERSION_2, }; static struct platform_device da8xx_emac_device = { .name = "davinci_emac", .id = 1, .dev = { .platform_data = &da8xx_emac_pdata, }, .num_resources = ARRAY_SIZE(da8xx_emac_resources), .resource = da8xx_emac_resources, }; static struct resource da8xx_mdio_resources[] = { { .start = DA8XX_EMAC_MDIO_BASE, .end = DA8XX_EMAC_MDIO_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, }; static struct platform_device da8xx_mdio_device = { .name = "davinci_mdio", .id = 0, .num_resources = ARRAY_SIZE(da8xx_mdio_resources), .resource = da8xx_mdio_resources, }; int __init da8xx_register_emac(void) { int ret; ret = platform_device_register(&da8xx_mdio_device); if (ret < 0) return ret; return platform_device_register(&da8xx_emac_device); } static struct resource da830_mcasp1_resources[] = { { .name = "mpu", .start = DAVINCI_DA830_MCASP1_REG_BASE, .end = DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1, .flags = IORESOURCE_MEM, }, /* TX event */ { .name = "tx", .start = DAVINCI_DA830_DMA_MCASP1_AXEVT, .end = DAVINCI_DA830_DMA_MCASP1_AXEVT, .flags = IORESOURCE_DMA, }, /* RX event */ { .name = "rx", .start = DAVINCI_DA830_DMA_MCASP1_AREVT, .end = DAVINCI_DA830_DMA_MCASP1_AREVT, .flags = IORESOURCE_DMA, }, { .name = "common", .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MCASPINT), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da830_mcasp1_device = { .name = "davinci-mcasp", .id = 1, .num_resources = ARRAY_SIZE(da830_mcasp1_resources), .resource = da830_mcasp1_resources, }; static struct resource da830_mcasp2_resources[] = { { .name = "mpu", .start = DAVINCI_DA830_MCASP2_REG_BASE, .end = DAVINCI_DA830_MCASP2_REG_BASE + (SZ_1K * 12) - 1, .flags = IORESOURCE_MEM, }, /* TX event */ { .name = "tx", .start = DAVINCI_DA830_DMA_MCASP2_AXEVT, .end = DAVINCI_DA830_DMA_MCASP2_AXEVT, .flags = IORESOURCE_DMA, }, /* RX event */ { .name = "rx", .start = DAVINCI_DA830_DMA_MCASP2_AREVT, .end = DAVINCI_DA830_DMA_MCASP2_AREVT, .flags = IORESOURCE_DMA, }, { .name = "common", .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MCASPINT), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da830_mcasp2_device = { .name = "davinci-mcasp", .id = 2, .num_resources = ARRAY_SIZE(da830_mcasp2_resources), .resource = da830_mcasp2_resources, }; static struct resource da850_mcasp_resources[] = { { .name = "mpu", .start = DAVINCI_DA8XX_MCASP0_REG_BASE, .end = DAVINCI_DA8XX_MCASP0_REG_BASE + (SZ_1K * 12) - 1, .flags = IORESOURCE_MEM, }, /* TX event */ { .name = "tx", .start = DAVINCI_DA8XX_DMA_MCASP0_AXEVT, .end = DAVINCI_DA8XX_DMA_MCASP0_AXEVT, .flags = IORESOURCE_DMA, }, /* RX event */ { .name = "rx", .start = DAVINCI_DA8XX_DMA_MCASP0_AREVT, .end = DAVINCI_DA8XX_DMA_MCASP0_AREVT, .flags = IORESOURCE_DMA, }, { .name = "common", .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MCASPINT), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da850_mcasp_device = { .name = "davinci-mcasp", .id = 0, .num_resources = ARRAY_SIZE(da850_mcasp_resources), .resource = da850_mcasp_resources, }; void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata) { struct platform_device *pdev; switch (id) { case 0: /* Valid for DA830/OMAP-L137 or DA850/OMAP-L138 */ pdev = &da850_mcasp_device; break; case 1: /* Valid for DA830/OMAP-L137 only */ if (!cpu_is_davinci_da830()) return; pdev = &da830_mcasp1_device; break; case 2: /* Valid for DA830/OMAP-L137 only */ if (!cpu_is_davinci_da830()) return; pdev = &da830_mcasp2_device; break; default: return; } pdev->dev.platform_data = pdata; platform_device_register(pdev); } static struct resource da8xx_pruss_resources[] = { { .start = DA8XX_PRUSS_MEM_BASE, .end = DA8XX_PRUSS_MEM_BASE + 0xFFFF, .flags = IORESOURCE_MEM, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT0), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT0), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT1), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT1), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT2), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT2), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT3), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT3), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT4), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT4), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT5), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT5), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT6), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT6), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT7), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_EVTOUT7), .flags = IORESOURCE_IRQ, }, }; static struct uio_pruss_pdata da8xx_uio_pruss_pdata = { .pintc_base = 0x4000, }; static struct platform_device da8xx_uio_pruss_dev = { .name = "pruss_uio", .id = -1, .num_resources = ARRAY_SIZE(da8xx_pruss_resources), .resource = da8xx_pruss_resources, .dev = { .coherent_dma_mask = DMA_BIT_MASK(32), .platform_data = &da8xx_uio_pruss_pdata, } }; int __init da8xx_register_uio_pruss(void) { da8xx_uio_pruss_pdata.sram_pool = sram_get_gen_pool(); return platform_device_register(&da8xx_uio_pruss_dev); } static struct lcd_ctrl_config lcd_cfg = { .panel_shade = COLOR_ACTIVE, .bpp = 16, }; struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = { .manu_name = "sharp", .controller_data = &lcd_cfg, .type = "Sharp_LCD035Q3DG01", }; struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata = { .manu_name = "sharp", .controller_data = &lcd_cfg, .type = "Sharp_LK043T1DG01", }; static struct resource da8xx_lcdc_resources[] = { [0] = { /* registers */ .start = DA8XX_LCD_CNTRL_BASE, .end = DA8XX_LCD_CNTRL_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, [1] = { /* interrupt */ .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_LCDINT), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_LCDINT), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da8xx_lcdc_device = { .name = "da8xx_lcdc", .id = 0, .num_resources = ARRAY_SIZE(da8xx_lcdc_resources), .resource = da8xx_lcdc_resources, .dev = { .coherent_dma_mask = DMA_BIT_MASK(32), } }; int __init da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata) { da8xx_lcdc_device.dev.platform_data = pdata; return platform_device_register(&da8xx_lcdc_device); } static struct resource da8xx_gpio_resources[] = { { /* registers */ .start = DA8XX_GPIO_BASE, .end = DA8XX_GPIO_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { /* interrupt */ .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO0), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO0), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO1), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO1), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO2), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO2), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO3), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO3), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO4), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO4), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO5), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO5), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO6), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO6), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO7), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO7), .flags = IORESOURCE_IRQ, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO8), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_GPIO8), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da8xx_gpio_device = { .name = "davinci_gpio", .id = -1, .num_resources = ARRAY_SIZE(da8xx_gpio_resources), .resource = da8xx_gpio_resources, }; int __init da8xx_register_gpio(void *pdata) { da8xx_gpio_device.dev.platform_data = pdata; return platform_device_register(&da8xx_gpio_device); } static struct resource da8xx_mmcsd0_resources[] = { { /* registers */ .start = DA8XX_MMCSD0_BASE, .end = DA8XX_MMCSD0_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { /* interrupt */ .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_MMCSDINT0), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_MMCSDINT0), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da8xx_mmcsd0_device = { .name = "da830-mmc", .id = 0, .num_resources = ARRAY_SIZE(da8xx_mmcsd0_resources), .resource = da8xx_mmcsd0_resources, }; int __init da8xx_register_mmcsd0(struct davinci_mmc_config *config) { da8xx_mmcsd0_device.dev.platform_data = config; return platform_device_register(&da8xx_mmcsd0_device); } #ifdef CONFIG_ARCH_DAVINCI_DA850 static struct resource da850_mmcsd1_resources[] = { { /* registers */ .start = DA850_MMCSD1_BASE, .end = DA850_MMCSD1_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { /* interrupt */ .start = DAVINCI_INTC_IRQ(IRQ_DA850_MMCSDINT0_1), .end = DAVINCI_INTC_IRQ(IRQ_DA850_MMCSDINT0_1), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da850_mmcsd1_device = { .name = "da830-mmc", .id = 1, .num_resources = ARRAY_SIZE(da850_mmcsd1_resources), .resource = da850_mmcsd1_resources, }; int __init da850_register_mmcsd1(struct davinci_mmc_config *config) { da850_mmcsd1_device.dev.platform_data = config; return platform_device_register(&da850_mmcsd1_device); } #endif static struct resource da8xx_rproc_resources[] = { { /* DSP boot address */ .name = "host1cfg", .start = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG, .end = DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG + 3, .flags = IORESOURCE_MEM, }, { /* DSP interrupt registers */ .name = "chipsig", .start = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG, .end = DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG + 7, .flags = IORESOURCE_MEM, }, { /* DSP L2 RAM */ .name = "l2sram", .start = DA8XX_DSP_L2_RAM_BASE, .end = DA8XX_DSP_L2_RAM_BASE + SZ_256K - 1, .flags = IORESOURCE_MEM, }, { /* DSP L1P RAM */ .name = "l1pram", .start = DA8XX_DSP_L1P_RAM_BASE, .end = DA8XX_DSP_L1P_RAM_BASE + SZ_32K - 1, .flags = IORESOURCE_MEM, }, { /* DSP L1D RAM */ .name = "l1dram", .start = DA8XX_DSP_L1D_RAM_BASE, .end = DA8XX_DSP_L1D_RAM_BASE + SZ_32K - 1, .flags = IORESOURCE_MEM, }, { /* dsp irq */ .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_CHIPINT0), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_CHIPINT0), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da8xx_dsp = { .name = "davinci-rproc", .dev = { .coherent_dma_mask = DMA_BIT_MASK(32), }, .num_resources = ARRAY_SIZE(da8xx_rproc_resources), .resource = da8xx_rproc_resources, }; static bool rproc_mem_inited __initdata; #if IS_ENABLED(CONFIG_DA8XX_REMOTEPROC) static phys_addr_t rproc_base __initdata; static unsigned long rproc_size __initdata; static int __init early_rproc_mem(char *p) { char *endp; if (p == NULL) return 0; rproc_size = memparse(p, &endp); if (*endp == '@') rproc_base = memparse(endp + 1, NULL); return 0; } early_param("rproc_mem", early_rproc_mem); void __init da8xx_rproc_reserve_cma(void) { struct cma *cma; int ret; if (!rproc_base || !rproc_size) { pr_err("%s: 'rproc_mem=nn@address' badly specified\n" " 'nn' and 'address' must both be non-zero\n", __func__); return; } pr_info("%s: reserving 0x%lx @ 0x%lx...\n", __func__, rproc_size, (unsigned long)rproc_base); ret = dma_contiguous_reserve_area(rproc_size, rproc_base, 0, &cma, true); if (ret) { pr_err("%s: dma_contiguous_reserve_area failed %d\n", __func__, ret); return; } da8xx_dsp.dev.cma_area = cma; rproc_mem_inited = true; } #else void __init da8xx_rproc_reserve_cma(void) { } #endif int __init da8xx_register_rproc(void) { int ret; if (!rproc_mem_inited) { pr_warn("%s: memory not reserved for DSP, not registering DSP device\n", __func__); return -ENOMEM; } ret = platform_device_register(&da8xx_dsp); if (ret) pr_err("%s: can't register DSP device: %d\n", __func__, ret); return ret; }; static struct resource da8xx_rtc_resources[] = { { .start = DA8XX_RTC_BASE, .end = DA8XX_RTC_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, { /* timer irq */ .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC), .flags = IORESOURCE_IRQ, }, { /* alarm irq */ .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_RTC), .flags = IORESOURCE_IRQ, }, }; static struct platform_device da8xx_rtc_device = { .name = "da830-rtc", .id = -1, .num_resources = ARRAY_SIZE(da8xx_rtc_resources), .resource = da8xx_rtc_resources, }; int da8xx_register_rtc(void) { return platform_device_register(&da8xx_rtc_device); } static void __iomem *da8xx_ddr2_ctlr_base; void __iomem * __init da8xx_get_mem_ctlr(void) { if (da8xx_ddr2_ctlr_base) return da8xx_ddr2_ctlr_base; da8xx_ddr2_ctlr_base = ioremap(DA8XX_DDR2_CTL_BASE, SZ_32K); if (!da8xx_ddr2_ctlr_base) pr_warn("%s: Unable to map DDR2 controller", __func__); return da8xx_ddr2_ctlr_base; } static struct resource da8xx_cpuidle_resources[] = { { .start = DA8XX_DDR2_CTL_BASE, .end = DA8XX_DDR2_CTL_BASE + SZ_32K - 1, .flags = IORESOURCE_MEM, }, }; /* DA8XX devices support DDR2 power down */ static struct davinci_cpuidle_config da8xx_cpuidle_pdata = { .ddr2_pdown = 1, }; static struct platform_device da8xx_cpuidle_device = { .name = "cpuidle-davinci", .num_resources = ARRAY_SIZE(da8xx_cpuidle_resources), .resource = da8xx_cpuidle_resources, .dev = { .platform_data = &da8xx_cpuidle_pdata, }, }; int __init da8xx_register_cpuidle(void) { da8xx_cpuidle_pdata.ddr2_ctlr_base = da8xx_get_mem_ctlr(); return platform_device_register(&da8xx_cpuidle_device); } static struct resource da8xx_spi0_resources[] = { [0] = { .start = DA8XX_SPI0_BASE, .end = DA8XX_SPI0_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT0), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT0), .flags = IORESOURCE_IRQ, }, }; static struct resource da8xx_spi1_resources[] = { [0] = { .start = DA830_SPI1_BASE, .end = DA830_SPI1_BASE + SZ_4K - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT1), .end = DAVINCI_INTC_IRQ(IRQ_DA8XX_SPINT1), .flags = IORESOURCE_IRQ, }, }; static struct davinci_spi_platform_data da8xx_spi_pdata[] = { [0] = { .version = SPI_VERSION_2, .intr_line = 1, .dma_event_q = EVENTQ_0, .prescaler_limit = 2, }, [1] = { .version = SPI_VERSION_2, .intr_line = 1, .dma_event_q = EVENTQ_0, .prescaler_limit = 2, }, }; static struct platform_device da8xx_spi_device[] = { [0] = { .name = "spi_davinci", .id = 0, .num_resources = ARRAY_SIZE(da8xx_spi0_resources), .resource = da8xx_spi0_resources, .dev = { .platform_data = &da8xx_spi_pdata[0], }, }, [1] = { .name = "spi_davinci", .id = 1, .num_resources = ARRAY_SIZE(da8xx_spi1_resources), .resource = da8xx_spi1_resources, .dev = { .platform_data = &da8xx_spi_pdata[1], }, }, }; int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect) { if (instance < 0 || instance > 1) return -EINVAL; da8xx_spi_pdata[instance].num_chipselect = num_chipselect; if (instance == 1 && cpu_is_davinci_da850()) { da8xx_spi1_resources[0].start = DA850_SPI1_BASE; da8xx_spi1_resources[0].end = DA850_SPI1_BASE + SZ_4K - 1; } return platform_device_register(&da8xx_spi_device[instance]); } #ifdef CONFIG_ARCH_DAVINCI_DA850 int __init da850_register_sata_refclk(int rate) { struct clk *clk; clk = clk_register_fixed_rate(NULL, "sata_refclk", NULL, 0, rate); if (IS_ERR(clk)) return PTR_ERR(clk); return clk_register_clkdev(clk, "refclk", "ahci_da850"); } static struct resource da850_sata_resources[] = { { .start = DA850_SATA_BASE, .end = DA850_SATA_BASE + 0x1fff, .flags = IORESOURCE_MEM, }, { .start = DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG, .end = DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG + 0x3, .flags = IORESOURCE_MEM, }, { .start = DAVINCI_INTC_IRQ(IRQ_DA850_SATAINT), .flags = IORESOURCE_IRQ, }, }; static u64 da850_sata_dmamask = DMA_BIT_MASK(32); static struct platform_device da850_sata_device = { .name = "ahci_da850", .id = -1, .dev = { .dma_mask = &da850_sata_dmamask, .coherent_dma_mask = DMA_BIT_MASK(32), }, .num_resources = ARRAY_SIZE(da850_sata_resources), .resource = da850_sata_resources, }; int __init da850_register_sata(unsigned long refclkpn) { int ret; ret = da850_register_sata_refclk(refclkpn); if (ret) return ret; return platform_device_register(&da850_sata_device); } #endif static struct regmap *da8xx_cfgchip; static const struct regmap_config da8xx_cfgchip_config __initconst = { .name = "cfgchip", .reg_bits = 32, .val_bits = 32, .reg_stride = 4, .max_register = DA8XX_CFGCHIP4_REG - DA8XX_CFGCHIP0_REG, }; /** * da8xx_get_cfgchip - Lazy gets CFGCHIP as regmap * * This is for use on non-DT boards only. For DT boards, use * syscon_regmap_lookup_by_compatible("ti,da830-cfgchip") * * Returns: Pointer to the CFGCHIP regmap or negative error code. */ struct regmap * __init da8xx_get_cfgchip(void) { if (IS_ERR_OR_NULL(da8xx_cfgchip)) da8xx_cfgchip = regmap_init_mmio(NULL, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP0_REG), &da8xx_cfgchip_config); return da8xx_cfgchip; }
utf-8
1
GPL-2
1991-2012 Linus Torvalds and many others
linux-5.16.7/arch/arm/mach-s3c/regs-irqtype.h
/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright 2008 Simtec Electronics * Ben Dooks <ben@simtec.co.uk> * http://armlinux.simtec.co.uk/ * * S3C - IRQ detection types. */ /* values for S3C2410_EXTINT0/1/2 and other cpus in the series, including * the S3C64XX */ #define S3C2410_EXTINT_LOWLEV (0x00) #define S3C2410_EXTINT_HILEV (0x01) #define S3C2410_EXTINT_FALLEDGE (0x02) #define S3C2410_EXTINT_RISEEDGE (0x04) #define S3C2410_EXTINT_BOTHEDGE (0x06)
utf-8
1
GPL-2
1991-2012 Linus Torvalds and many others
allegro4.4-4.4.3.1/src/x/xmouse.c
/* ______ ___ ___ * /\ _ \ /\_ \ /\_ \ * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ * /\____/ * \_/__/ * * X-Windows mouse module. * * By Michael Bukin. * * See readme.txt for copyright information. */ #include "allegro.h" #include "allegro/internal/aintern.h" #include "allegro/platform/aintunix.h" #include "xwin.h" #include <X11/cursorfont.h> /* TRUE if the requested mouse range extends beyond the regular * (0, 0, SCREEN_W-1, SCREEN_H-1) range. This is aimed at detecting * whether the user mouse coordinates are relative to the 'screen' * bitmap (semantics associated with scrolling) or to the video page * currently being displayed (semantics associated with page flipping). * We cannot differentiate them properly because both use the same * scroll_screen() method. */ int _xwin_mouse_extended_range = FALSE; static int mouse_minx = 0; static int mouse_miny = 0; static int mouse_maxx = 319; static int mouse_maxy = 199; static int mymickey_x = 0; static int mymickey_y = 0; static int mouse_mult = -1; /* mouse acceleration multiplier */ static int mouse_div = -1; /* mouse acceleration divisor */ static int mouse_threshold = -1; /* mouse acceleration threshold */ static int last_xspeed = -1; /* latest set_mouse_speed() settings */ static int last_yspeed = -1; static int _xwin_mousedrv_init(void); static void _xwin_mousedrv_exit(void); static void _xwin_mousedrv_position(int x, int y); static void _xwin_mousedrv_set_range(int x1, int y1, int x2, int y2); static void _xwin_mousedrv_set_speed(int xspeed, int yspeed); static void _xwin_mousedrv_get_mickeys(int *mickeyx, int *mickeyy); static int _xwin_select_system_cursor(AL_CONST int cursor); static void _xwin_set_mouse_speed(int xspeed, int yspeed); static MOUSE_DRIVER mouse_xwin = { MOUSE_XWINDOWS, empty_string, empty_string, "X-Windows mouse", _xwin_mousedrv_init, _xwin_mousedrv_exit, NULL, NULL, _xwin_mousedrv_position, _xwin_mousedrv_set_range, _xwin_mousedrv_set_speed, _xwin_mousedrv_get_mickeys, NULL, _xwin_enable_hardware_cursor, _xwin_select_system_cursor }; /* list the available drivers */ _DRIVER_INFO _xwin_mouse_driver_list[] = { { MOUSE_XWINDOWS, &mouse_xwin, TRUE }, { 0, NULL, 0 } }; /* _xwin_mousedrv_handler: * Mouse "interrupt" handler for mickey-mode driver. */ static void _xwin_mousedrv_handler(int x, int y, int z, int w, int buttons) { _mouse_b = buttons; mymickey_x += x; mymickey_y += y; _mouse_x += x; _mouse_y += y; _mouse_z += z; _mouse_w += w; if ((_mouse_x < mouse_minx) || (_mouse_x > mouse_maxx) || (_mouse_y < mouse_miny) || (_mouse_y > mouse_maxy)) { _mouse_x = CLAMP(mouse_minx, _mouse_x, mouse_maxx); _mouse_y = CLAMP(mouse_miny, _mouse_y, mouse_maxy); } _handle_mouse_input(); } /* _xwin_mousedrv_init: * Initializes the mickey-mode driver. */ static int _xwin_mousedrv_init(void) { int num_buttons; unsigned char map[8]; num_buttons = _xwin_get_pointer_mapping(map, sizeof(map)); num_buttons = CLAMP(2, num_buttons, 3); last_xspeed = -1; last_yspeed = -1; XLOCK(); _xwin_mouse_interrupt = _xwin_mousedrv_handler; XUNLOCK(); return num_buttons; } /* _xwin_mousedrv_exit: * Shuts down the mickey-mode driver. */ static void _xwin_mousedrv_exit(void) { XLOCK(); if (mouse_mult >= 0) XChangePointerControl(_xwin.display, 1, 1, mouse_mult, mouse_div, mouse_threshold); _xwin_mouse_interrupt = 0; XUNLOCK(); } /* _xwin_mousedrv_position: * Sets the position of the mickey-mode mouse. */ static void _xwin_mousedrv_position(int x, int y) { XLOCK(); _mouse_x = x; _mouse_y = y; mymickey_x = mymickey_y = 0; if (_xwin.hw_cursor_ok) XWarpPointer(_xwin.display, _xwin.window, _xwin.window, 0, 0, _xwin.window_width, _xwin.window_height, x, y); XUNLOCK(); _xwin_set_warped_mouse_mode(FALSE); } /* _xwin_mousedrv_set_range: * Sets the range of the mickey-mode mouse. */ static void _xwin_mousedrv_set_range(int x1, int y1, int x2, int y2) { mouse_minx = x1; mouse_miny = y1; mouse_maxx = x2; mouse_maxy = y2; if ((mouse_maxx >= SCREEN_W) || (mouse_maxy >= SCREEN_H)) _xwin_mouse_extended_range = TRUE; else _xwin_mouse_extended_range = FALSE; XLOCK(); _mouse_x = CLAMP(mouse_minx, _mouse_x, mouse_maxx); _mouse_y = CLAMP(mouse_miny, _mouse_y, mouse_maxy); XUNLOCK(); } /* _xwin_mousedrv_set_speed: * Sets the speed of the mouse cursor. We don't set the speed if the cursor * isn't in the window, but we remember the setting so it will be set the * next time the cursor enters the window. */ static void _xwin_mousedrv_set_speed(int xspeed, int yspeed) { if (_mouse_on) { _xwin_set_mouse_speed(xspeed, yspeed); } last_xspeed = xspeed; last_yspeed = yspeed; } /* _xwin_mousedrv_get_mickeys: * Reads the mickey-mode count. */ static void _xwin_mousedrv_get_mickeys(int *mickeyx, int *mickeyy) { int temp_x = mymickey_x; int temp_y = mymickey_y; mymickey_x -= temp_x; mymickey_y -= temp_y; *mickeyx = temp_x; *mickeyy = temp_y; _xwin_set_warped_mouse_mode(TRUE); } /* _xwin_select_system_cursor: * Select an OS native cursor */ static int _xwin_select_system_cursor(AL_CONST int cursor) { switch(cursor) { case MOUSE_CURSOR_ARROW: _xwin.cursor_shape = XC_left_ptr; break; case MOUSE_CURSOR_BUSY: _xwin.cursor_shape = XC_watch; break; case MOUSE_CURSOR_QUESTION: _xwin.cursor_shape = XC_question_arrow; break; case MOUSE_CURSOR_EDIT: _xwin.cursor_shape = XC_xterm; break; default: return 0; } XLOCK(); if (_xwin.cursor != None) { XUndefineCursor(_xwin.display, _xwin.window); XFreeCursor(_xwin.display, _xwin.cursor); } _xwin.cursor = XCreateFontCursor(_xwin.display, _xwin.cursor_shape); XDefineCursor(_xwin.display, _xwin.window, _xwin.cursor); XUNLOCK(); return cursor; } /* _xwin_set_mouse_speed: * The actual function that sets the speed of the mouse cursor. * Each step slows down or speeds the mouse up by 0.5x. */ static void _xwin_set_mouse_speed(int xspeed, int yspeed) { int speed; int hundredths; XLOCK(); if (mouse_mult < 0) XGetPointerControl(_xwin.display, &mouse_mult, &mouse_div, &mouse_threshold); speed = MAX(1, (xspeed + yspeed) / 2); if (mouse_div == 0) hundredths = mouse_mult * 100; else hundredths = (mouse_mult * 100 / mouse_div); hundredths -= (speed - 2) * 50; if (hundredths < 0) hundredths = 0; XChangePointerControl(_xwin.display, 1, 1, hundredths, 100, mouse_threshold); XUNLOCK(); } /* _xwin_mouse_leave_notify: * Reset the mouse speed to its original value when the cursor leave the * Allegro window. */ void _xwin_mouse_leave_notify(void) { if (mouse_mult >= 0) { XLOCK(); XChangePointerControl(_xwin.display, 1, 1, mouse_mult, mouse_div, mouse_threshold); XUNLOCK(); } } /* _xwin_mouse_enter_notify: * Restore the mouse speed setting when the mouse cursor re-enters the * Allegro window. */ void _xwin_mouse_enter_notify(void) { if (last_xspeed >= 0) { _xwin_set_mouse_speed(last_xspeed, last_yspeed); } }
utf-8
1
Allegro-gift-ware
1996-2011 Shawn Hargreaves and the Allegro developers.
thunderbird-91.6.0/dom/media/MediaQueue.h
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=2 sw=2 sts=2 et cindent: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #if !defined(MediaQueue_h_) # define MediaQueue_h_ # include <type_traits> # include "mozilla/RecursiveMutex.h" # include "mozilla/TaskQueue.h" # include "nsDeque.h" # include "MediaEventSource.h" # include "TimeUnits.h" namespace mozilla { class AudioData; template <class T> class MediaQueue : private nsRefPtrDeque<T> { public: MediaQueue() : nsRefPtrDeque<T>(), mRecursiveMutex("mediaqueue"), mEndOfStream(false) {} ~MediaQueue() { Reset(); } inline size_t GetSize() const { RecursiveMutexAutoLock lock(mRecursiveMutex); return nsRefPtrDeque<T>::GetSize(); } inline void PushFront(T* aItem) { RecursiveMutexAutoLock lock(mRecursiveMutex); nsRefPtrDeque<T>::PushFront(aItem); } inline void Push(T* aItem) { MOZ_DIAGNOSTIC_ASSERT(aItem); Push(do_AddRef(aItem)); } inline void Push(already_AddRefed<T> aItem) { RecursiveMutexAutoLock lock(mRecursiveMutex); T* item = aItem.take(); MOZ_DIAGNOSTIC_ASSERT(item); MOZ_DIAGNOSTIC_ASSERT(item->GetEndTime() >= item->mTime); nsRefPtrDeque<T>::Push(dont_AddRef(item)); mPushEvent.Notify(RefPtr<T>(item)); // Pushing new data after queue has ended means that the stream is active // again, so we should not mark it as ended. if (mEndOfStream) { mEndOfStream = false; } } inline already_AddRefed<T> PopFront() { RecursiveMutexAutoLock lock(mRecursiveMutex); RefPtr<T> rv = nsRefPtrDeque<T>::PopFront(); if (rv) { MOZ_DIAGNOSTIC_ASSERT(rv->GetEndTime() >= rv->mTime); mPopFrontEvent.Notify(RefPtr<T>(rv)); } return rv.forget(); } inline already_AddRefed<T> PopBack() { RecursiveMutexAutoLock lock(mRecursiveMutex); return nsRefPtrDeque<T>::Pop(); } inline RefPtr<T> PeekFront() const { RecursiveMutexAutoLock lock(mRecursiveMutex); return nsRefPtrDeque<T>::PeekFront(); } inline RefPtr<T> PeekBack() const { RecursiveMutexAutoLock lock(mRecursiveMutex); return nsRefPtrDeque<T>::Peek(); } void Reset() { RecursiveMutexAutoLock lock(mRecursiveMutex); nsRefPtrDeque<T>::Erase(); mEndOfStream = false; } bool AtEndOfStream() const { RecursiveMutexAutoLock lock(mRecursiveMutex); return GetSize() == 0 && mEndOfStream; } // Returns true if the media queue has had its last item added to it. // This happens when the media stream has been completely decoded. Note this // does not mean that the corresponding stream has finished playback. bool IsFinished() const { RecursiveMutexAutoLock lock(mRecursiveMutex); return mEndOfStream; } // Informs the media queue that it won't be receiving any more items. void Finish() { RecursiveMutexAutoLock lock(mRecursiveMutex); if (!mEndOfStream) { mEndOfStream = true; mFinishEvent.Notify(); } } // Returns the approximate number of microseconds of items in the queue. int64_t Duration() const { RecursiveMutexAutoLock lock(mRecursiveMutex); if (GetSize() == 0) { return 0; } T* last = nsRefPtrDeque<T>::Peek(); T* first = nsRefPtrDeque<T>::PeekFront(); return (last->GetEndTime() - first->mTime).ToMicroseconds(); } void LockedForEach(nsDequeFunctor<T>& aFunctor) const { RecursiveMutexAutoLock lock(mRecursiveMutex); nsRefPtrDeque<T>::ForEach(aFunctor); } // Fill aResult with the elements which end later than the given time aTime. void GetElementsAfter(const media::TimeUnit& aTime, nsTArray<RefPtr<T>>* aResult) { GetElementsAfterStrict(aTime.ToMicroseconds(), aResult); } void GetFirstElements(uint32_t aMaxElements, nsTArray<RefPtr<T>>* aResult) { RecursiveMutexAutoLock lock(mRecursiveMutex); for (size_t i = 0; i < aMaxElements && i < GetSize(); ++i) { *aResult->AppendElement() = nsRefPtrDeque<T>::ObjectAt(i); } } uint32_t AudioFramesCount() { static_assert(std::is_same_v<T, AudioData>, "Only usable with MediaQueue<AudioData>"); RecursiveMutexAutoLock lock(mRecursiveMutex); uint32_t frames = 0; for (size_t i = 0; i < GetSize(); ++i) { T* v = nsRefPtrDeque<T>::ObjectAt(i); frames += v->Frames(); } return frames; } MediaEventSource<RefPtr<T>>& PopFrontEvent() { return mPopFrontEvent; } MediaEventSource<RefPtr<T>>& PushEvent() { return mPushEvent; } MediaEventSource<void>& FinishEvent() { return mFinishEvent; } private: // Extracts elements from the queue into aResult, in order. // Elements whose end time is before or equal to aTime are ignored. void GetElementsAfterStrict(int64_t aTime, nsTArray<RefPtr<T>>* aResult) { RecursiveMutexAutoLock lock(mRecursiveMutex); if (GetSize() == 0) return; size_t i; for (i = GetSize() - 1; i > 0; --i) { T* v = nsRefPtrDeque<T>::ObjectAt(i); if (v->GetEndTime().ToMicroseconds() < aTime) break; } for (; i < GetSize(); ++i) { RefPtr<T> elem = nsRefPtrDeque<T>::ObjectAt(i); if (elem->GetEndTime().ToMicroseconds() > aTime) { aResult->AppendElement(elem); } } } mutable RecursiveMutex mRecursiveMutex; MediaEventProducer<RefPtr<T>> mPopFrontEvent; MediaEventProducer<RefPtr<T>> mPushEvent; MediaEventProducer<void> mFinishEvent; // True when we've decoded the last frame of data in the // bitstream for which we're queueing frame data. bool mEndOfStream; }; } // namespace mozilla #endif
utf-8
1
MPL-2.0 or GPL-2 or LGPL-2.1
1998-2016, Mozilla Project
libreoffice-7.3.1~rc1/sw/inc/unotbl.hxx
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * 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 . */ #ifndef INCLUDED_SW_INC_UNOTBL_HXX #define INCLUDED_SW_INC_UNOTBL_HXX #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/util/XSortable.hpp> #include <com/sun/star/chart/XChartDataArray.hpp> #include <com/sun/star/text/XTextTableCursor.hpp> #include <com/sun/star/text/XTextTable.hpp> #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/sheet/XCellRangeData.hpp> #include <com/sun/star/table/XAutoFormattable.hpp> #include <cppuhelper/implbase.hxx> #include <comphelper/uno3.hxx> #include <svl/listener.hxx> #include "TextCursorHelper.hxx" #include "unotext.hxx" #include "frmfmt.hxx" #include "unocrsr.hxx" class SwTable; class SwTableBox; class SwTableLine; class SwTableCursor; class SfxItemPropertySet; typedef cppu::WeakImplHelper < css::table::XCell, css::lang::XServiceInfo, css::beans::XPropertySet, css::container::XEnumerationAccess > SwXCellBaseClass; class SwXCell final : public SwXCellBaseClass, public SwXText, public SvtListener { friend void sw_setString( SwXCell &rCell, const OUString &rText, bool bKeepNumberFormat ); friend void sw_setValue( SwXCell &rCell, double nVal ); const SfxItemPropertySet* m_pPropSet; SwTableBox* m_pBox; // only set in non-XML import const SwStartNode* m_pStartNode; // only set in XML import SwFrameFormat* m_pTableFormat; // table position where pBox was found last size_t m_nFndPos; css::uno::Reference<css::text::XText> m_xParentText; static size_t const NOTFOUND = SAL_MAX_SIZE; virtual const SwStartNode *GetStartNode() const override; virtual css::uno::Reference< css::text::XTextCursor > CreateCursor() override; bool IsValid() const; virtual ~SwXCell() override; virtual void Notify(const SfxHint&) override; public: SwXCell(SwFrameFormat* pTableFormat, SwTableBox* pBox, size_t nPos); SwXCell(SwFrameFormat* pTableFormat, const SwStartNode& rStartNode); // XML import interface static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); //XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; virtual void SAL_CALL acquire( ) noexcept override; virtual void SAL_CALL release( ) noexcept override; //XTypeProvider virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override; virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override; //XCell virtual OUString SAL_CALL getFormula( ) override; virtual void SAL_CALL setFormula( const OUString& aFormula ) override; virtual double SAL_CALL getValue( ) override; /// @throws css::uno::RuntimeException double getValue( ) const { return const_cast<SwXCell*>(this)->getValue(); }; virtual void SAL_CALL setValue( double nValue ) override; virtual css::table::CellContentType SAL_CALL getType( ) override; virtual sal_Int32 SAL_CALL getError( ) override; //XText virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override; virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > & aTextPosition) override; virtual void SAL_CALL setString(const OUString& aString) override; //XPropertySet virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; //XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; //XEnumerationAccess - was: XParagraphEnumerationAccess virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override; //XElementAccess virtual css::uno::Type SAL_CALL getElementType( ) override; virtual sal_Bool SAL_CALL hasElements( ) override; SwTableBox* GetTableBox() const { return m_pBox; } static rtl::Reference<SwXCell> CreateXCell(SwFrameFormat* pTableFormat, SwTableBox* pBox, SwTable *pTable = nullptr ); SwTableBox* FindBox(SwTable* pTable, SwTableBox* pBox); SwFrameFormat* GetFrameFormat() const { return m_pTableFormat; } double GetForcedNumericalValue() const; css::uno::Any GetAny() const; }; class SwXTextTableRow final : public cppu::WeakImplHelper<css::beans::XPropertySet, css::lang::XServiceInfo> , public SvtListener { SwFrameFormat* m_pFormat; SwTableLine* m_pLine; const SfxItemPropertySet* m_pPropSet; SwFrameFormat* GetFrameFormat() { return m_pFormat; } const SwFrameFormat* GetFrameFormat() const { return m_pFormat; } virtual ~SwXTextTableRow() override; public: SwXTextTableRow(SwFrameFormat* pFormat, SwTableLine* pLine); //XPropertySet virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; //XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; static SwTableLine* FindLine(SwTable* pTable, SwTableLine const * pLine); void Notify(const SfxHint&) override; }; typedef cppu::WeakImplHelper< css::text::XTextTableCursor, css::lang::XServiceInfo, css::beans::XPropertySet> SwXTextTableCursor_Base; class SW_DLLPUBLIC SwXTextTableCursor final : public SwXTextTableCursor_Base , public SvtListener , public OTextCursorHelper { SwFrameFormat* m_pFrameFormat; const SfxItemPropertySet* m_pPropSet; public: SwXTextTableCursor(SwFrameFormat* pFormat, SwTableBox const* pBox); SwXTextTableCursor(SwFrameFormat& rTableFormat, const SwTableCursor* pTableSelection); DECLARE_XINTERFACE() //XTextTableCursor virtual OUString SAL_CALL getRangeName() override; virtual sal_Bool SAL_CALL gotoCellByName( const OUString& aCellName, sal_Bool bExpand ) override; virtual sal_Bool SAL_CALL goLeft( sal_Int16 nCount, sal_Bool bExpand ) override; virtual sal_Bool SAL_CALL goRight( sal_Int16 nCount, sal_Bool bExpand ) override; virtual sal_Bool SAL_CALL goUp( sal_Int16 nCount, sal_Bool bExpand ) override; virtual sal_Bool SAL_CALL goDown( sal_Int16 nCount, sal_Bool bExpand ) override; virtual void SAL_CALL gotoStart( sal_Bool bExpand ) override; virtual void SAL_CALL gotoEnd( sal_Bool bExpand ) override; virtual sal_Bool SAL_CALL mergeRange() override; virtual sal_Bool SAL_CALL splitRange( sal_Int16 Count, sal_Bool Horizontal ) override; //XPropertySet virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; //XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; // ITextCursorHelper virtual const SwPaM* GetPaM() const override; virtual SwPaM* GetPaM() override; virtual const SwDoc* GetDoc() const override; virtual SwDoc* GetDoc() override; virtual void Notify( const SfxHint& ) override; const SwUnoCursor& GetCursor() const; SwUnoCursor& GetCursor(); sw::UnoCursorPointer m_pUnoCursor; SwFrameFormat* GetFrameFormat() const { return m_pFrameFormat; } }; struct SwRangeDescriptor { sal_Int32 nTop; sal_Int32 nLeft; sal_Int32 nBottom; sal_Int32 nRight; void Normalize(); }; class SAL_DLLPUBLIC_RTTI SwXTextTable final : public cppu::WeakImplHelper < css::text::XTextTable, css::lang::XServiceInfo, css::table::XCellRange, css::chart::XChartDataArray, css::beans::XPropertySet, css::container::XNamed, css::table::XAutoFormattable, css::util::XSortable, css::lang::XUnoTunnel, css::sheet::XCellRangeData > { private: class Impl; ::sw::UnoImplPtr<Impl> m_pImpl; SwXTextTable(); SwXTextTable(SwFrameFormat& rFrameFormat); virtual ~SwXTextTable() override; public: static css::uno::Reference<css::text::XTextTable> CreateXTextTable(SwFrameFormat * pFrameFormat); SW_DLLPUBLIC static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); SW_DLLPUBLIC static void GetCellPosition(const OUString& rCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow); SW_DLLPUBLIC SwFrameFormat* GetFrameFormat(); //XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; //XTextTable virtual void SAL_CALL initialize( sal_Int32 nRows, sal_Int32 nColumns ) override; virtual css::uno::Reference< css::table::XTableRows > SAL_CALL getRows( ) override; virtual css::uno::Reference< css::table::XTableColumns > SAL_CALL getColumns( ) override; virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByName( const OUString& aCellName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getCellNames( ) override; virtual css::uno::Reference< css::text::XTextTableCursor > SAL_CALL createCursorByCellName( const OUString& aCellName ) override; //XTextContent virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > & xTextRange) override; virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getAnchor( ) override; //XComponent virtual void SAL_CALL dispose() override; virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override; virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > & aListener) override; //XCellRange virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) override; virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) override; virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByName( const OUString& aRange ) override; //XChartDataArray virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData( ) override; virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Sequence< double > >& aData ) override; virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions( ) override; virtual void SAL_CALL setRowDescriptions( const css::uno::Sequence< OUString >& aRowDescriptions ) override; virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions( ) override; virtual void SAL_CALL setColumnDescriptions( const css::uno::Sequence< OUString >& aColumnDescriptions ) override; //XChartData virtual void SAL_CALL addChartDataChangeEventListener( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override; virtual void SAL_CALL removeChartDataChangeEventListener( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override; virtual double SAL_CALL getNotANumber( ) override; virtual sal_Bool SAL_CALL isNotANumber( double nNumber ) override; //XSortable virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override; virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue >& xDescriptor) override; //XAutoFormattable virtual void SAL_CALL autoFormat(const OUString& aName) override; //XPropertySet virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override; virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override; virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; //XNamed virtual OUString SAL_CALL getName() override; virtual void SAL_CALL setName(const OUString& Name_) override; //XCellRangeData virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getDataArray( ) override; virtual void SAL_CALL setDataArray( const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aArray ) override; //XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; class SwXCellRange final : public cppu::WeakImplHelper < css::table::XCellRange, css::lang::XServiceInfo, css::lang::XUnoTunnel, css::beans::XPropertySet, css::chart::XChartDataArray, css::util::XSortable, css::sheet::XCellRangeData > { private: class Impl; ::sw::UnoImplPtr<Impl> m_pImpl; SwXCellRange(const sw::UnoCursorPointer& pCursor, SwFrameFormat& rFrameFormat, SwRangeDescriptor const & rDesc); virtual ~SwXCellRange() override; public: static ::rtl::Reference<SwXCellRange> CreateXCellRange( const sw::UnoCursorPointer& pCursor, SwFrameFormat& rFrameFormat, SwRangeDescriptor const & rDesc); static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId(); void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel); std::vector<css::uno::Reference<css::table::XCell>> GetCells(); const SwUnoCursor* GetTableCursor() const; //XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; //XCellRange virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) override; virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) override; virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByName( const OUString& aRange ) override; //XPropertySet virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override; virtual void SAL_CALL setPropertyValue(const OUString& aPropertyName, const css::uno::Any& aValue) override; virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& PropertyName) override; virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override; virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override; virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override; //XChartData virtual void SAL_CALL addChartDataChangeEventListener( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override; virtual void SAL_CALL removeChartDataChangeEventListener( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) override; virtual double SAL_CALL getNotANumber( ) override; virtual sal_Bool SAL_CALL isNotANumber( double nNumber ) override; //XChartDataArray virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData( ) override; virtual void SAL_CALL setData( const css::uno::Sequence< css::uno::Sequence< double > >& aData ) override; virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions( ) override; virtual void SAL_CALL setRowDescriptions( const css::uno::Sequence< OUString >& aRowDescriptions ) override; virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions( ) override; virtual void SAL_CALL setColumnDescriptions( const css::uno::Sequence< OUString >& aColumnDescriptions ) override; //XSortable virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override; virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue >& xDescriptor) override; //XCellRangeData virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getDataArray( ) override; virtual void SAL_CALL setDataArray( const css::uno::Sequence< css::uno::Sequence< css::uno::Any > >& aArray ) override; //XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; class SwXTableRows final : public cppu::WeakImplHelper < css::table::XTableRows, css::lang::XServiceInfo > { class Impl; ::sw::UnoImplPtr<Impl> m_pImpl; SwFrameFormat* GetFrameFormat(); const SwFrameFormat* GetFrameFormat() const { return const_cast<SwXTableRows*>(this)->GetFrameFormat(); } virtual ~SwXTableRows() override; public: SwXTableRows(SwFrameFormat& rFrameFormat); //XIndexAccess virtual sal_Int32 SAL_CALL getCount() override; virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override; //XElementAccess virtual css::uno::Type SAL_CALL getElementType( ) override; virtual sal_Bool SAL_CALL hasElements( ) override; //XTableRows virtual void SAL_CALL insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) override; virtual void SAL_CALL removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) override; //XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; class SwXTableColumns final : public cppu::WeakImplHelper < css::table::XTableColumns, css::lang::XServiceInfo > { private: class Impl; ::sw::UnoImplPtr<Impl> m_pImpl; SwFrameFormat* GetFrameFormat() const; virtual ~SwXTableColumns() override; public: SwXTableColumns(SwFrameFormat& rFrameFormat); //XIndexAccess virtual sal_Int32 SAL_CALL getCount() override; virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override; //XElementAccess virtual css::uno::Type SAL_CALL getElementType( ) override; virtual sal_Bool SAL_CALL hasElements( ) override; //XTableColumns virtual void SAL_CALL insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) override; virtual void SAL_CALL removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) override; //XServiceInfo virtual OUString SAL_CALL getImplementationName() override; virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; }; int sw_CompareCellRanges( const OUString &rRange1StartCell, const OUString &rRange1EndCell, const OUString &rRange2StartCell, const OUString &rRange2EndCell, bool bCmpColsFirst ); void sw_NormalizeRange( OUString &rCell1, OUString &rCell2 ); OUString sw_GetCellName( sal_Int32 nColumn, sal_Int32 nRow ); int sw_CompareCellsByColFirst( const OUString &rCellName1, const OUString &rCellName2 ); int sw_CompareCellsByRowFirst( const OUString &rCellName1, const OUString &rCellName2 ); #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
utf-8
1
MPL-2.0
Copyright 2000, 2010 Oracle and/or its affiliates. Copyright (c) 2000, 2010 LibreOffice contributors and/or their affiliates.
android-platform-frameworks-native-10.0.0+r36/opengl/tools/glgen/stubs/egl/eglCreatePbufferFromClientBuffer.cpp
/* EGLSurface eglCreatePbufferFromClientBuffer ( EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list ) */ static jobject android_eglCreatePbufferFromClientBuffer (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jlong buffer, jobject config, jintArray attrib_list_ref, jint offset) { jint _exception = 0; const char * _exceptionType = NULL; const char * _exceptionMessage = NULL; EGLSurface _returnValue = (EGLSurface) 0; EGLDisplay dpy_native = (EGLDisplay) fromEGLHandle(_env, egldisplayGetHandleID, dpy); EGLConfig config_native = (EGLConfig) fromEGLHandle(_env, eglconfigGetHandleID, config); bool attrib_list_sentinel = false; EGLint *attrib_list_base = (EGLint *) 0; jint _remaining; EGLint *attrib_list = (EGLint *) 0; if (attrib_list_ref) { if (offset < 0) { _exception = 1; _exceptionType = "java/lang/IllegalArgumentException"; _exceptionMessage = "offset < 0"; goto exit; } _remaining = _env->GetArrayLength(attrib_list_ref) - offset; attrib_list_base = (EGLint *) _env->GetIntArrayElements(attrib_list_ref, (jboolean *)0); attrib_list = attrib_list_base + offset; attrib_list_sentinel = false; for (int i = _remaining - 1; i >= 0; i--) { if (attrib_list[i] == EGL_NONE){ attrib_list_sentinel = true; break; } } if (attrib_list_sentinel == false) { _exception = 1; _exceptionType = "java/lang/IllegalArgumentException"; _exceptionMessage = "attrib_list must contain EGL_NONE!"; goto exit; } } _returnValue = eglCreatePbufferFromClientBuffer( (EGLDisplay)dpy_native, (EGLenum)buftype, reinterpret_cast<EGLClientBuffer>(buffer), (EGLConfig)config_native, (EGLint *)attrib_list ); exit: if (attrib_list_base) { _env->ReleaseIntArrayElements(attrib_list_ref, attrib_list_base, JNI_ABORT); } if (_exception) { jniThrowException(_env, _exceptionType, _exceptionMessage); return nullptr; } return toEGLHandle(_env, eglsurfaceClass, eglsurfaceConstructor, _returnValue); } static jobject android_eglCreatePbufferFromClientBufferInt (JNIEnv *_env, jobject _this, jobject dpy, jint buftype, jint buffer, jobject config, jintArray attrib_list_ref, jint offset) { if(sizeof(void*) != sizeof(uint32_t)) { jniThrowException(_env, "java/lang/UnsupportedOperationException", "eglCreatePbufferFromClientBuffer"); return 0; } return android_eglCreatePbufferFromClientBuffer(_env, _this, dpy, buftype, buffer, config, attrib_list_ref, offset); }
utf-8
1
Apache-2.0
2005-2019, The Android Open Source Project
tracker-3.1.2/src/libtracker-sparql/tracker-serializer-xml.h
/* * Copyright (C) 2020, Red Hat, Inc * * 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: Carlos Garnacho <carlosg@gnome.org> */ #ifndef TRACKER_SERIALIZER_XML_H #define TRACKER_SERIALIZER_XML_H #include <libtracker-sparql/tracker-sparql.h> #include <libtracker-sparql/tracker-private.h> #include <libtracker-sparql/tracker-serializer.h> #define TRACKER_TYPE_SERIALIZER_XML (tracker_serializer_xml_get_type()) G_DECLARE_FINAL_TYPE (TrackerSerializerXml, tracker_serializer_xml, TRACKER, SERIALIZER_XML, TrackerSerializer); #endif /* TRACKER_SERIALIZER_XML_H */
utf-8
1
GPL-2.0+
2008-2011 Nokia <ivan.frade@nokia.com> 2006 Jamie McCracken <jamiemcc@gnome.org> 2012-2013 Martyn Russell <martyn@lanedo.com> 2012-2020 Sam Thursfield <sam@afuera.me.uk> 2014 Lanedo <martyn@lanedo.com> 2014, Softathome <philippe.judge@softathome.com> 2014-2020 Red Hat Inc. 2019 Sam Thursfield <sam@afuera.me.uk> 2020 Carlos Garnacho <carlosg@gnome.org>
samba-4.13.14+dfsg/auth/credentials/credentials.c
/* Unix SMB/CIFS implementation. User credentials handling Copyright (C) Jelmer Vernooij 2005 Copyright (C) Tim Potter 2001 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005 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 3 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, see <http://www.gnu.org/licenses/>. */ #include "includes.h" #include "librpc/gen_ndr/samr.h" /* for struct samrPassword */ #include "auth/credentials/credentials.h" #include "auth/credentials/credentials_internal.h" #include "auth/gensec/gensec.h" #include "libcli/auth/libcli_auth.h" #include "tevent.h" #include "param/param.h" #include "system/filesys.h" /** * Create a new credentials structure * @param mem_ctx TALLOC_CTX parent for credentials structure */ _PUBLIC_ struct cli_credentials *cli_credentials_init(TALLOC_CTX *mem_ctx) { struct cli_credentials *cred = talloc_zero(mem_ctx, struct cli_credentials); if (cred == NULL) { return cred; } cred->winbind_separator = '\\'; return cred; } _PUBLIC_ void cli_credentials_set_callback_data(struct cli_credentials *cred, void *callback_data) { cred->priv_data = callback_data; } _PUBLIC_ void *_cli_credentials_callback_data(struct cli_credentials *cred) { return cred->priv_data; } /** * Create a new anonymous credential * @param mem_ctx TALLOC_CTX parent for credentials structure */ _PUBLIC_ struct cli_credentials *cli_credentials_init_anon(TALLOC_CTX *mem_ctx) { struct cli_credentials *anon_credentials; anon_credentials = cli_credentials_init(mem_ctx); cli_credentials_set_anonymous(anon_credentials); return anon_credentials; } _PUBLIC_ void cli_credentials_set_kerberos_state(struct cli_credentials *creds, enum credentials_use_kerberos use_kerberos) { creds->use_kerberos = use_kerberos; } _PUBLIC_ void cli_credentials_set_forced_sasl_mech(struct cli_credentials *creds, const char *sasl_mech) { TALLOC_FREE(creds->forced_sasl_mech); creds->forced_sasl_mech = talloc_strdup(creds, sasl_mech); } _PUBLIC_ void cli_credentials_set_krb_forwardable(struct cli_credentials *creds, enum credentials_krb_forwardable krb_forwardable) { creds->krb_forwardable = krb_forwardable; } _PUBLIC_ enum credentials_use_kerberos cli_credentials_get_kerberos_state(struct cli_credentials *creds) { return creds->use_kerberos; } _PUBLIC_ const char *cli_credentials_get_forced_sasl_mech(struct cli_credentials *creds) { return creds->forced_sasl_mech; } _PUBLIC_ enum credentials_krb_forwardable cli_credentials_get_krb_forwardable(struct cli_credentials *creds) { return creds->krb_forwardable; } _PUBLIC_ void cli_credentials_set_gensec_features(struct cli_credentials *creds, uint32_t gensec_features) { creds->gensec_features = gensec_features; } _PUBLIC_ uint32_t cli_credentials_get_gensec_features(struct cli_credentials *creds) { return creds->gensec_features; } /** * Obtain the username for this credentials context. * @param cred credentials context * @retval The username set on this context. * @note Return value will never be NULL except by programmer error. */ _PUBLIC_ const char *cli_credentials_get_username(struct cli_credentials *cred) { if (cred->machine_account_pending) { cli_credentials_set_machine_account(cred, cred->machine_account_pending_lp_ctx); } if (cred->username_obtained == CRED_CALLBACK && !cred->callback_running) { cred->callback_running = true; cred->username = cred->username_cb(cred); cred->callback_running = false; if (cred->username_obtained == CRED_CALLBACK) { cred->username_obtained = CRED_CALLBACK_RESULT; cli_credentials_invalidate_ccache(cred, cred->username_obtained); } } return cred->username; } _PUBLIC_ bool cli_credentials_set_username(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained) { if (obtained >= cred->username_obtained) { cred->username = talloc_strdup(cred, val); cred->username_obtained = obtained; cli_credentials_invalidate_ccache(cred, cred->username_obtained); return true; } return false; } _PUBLIC_ bool cli_credentials_set_username_callback(struct cli_credentials *cred, const char *(*username_cb) (struct cli_credentials *)) { if (cred->username_obtained < CRED_CALLBACK) { cred->username_cb = username_cb; cred->username_obtained = CRED_CALLBACK; return true; } return false; } _PUBLIC_ bool cli_credentials_set_bind_dn(struct cli_credentials *cred, const char *bind_dn) { cred->bind_dn = talloc_strdup(cred, bind_dn); return true; } /** * Obtain the BIND DN for this credentials context. * @param cred credentials context * @retval The username set on this context. * @note Return value will be NULL if not specified explictly */ _PUBLIC_ const char *cli_credentials_get_bind_dn(struct cli_credentials *cred) { return cred->bind_dn; } /** * Obtain the client principal for this credentials context. * @param cred credentials context * @retval The username set on this context. * @note Return value will never be NULL except by programmer error. */ _PUBLIC_ char *cli_credentials_get_principal_and_obtained(struct cli_credentials *cred, TALLOC_CTX *mem_ctx, enum credentials_obtained *obtained) { if (cred->machine_account_pending) { cli_credentials_set_machine_account(cred, cred->machine_account_pending_lp_ctx); } if (cred->principal_obtained == CRED_CALLBACK && !cred->callback_running) { cred->callback_running = true; cred->principal = cred->principal_cb(cred); cred->callback_running = false; if (cred->principal_obtained == CRED_CALLBACK) { cred->principal_obtained = CRED_CALLBACK_RESULT; cli_credentials_invalidate_ccache(cred, cred->principal_obtained); } } if (cred->principal_obtained < cred->username_obtained || cred->principal_obtained < MAX(cred->domain_obtained, cred->realm_obtained)) { const char *effective_username = NULL; const char *effective_realm = NULL; enum credentials_obtained effective_obtained; effective_username = cli_credentials_get_username(cred); if (effective_username == NULL || strlen(effective_username) == 0) { *obtained = cred->username_obtained; return NULL; } if (cred->domain_obtained > cred->realm_obtained) { effective_realm = cli_credentials_get_domain(cred); effective_obtained = MIN(cred->domain_obtained, cred->username_obtained); } else { effective_realm = cli_credentials_get_realm(cred); effective_obtained = MIN(cred->realm_obtained, cred->username_obtained); } if (effective_realm == NULL || strlen(effective_realm) == 0) { effective_realm = cli_credentials_get_domain(cred); effective_obtained = MIN(cred->domain_obtained, cred->username_obtained); } if (effective_realm != NULL && strlen(effective_realm) != 0) { *obtained = effective_obtained; return talloc_asprintf(mem_ctx, "%s@%s", effective_username, effective_realm); } } *obtained = cred->principal_obtained; return talloc_strdup(mem_ctx, cred->principal); } /** * Obtain the client principal for this credentials context. * @param cred credentials context * @retval The username set on this context. * @note Return value will never be NULL except by programmer error. */ _PUBLIC_ char *cli_credentials_get_principal(struct cli_credentials *cred, TALLOC_CTX *mem_ctx) { enum credentials_obtained obtained; return cli_credentials_get_principal_and_obtained(cred, mem_ctx, &obtained); } _PUBLIC_ bool cli_credentials_set_principal(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained) { if (obtained >= cred->principal_obtained) { cred->principal = talloc_strdup(cred, val); if (cred->principal == NULL) { return false; } cred->principal_obtained = obtained; cli_credentials_invalidate_ccache(cred, cred->principal_obtained); return true; } return false; } /* Set a callback to get the principal. This could be a popup dialog, * a terminal prompt or similar. */ _PUBLIC_ bool cli_credentials_set_principal_callback(struct cli_credentials *cred, const char *(*principal_cb) (struct cli_credentials *)) { if (cred->principal_obtained < CRED_CALLBACK) { cred->principal_cb = principal_cb; cred->principal_obtained = CRED_CALLBACK; return true; } return false; } /* Some of our tools are 'anonymous by default'. This is a single * function to determine if authentication has been explicitly * requested */ _PUBLIC_ bool cli_credentials_authentication_requested(struct cli_credentials *cred) { uint32_t gensec_features = 0; if (cred->bind_dn) { return true; } /* * If we forced the mech we clearly want authentication. E.g. to use * SASL/EXTERNAL which has no credentials. */ if (cred->forced_sasl_mech) { return true; } if (cli_credentials_is_anonymous(cred)){ return false; } if (cred->principal_obtained >= CRED_SPECIFIED) { return true; } if (cred->username_obtained >= CRED_SPECIFIED) { return true; } if (cli_credentials_get_kerberos_state(cred) == CRED_MUST_USE_KERBEROS) { return true; } gensec_features = cli_credentials_get_gensec_features(cred); if (gensec_features & GENSEC_FEATURE_NTLM_CCACHE) { return true; } if (gensec_features & GENSEC_FEATURE_SIGN) { return true; } if (gensec_features & GENSEC_FEATURE_SEAL) { return true; } return false; } /** * Obtain the password for this credentials context. * @param cred credentials context * @retval If set, the cleartext password, otherwise NULL */ _PUBLIC_ const char *cli_credentials_get_password(struct cli_credentials *cred) { if (cred->machine_account_pending) { cli_credentials_set_machine_account(cred, cred->machine_account_pending_lp_ctx); } if (cred->password_obtained == CRED_CALLBACK && !cred->callback_running && !cred->password_will_be_nt_hash) { cred->callback_running = true; cred->password = cred->password_cb(cred); cred->callback_running = false; if (cred->password_obtained == CRED_CALLBACK) { cred->password_obtained = CRED_CALLBACK_RESULT; cli_credentials_invalidate_ccache(cred, cred->password_obtained); } } return cred->password; } /* Set a password on the credentials context, including an indication * of 'how' the password was obtained */ _PUBLIC_ bool cli_credentials_set_password(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained) { if (obtained >= cred->password_obtained) { cred->lm_response = data_blob_null; cred->nt_response = data_blob_null; cred->nt_hash = NULL; cred->password = NULL; cli_credentials_invalidate_ccache(cred, obtained); cred->password_tries = 0; if (val == NULL) { cred->password_obtained = obtained; return true; } if (cred->password_will_be_nt_hash) { struct samr_Password *nt_hash = NULL; size_t val_len = strlen(val); size_t converted; nt_hash = talloc(cred, struct samr_Password); if (nt_hash == NULL) { return false; } converted = strhex_to_str((char *)nt_hash->hash, sizeof(nt_hash->hash), val, val_len); if (converted != sizeof(nt_hash->hash)) { TALLOC_FREE(nt_hash); return false; } cred->nt_hash = nt_hash; cred->password_obtained = obtained; return true; } cred->password = talloc_strdup(cred, val); if (cred->password == NULL) { return false; } /* Don't print the actual password in talloc memory dumps */ talloc_set_name_const(cred->password, "password set via cli_credentials_set_password"); cred->password_obtained = obtained; return true; } return false; } _PUBLIC_ bool cli_credentials_set_password_callback(struct cli_credentials *cred, const char *(*password_cb) (struct cli_credentials *)) { if (cred->password_obtained < CRED_CALLBACK) { cred->password_tries = 3; cred->password_cb = password_cb; cred->password_obtained = CRED_CALLBACK; cli_credentials_invalidate_ccache(cred, cred->password_obtained); return true; } return false; } /** * Obtain the 'old' password for this credentials context (used for join accounts). * @param cred credentials context * @retval If set, the cleartext password, otherwise NULL */ _PUBLIC_ const char *cli_credentials_get_old_password(struct cli_credentials *cred) { if (cred->machine_account_pending) { cli_credentials_set_machine_account(cred, cred->machine_account_pending_lp_ctx); } return cred->old_password; } _PUBLIC_ bool cli_credentials_set_old_password(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained) { cred->old_password = talloc_strdup(cred, val); if (cred->old_password) { /* Don't print the actual password in talloc memory dumps */ talloc_set_name_const(cred->old_password, "password set via cli_credentials_set_old_password"); } cred->old_nt_hash = NULL; return true; } /** * Obtain the password, in the form MD4(unicode(password)) for this credentials context. * * Sometimes we only have this much of the password, while the rest of * the time this call avoids calling E_md4hash themselves. * * @param cred credentials context * @retval If set, the cleartext password, otherwise NULL */ _PUBLIC_ struct samr_Password *cli_credentials_get_nt_hash(struct cli_credentials *cred, TALLOC_CTX *mem_ctx) { enum credentials_obtained password_obtained; enum credentials_obtained ccache_threshold; enum credentials_obtained client_gss_creds_threshold; bool password_is_nt_hash; const char *password = NULL; struct samr_Password *nt_hash = NULL; if (cred->nt_hash != NULL) { /* * If we already have a hash it's easy. */ goto return_hash; } /* * This is a bit tricky, with password_will_be_nt_hash * we still need to get the value via the password_callback * but if we did that we should not remember it's state * in the long run so we need to undo it. */ password_obtained = cred->password_obtained; ccache_threshold = cred->ccache_threshold; client_gss_creds_threshold = cred->client_gss_creds_threshold; password_is_nt_hash = cred->password_will_be_nt_hash; cred->password_will_be_nt_hash = false; password = cli_credentials_get_password(cred); cred->password_will_be_nt_hash = password_is_nt_hash; if (password_is_nt_hash && password_obtained == CRED_CALLBACK) { /* * We got the nt_hash as string via the callback, * so we need to undo the state change. * * And also don't remember it as plaintext password. */ cred->client_gss_creds_threshold = client_gss_creds_threshold; cred->ccache_threshold = ccache_threshold; cred->password_obtained = password_obtained; cred->password = NULL; } if (password == NULL) { return NULL; } nt_hash = talloc(cred, struct samr_Password); if (nt_hash == NULL) { return NULL; } if (password_is_nt_hash) { size_t password_len = strlen(password); size_t converted; converted = strhex_to_str((char *)nt_hash->hash, sizeof(nt_hash->hash), password, password_len); if (converted != sizeof(nt_hash->hash)) { TALLOC_FREE(nt_hash); return NULL; } } else { E_md4hash(password, nt_hash->hash); } cred->nt_hash = nt_hash; nt_hash = NULL; return_hash: nt_hash = talloc(mem_ctx, struct samr_Password); if (nt_hash == NULL) { return NULL; } *nt_hash = *cred->nt_hash; return nt_hash; } /** * Obtain the old password, in the form MD4(unicode(password)) for this credentials context. * * Sometimes we only have this much of the password, while the rest of * the time this call avoids calling E_md4hash themselves. * * @param cred credentials context * @retval If set, the cleartext password, otherwise NULL */ _PUBLIC_ struct samr_Password *cli_credentials_get_old_nt_hash(struct cli_credentials *cred, TALLOC_CTX *mem_ctx) { const char *old_password = NULL; if (cred->old_nt_hash != NULL) { struct samr_Password *nt_hash = talloc(mem_ctx, struct samr_Password); if (!nt_hash) { return NULL; } *nt_hash = *cred->old_nt_hash; return nt_hash; } old_password = cli_credentials_get_old_password(cred); if (old_password) { struct samr_Password *nt_hash = talloc(mem_ctx, struct samr_Password); if (!nt_hash) { return NULL; } E_md4hash(old_password, nt_hash->hash); return nt_hash; } return NULL; } /** * Obtain the 'short' or 'NetBIOS' domain for this credentials context. * @param cred credentials context * @retval The domain set on this context. * @note Return value will never be NULL except by programmer error. */ _PUBLIC_ const char *cli_credentials_get_domain(struct cli_credentials *cred) { if (cred->machine_account_pending) { cli_credentials_set_machine_account(cred, cred->machine_account_pending_lp_ctx); } if (cred->domain_obtained == CRED_CALLBACK && !cred->callback_running) { cred->callback_running = true; cred->domain = cred->domain_cb(cred); cred->callback_running = false; if (cred->domain_obtained == CRED_CALLBACK) { cred->domain_obtained = CRED_CALLBACK_RESULT; cli_credentials_invalidate_ccache(cred, cred->domain_obtained); } } return cred->domain; } _PUBLIC_ bool cli_credentials_set_domain(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained) { if (obtained >= cred->domain_obtained) { /* it is important that the domain be in upper case, * particularly for the sensitive NTLMv2 * calculations */ cred->domain = strupper_talloc(cred, val); cred->domain_obtained = obtained; /* setting domain does not mean we have to invalidate ccache * because domain in not used for Kerberos operations. * If ccache invalidation is required, one will anyway specify * a password to kinit, and that will force invalidation of the ccache */ return true; } return false; } bool cli_credentials_set_domain_callback(struct cli_credentials *cred, const char *(*domain_cb) (struct cli_credentials *)) { if (cred->domain_obtained < CRED_CALLBACK) { cred->domain_cb = domain_cb; cred->domain_obtained = CRED_CALLBACK; return true; } return false; } /** * Obtain the Kerberos realm for this credentials context. * @param cred credentials context * @retval The realm set on this context. * @note Return value will never be NULL except by programmer error. */ _PUBLIC_ const char *cli_credentials_get_realm(struct cli_credentials *cred) { if (cred->machine_account_pending) { cli_credentials_set_machine_account(cred, cred->machine_account_pending_lp_ctx); } if (cred->realm_obtained == CRED_CALLBACK && !cred->callback_running) { cred->callback_running = true; cred->realm = cred->realm_cb(cred); cred->callback_running = false; if (cred->realm_obtained == CRED_CALLBACK) { cred->realm_obtained = CRED_CALLBACK_RESULT; cli_credentials_invalidate_ccache(cred, cred->realm_obtained); } } return cred->realm; } /** * Set the realm for this credentials context, and force it to * uppercase for the sanity of our local kerberos libraries */ _PUBLIC_ bool cli_credentials_set_realm(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained) { if (obtained >= cred->realm_obtained) { cred->realm = strupper_talloc(cred, val); cred->realm_obtained = obtained; cli_credentials_invalidate_ccache(cred, cred->realm_obtained); return true; } return false; } bool cli_credentials_set_realm_callback(struct cli_credentials *cred, const char *(*realm_cb) (struct cli_credentials *)) { if (cred->realm_obtained < CRED_CALLBACK) { cred->realm_cb = realm_cb; cred->realm_obtained = CRED_CALLBACK; return true; } return false; } /** * Obtain the 'short' or 'NetBIOS' workstation name for this credentials context. * * @param cred credentials context * @retval The workstation name set on this context. * @note Return value will never be NULL except by programmer error. */ _PUBLIC_ const char *cli_credentials_get_workstation(struct cli_credentials *cred) { if (cred->workstation_obtained == CRED_CALLBACK && !cred->callback_running) { cred->callback_running = true; cred->workstation = cred->workstation_cb(cred); cred->callback_running = false; if (cred->workstation_obtained == CRED_CALLBACK) { cred->workstation_obtained = CRED_CALLBACK_RESULT; } } return cred->workstation; } _PUBLIC_ bool cli_credentials_set_workstation(struct cli_credentials *cred, const char *val, enum credentials_obtained obtained) { if (obtained >= cred->workstation_obtained) { cred->workstation = talloc_strdup(cred, val); cred->workstation_obtained = obtained; return true; } return false; } bool cli_credentials_set_workstation_callback(struct cli_credentials *cred, const char *(*workstation_cb) (struct cli_credentials *)) { if (cred->workstation_obtained < CRED_CALLBACK) { cred->workstation_cb = workstation_cb; cred->workstation_obtained = CRED_CALLBACK; return true; } return false; } /** * Given a string, typically obtained from a -U argument, parse it into domain, username, realm and password fields * * The format accepted is [domain\\]user[%password] or user[@realm][%password] * * @param credentials Credentials structure on which to set the password * @param data the string containing the username, password etc * @param obtained This enum describes how 'specified' this password is */ _PUBLIC_ void cli_credentials_parse_string(struct cli_credentials *credentials, const char *data, enum credentials_obtained obtained) { char *uname, *p; if (strcmp("%",data) == 0) { cli_credentials_set_anonymous(credentials); return; } uname = talloc_strdup(credentials, data); if ((p = strchr_m(uname,'%'))) { *p = 0; cli_credentials_set_password(credentials, p+1, obtained); } if ((p = strchr_m(uname,'@'))) { /* * We also need to set username and domain * in order to undo the effect of * cli_credentials_guess(). */ cli_credentials_set_username(credentials, uname, obtained); cli_credentials_set_domain(credentials, "", obtained); cli_credentials_set_principal(credentials, uname, obtained); *p = 0; cli_credentials_set_realm(credentials, p+1, obtained); return; } else if ((p = strchr_m(uname,'\\')) || (p = strchr_m(uname, '/')) || (p = strchr_m(uname, credentials->winbind_separator))) { const char *domain = NULL; domain = uname; *p = 0; uname = p+1; if (obtained == credentials->realm_obtained && !strequal_m(credentials->domain, domain)) { /* * We need to undo a former set with the same level * in order to get the expected result from * cli_credentials_get_principal(). * * But we only need to do that if the domain * actually changes. */ cli_credentials_set_realm(credentials, domain, obtained); } cli_credentials_set_domain(credentials, domain, obtained); } if (obtained == credentials->principal_obtained && !strequal_m(credentials->username, uname)) { /* * We need to undo a former set with the same level * in order to get the expected result from * cli_credentials_get_principal(). * * But we only need to do that if the username * actually changes. */ credentials->principal_obtained = CRED_UNINITIALISED; credentials->principal = NULL; } cli_credentials_set_username(credentials, uname, obtained); } /** * Given a a credentials structure, print it as a string * * The format output is [domain\\]user[%password] or user[@realm][%password] * * @param credentials Credentials structure on which to set the password * @param mem_ctx The memory context to place the result on */ _PUBLIC_ char *cli_credentials_get_unparsed_name(struct cli_credentials *credentials, TALLOC_CTX *mem_ctx) { const char *bind_dn = cli_credentials_get_bind_dn(credentials); const char *domain = NULL; const char *username = NULL; char *name = NULL; if (bind_dn) { name = talloc_strdup(mem_ctx, bind_dn); } else { cli_credentials_get_ntlm_username_domain(credentials, mem_ctx, &username, &domain); if (domain && domain[0]) { name = talloc_asprintf(mem_ctx, "%s\\%s", domain, username); } else { name = talloc_asprintf(mem_ctx, "%s", username); } } return name; } /** * Specifies default values for domain, workstation and realm * from the smb.conf configuration file * * @param cred Credentials structure to fill in */ _PUBLIC_ void cli_credentials_set_conf(struct cli_credentials *cred, struct loadparm_context *lp_ctx) { const char *sep = NULL; const char *realm = lpcfg_realm(lp_ctx); cli_credentials_set_username(cred, "", CRED_UNINITIALISED); if (lpcfg_parm_is_cmdline(lp_ctx, "workgroup")) { cli_credentials_set_domain(cred, lpcfg_workgroup(lp_ctx), CRED_SPECIFIED); } else { cli_credentials_set_domain(cred, lpcfg_workgroup(lp_ctx), CRED_UNINITIALISED); } if (lpcfg_parm_is_cmdline(lp_ctx, "netbios name")) { cli_credentials_set_workstation(cred, lpcfg_netbios_name(lp_ctx), CRED_SPECIFIED); } else { cli_credentials_set_workstation(cred, lpcfg_netbios_name(lp_ctx), CRED_UNINITIALISED); } if (realm != NULL && strlen(realm) == 0) { realm = NULL; } if (lpcfg_parm_is_cmdline(lp_ctx, "realm")) { cli_credentials_set_realm(cred, realm, CRED_SPECIFIED); } else { cli_credentials_set_realm(cred, realm, CRED_UNINITIALISED); } sep = lpcfg_winbind_separator(lp_ctx); if (sep != NULL && sep[0] != '\0') { cred->winbind_separator = *lpcfg_winbind_separator(lp_ctx); } } /** * Guess defaults for credentials from environment variables, * and from the configuration file * * @param cred Credentials structure to fill in */ _PUBLIC_ void cli_credentials_guess(struct cli_credentials *cred, struct loadparm_context *lp_ctx) { char *p; const char *error_string; if (lp_ctx != NULL) { cli_credentials_set_conf(cred, lp_ctx); } if (getenv("LOGNAME")) { cli_credentials_set_username(cred, getenv("LOGNAME"), CRED_GUESS_ENV); } if (getenv("USER")) { cli_credentials_parse_string(cred, getenv("USER"), CRED_GUESS_ENV); if ((p = strchr_m(getenv("USER"),'%'))) { memset(p,0,strlen(cred->password)); } } if (getenv("PASSWD")) { cli_credentials_set_password(cred, getenv("PASSWD"), CRED_GUESS_ENV); } if (getenv("PASSWD_FD")) { cli_credentials_parse_password_fd(cred, atoi(getenv("PASSWD_FD")), CRED_GUESS_FILE); } p = getenv("PASSWD_FILE"); if (p && p[0]) { cli_credentials_parse_password_file(cred, p, CRED_GUESS_FILE); } if (lp_ctx != NULL && cli_credentials_get_kerberos_state(cred) != CRED_DONT_USE_KERBEROS) { cli_credentials_set_ccache(cred, lp_ctx, NULL, CRED_GUESS_FILE, &error_string); } } /** * Attach NETLOGON credentials for use with SCHANNEL */ _PUBLIC_ void cli_credentials_set_netlogon_creds( struct cli_credentials *cred, const struct netlogon_creds_CredentialState *netlogon_creds) { TALLOC_FREE(cred->netlogon_creds); if (netlogon_creds == NULL) { return; } cred->netlogon_creds = netlogon_creds_copy(cred, netlogon_creds); } /** * Return attached NETLOGON credentials */ _PUBLIC_ struct netlogon_creds_CredentialState *cli_credentials_get_netlogon_creds(struct cli_credentials *cred) { return cred->netlogon_creds; } /** * Set NETLOGON secure channel type */ _PUBLIC_ void cli_credentials_set_secure_channel_type(struct cli_credentials *cred, enum netr_SchannelType secure_channel_type) { cred->secure_channel_type = secure_channel_type; } /** * Return NETLOGON secure chanel type */ _PUBLIC_ time_t cli_credentials_get_password_last_changed_time(struct cli_credentials *cred) { return cred->password_last_changed_time; } /** * Set NETLOGON secure channel type */ _PUBLIC_ void cli_credentials_set_password_last_changed_time(struct cli_credentials *cred, time_t last_changed_time) { cred->password_last_changed_time = last_changed_time; } /** * Return NETLOGON secure chanel type */ _PUBLIC_ enum netr_SchannelType cli_credentials_get_secure_channel_type(struct cli_credentials *cred) { return cred->secure_channel_type; } /** * Fill in a credentials structure as the anonymous user */ _PUBLIC_ void cli_credentials_set_anonymous(struct cli_credentials *cred) { cli_credentials_set_username(cred, "", CRED_SPECIFIED); cli_credentials_set_domain(cred, "", CRED_SPECIFIED); cli_credentials_set_password(cred, NULL, CRED_SPECIFIED); cli_credentials_set_principal(cred, NULL, CRED_SPECIFIED); cli_credentials_set_realm(cred, NULL, CRED_SPECIFIED); cli_credentials_set_workstation(cred, "", CRED_UNINITIALISED); cli_credentials_set_kerberos_state(cred, CRED_DONT_USE_KERBEROS); } /** * Describe a credentials context as anonymous or authenticated * @retval true if anonymous, false if a username is specified */ _PUBLIC_ bool cli_credentials_is_anonymous(struct cli_credentials *cred) { const char *username; /* if bind dn is set it's not anonymous */ if (cred->bind_dn) { return false; } if (cred->machine_account_pending) { cli_credentials_set_machine_account(cred, cred->machine_account_pending_lp_ctx); } /* if principal is set, it's not anonymous */ if ((cred->principal != NULL) && cred->principal_obtained >= cred->username_obtained) { return false; } username = cli_credentials_get_username(cred); /* Yes, it is deliberate that we die if we have a NULL pointer * here - anonymous is "", not NULL, which is 'never specified, * never guessed', ie programmer bug */ if (!username[0]) { return true; } return false; } /** * Mark the current password for a credentials struct as wrong. This will * cause the password to be prompted again (if a callback is set). * * This will decrement the number of times the password can be tried. * * @retval whether the credentials struct is finished */ _PUBLIC_ bool cli_credentials_wrong_password(struct cli_credentials *cred) { if (cred->password_obtained != CRED_CALLBACK_RESULT) { return false; } if (cred->password_tries == 0) { return false; } cred->password_tries--; if (cred->password_tries == 0) { return false; } cred->password_obtained = CRED_CALLBACK; return true; } _PUBLIC_ void cli_credentials_get_ntlm_username_domain(struct cli_credentials *cred, TALLOC_CTX *mem_ctx, const char **username, const char **domain) { if (cred->principal_obtained >= cred->username_obtained) { *domain = talloc_strdup(mem_ctx, ""); *username = cli_credentials_get_principal(cred, mem_ctx); } else { *domain = cli_credentials_get_domain(cred); *username = cli_credentials_get_username(cred); } } /** * Read a named file, and parse it for username, domain, realm and password * * @param credentials Credentials structure on which to set the password * @param file a named file to read the details from * @param obtained This enum describes how 'specified' this password is */ _PUBLIC_ bool cli_credentials_parse_file(struct cli_credentials *cred, const char *file, enum credentials_obtained obtained) { uint16_t len = 0; char *ptr, *val, *param; char **lines; int i, numlines; const char *realm = NULL; const char *domain = NULL; const char *password = NULL; const char *username = NULL; lines = file_lines_load(file, &numlines, 0, NULL); if (lines == NULL) { /* fail if we can't open the credentials file */ d_printf("ERROR: Unable to open credentials file!\n"); return false; } for (i = 0; i < numlines; i++) { len = strlen(lines[i]); if (len == 0) continue; /* break up the line into parameter & value. * will need to eat a little whitespace possibly */ param = lines[i]; if (!(ptr = strchr_m (lines[i], '='))) continue; val = ptr+1; *ptr = '\0'; /* eat leading white space */ while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) val++; if (strwicmp("password", param) == 0) { password = val; } else if (strwicmp("username", param) == 0) { username = val; } else if (strwicmp("domain", param) == 0) { domain = val; } else if (strwicmp("realm", param) == 0) { realm = val; } /* * We need to readd '=' in order to let * the strlen() work in the last loop * that clears the memory. */ *ptr = '='; } if (realm != NULL && strlen(realm) != 0) { /* * only overwrite with a valid string */ cli_credentials_set_realm(cred, realm, obtained); } if (domain != NULL && strlen(domain) != 0) { /* * only overwrite with a valid string */ cli_credentials_set_domain(cred, domain, obtained); } if (password != NULL) { /* * Here we allow "". */ cli_credentials_set_password(cred, password, obtained); } if (username != NULL) { /* * The last "username" line takes preference * if the string also contains domain, realm or * password. */ cli_credentials_parse_string(cred, username, obtained); } for (i = 0; i < numlines; i++) { len = strlen(lines[i]); memset(lines[i], 0, len); } talloc_free(lines); return true; } /** * Read a named file, and parse it for a password * * @param credentials Credentials structure on which to set the password * @param file a named file to read the password from * @param obtained This enum describes how 'specified' this password is */ _PUBLIC_ bool cli_credentials_parse_password_file(struct cli_credentials *credentials, const char *file, enum credentials_obtained obtained) { int fd = open(file, O_RDONLY, 0); bool ret; if (fd < 0) { fprintf(stderr, "Error opening password file %s: %s\n", file, strerror(errno)); return false; } ret = cli_credentials_parse_password_fd(credentials, fd, obtained); close(fd); return ret; } /** * Read a file descriptor, and parse it for a password (eg from a file or stdin) * * @param credentials Credentials structure on which to set the password * @param fd open file descriptor to read the password from * @param obtained This enum describes how 'specified' this password is */ _PUBLIC_ bool cli_credentials_parse_password_fd(struct cli_credentials *credentials, int fd, enum credentials_obtained obtained) { char *p; char pass[128]; for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */ p && p - pass < sizeof(pass);) { switch (read(fd, p, 1)) { case 1: if (*p != '\n' && *p != '\0') { *++p = '\0'; /* advance p, and null-terminate pass */ break; } FALL_THROUGH; case 0: if (p - pass) { *p = '\0'; /* null-terminate it, just in case... */ p = NULL; /* then force the loop condition to become false */ break; } fprintf(stderr, "Error reading password from file descriptor " "%d: empty password\n", fd); return false; default: fprintf(stderr, "Error reading password from file descriptor %d: %s\n", fd, strerror(errno)); return false; } } cli_credentials_set_password(credentials, pass, obtained); return true; } /** * Encrypt a data blob using the session key and the negotiated encryption * algorithm * * @param state Credential state, contains the session key and algorithm * @param data Data blob containing the data to be encrypted. * */ _PUBLIC_ NTSTATUS netlogon_creds_session_encrypt( struct netlogon_creds_CredentialState *state, DATA_BLOB data) { NTSTATUS status; if (data.data == NULL || data.length == 0) { DBG_ERR("Nothing to encrypt " "data.data == NULL or data.length == 0"); return NT_STATUS_INVALID_PARAMETER; } /* * Don't crypt an all-zero password it will give away the * NETLOGON pipe session key . */ if (all_zero(data.data, data.length)) { DBG_ERR("Supplied data all zeros, could leak session key"); return NT_STATUS_INVALID_PARAMETER; } if (state->negotiate_flags & NETLOGON_NEG_SUPPORTS_AES) { status = netlogon_creds_aes_encrypt(state, data.data, data.length); } else if (state->negotiate_flags & NETLOGON_NEG_ARCFOUR) { status = netlogon_creds_arcfour_crypt(state, data.data, data.length); } else { DBG_ERR("Unsupported encryption option negotiated"); status = NT_STATUS_NOT_SUPPORTED; } if (!NT_STATUS_IS_OK(status)) { return status; } return NT_STATUS_OK; }
utf-8
1
GPL-3.0+
1992-2012 Andrew Tridgell and the Samba Team
liquid-dsp-1.3.2/examples/windowf_example.c
// // windowf_example.c // // This example demonstrates the functionality of a window buffer (also // known as a circular or ring buffer) of floating-point values. Values // are written to and read from the buffer using several different // methods. // // SEE ALSO: bufferf_example.c // wdelayf_example.c // #include <stdio.h> #include "liquid.h" int main() { // initialize vector of data for testing float v[] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; float *r; // reader unsigned int i; // create window: 10 elements, initialized to 0 // w: 0 0 0 0 0 0 0 0 0 0 windowf w = windowf_create(10); // push 4 elements // w: 0 0 0 0 0 0 1 1 1 1 windowf_push(w, 1); windowf_push(w, 1); windowf_push(w, 1); windowf_push(w, 1); // push 4 more elements // w: 0 0 1 1 1 1 9 8 7 6 windowf_write(w, v, 4); // push 4 more elements // w: 1 1 9 8 7 6 3 3 3 3 windowf_push(w, 3); windowf_push(w, 3); windowf_push(w, 3); windowf_push(w, 3); // read the buffer by assigning the pointer // appropriately windowf_read(w, &r); // manual print printf("manual output:\n"); for (i=0; i<10; i++) printf("%6u : %f\n", i, r[i]); windowf_debug_print(w); // clean it up windowf_destroy(w); printf("done.\n"); return 0; }
utf-8
1
Expat
2007-2017 Joseph Gaeddert
squid-5.2/lib/ntlmauth/support_endian.h
/* * Copyright (C) 1996-2021 The Squid Software Foundation and contributors * * Squid software is distributed under GPLv2+ license and includes * contributions from numerous individuals and organizations. * Please see the COPYING and CONTRIBUTORS files for details. */ #ifndef SQUID_LIB_NTLMAUTH_SUPPORT_ENDIAN_H #define SQUID_LIB_NTLMAUTH_SUPPORT_ENDIAN_H #if HAVE_BYTESWAP_H #include <byteswap.h> #endif #if HAVE_MACHINE_BYTE_SWAP_H #include <machine/byte_swap.h> #endif #if HAVE_SYS_BSWAP_H #include <sys/bswap.h> #endif #if HAVE_ENDIAN_H #include <endian.h> #endif #if HAVE_SYS_ENDIAN_H #include <sys/endian.h> #endif /* * Macros to deal with byte swapping. These macros provide * the following interface: * * // Byte-swap * uint16_t bswap16(uint16_t); * uint32_t bswap32(uint32_t); * * // Convert from host byte order to little-endian, and vice versa. * uint16_t htole16(uint16_t); * uint32_t htole32(uint32_t); * uint16_t le16toh(uint16_t); * uint32_t le32toh(uint32_t); * * XXX: What about unusual byte orders like 3412 or 2143 ? * Never had any problems reported, so we do not worry about them. */ #if !HAVE_HTOLE16 && !defined(htole16) /* Define bswap16() in terms of bswap_16() or the hard way. */ #if !HAVE_BSWAP16 && !defined(bswap16) # if HAVE_BSWAP_16 || defined(bswap_16) # define bswap16(x) bswap_16(x) # else // 'hard way' # define bswap16(x) \ (((((uint16_t)(x)) >> 8) & 0xff) | ((((uint16_t)(x)) & 0xff) << 8)) # endif #endif /* Define htole16() in terms of bswap16(). */ # if defined(WORDS_BIGENDIAN) # define htole16(x) bswap16(x) # else # define htole16(x) (x) # endif #endif #if !HAVE_HTOLE32 && !defined(htole32) #if ! HAVE_BSWAP32 && ! defined(bswap32) /* Define bswap32() in terms of bswap_32() or the hard way. */ # if HAVE_BSWAP_32 || defined(bswap_32) # define bswap32(x) bswap_32(x) # else // 'hard way' # define bswap32(x) \ (((((uint32_t)(x)) & 0xff000000) >> 24) | \ ((((uint32_t)(x)) & 0x00ff0000) >> 8) | \ ((((uint32_t)(x)) & 0x0000ff00) << 8) | \ ((((uint32_t)(x)) & 0x000000ff) << 24)) # endif /* Define htole32() in terms of bswap32(). */ #endif # if defined(WORDS_BIGENDIAN) # define htole32(x) bswap32(x) # else # define htole32(x) (x) # endif #endif /* Define letoh*() in terms of htole*(). The swap is symmetrical. */ #if !HAVE_LE16TOH && !defined(le16toh) #define le16toh(x) htole16(x) #endif #if !HAVE_LE32TOH && !defined(le32toh) #define le32toh(x) htole32(x) #endif #endif /* SQUID_LIB_NTLMAUTH_SUPPORT_ENDIAN_H */
utf-8
1
unknown
unknown
paraview-5.10.0~rc1/VTK/ThirdParty/vtkm/vtkvtkm/vtk-m/vtkm/cont/CellSetExtrude.h
//============================================================================ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt 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. //============================================================================ #ifndef vtk_m_cont_CellSetExtrude_h #define vtk_m_cont_CellSetExtrude_h #include <vtkm/TopologyElementTag.h> #include <vtkm/cont/ArrayHandle.h> #include <vtkm/cont/ArrayHandleCounting.h> #include <vtkm/cont/ArrayHandleXGCCoordinates.h> #include <vtkm/cont/CellSet.h> #include <vtkm/cont/Invoker.h> #include <vtkm/exec/ConnectivityExtrude.h> #include <vtkm/exec/arg/ThreadIndicesExtrude.h> namespace vtkm { namespace cont { namespace detail { template <typename VisitTopology, typename IncidentTopology> struct CellSetExtrudeConnectivityChooser; template <> struct CellSetExtrudeConnectivityChooser<vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint> { using ExecConnectivityType = vtkm::exec::ConnectivityExtrude; }; template <> struct CellSetExtrudeConnectivityChooser<vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell> { using ExecConnectivityType = vtkm::exec::ReverseConnectivityExtrude; }; } // namespace detail class VTKM_CONT_EXPORT CellSetExtrude : public CellSet { public: VTKM_CONT CellSetExtrude(); VTKM_CONT CellSetExtrude(const vtkm::cont::ArrayHandle<vtkm::Int32>& conn, vtkm::Int32 numberOfPointsPerPlane, vtkm::Int32 numberOfPlanes, const vtkm::cont::ArrayHandle<vtkm::Int32>& nextNode, bool periodic); VTKM_CONT CellSetExtrude(const CellSetExtrude& src); VTKM_CONT CellSetExtrude(CellSetExtrude&& src) noexcept; VTKM_CONT CellSetExtrude& operator=(const CellSetExtrude& src); VTKM_CONT CellSetExtrude& operator=(CellSetExtrude&& src) noexcept; virtual ~CellSetExtrude() override; vtkm::Int32 GetNumberOfPlanes() const; vtkm::Id GetNumberOfCells() const override; vtkm::Id GetNumberOfPoints() const override; vtkm::Id GetNumberOfFaces() const override; vtkm::Id GetNumberOfEdges() const override; VTKM_CONT vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagCell) const; VTKM_CONT vtkm::Id2 GetSchedulingRange(vtkm::TopologyElementTagPoint) const; vtkm::UInt8 GetCellShape(vtkm::Id id) const override; vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id id) const override; void GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const override; std::shared_ptr<CellSet> NewInstance() const override; void DeepCopy(const CellSet* src) override; void PrintSummary(std::ostream& out) const override; void ReleaseResourcesExecution() override; const vtkm::cont::ArrayHandle<vtkm::Int32>& GetConnectivityArray() const { return this->Connectivity; } vtkm::Int32 GetNumberOfPointsPerPlane() const { return this->NumberOfPointsPerPlane; } const vtkm::cont::ArrayHandle<vtkm::Int32>& GetNextNodeArray() const { return this->NextNode; } bool GetIsPeriodic() const { return this->IsPeriodic; } template <vtkm::IdComponent NumIndices> VTKM_CONT void GetIndices(vtkm::Id index, vtkm::Vec<vtkm::Id, NumIndices>& ids) const; VTKM_CONT void GetIndices(vtkm::Id index, vtkm::cont::ArrayHandle<vtkm::Id>& ids) const; template <typename VisitTopology, typename IncidentTopology> using ExecConnectivityType = typename detail::CellSetExtrudeConnectivityChooser<VisitTopology, IncidentTopology>::ExecConnectivityType; template <typename DeviceAdapter, typename VisitTopology, typename IncidentTopology> struct VTKM_DEPRECATED( 1.6, "Replace ExecutionTypes<D, V, I>::ExecObjectType with ExecConnectivityType<V, I>.") ExecutionTypes { using ExecObjectType = ExecConnectivityType<VisitTopology, IncidentTopology>; }; vtkm::exec::ConnectivityExtrude PrepareForInput(vtkm::cont::DeviceAdapterId, vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint, vtkm::cont::Token&) const; vtkm::exec::ReverseConnectivityExtrude PrepareForInput(vtkm::cont::DeviceAdapterId, vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell, vtkm::cont::Token&) const; VTKM_DEPRECATED(1.6, "Provide a vtkm::cont::Token object when calling PrepareForInput.") vtkm::exec::ConnectivityExtrude PrepareForInput( vtkm::cont::DeviceAdapterId device, vtkm::TopologyElementTagCell visitTopology, vtkm::TopologyElementTagPoint incidentTopology) const { vtkm::cont::Token token; return this->PrepareForInput(device, visitTopology, incidentTopology, token); } VTKM_DEPRECATED(1.6, "Provide a vtkm::cont::Token object when calling PrepareForInput.") vtkm::exec::ReverseConnectivityExtrude PrepareForInput( vtkm::cont::DeviceAdapterId device, vtkm::TopologyElementTagPoint visitTopology, vtkm::TopologyElementTagCell incidentTopology) const { vtkm::cont::Token token; return this->PrepareForInput(device, visitTopology, incidentTopology, token); } private: void BuildReverseConnectivity(); bool IsPeriodic; vtkm::Int32 NumberOfPointsPerPlane; vtkm::Int32 NumberOfCellsPerPlane; vtkm::Int32 NumberOfPlanes; vtkm::cont::ArrayHandle<vtkm::Int32> Connectivity; vtkm::cont::ArrayHandle<vtkm::Int32> NextNode; bool ReverseConnectivityBuilt; vtkm::cont::ArrayHandle<vtkm::Int32> RConnectivity; vtkm::cont::ArrayHandle<vtkm::Int32> ROffsets; vtkm::cont::ArrayHandle<vtkm::Int32> RCounts; vtkm::cont::ArrayHandle<vtkm::Int32> PrevNode; }; template <typename T> CellSetExtrude make_CellSetExtrude(const vtkm::cont::ArrayHandle<vtkm::Int32>& conn, const vtkm::cont::ArrayHandleXGCCoordinates<T>& coords, const vtkm::cont::ArrayHandle<vtkm::Int32>& nextNode, bool periodic = true) { return CellSetExtrude{ conn, coords.GetNumberOfPointsPerPlane(), coords.GetNumberOfPlanes(), nextNode, periodic }; } template <typename T> CellSetExtrude make_CellSetExtrude(const std::vector<vtkm::Int32>& conn, const vtkm::cont::ArrayHandleXGCCoordinates<T>& coords, const std::vector<vtkm::Int32>& nextNode, bool periodic = true) { return CellSetExtrude{ vtkm::cont::make_ArrayHandle(conn, vtkm::CopyFlag::On), static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()), static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()), vtkm::cont::make_ArrayHandle(nextNode, vtkm::CopyFlag::On), periodic }; } template <typename T> CellSetExtrude make_CellSetExtrude(std::vector<vtkm::Int32>&& conn, const vtkm::cont::ArrayHandleXGCCoordinates<T>& coords, std::vector<vtkm::Int32>&& nextNode, bool periodic = true) { return CellSetExtrude{ vtkm::cont::make_ArrayHandleMove(std::move(conn)), static_cast<vtkm::Int32>(coords.GetNumberOfPointsPerPlane()), static_cast<vtkm::Int32>(coords.GetNumberOfPlanes()), vtkm::cont::make_ArrayHandleMove(std::move(nextNode)), periodic }; } } } // vtkm::cont //============================================================================= // Specializations of serialization related classes /// @cond SERIALIZATION namespace vtkm { namespace cont { template <> struct SerializableTypeString<vtkm::cont::CellSetExtrude> { static VTKM_CONT const std::string& Get() { static std::string name = "CS_Extrude"; return name; } }; } } // vtkm::cont namespace mangled_diy_namespace { template <> struct Serialization<vtkm::cont::CellSetExtrude> { private: using Type = vtkm::cont::CellSetExtrude; public: static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs) { vtkmdiy::save(bb, cs.GetNumberOfPointsPerPlane()); vtkmdiy::save(bb, cs.GetNumberOfPlanes()); vtkmdiy::save(bb, cs.GetIsPeriodic()); vtkmdiy::save(bb, cs.GetConnectivityArray()); vtkmdiy::save(bb, cs.GetNextNodeArray()); } static VTKM_CONT void load(BinaryBuffer& bb, Type& cs) { vtkm::Int32 numberOfPointsPerPlane; vtkm::Int32 numberOfPlanes; bool isPeriodic; vtkm::cont::ArrayHandle<vtkm::Int32> conn; vtkm::cont::ArrayHandle<vtkm::Int32> nextNode; vtkmdiy::load(bb, numberOfPointsPerPlane); vtkmdiy::load(bb, numberOfPlanes); vtkmdiy::load(bb, isPeriodic); vtkmdiy::load(bb, conn); vtkmdiy::load(bb, nextNode); cs = Type{ conn, numberOfPointsPerPlane, numberOfPlanes, nextNode, isPeriodic }; } }; } // diy /// @endcond SERIALIZATION #endif // vtk_m_cont_CellSetExtrude.h
utf-8
1
BSD-3-clause
2000-2005 Kitware Inc. 28 Corporate Drive, Suite 204, Clifton Park, NY, 12065, USA. 2000-2005 Kitware Inc. 28 Corporate Drive, Suite 204, Clifton Park, NY, 12065, USA.
cc65-2.19/src/sim65/paravirt.h
/*****************************************************************************/ /* */ /* paravirt.h */ /* */ /* Paravirtualization for the sim65 6502 simulator */ /* */ /* */ /* */ /* (C) 2013-2013 Ullrich von Bassewitz */ /* Römerstrasse 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ /* warranty. In no event will the authors be held liable for any damages */ /* arising from the use of this software. */ /* */ /* Permission is granted to anyone to use this software for any purpose, */ /* including commercial applications, and to alter it and redistribute it */ /* freely, subject to the following restrictions: */ /* */ /* 1. The origin of this software must not be misrepresented; you must not */ /* claim that you wrote the original software. If you use this software */ /* in a product, an acknowledgment in the product documentation would be */ /* appreciated but is not required. */ /* 2. Altered source versions must be plainly marked as such, and must not */ /* be misrepresented as being the original software. */ /* 3. This notice may not be removed or altered from any source */ /* distribution. */ /* */ /*****************************************************************************/ #ifndef PARAVIRT_H #define PARAVIRT_H /*****************************************************************************/ /* Data */ /*****************************************************************************/ #define PARAVIRT_BASE 0xFFF4 /* Lowest address used by a paravirtualization hook */ /*****************************************************************************/ /* Code */ /*****************************************************************************/ void ParaVirtInit (unsigned aArgStart, unsigned char aSPAddr); /* Initialize the paravirtualization subsystem */ void ParaVirtHooks (CPURegs* Regs); /* Potentially execute paravirtualization hooks */ /* End of paravirt.h */ #endif
ISO-8859-1
0.73
BSD-3-zlib
2004- Oliver Schmidt <ol.sc@web.de>, 1999-2015 Ullrich von Bassewitz <uz@cc65.org>, 1989 John R. Dunning <jrd@jrd.org>
eqonomize-1.5.3/src/recurrenceeditwidget.cpp
/*************************************************************************** * Copyright (C) 2006-2008, 2014, 2016 by Hanna Knutsson * * hanna.knutsson@protonmail.com * * * * This file is part of Eqonomize!. * * * * Eqonomize! is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * Eqonomize! 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 Eqonomize!. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ #ifdef HAVE_CONFIG_H # include <config.h> #endif #include <QButtonGroup> #include <QBoxLayout> #include <QCheckBox> #include <QComboBox> #include <QGridLayout> #include <QGroupBox> #include <QHBoxLayout> #include <QLabel> #include <QLayout> #include <QListWidget> #include <QLineEdit> #include <QObject> #include <QPushButton> #include <QRadioButton> #include <QSpinBox> #include <QStackedWidget> #include <QVBoxLayout> #include <QDialogButtonBox> #include <QDateEdit> #include <QMessageBox> #include "budget.h" #include "eqonomizevalueedit.h" #include "recurrence.h" #include "recurrenceeditwidget.h" EditExceptionsDialog::EditExceptionsDialog(QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Edit Exceptions")); setModal(true); QVBoxLayout *box1 = new QVBoxLayout(this); QGridLayout *layout = new QGridLayout(); box1->addLayout(layout); layout->addWidget(new QLabel(tr("Occurrences:"), this), 0, 0); occurrencesList = new QListWidget(this); occurrencesList->setSelectionMode(QListWidget::ExtendedSelection); layout->addWidget(occurrencesList, 1, 0); QVBoxLayout *buttonsLayout = new QVBoxLayout(); layout->addLayout(buttonsLayout, 0, 1, -1, 1); buttonsLayout->addStretch(1); addButton = new QPushButton(tr("Add Exception"), this); addButton->setEnabled(false); buttonsLayout->addWidget(addButton); deleteButton = new QPushButton(tr("Remove Exception"), this); deleteButton->setEnabled(false); buttonsLayout->addWidget(deleteButton); buttonsLayout->addStretch(1); layout->addWidget(new QLabel(tr("Exceptions:"), this), 0, 2); exceptionsList = new QListWidget(this); exceptionsList->setSelectionMode(QListWidget::ExtendedSelection); layout->addWidget(exceptionsList, 1, 2); infoLabel = new QLabel(QString("<i>") + tr("Only the first fifty occurrences are shown.") + QString("</i>"), this); infoLabel->hide(); layout->addWidget(infoLabel, 2, 0, 1, -1); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal, this); buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); buttonBox->button(QDialogButtonBox::Cancel)->setAutoDefault(false); buttonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); connect(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept())); box1->addWidget(buttonBox); connect(occurrencesList, SIGNAL(itemSelectionChanged()), this, SLOT(onSelectionChanged())); connect(exceptionsList, SIGNAL(itemSelectionChanged()), this, SLOT(onSelectionChanged())); connect(addButton, SIGNAL(clicked()), this, SLOT(addException())); connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteException())); } EditExceptionsDialog::~EditExceptionsDialog() { } void EditExceptionsDialog::setRecurrence(Recurrence *rec) { occurrencesList->clear(); exceptionsList->clear(); if(rec) { QDate next_date = rec->firstOccurrence(); int i = 0; for(; i < 50 && next_date.isValid(); i++) { occurrencesList->addItem(QLocale().toString(next_date, QLocale::ShortFormat)); next_date = rec->nextOccurrence(next_date); } if(i == 50) { infoLabel->show(); } else { infoLabel->hide(); } for(QVector<QDate>::size_type i = 0; i < rec->exceptions.size(); i++) { exceptionsList->addItem(QLocale().toString(rec->exceptions[i], QLocale::ShortFormat)); } exceptionsList->sortItems(); } o_rec = rec; saveValues(); } void EditExceptionsDialog::modifyExceptions(Recurrence *rec) { for(int i = 0; i < exceptionsList->count(); i++) { rec->addException(QLocale().toDate(exceptionsList->item(i)->text(), QLocale::ShortFormat)); } } bool EditExceptionsDialog::validValues() { return true; } void EditExceptionsDialog::saveValues() { savedExceptions.clear(); for(int i = 0; i < exceptionsList->count(); i++) { savedExceptions.append(exceptionsList->item(i)->text()); } } void EditExceptionsDialog::restoreValues() { exceptionsList->clear(); exceptionsList->addItems(savedExceptions); } void EditExceptionsDialog::accept() { if(!validValues()) return; saveValues(); QDialog::accept(); } void EditExceptionsDialog::reject() { restoreValues(); QDialog::reject(); } void EditExceptionsDialog::onSelectionChanged() { QList<QListWidgetItem*> list = exceptionsList->selectedItems(); deleteButton->setEnabled(!list.isEmpty()); list = occurrencesList->selectedItems(); if(!list.isEmpty() && list.first() == occurrencesList->item(0)) { occurrencesList->item(0)->setSelected(false); list.removeFirst(); } addButton->setEnabled(!list.isEmpty()); } void EditExceptionsDialog::addException() { QList<QListWidgetItem*> list = occurrencesList->selectedItems(); for(int i = 0; i < list.count(); i++) { exceptionsList->addItem(list[i]->text()); delete list[i]; } exceptionsList->sortItems(); } void EditExceptionsDialog::deleteException() { QList<QListWidgetItem*> list = exceptionsList->selectedItems(); for(int i = 0; i < list.count(); i++) { delete list[i]; } modifyExceptions(o_rec); occurrencesList->clear(); QDate next_date = o_rec->firstOccurrence(); for(int i = 0; i < 50 && next_date.isValid(); i++) { occurrencesList->addItem(QLocale().toString(next_date, QLocale::ShortFormat)); next_date = o_rec->nextOccurrence(next_date); } } EditRangeDialog::EditRangeDialog(const QDate &startdate, QWidget *parent) : QDialog(parent), date(startdate) { setWindowTitle(tr("Edit Recurrence Range")); setModal(true); QVBoxLayout *box1 = new QVBoxLayout(this); QGridLayout *rangeLayout = new QGridLayout(); box1->addLayout(rangeLayout); startLabel = new QLabel(tr("Begins on: %1").arg(QLocale().toString(startdate)), this); rangeLayout->addWidget(startLabel, 0, 0, 1, 3); rangeButtonGroup = new QButtonGroup(this); foreverButton = new QRadioButton(tr("No ending date"), this); rangeButtonGroup->addButton(foreverButton); rangeLayout->addWidget(foreverButton, 1, 0, 1, 3); fixedCountButton = new QRadioButton(tr("End after"), this); rangeButtonGroup->addButton(fixedCountButton); rangeLayout->addWidget(fixedCountButton, 2, 0); fixedCountEdit = new QSpinBox(this); fixedCountEdit->setRange(1, 9999); rangeLayout->addWidget(fixedCountEdit, 2, 1); rangeLayout ->addWidget(new QLabel(tr("occurrence(s)"), this), 2, 2); endDateButton = new QRadioButton(tr("End on"), this); rangeButtonGroup->addButton(endDateButton); rangeLayout->addWidget(endDateButton, 3, 0); endDateEdit = new EqonomizeDateEdit(startdate, this); endDateEdit->setCalendarPopup(true); rangeLayout->addWidget(endDateEdit, 3, 1, 1, 2); setRecurrence(NULL); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal, this); buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); buttonBox->button(QDialogButtonBox::Cancel)->setAutoDefault(false); buttonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); connect(buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept())); box1->addWidget(buttonBox); connect(fixedCountButton, SIGNAL(toggled(bool)), fixedCountEdit, SLOT(setEnabled(bool))); connect(endDateButton, SIGNAL(toggled(bool)), endDateEdit, SLOT(setEnabled(bool))); } EditRangeDialog::~EditRangeDialog() { } void EditRangeDialog::setStartDate(const QDate &startdate) { startLabel->setText(tr("Begins on: %1").arg(QLocale().toString(startdate))); date = startdate; if(!endDateButton->isChecked() && date > endDateEdit->date()) { endDateEdit->setDate(date); } } void EditRangeDialog::setRecurrence(Recurrence *rec) { if(rec && rec->fixedOccurrenceCount() > 0) { fixedCountButton->setChecked(true); fixedCountEdit->setValue(rec->fixedOccurrenceCount()); endDateEdit->setEnabled(false); fixedCountEdit->setEnabled(true); endDateEdit->setDate(date); } else if(rec && !rec->endDate().isNull()) { endDateButton->setChecked(true); endDateEdit->setDate(rec->endDate()); endDateEdit->setEnabled(true); fixedCountEdit->setEnabled(false); fixedCountEdit->setValue(1); } else { foreverButton->setChecked(true); endDateEdit->setEnabled(false); fixedCountEdit->setEnabled(false); endDateEdit->setDate(date); fixedCountEdit->setValue(1); } saveValues(); } int EditRangeDialog::fixedCount() { if(fixedCountButton->isChecked()) { return fixedCountEdit->value(); } return -1; } QDate EditRangeDialog::endDate() { if(endDateButton->isChecked()) { return endDateEdit->date(); } return QDate(); } void EditRangeDialog::accept() { if(!validValues()) return; saveValues(); QDialog::accept(); } void EditRangeDialog::reject() { restoreValues(); QDialog::reject(); } void EditRangeDialog::saveValues() { fixedCountEdit_value = fixedCountEdit->value(); endDateEdit_value = endDateEdit->date(); if(foreverButton->isChecked()) checkedButton = foreverButton; else if(endDateButton->isChecked()) checkedButton = endDateButton; else checkedButton = fixedCountButton; } void EditRangeDialog::restoreValues() { fixedCountEdit->setValue(fixedCountEdit_value); endDateEdit->setDate(endDateEdit_value); checkedButton->setChecked(true); } bool EditRangeDialog::validValues() { if(endDateButton->isChecked()) { if(!endDateEdit->date().isValid()) { QMessageBox::critical(this, tr("Error"), tr("Invalid date.")); endDateEdit->setFocus(); endDateEdit->setCurrentSection(QDateTimeEdit::DaySection); return false; } if(endDateEdit->date() < date) { QMessageBox::critical(this, tr("Error"), tr("End date before start date.")); endDateEdit->setFocus(); endDateEdit->setCurrentSection(QDateTimeEdit::DaySection); return false; } } return true; } RecurrenceEditWidget::RecurrenceEditWidget(const QDate &startdate, Budget *budg, QWidget *parent) : QWidget(parent), date(startdate), budget(budg) { QVBoxLayout *recurrenceLayout = new QVBoxLayout(this); //recurrenceLayout->setContentsMargins(0, 0, 0, 0); recurrenceButton = new QCheckBox(tr("Enable recurrence"), this); recurrenceLayout->addWidget(recurrenceButton); ruleGroup = new QGroupBox(tr("Recurrence Rule"), this); QVBoxLayout *ruleGroup_layout = new QVBoxLayout(ruleGroup); typeCombo = new QComboBox(ruleGroup); typeCombo->setEditable(false); typeCombo->addItem(tr("Daily")); typeCombo->addItem(tr("Weekly")); typeCombo->addItem(tr("Monthly")); typeCombo->addItem(tr("Yearly")); typeCombo->setCurrentIndex(2); ruleGroup_layout->addWidget(typeCombo); ruleStack = new QStackedWidget(ruleGroup); ruleGroup_layout->addWidget(ruleStack); QWidget *dailyRuleWidget = new QWidget(ruleStack); ruleStack->addWidget(dailyRuleWidget); QWidget *weeklyRuleWidget = new QWidget(ruleStack); ruleStack->addWidget(weeklyRuleWidget); QWidget *monthlyRuleWidget = new QWidget(ruleStack); ruleStack->addWidget(monthlyRuleWidget); QWidget *yearlyRuleWidget = new QWidget(ruleStack); ruleStack->addWidget(yearlyRuleWidget); QVBoxLayout *dailyRuleLayout = new QVBoxLayout(dailyRuleWidget); QHBoxLayout *dailyFrequencyLayout = new QHBoxLayout(); dailyRuleLayout->addLayout(dailyFrequencyLayout); dailyFrequencyLayout->addWidget(new QLabel(tr("Recur every"), dailyRuleWidget)); dailyFrequencyEdit = new QSpinBox(dailyRuleWidget); dailyFrequencyEdit->setRange(1, 9999); dailyFrequencyLayout->addWidget(dailyFrequencyEdit); dailyFrequencyLayout->addWidget(new QLabel(tr("day(s)"), dailyRuleWidget)); dailyFrequencyLayout->addStretch(1); dailyRuleLayout->addStretch(1); QVBoxLayout *weeklyRuleLayout = new QVBoxLayout(weeklyRuleWidget); QHBoxLayout *weeklyFrequencyLayout = new QHBoxLayout(); weeklyRuleLayout->addLayout(weeklyFrequencyLayout); weeklyFrequencyLayout->addWidget(new QLabel(tr("Recur every"), weeklyRuleWidget)); weeklyFrequencyEdit = new QSpinBox(weeklyRuleWidget); weeklyFrequencyEdit->setRange(1, 9999); weeklyFrequencyLayout->addWidget(weeklyFrequencyEdit); weeklyFrequencyLayout->addWidget(new QLabel(tr("week(s) on:"), weeklyRuleWidget)); weeklyFrequencyLayout->addStretch(1); QHBoxLayout *weeklyDaysLayout = new QHBoxLayout(); weeklyRuleLayout->addLayout(weeklyDaysLayout); int weekStart = QLocale().firstDayOfWeek(); for(int i = 0; i < 7; ++i ) { weeklyButtons[i] = new QCheckBox(QLocale().standaloneDayName(i + 1, QLocale::ShortFormat), weeklyRuleWidget); } for(int i = weekStart - 1; i < 7; ++i ) { weeklyDaysLayout->addWidget(weeklyButtons[i]); } for(int i = 0; i < weekStart - 1; ++i ) { weeklyDaysLayout->addWidget(weeklyButtons[i]); } weeklyRuleLayout->addStretch(1); QVBoxLayout *monthlyRuleLayout = new QVBoxLayout(monthlyRuleWidget); QHBoxLayout *monthlyFrequencyLayout = new QHBoxLayout(); monthlyRuleLayout->addLayout(monthlyFrequencyLayout); monthlyFrequencyLayout->addWidget(new QLabel(tr("Recur every"), monthlyRuleWidget)); monthlyFrequencyEdit = new QSpinBox(monthlyRuleWidget); monthlyFrequencyEdit->setRange(1, 9999); monthlyFrequencyLayout->addWidget(monthlyFrequencyEdit); monthlyFrequencyLayout->addWidget(new QLabel(tr("month(s), after the start month"), monthlyRuleWidget)); monthlyFrequencyLayout->addStretch(1); QButtonGroup *monthlyButtonGroup = new QButtonGroup(this); QGridLayout *monthlyButtonLayout = new QGridLayout(); monthlyRuleLayout->addLayout(monthlyButtonLayout, 1); monthlyOnDayButton = new QRadioButton(tr("Recur on the"), monthlyRuleWidget); monthlyOnDayButton->setChecked(true); monthlyButtonGroup->addButton(monthlyOnDayButton); monthlyButtonLayout->addWidget(monthlyOnDayButton, 0, 0); QBoxLayout *monthlyDayLayout = new QHBoxLayout(); monthlyDayCombo = new QComboBox(monthlyRuleWidget); monthlyDayCombo->addItem(tr("1st")); monthlyDayCombo->addItem(tr("2nd")); monthlyDayCombo->addItem(tr("3rd")); monthlyDayCombo->addItem(tr("4th")); monthlyDayCombo->addItem(tr("5th")); monthlyDayCombo->addItem(tr("6th")); monthlyDayCombo->addItem(tr("7th")); monthlyDayCombo->addItem(tr("8th")); monthlyDayCombo->addItem(tr("9th")); monthlyDayCombo->addItem(tr("10th")); monthlyDayCombo->addItem(tr("11th")); monthlyDayCombo->addItem(tr("12th")); monthlyDayCombo->addItem(tr("13th")); monthlyDayCombo->addItem(tr("14th")); monthlyDayCombo->addItem(tr("15th")); monthlyDayCombo->addItem(tr("16th")); monthlyDayCombo->addItem(tr("17th")); monthlyDayCombo->addItem(tr("18th")); monthlyDayCombo->addItem(tr("19th")); monthlyDayCombo->addItem(tr("20th")); monthlyDayCombo->addItem(tr("21st")); monthlyDayCombo->addItem(tr("22nd")); monthlyDayCombo->addItem(tr("23rd")); monthlyDayCombo->addItem(tr("24th")); monthlyDayCombo->addItem(tr("25th")); monthlyDayCombo->addItem(tr("26th")); monthlyDayCombo->addItem(tr("27th")); monthlyDayCombo->addItem(tr("28th")); monthlyDayCombo->addItem(tr("29th")); monthlyDayCombo->addItem(tr("30th")); monthlyDayCombo->addItem(tr("31st")); monthlyDayCombo->addItem(tr("Last")); monthlyDayCombo->addItem(tr("2nd Last")); monthlyDayCombo->addItem(tr("3rd Last")); monthlyDayCombo->addItem(tr("4th Last")); monthlyDayCombo->addItem(tr("5th Last")); monthlyDayLayout->addWidget(monthlyDayCombo); monthlyDayLayout->addWidget(new QLabel(tr("day"), monthlyRuleWidget)); monthlyWeekendCombo = new QComboBox(monthlyRuleWidget); monthlyWeekendCombo->addItem(tr("possibly on weekend")); monthlyWeekendCombo->addItem(tr("but before weekend")); monthlyWeekendCombo->addItem(tr("but after weekend")); monthlyWeekendCombo->addItem(tr("on nearest weekday")); monthlyDayLayout->addWidget(monthlyWeekendCombo); monthlyDayLayout->addStretch(1); monthlyButtonLayout->addLayout(monthlyDayLayout, 0, 1); monthlyOnDayOfWeekButton = new QRadioButton(tr("Recur on the"), monthlyRuleWidget); monthlyButtonGroup->addButton(monthlyOnDayOfWeekButton); monthlyButtonLayout->addWidget(monthlyOnDayOfWeekButton, 1, 0); QBoxLayout *monthlyWeekLayout = new QHBoxLayout(); monthlyWeekCombo = new QComboBox(monthlyRuleWidget); monthlyWeekCombo->addItem(tr("1st")); monthlyWeekCombo->addItem(tr("2nd")); monthlyWeekCombo->addItem(tr("3rd")); monthlyWeekCombo->addItem(tr("4th")); monthlyWeekCombo->addItem(tr("5th")); monthlyWeekCombo->addItem(tr("Last")); monthlyWeekCombo->addItem(tr("2nd Last")); monthlyWeekCombo->addItem(tr("3rd Last")); monthlyWeekCombo->addItem(tr("4th Last")); monthlyWeekLayout->addWidget(monthlyWeekCombo); monthlyDayOfWeekCombo = new QComboBox(monthlyRuleWidget); monthlyWeekLayout->addWidget(monthlyDayOfWeekCombo); monthlyWeekLayout->addStretch(1); monthlyButtonLayout->addLayout(monthlyWeekLayout, 1, 1); monthlyRuleLayout->addStretch(1); QVBoxLayout *yearlyRuleLayout = new QVBoxLayout(yearlyRuleWidget); QHBoxLayout *yearlyFrequencyLayout = new QHBoxLayout(); yearlyRuleLayout->addLayout(yearlyFrequencyLayout); yearlyFrequencyLayout->addWidget(new QLabel(tr("Recur every"), yearlyRuleWidget)); yearlyFrequencyEdit = new QSpinBox(yearlyRuleWidget); yearlyFrequencyEdit->setRange(1, 9999); yearlyFrequencyLayout->addWidget(yearlyFrequencyEdit); yearlyFrequencyLayout->addWidget(new QLabel(tr("year(s), after the start year"), yearlyRuleWidget)); yearlyFrequencyLayout->addStretch(1); QButtonGroup *yearlyButtonGroup = new QButtonGroup(this); QGridLayout *yearlyButtonLayout = new QGridLayout(); yearlyRuleLayout->addLayout(yearlyButtonLayout, 1); yearlyOnDayOfMonthButton = new QRadioButton(tr("Recur on day", "part before XXX of 'Recur on day XXX of month YYY'"), yearlyRuleWidget); yearlyButtonGroup->addButton(yearlyOnDayOfMonthButton); yearlyOnDayOfMonthButton->setChecked(true); yearlyButtonLayout->addWidget(yearlyOnDayOfMonthButton, 0, 0); QBoxLayout *yearlyMonthLayout = new QHBoxLayout(); yearlyDayOfMonthEdit = new QSpinBox(yearlyRuleWidget); yearlyDayOfMonthEdit->setRange(1, 31); yearlyMonthLayout->addWidget(yearlyDayOfMonthEdit); yearlyMonthLayout->addWidget(new QLabel(tr("of", "part between XXX and YYY of 'Recur on day XXX of month YYY'"), yearlyRuleWidget)); yearlyMonthCombo = new QComboBox(yearlyRuleWidget); yearlyMonthLayout->addWidget(yearlyMonthCombo); yearlyWeekendCombo_month = new QComboBox(yearlyRuleWidget); yearlyWeekendCombo_month->addItem(tr("possibly on weekend")); yearlyWeekendCombo_month->addItem(tr("but before weekend")); yearlyWeekendCombo_month->addItem(tr("but after weekend")); yearlyWeekendCombo_month->addItem(tr("nearest weekend day")); yearlyMonthLayout->addWidget(yearlyWeekendCombo_month); yearlyMonthLayout->addStretch(1); yearlyButtonLayout->addLayout(yearlyMonthLayout, 0, 1); yearlyOnDayOfWeekButton = new QRadioButton(tr("On the", "Part before NNN in 'Recur on the NNN. WEEKDAY of MONTH'"), yearlyRuleWidget); yearlyButtonGroup->addButton(yearlyOnDayOfWeekButton); yearlyButtonLayout->addWidget(yearlyOnDayOfWeekButton, 1, 0); QBoxLayout *yearlyWeekLayout = new QHBoxLayout(); yearlyWeekCombo = new QComboBox(yearlyRuleWidget); yearlyWeekCombo->addItem(tr("1st")); yearlyWeekCombo->addItem(tr("2nd")); yearlyWeekCombo->addItem(tr("3rd")); yearlyWeekCombo->addItem(tr("4th")); yearlyWeekCombo->addItem(tr("5th")); yearlyWeekCombo->addItem(tr("Last")); yearlyWeekCombo->addItem(tr("2nd Last")); yearlyWeekCombo->addItem(tr("3rd Last")); yearlyWeekCombo->addItem(tr("4th Last")); yearlyWeekCombo->addItem(tr("5th Last")); yearlyWeekLayout->addWidget(yearlyWeekCombo); yearlyDayOfWeekCombo = new QComboBox(yearlyRuleWidget); yearlyWeekLayout->addWidget(yearlyDayOfWeekCombo); yearlyWeekLayout->addWidget(new QLabel(tr("of", "part between WEEKDAY and MONTH in 'Recur on NNN. WEEKDAY of MONTH'"), yearlyRuleWidget)); yearlyMonthCombo_week = new QComboBox(yearlyRuleWidget); yearlyWeekLayout->addWidget(yearlyMonthCombo_week); yearlyWeekLayout->addStretch(1); yearlyButtonLayout->addLayout(yearlyWeekLayout, 1, 1); yearlyOnDayOfYearButton = new QRadioButton(tr("Recur on day #"), yearlyRuleWidget); yearlyButtonGroup->addButton(yearlyOnDayOfYearButton); yearlyButtonLayout->addWidget(yearlyOnDayOfYearButton, 2, 0); QBoxLayout *yearlyDayLayout = new QHBoxLayout(); yearlyDayOfYearEdit = new QSpinBox(yearlyRuleWidget); yearlyDayOfYearEdit->setRange(1, 366); yearlyDayLayout->addWidget(yearlyDayOfYearEdit); yearlyDayLayout->addWidget(new QLabel(tr(" of the year", "part after NNN of 'Recur on day #NNN of the year'"), yearlyRuleWidget)); yearlyWeekendCombo_day = new QComboBox(yearlyRuleWidget); yearlyWeekendCombo_day->addItem(tr("possibly on weekend")); yearlyWeekendCombo_day->addItem(tr("but before weekend")); yearlyWeekendCombo_day->addItem(tr("but after weekend")); yearlyWeekendCombo_day->addItem(tr("nearest weekend day")); yearlyDayLayout->addWidget(yearlyWeekendCombo_day); yearlyDayLayout->addStretch(1); yearlyButtonLayout->addLayout(yearlyDayLayout, 2, 1); yearlyRuleLayout->addStretch(1); recurrenceLayout->addWidget(ruleGroup); QHBoxLayout *buttonLayout = new QHBoxLayout(); recurrenceLayout->addLayout(buttonLayout); rangeButton = new QPushButton(tr("Range…"), this); buttonLayout->addWidget(rangeButton); exceptionsButton = new QPushButton(tr("Occurrences/Exceptions…"), this); buttonLayout->addWidget(exceptionsButton); recurrenceLayout->addStretch(1); ruleStack->setCurrentIndex(2); recurrenceButton->setChecked(false); ruleGroup->setEnabled(false); rangeButton->setEnabled(false); exceptionsButton->setEnabled(false); rangeDialog = new EditRangeDialog(date, this); rangeDialog->hide(); exceptionsDialog = new EditExceptionsDialog(this); exceptionsDialog->hide(); int months = 0; QDate date = QDate::currentDate(); for(int i = 0; i < 10; i++) { int months2 = 12; if(months2 > months) { for(int i2 = months + 1; i2 <= months2; i2++) { yearlyMonthCombo_week->addItem(QLocale().monthName(i2, QLocale::LongFormat)); yearlyMonthCombo->addItem(QLocale().monthName(i2, QLocale::LongFormat)); } months = months2; } date = date.addYears(1); } for(int i = 1; i <= 7; i++) { yearlyDayOfWeekCombo->addItem(QLocale().standaloneDayName(i)); monthlyDayOfWeekCombo->addItem(QLocale().standaloneDayName(i)); } connect(typeCombo, SIGNAL(activated(int)), ruleStack, SLOT(setCurrentIndex(int))); connect(rangeButton, SIGNAL(clicked()), this, SLOT(editRange())); connect(exceptionsButton, SIGNAL(clicked()), this, SLOT(editExceptions())); connect(recurrenceButton, SIGNAL(toggled(bool)), ruleGroup, SLOT(setEnabled(bool))); connect(recurrenceButton, SIGNAL(toggled(bool)), rangeButton, SLOT(setEnabled(bool))); connect(recurrenceButton, SIGNAL(toggled(bool)), exceptionsButton, SLOT(setEnabled(bool))); } RecurrenceEditWidget::~RecurrenceEditWidget() { } void RecurrenceEditWidget::editExceptions() { Recurrence *rec = createRecurrence(); exceptionsDialog->setRecurrence(rec); exceptionsDialog->exec(); exceptionsDialog->hide(); delete rec; } void RecurrenceEditWidget::editRange() { rangeDialog->exec(); rangeDialog->hide(); } void RecurrenceEditWidget::setRecurrence(Recurrence *rec) { rangeDialog->setRecurrence(rec); exceptionsDialog->setRecurrence(rec); if(!rec) { recurrenceButton->setChecked(false); recurrenceButton->setChecked(false); ruleGroup->setEnabled(false); rangeButton->setEnabled(false); exceptionsButton->setEnabled(false); return; } switch(rec->type()) { case RECURRENCE_TYPE_DAILY: { DailyRecurrence *drec = (DailyRecurrence*) rec; dailyFrequencyEdit->setValue(drec->frequency()); typeCombo->setCurrentIndex(0); break; } case RECURRENCE_TYPE_WEEKLY: { WeeklyRecurrence *wrec = (WeeklyRecurrence*) rec; weeklyFrequencyEdit->setValue(wrec->frequency()); for(int i = 0; i < 7; i++) { weeklyButtons[i]->setChecked(wrec->dayOfWeek(i + 1)); } typeCombo->setCurrentIndex(1); break; } case RECURRENCE_TYPE_MONTHLY: { MonthlyRecurrence *mrec = (MonthlyRecurrence*) rec; monthlyFrequencyEdit->setValue(mrec->frequency()); if(mrec->dayOfWeek() > 0) { monthlyOnDayOfWeekButton->setChecked(true); monthlyDayOfWeekCombo->setCurrentIndex(mrec->dayOfWeek() - 1); int week = mrec->week(); if(week <= 0) week = 6 - week; monthlyWeekCombo->setCurrentIndex(week - 1); } else { monthlyOnDayButton->setChecked(true); int day = mrec->day(); if(day <= 0) day = 32 - day; monthlyDayCombo->setCurrentIndex(day - 1); monthlyWeekendCombo->setCurrentIndex(mrec->weekendHandling()); } typeCombo->setCurrentIndex(2); break; } case RECURRENCE_TYPE_YEARLY: { YearlyRecurrence *yrec = (YearlyRecurrence*) rec; yearlyFrequencyEdit->setValue(yrec->frequency()); if(yrec->dayOfYear() > 0) { yearlyOnDayOfYearButton->setChecked(true); yearlyDayOfYearEdit->setValue(yrec->dayOfYear()); yearlyWeekendCombo_day->setCurrentIndex(yrec->weekendHandling()); yearlyWeekendCombo_month->setCurrentIndex(yrec->weekendHandling()); } else if(yrec->dayOfWeek() > 0) { yearlyOnDayOfWeekButton->setChecked(true); yearlyDayOfWeekCombo->setCurrentIndex(yrec->dayOfWeek() - 1); int week = yrec->week(); if(week <= 0) week = 6 - week; yearlyWeekCombo->setCurrentIndex(week - 1); yearlyMonthCombo_week->setCurrentIndex(yrec->month() - 1); } else { yearlyOnDayOfMonthButton->setChecked(true); yearlyDayOfMonthEdit->setValue(yrec->dayOfMonth()); yearlyMonthCombo->setCurrentIndex(yrec->month() - 1); yearlyWeekendCombo_day->setCurrentIndex(yrec->weekendHandling()); yearlyWeekendCombo_month->setCurrentIndex(yrec->weekendHandling()); } typeCombo->setCurrentIndex(3); break; } } ruleStack->setCurrentIndex(typeCombo->currentIndex()); recurrenceButton->setChecked(true); ruleGroup->setEnabled(true); rangeButton->setEnabled(true); exceptionsButton->setEnabled(true); } Recurrence *RecurrenceEditWidget::createRecurrence() { if(!recurrenceButton->isChecked() || !validValues()) return NULL; switch(typeCombo->currentIndex()) { case 0: { DailyRecurrence *rec = new DailyRecurrence(budget); rec->set(date, rangeDialog->endDate(), dailyFrequencyEdit->value(), rangeDialog->fixedCount()); exceptionsDialog->modifyExceptions(rec); return rec; } case 1: { WeeklyRecurrence *rec = new WeeklyRecurrence(budget); rec->set(date, rangeDialog->endDate(), weeklyButtons[0]->isChecked(), weeklyButtons[1]->isChecked(), weeklyButtons[2]->isChecked(), weeklyButtons[3]->isChecked(), weeklyButtons[4]->isChecked(), weeklyButtons[5]->isChecked(), weeklyButtons[6]->isChecked(), weeklyFrequencyEdit->value(), rangeDialog->fixedCount()); exceptionsDialog->modifyExceptions(rec); return rec; } case 2: { MonthlyRecurrence *rec = new MonthlyRecurrence(budget); if(monthlyOnDayButton->isChecked()) { int day = monthlyDayCombo->currentIndex() + 1; if(day > 31) day = 32 - day; rec->setOnDay(date, rangeDialog->endDate(), day, (WeekendHandling) monthlyWeekendCombo->currentIndex(), monthlyFrequencyEdit->value(), rangeDialog->fixedCount()); } else { int week = monthlyWeekCombo->currentIndex() + 1; if(week > 5) week = 6 - week; rec->setOnDayOfWeek(date, rangeDialog->endDate(), monthlyDayOfWeekCombo->currentIndex() + 1, week, monthlyFrequencyEdit->value(), rangeDialog->fixedCount()); } exceptionsDialog->modifyExceptions(rec); return rec; } case 3: { YearlyRecurrence *rec = new YearlyRecurrence(budget); if(yearlyOnDayOfMonthButton->isChecked()) { rec->setOnDayOfMonth(date, rangeDialog->endDate(), yearlyMonthCombo->currentIndex() + 1, yearlyDayOfMonthEdit->value(), (WeekendHandling) yearlyWeekendCombo_month->currentIndex(), yearlyFrequencyEdit->value(), rangeDialog->fixedCount()); } else if(yearlyOnDayOfWeekButton->isChecked()) { int week = yearlyWeekCombo->currentIndex() + 1; if(week > 5) week = 6 - week; rec->setOnDayOfWeek(date, rangeDialog->endDate(), yearlyMonthCombo_week->currentIndex() + 1, yearlyDayOfWeekCombo->currentIndex() + 1, week, yearlyFrequencyEdit->value(), rangeDialog->fixedCount()); } else { rec->setOnDayOfYear(date, rangeDialog->endDate(), yearlyDayOfYearEdit->value(), (WeekendHandling) yearlyWeekendCombo_day->currentIndex(), yearlyFrequencyEdit->value(), rangeDialog->fixedCount()); } exceptionsDialog->modifyExceptions(rec); return rec; } } return NULL; } bool RecurrenceEditWidget::validValues() { if(!recurrenceButton->isChecked()) return true; switch(typeCombo->currentIndex()) { case 0: { break; } case 1: { bool b = false; for(int i = 0; i < 7; i++) { if(weeklyButtons[i]->isChecked()) { b = true; break; } } if(!b) { QMessageBox::critical(this, tr("Error"), tr("No day of week selected for weekly recurrence.")); weeklyButtons[0]->setFocus(); return false; } break; } case 2: { int i_frequency = monthlyFrequencyEdit->value(); if(i_frequency % 12 == 0) { int i_dayofmonth = monthlyDayCombo->currentIndex() + 1; int i_month = date.month(); if(i_dayofmonth <= 31 && ((i_month == 2 && i_dayofmonth > 29) || (i_dayofmonth > 30 && (i_month == 4 || i_month == 6 || i_month == 9 || i_month == 11)))) { QMessageBox::critical(this, tr("Error"), tr("Selected day will never occur with selected frequency and start date.")); monthlyDayCombo->setFocus(); return false; } } break; } case 3: { if(yearlyOnDayOfMonthButton->isChecked()) { int i_frequency = yearlyFrequencyEdit->value(); int i_dayofmonth = yearlyDayOfMonthEdit->value(); int i_month = yearlyMonthCombo->currentIndex() + 1; if(IS_GREGORIAN_CALENDAR) { if((i_month == 2 && i_dayofmonth > 29) || (i_dayofmonth > 30 && (i_month == 4 || i_month == 6 || i_month == 9 || i_month == 11))) { QMessageBox::critical(this, tr("Error"), tr("Selected day does not exist in selected month.")); yearlyDayOfMonthEdit->setFocus(); return false; } else if(i_month != 2 || i_dayofmonth < 29) { break; } } QDate nextdate; nextdate.setDate(date.year(), i_month, 1); if(i_dayofmonth > nextdate.daysInMonth()) { int i = 10; do { if(i == 0) { QMessageBox::critical(this, tr("Error"), tr("Selected day will never occur with selected frequency and start date.")); yearlyDayOfMonthEdit->setFocus(); return false; } nextdate = nextdate.addYears(i_frequency); nextdate.setDate(nextdate.year(), i_month, 1); i--; } while(i_dayofmonth > nextdate.daysInMonth()); } } else if(yearlyOnDayOfYearButton->isChecked()) { int i_frequency = yearlyFrequencyEdit->value(); int i_dayofyear = yearlyDayOfYearEdit->value(); if(i_dayofyear > date.daysInYear()) { QDate nextdate = date; int i = 10; do { if(i == 0) { QMessageBox::critical(this, tr("Error"), tr("Selected day will never occur with selected frequency and start date.")); yearlyDayOfYearEdit->setFocus(); return false; } nextdate = nextdate.addYears(i_frequency); i--; } while(i_dayofyear > nextdate.daysInYear()); } } break; } } if(!rangeDialog->validValues()) return false; if(!exceptionsDialog->validValues()) return false; return true; } void RecurrenceEditWidget::setStartDate(const QDate &startdate) { if(!startdate.isValid()) return; date = startdate; rangeDialog->setStartDate(date); }
utf-8
1
GPL-3+
2006-2022 Hanna Knutsson <hanna.knutsson@protonmail.com>
grpc-1.30.2/src/core/lib/iomgr/poller/eventmanager_interface.h
/* * * Copyright 2019 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef GRPC_CORE_LIB_IOMGR_POLLER_EVENTMANAGER_INTERFACE_H #define GRPC_CORE_LIB_IOMGR_POLLER_EVENTMANAGER_INTERFACE_H namespace grpc { namespace experimental { class BaseEventManagerInterface { public: virtual ~BaseEventManagerInterface() {} }; class EpollEventManagerInterface : public BaseEventManagerInterface {}; } // namespace experimental } // namespace grpc #endif /* GRPC_CORE_LIB_IOMGR_POLLER_EVENTMANAGER_INTERFACE_H */
utf-8
1
Apache-2.0
2008, Google Inc. 2015, Google Inc. 2015-2016, Google Inc. 2016, Google Inc. 2017, Google Inc. Esben Mose Hansen, Ange Optimization ApS 2009, Kitware, Inc. 2009-2011, Philip Lowman <philip@yhbt.com> 2016 The Chromium Authors. All rights reserved.
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
2
Edit dataset card