blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
sequencelengths
1
1
author
stringlengths
0
119
cd89826a08896a4e070e25e6ca747031fc0984c2
818df5a6b667055f9c472e72ee0fc823f86de819
/628.cpp
fd3f0f9aca8f3f5448e2d232baa6e559ecbedf3f
[]
no_license
kalex1994/UVA
0a495e971fdcf92a785421a5c741bda915c21fca
cf45c6174cd299df14e8b52637c29ea7c3ec0f20
refs/heads/master
2021-01-01T19:47:13.630295
2016-10-15T19:14:46
2016-10-15T19:14:46
12,342,624
0
0
null
null
null
null
UTF-8
C++
false
false
874
cpp
#include <iostream> #include <cstdio> #include <string> #include <vector> #include <cstring> #include <algorithm> #include <sstream> #include <cmath> #include <map> #include <set> using namespace std; int n, m; string words[100]; string rule; void make_passwords(string password, size_t index) { if (index >= rule.length()) { cout << password << "\n"; return; } if (rule[index] == '0') { for(int i = 0; i <= 9; ++i) make_passwords(password + string(1, i + '0'), index + 1); } else { for(int i = 0; i < n; ++i) make_passwords(password + words[i], index + 1); } } int main() { #ifndef ONLINE_JUDGE freopen("E:\\IN.txt", "r", stdin); freopen("E:\\OUT.txt", "w", stdout); #endif while(cin >> n) { for(int i = 0; i < n; ++i) cin >> words[i]; cin >> m; while(m--) { cin >> rule; cout << "--\n"; make_passwords("", 0); } } }
aa5ec7f975cd1cd5c5bf2cbc627d2989d7a33d36
a51f2693e411771dc089fe2fffe5656c92166f6b
/gui/actions/kalenderviewcontroler.h
ee5a3a7289634e47153c7674bff65ff37a0ded3e
[]
no_license
mdirks/stundenplaner
d4921b70772aee85f0ce84e9b8cbf1ca2f8620f1
ef8bd04d15941672669ee9732817e2cbe0d112f9
refs/heads/master
2021-09-11T14:36:57.387004
2021-09-05T12:49:56
2021-09-05T12:49:56
82,451,937
0
0
null
null
null
null
UTF-8
C++
false
false
1,954
h
/*************************************************************************** * Copyright (C) 2008 by Marcus Dirks * * [email protected] * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef KALENDERVIEWCONTROLER_H #define KALENDERVIEWCONTROLER_H #include "gui/forms/kalenderview.h" #include "weekmapviewcontroler.h" /** @author Marcus Dirks <[email protected]> */ class KalenderViewControler : public WeekMapViewControler { Q_OBJECT public: KalenderViewControler(KalenderView *kview); ~KalenderViewControler(); protected: virtual QMenu* getPopupMenu(); /* public slots: setPlanning(); */ private: bool isPlanning; public slots: void togglePlanning(); virtual void activateSelected(PObjectGraphicsItemNP *selectedItem); }; #endif
41ef37b9e95f4397ac1ca73b715b01c0a004a04e
10464800f55b04f9f821d9b6a12b58f4185bc7df
/RapidXML/zip.cpp
7a1583ce1d007d9fb55c2fbfb68c442bc9740a69
[ "MIT", "BSL-1.0" ]
permissive
TheGnewGuy/ODSUtilities
6c2b6681b4bd02714dbbf5c0963739e9431d1e92
b477e4af8b19cdf316e0e966690ea6cffa329257
refs/heads/master
2021-01-25T03:20:14.310574
2015-01-26T03:24:31
2015-01-26T03:24:31
28,576,223
0
0
null
null
null
null
UTF-8
C++
false
false
113,153
cpp
#include "stdafx.h" #include <windows.h> #include <stdio.h> #include <tchar.h> #include "zip.h" // On MSVC, disable "conditional expression is constant" warning (level 4). // This warning is almost impossible to avoid with certain types of templated code #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4996) // #endif // THIS FILE is almost entirely based upon code by info-zip. // It has been modified by Lucian Wischik. The modifications // were a complete rewrite of the bit of code that generates the // layout of the zipfile, and support for zipping to/from memory // or handles or pipes or pagefile or diskfiles, encryption, unicode. // The original code may be found at http://www.info-zip.org // The original copyright text follows. // // // // This is version 1999-Oct-05 of the Info-ZIP copyright and license. // The definitive version of this document should be available at // ftp://ftp.cdrom.com/pub/infozip/license.html indefinitely. // // Copyright (c) 1990-1999 Info-ZIP. All rights reserved. // // For the purposes of this copyright and license, "Info-ZIP" is defined as // the following set of individuals: // // Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois, // Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase, // Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum, // Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller, // Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel, // Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen, // Paul von Behren, Rich Wales, Mike White // // This software is provided "as is," without warranty of any kind, express // or implied. In no event shall Info-ZIP or its contributors be held liable // for any direct, indirect, incidental, special or consequential damages // arising out of the use of or inability to use 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. Redistributions of source code must retain the above copyright notice, // definition, disclaimer, and this list of conditions. // // 2. Redistributions in binary form must reproduce the above copyright // notice, definition, disclaimer, and this list of conditions in // documentation and/or other materials provided with the distribution. // // 3. Altered versions--including, but not limited to, ports to new operating // systems, existing ports with new graphical interfaces, and dynamic, // shared, or static library versions--must be plainly marked as such // and must not be misrepresented as being the original source. Such // altered versions also must not be misrepresented as being Info-ZIP // releases--including, but not limited to, labeling of the altered // versions with the names "Info-ZIP" (or any variation thereof, including, // but not limited to, different capitalizations), "Pocket UnZip," "WiZ" // or "MacZip" without the explicit permission of Info-ZIP. Such altered // versions are further prohibited from misrepresentative use of the // Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s). // // 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip," // "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own source and // binary releases. // typedef unsigned char uch; // unsigned 8-bit value typedef unsigned short ush; // unsigned 16-bit value typedef unsigned long ulg; // unsigned 32-bit value typedef size_t extent; // file size typedef unsigned Pos; // must be at least 32 bits typedef unsigned IPos; // A Pos is an index in the character window. Pos is used only for parameter passing #ifndef EOF #define EOF (-1) #endif // Error return values. The values 0..4 and 12..18 follow the conventions // of PKZIP. The values 4..10 are all assigned to "insufficient memory" // by PKZIP, so the codes 5..10 are used here for other purposes. #define ZE_MISS -1 // used by procname(), zipbare() #define ZE_OK 0 // success #define ZE_EOF 2 // unexpected end of zip file #define ZE_FORM 3 // zip file structure error #define ZE_MEM 4 // out of memory #define ZE_LOGIC 5 // internal logic error #define ZE_BIG 6 // entry too large to split #define ZE_NOTE 7 // invalid comment format #define ZE_TEST 8 // zip test (-T) failed or out of memory #define ZE_ABORT 9 // user interrupt or termination #define ZE_TEMP 10 // error using a temp file #define ZE_READ 11 // read or seek error #define ZE_NONE 12 // nothing to do #define ZE_NAME 13 // missing or empty zip file #define ZE_WRITE 14 // error writing to a file #define ZE_CREAT 15 // couldn't open to write #define ZE_PARMS 16 // bad command line #define ZE_OPEN 18 // could not open a specified file to read #define ZE_MAXERR 18 // the highest error number // internal file attribute #define UNKNOWN (-1) #define BINARY 0 #define ASCII 1 #define BEST -1 // Use best method (deflation or store) #define STORE 0 // Store method #define DEFLATE 8 // Deflation method #define CRCVAL_INITIAL 0L // MSDOS file or directory attributes #define MSDOS_HIDDEN_ATTR 0x02 #define MSDOS_DIR_ATTR 0x10 // Lengths of headers after signatures in bytes #define LOCHEAD 26 #define CENHEAD 42 #define ENDHEAD 18 // Definitions for extra field handling: #define EB_HEADSIZE 4 /* length of a extra field block header */ #define EB_LEN 2 /* offset of data length field in header */ #define EB_UT_MINLEN 1 /* minimal UT field contains Flags byte */ #define EB_UT_FLAGS 0 /* byte offset of Flags field */ #define EB_UT_TIME1 1 /* byte offset of 1st time value */ #define EB_UT_FL_MTIME (1 << 0) /* mtime present */ #define EB_UT_FL_ATIME (1 << 1) /* atime present */ #define EB_UT_FL_CTIME (1 << 2) /* ctime present */ #define EB_UT_LEN(n) (EB_UT_MINLEN + 4 * (n)) #define EB_L_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(3)) #define EB_C_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(1)) // Macros for writing machine integers to little-endian format #define PUTSH(a,f) {char _putsh_c=(char)((a)&0xff); wfunc(param,&_putsh_c,1); _putsh_c=(char)((a)>>8); wfunc(param,&_putsh_c,1);} #define PUTLG(a,f) {PUTSH((a) & 0xffff,(f)) PUTSH((a) >> 16,(f))} // -- Structure of a ZIP file -- // Signatures for zip file information headers #define LOCSIG 0x04034b50L #define CENSIG 0x02014b50L #define ENDSIG 0x06054b50L #define EXTLOCSIG 0x08074b50L #define MIN_MATCH 3 #define MAX_MATCH 258 // The minimum and maximum match lengths #define WSIZE (0x8000) // Maximum window size = 32K. If you are really short of memory, compile // with a smaller WSIZE but this reduces the compression ratio for files // of size > WSIZE. WSIZE must be a power of two in the current implementation. // #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) // Minimum amount of lookahead, except at the end of the input file. // See deflate.c for comments about the MIN_MATCH+1. // #define MAX_DIST (WSIZE-MIN_LOOKAHEAD) // In order to simplify the code, particularly on 16 bit machines, match // distances are limited to MAX_DIST instead of WSIZE. // #define ZIP_HANDLE 1 #define ZIP_FILENAME 2 #define ZIP_MEMORY 3 #define ZIP_FOLDER 4 // =========================================================================== // Constants // #define MAX_BITS 15 // All codes must not exceed MAX_BITS bits #define MAX_BL_BITS 7 // Bit length codes must not exceed MAX_BL_BITS bits #define LENGTH_CODES 29 // number of length codes, not counting the special END_BLOCK code #define LITERALS 256 // number of literal bytes 0..255 #define END_BLOCK 256 // end of block literal code #define L_CODES (LITERALS+1+LENGTH_CODES) // number of Literal or Length codes, including the END_BLOCK code #define D_CODES 30 // number of distance codes #define BL_CODES 19 // number of codes used to transfer the bit lengths #define STORED_BLOCK 0 #define STATIC_TREES 1 #define DYN_TREES 2 // The three kinds of block type #define LIT_BUFSIZE 0x8000 #define DIST_BUFSIZE LIT_BUFSIZE // Sizes of match buffers for literals/lengths and distances. There are // 4 reasons for limiting LIT_BUFSIZE to 64K: // - frequencies can be kept in 16 bit counters // - if compression is not successful for the first block, all input data is // still in the window so we can still emit a stored block even when input // comes from standard input. (This can also be done for all blocks if // LIT_BUFSIZE is not greater than 32K.) // - if compression is not successful for a file smaller than 64K, we can // even emit a stored file instead of a stored block (saving 5 bytes). // - creating new Huffman trees less frequently may not provide fast // adaptation to changes in the input data statistics. (Take for // example a binary file with poorly compressible code followed by // a highly compressible string table.) Smaller buffer sizes give // fast adaptation but have of course the overhead of transmitting trees // more frequently. // - I can't count above 4 // The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save // memory at the expense of compression). Some optimizations would be possible // if we rely on DIST_BUFSIZE == LIT_BUFSIZE. // #define REP_3_6 16 // repeat previous bit length 3-6 times (2 bits of repeat count) #define REPZ_3_10 17 // repeat a zero length 3-10 times (3 bits of repeat count) #define REPZ_11_138 18 // repeat a zero length 11-138 times (7 bits of repeat count) #define HEAP_SIZE (2*L_CODES+1) // maximum heap size // =========================================================================== // Local data used by the "bit string" routines. // #define Buf_size (8 * 2*sizeof(char)) // Number of bits used within bi_buf. (bi_buf may be implemented on // more than 16 bits on some systems.) // Output a 16 bit value to the bit stream, lower (oldest) byte first #define PUTSHORT(state,w) \ { if (state.bs.out_offset >= state.bs.out_size-1) \ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \ state.bs.out_buf[state.bs.out_offset++] = (char) ((w) & 0xff); \ state.bs.out_buf[state.bs.out_offset++] = (char) ((ush)(w) >> 8); \ } #define PUTBYTE(state,b) \ { if (state.bs.out_offset >= state.bs.out_size) \ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \ state.bs.out_buf[state.bs.out_offset++] = (char) (b); \ } // DEFLATE.CPP HEADER #define HASH_BITS 15 // For portability to 16 bit machines, do not use values above 15. #define HASH_SIZE (unsigned)(1<<HASH_BITS) #define HASH_MASK (HASH_SIZE-1) #define WMASK (WSIZE-1) // HASH_SIZE and WSIZE must be powers of two #define NIL 0 // Tail of hash chains #define FAST 4 #define SLOW 2 // speed options for the general purpose bit flag #define TOO_FAR 4096 // Matches of length 3 are discarded if their distance exceeds TOO_FAR #define EQUAL 0 // result of memcmp for equal strings // =========================================================================== // Local data used by the "longest match" routines. #define H_SHIFT ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH) // Number of bits by which ins_h and del_h must be shifted at each // input step. It must be such that after MIN_MATCH steps, the oldest // byte no longer takes part in the hash key, that is: // H_SHIFT * MIN_MATCH >= HASH_BITS #define max_insert_length max_lazy_match // Insert new strings in the hash table only if the match length // is not greater than this length. This saves time but degrades compression. // max_insert_length is used only for compression levels <= 3. const int extra_lbits[LENGTH_CODES] // extra bits for each length code = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; const int extra_dbits[D_CODES] // extra bits for each distance code = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; const int extra_blbits[BL_CODES]// extra bits for each bit length code = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; const uch bl_order[BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; // The lengths of the bit length codes are sent in order of decreasing // probability, to avoid transmitting the lengths for unused bit length codes. typedef struct config { ush good_length; // reduce lazy search above this match length ush max_lazy; // do not perform lazy search above this match length ush nice_length; // quit search above this match length ush max_chain; } config; // Values for max_lazy_match, good_match, nice_match and max_chain_length, // depending on the desired pack level (0..9). The values given below have // been tuned to exclude worst case performance for pathological files. // Better values may be found for specific files. // const config configuration_table[10] = { // good lazy nice chain {0, 0, 0, 0}, // 0 store only {4, 4, 8, 4}, // 1 maximum speed, no lazy matches {4, 5, 16, 8}, // 2 {4, 6, 32, 32}, // 3 {4, 4, 16, 16}, // 4 lazy matches */ {8, 16, 32, 32}, // 5 {8, 16, 128, 128}, // 6 {8, 32, 128, 256}, // 7 {32, 128, 258, 1024}, // 8 {32, 258, 258, 4096}};// 9 maximum compression */ // Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 // For deflate_fast() (levels <= 3) good is ignored and lazy has a different meaning. // Data structure describing a single value and its code string. typedef struct ct_data { union { ush freq; // frequency count ush code; // bit string } fc; union { ush dad; // father node in Huffman tree ush len; // length of bit string } dl; } ct_data; typedef struct tree_desc { ct_data *dyn_tree; // the dynamic tree ct_data *static_tree; // corresponding static tree or NULL const int *extra_bits; // extra bits for each code or NULL int extra_base; // base index for extra_bits int elems; // max number of elements in the tree int max_length; // max bit length for the codes int max_code; // largest code with non zero frequency } tree_desc; class TTreeState { public: TTreeState(); ct_data dyn_ltree[HEAP_SIZE]; // literal and length tree ct_data dyn_dtree[2*D_CODES+1]; // distance tree ct_data static_ltree[L_CODES+2]; // the static literal tree... // ... Since the bit lengths are imposed, there is no need for the L_CODES // extra codes used during heap construction. However the codes 286 and 287 // are needed to build a canonical tree (see ct_init below). ct_data static_dtree[D_CODES]; // the static distance tree... // ... (Actually a trivial tree since all codes use 5 bits.) ct_data bl_tree[2*BL_CODES+1]; // Huffman tree for the bit lengths tree_desc l_desc; tree_desc d_desc; tree_desc bl_desc; ush bl_count[MAX_BITS+1]; // number of codes at each bit length for an optimal tree int heap[2*L_CODES+1]; // heap used to build the Huffman trees int heap_len; // number of elements in the heap int heap_max; // element of largest frequency // The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. // The same heap array is used to build all trees. uch depth[2*L_CODES+1]; // Depth of each subtree used as tie breaker for trees of equal frequency uch length_code[MAX_MATCH-MIN_MATCH+1]; // length code for each normalized match length (0 == MIN_MATCH) uch dist_code[512]; // distance codes. The first 256 values correspond to the distances // 3 .. 258, the last 256 values correspond to the top 8 bits of // the 15 bit distances. int base_length[LENGTH_CODES]; // First normalized length for each code (0 = MIN_MATCH) int base_dist[D_CODES]; // First normalized distance for each code (0 = distance of 1) uch far l_buf[LIT_BUFSIZE]; // buffer for literals/lengths ush far d_buf[DIST_BUFSIZE]; // buffer for distances uch flag_buf[(LIT_BUFSIZE/8)]; // flag_buf is a bit array distinguishing literals from lengths in // l_buf, and thus indicating the presence or absence of a distance. unsigned last_lit; // running index in l_buf unsigned last_dist; // running index in d_buf unsigned last_flags; // running index in flag_buf uch flags; // current flags not yet saved in flag_buf uch flag_bit; // current bit used in flags // bits are filled in flags starting at bit 0 (least significant). // Note: these flags are overkill in the current code since we don't // take advantage of DIST_BUFSIZE == LIT_BUFSIZE. ulg opt_len; // bit length of current block with optimal trees ulg static_len; // bit length of current block with static trees ulg cmpr_bytelen; // total byte length of compressed file ulg cmpr_len_bits; // number of bits past 'cmpr_bytelen' ulg input_len; // total byte length of input file // input_len is for debugging only since we can get it by other means. ush *file_type; // pointer to UNKNOWN, BINARY or ASCII // int *file_method; // pointer to DEFLATE or STORE }; TTreeState::TTreeState() { tree_desc a = {dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0}; l_desc = a; tree_desc b = {dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0}; d_desc = b; tree_desc c = {bl_tree, NULL, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0}; bl_desc = c; last_lit=0; last_dist=0; last_flags=0; } class TBitState { public: int flush_flg; // unsigned bi_buf; // Output buffer. bits are inserted starting at the bottom (least significant // bits). The width of bi_buf must be at least 16 bits. int bi_valid; // Number of valid bits in bi_buf. All bits above the last valid bit // are always zero. char *out_buf; // Current output buffer. unsigned out_offset; // Current offset in output buffer. // On 16 bit machines, the buffer is limited to 64K. unsigned out_size; // Size of current output buffer ulg bits_sent; // bit length of the compressed data only needed for debugging??? }; class TDeflateState { public: TDeflateState() {window_size=0;} uch window[2L*WSIZE]; // Sliding window. Input bytes are read into the second half of the window, // and move to the first half later to keep a dictionary of at least WSIZE // bytes. With this organization, matches are limited to a distance of // WSIZE-MAX_MATCH bytes, but this ensures that IO is always // performed with a length multiple of the block size. Also, it limits // the window size to 64K, which is quite useful on MSDOS. // To do: limit the window size to WSIZE+CBSZ if SMALL_MEM (the code would // be less efficient since the data would have to be copied WSIZE/CBSZ times) Pos prev[WSIZE]; // Link to older string with same hash index. To limit the size of this // array to 64K, this link is maintained only for the last 32K strings. // An index in this array is thus a window index modulo 32K. Pos head[HASH_SIZE]; // Heads of the hash chains or NIL. If your compiler thinks that // HASH_SIZE is a dynamic value, recompile with -DDYN_ALLOC. ulg window_size; // window size, 2*WSIZE except for MMAP or BIG_MEM, where it is the // input file length plus MIN_LOOKAHEAD. long block_start; // window position at the beginning of the current output block. Gets // negative when the window is moved backwards. int sliding; // Set to false when the input file is already in memory unsigned ins_h; // hash index of string to be inserted unsigned int prev_length; // Length of the best match at previous step. Matches not greater than this // are discarded. This is used in the lazy match evaluation. unsigned strstart; // start of string to insert unsigned match_start; // start of matching string int eofile; // flag set at end of input file unsigned lookahead; // number of valid bytes ahead in window unsigned max_chain_length; // To speed up deflation, hash chains are never searched beyond this length. // A higher limit improves compression ratio but degrades the speed. unsigned int max_lazy_match; // Attempt to find a better match only when the current match is strictly // smaller than this value. This mechanism is used only for compression // levels >= 4. unsigned good_match; // Use a faster search when the previous match is longer than this int nice_match; // Stop searching when current match exceeds this }; typedef __int64 lutime_t; // define it ourselves since we don't include time.h typedef struct iztimes { lutime_t atime,mtime,ctime; } iztimes; // access, modify, create times typedef struct zlist { ush vem, ver, flg, how; // See central header in zipfile.c for what vem..off are ulg tim, crc, siz, len; extent nam, ext, cext, com; // offset of ext must be >= LOCHEAD ush dsk, att, lflg; // offset of lflg must be >= LOCHEAD ulg atx, off; char name[MAX_PATH]; // File name in zip file char *extra; // Extra field (set only if ext != 0) char *cextra; // Extra in central (set only if cext != 0) char *comment; // Comment (set only if com != 0) char iname[MAX_PATH]; // Internal file name after cleanup char zname[MAX_PATH]; // External version of internal name int mark; // Marker for files to operate on int trash; // Marker for files to delete int dosflag; // Set to force MSDOS file attributes struct zlist far *nxt; // Pointer to next header in list } TZipFileInfo; struct TState; typedef unsigned (*READFUNC)(TState &state, char *buf,unsigned size); typedef unsigned (*FLUSHFUNC)(void *param, const char *buf, unsigned *size); typedef unsigned (*WRITEFUNC)(void *param, const char *buf, unsigned size); struct TState { void *param; int level; bool seekable; READFUNC readfunc; FLUSHFUNC flush_outbuf; TTreeState ts; TBitState bs; TDeflateState ds; const char *err; }; void Assert(TState &state,bool cond, const char *msg) { if (cond) return; state.err=msg; } void __cdecl Trace(const char *x, ...) {va_list paramList; va_start(paramList, x); paramList; va_end(paramList);} void __cdecl Tracec(bool ,const char *x, ...) {va_list paramList; va_start(paramList, x); paramList; va_end(paramList);} // =========================================================================== // Local (static) routines in this file. // void init_block (TState &); void pqdownheap (TState &,ct_data *tree, int k); void gen_bitlen (TState &,tree_desc *desc); void gen_codes (TState &state,ct_data *tree, int max_code); void build_tree (TState &,tree_desc *desc); void scan_tree (TState &,ct_data *tree, int max_code); void send_tree (TState &state,ct_data *tree, int max_code); int build_bl_tree (TState &); void send_all_trees (TState &state,int lcodes, int dcodes, int blcodes); void compress_block (TState &state,ct_data *ltree, ct_data *dtree); void set_file_type (TState &); void send_bits (TState &state, int value, int length); unsigned bi_reverse (unsigned code, int len); void bi_windup (TState &state); void copy_block (TState &state,char *buf, unsigned len, int header); #define send_code(state, c, tree) send_bits(state, tree[c].fc.code, tree[c].dl.len) // Send a code of the given tree. c and tree must not have side effects // alternatively... //#define send_code(state, c, tree) // { if (state.verbose>1) fprintf(stderr,"\ncd %3d ",(c)); // send_bits(state, tree[c].fc.code, tree[c].dl.len); } #define d_code(dist) ((dist) < 256 ? state.ts.dist_code[dist] : state.ts.dist_code[256+((dist)>>7)]) // Mapping from a distance to a distance code. dist is the distance - 1 and // must not have side effects. dist_code[256] and dist_code[257] are never used. #define Max(a,b) (a >= b ? a : b) /* the arguments must not have side effects */ /* =========================================================================== * Allocate the match buffer, initialize the various tables and save the * location of the internal file attribute (ascii/binary) and method * (DEFLATE/STORE). */ void ct_init(TState &state, ush *attr) { int n; /* iterates over tree elements */ int bits; /* bit counter */ int length; /* length value */ int code; /* code value */ int dist; /* distance index */ state.ts.file_type = attr; //state.ts.file_method = method; state.ts.cmpr_bytelen = state.ts.cmpr_len_bits = 0L; state.ts.input_len = 0L; if (state.ts.static_dtree[0].dl.len != 0) return; /* ct_init already called */ /* Initialize the mapping length (0..255) -> length code (0..28) */ length = 0; for (code = 0; code < LENGTH_CODES-1; code++) { state.ts.base_length[code] = length; for (n = 0; n < (1<<extra_lbits[code]); n++) { state.ts.length_code[length++] = (uch)code; } } Assert(state,length == 256, "ct_init: length != 256"); /* Note that the length 255 (match length 258) can be represented * in two different ways: code 284 + 5 bits or code 285, so we * overwrite length_code[255] to use the best encoding: */ state.ts.length_code[length-1] = (uch)code; /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ dist = 0; for (code = 0 ; code < 16; code++) { state.ts.base_dist[code] = dist; for (n = 0; n < (1<<extra_dbits[code]); n++) { state.ts.dist_code[dist++] = (uch)code; } } Assert(state,dist == 256, "ct_init: dist != 256"); dist >>= 7; /* from now on, all distances are divided by 128 */ for ( ; code < D_CODES; code++) { state.ts.base_dist[code] = dist << 7; for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { state.ts.dist_code[256 + dist++] = (uch)code; } } Assert(state,dist == 256, "ct_init: 256+dist != 512"); /* Construct the codes of the static literal tree */ for (bits = 0; bits <= MAX_BITS; bits++) state.ts.bl_count[bits] = 0; n = 0; while (n <= 143) state.ts.static_ltree[n++].dl.len = 8, state.ts.bl_count[8]++; while (n <= 255) state.ts.static_ltree[n++].dl.len = 9, state.ts.bl_count[9]++; while (n <= 279) state.ts.static_ltree[n++].dl.len = 7, state.ts.bl_count[7]++; while (n <= 287) state.ts.static_ltree[n++].dl.len = 8, state.ts.bl_count[8]++; /* fc.codes 286 and 287 do not exist, but we must include them in the * tree construction to get a canonical Huffman tree (longest code * all ones) */ gen_codes(state,(ct_data *)state.ts.static_ltree, L_CODES+1); /* The static distance tree is trivial: */ for (n = 0; n < D_CODES; n++) { state.ts.static_dtree[n].dl.len = 5; state.ts.static_dtree[n].fc.code = (ush)bi_reverse(n, 5); } /* Initialize the first block of the first file: */ init_block(state); } /* =========================================================================== * Initialize a new block. */ void init_block(TState &state) { int n; /* iterates over tree elements */ /* Initialize the trees. */ for (n = 0; n < L_CODES; n++) state.ts.dyn_ltree[n].fc.freq = 0; for (n = 0; n < D_CODES; n++) state.ts.dyn_dtree[n].fc.freq = 0; for (n = 0; n < BL_CODES; n++) state.ts.bl_tree[n].fc.freq = 0; state.ts.dyn_ltree[END_BLOCK].fc.freq = 1; state.ts.opt_len = state.ts.static_len = 0L; state.ts.last_lit = state.ts.last_dist = state.ts.last_flags = 0; state.ts.flags = 0; state.ts.flag_bit = 1; } #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ /* =========================================================================== * Remove the smallest element from the heap and recreate the heap with * one less element. Updates heap and heap_len. */ #define pqremove(tree, top) \ {\ top = state.ts.heap[SMALLEST]; \ state.ts.heap[SMALLEST] = state.ts.heap[state.ts.heap_len--]; \ pqdownheap(state,tree, SMALLEST); \ } /* =========================================================================== * Compares to subtrees, using the tree depth as tie breaker when * the subtrees have equal frequency. This minimizes the worst case length. */ #define smaller(tree, n, m) \ (tree[n].fc.freq < tree[m].fc.freq || \ (tree[n].fc.freq == tree[m].fc.freq && state.ts.depth[n] <= state.ts.depth[m])) /* =========================================================================== * Restore the heap property by moving down the tree starting at node k, * exchanging a node with the smallest of its two sons if necessary, stopping * when the heap property is re-established (each father smaller than its * two sons). */ void pqdownheap(TState &state,ct_data *tree, int k) { int v = state.ts.heap[k]; int j = k << 1; /* left son of k */ int htemp; /* required because of bug in SASC compiler */ while (j <= state.ts.heap_len) { /* Set j to the smallest of the two sons: */ if (j < state.ts.heap_len && smaller(tree, state.ts.heap[j+1], state.ts.heap[j])) j++; /* Exit if v is smaller than both sons */ htemp = state.ts.heap[j]; if (smaller(tree, v, htemp)) break; /* Exchange v with the smallest son */ state.ts.heap[k] = htemp; k = j; /* And continue down the tree, setting j to the left son of k */ j <<= 1; } state.ts.heap[k] = v; } /* =========================================================================== * Compute the optimal bit lengths for a tree and update the total bit length * for the current block. * IN assertion: the fields freq and dad are set, heap[heap_max] and * above are the tree nodes sorted by increasing frequency. * OUT assertions: the field len is set to the optimal bit length, the * array bl_count contains the frequencies for each bit length. * The length opt_len is updated; static_len is also updated if stree is * not null. */ void gen_bitlen(TState &state,tree_desc *desc) { ct_data *tree = desc->dyn_tree; const int *extra = desc->extra_bits; int base = desc->extra_base; int max_code = desc->max_code; int max_length = desc->max_length; ct_data *stree = desc->static_tree; int h; /* heap index */ int n, m; /* iterate over the tree elements */ int bits; /* bit length */ int xbits; /* extra bits */ ush f; /* frequency */ int overflow = 0; /* number of elements with bit length too large */ for (bits = 0; bits <= MAX_BITS; bits++) state.ts.bl_count[bits] = 0; /* In a first pass, compute the optimal bit lengths (which may * overflow in the case of the bit length tree). */ tree[state.ts.heap[state.ts.heap_max]].dl.len = 0; /* root of the heap */ for (h = state.ts.heap_max+1; h < HEAP_SIZE; h++) { n = state.ts.heap[h]; bits = tree[tree[n].dl.dad].dl.len + 1; if (bits > max_length) bits = max_length, overflow++; tree[n].dl.len = (ush)bits; /* We overwrite tree[n].dl.dad which is no longer needed */ if (n > max_code) continue; /* not a leaf node */ state.ts.bl_count[bits]++; xbits = 0; if (n >= base) xbits = extra[n-base]; f = tree[n].fc.freq; state.ts.opt_len += (ulg)f * (bits + xbits); if (stree) state.ts.static_len += (ulg)f * (stree[n].dl.len + xbits); } if (overflow == 0) return; Trace("\nbit length overflow\n"); /* This happens for example on obj2 and pic of the Calgary corpus */ /* Find the first bit length which could increase: */ do { bits = max_length-1; while (state.ts.bl_count[bits] == 0) bits--; state.ts.bl_count[bits]--; /* move one leaf down the tree */ state.ts.bl_count[bits+1] += (ush)2; /* move one overflow item as its brother */ state.ts.bl_count[max_length]--; /* The brother of the overflow item also moves one step up, * but this does not affect bl_count[max_length] */ overflow -= 2; } while (overflow > 0); /* Now recompute all bit lengths, scanning in increasing frequency. * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all * lengths instead of fixing only the wrong ones. This idea is taken * from 'ar' written by Haruhiko Okumura.) */ for (bits = max_length; bits != 0; bits--) { n = state.ts.bl_count[bits]; while (n != 0) { m = state.ts.heap[--h]; if (m > max_code) continue; if (tree[m].dl.len != (ush)bits) { Trace("code %d bits %d->%d\n", m, tree[m].dl.len, bits); state.ts.opt_len += ((long)bits-(long)tree[m].dl.len)*(long)tree[m].fc.freq; tree[m].dl.len = (ush)bits; } n--; } } } /* =========================================================================== * Generate the codes for a given tree and bit counts (which need not be * optimal). * IN assertion: the array bl_count contains the bit length statistics for * the given tree and the field len is set for all tree elements. * OUT assertion: the field code is set for all tree elements of non * zero code length. */ void gen_codes (TState &state, ct_data *tree, int max_code) { ush next_code[MAX_BITS+1]; /* next code value for each bit length */ ush code = 0; /* running code value */ int bits; /* bit index */ int n; /* code index */ /* The distribution counts are first used to generate the code values * without bit reversal. */ for (bits = 1; bits <= MAX_BITS; bits++) { next_code[bits] = code = (ush)((code + state.ts.bl_count[bits-1]) << 1); } /* Check that the bit counts in bl_count are consistent. The last code * must be all ones. */ Assert(state,code + state.ts.bl_count[MAX_BITS]-1 == (1<< ((ush) MAX_BITS)) - 1, "inconsistent bit counts"); Trace("\ngen_codes: max_code %d ", max_code); for (n = 0; n <= max_code; n++) { int len = tree[n].dl.len; if (len == 0) continue; /* Now reverse the bits */ tree[n].fc.code = (ush)bi_reverse(next_code[len]++, len); //Tracec(tree != state.ts.static_ltree, "\nn %3d %c l %2d c %4x (%x) ", n, (isgraph(n) ? n : ' '), len, tree[n].fc.code, next_code[len]-1); } } /* =========================================================================== * Construct one Huffman tree and assigns the code bit strings and lengths. * Update the total bit length for the current block. * IN assertion: the field freq is set for all tree elements. * OUT assertions: the fields len and code are set to the optimal bit length * and corresponding code. The length opt_len is updated; static_len is * also updated if stree is not null. The field max_code is set. */ void build_tree(TState &state,tree_desc *desc) { ct_data *tree = desc->dyn_tree; ct_data *stree = desc->static_tree; int elems = desc->elems; int n, m; /* iterate over heap elements */ int max_code = -1; /* largest code with non zero frequency */ int node = elems; /* next internal node of the tree */ /* Construct the initial heap, with least frequent element in * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. * heap[0] is not used. */ state.ts.heap_len = 0, state.ts.heap_max = HEAP_SIZE; for (n = 0; n < elems; n++) { if (tree[n].fc.freq != 0) { state.ts.heap[++state.ts.heap_len] = max_code = n; state.ts.depth[n] = 0; } else { tree[n].dl.len = 0; } } /* The pkzip format requires that at least one distance code exists, * and that at least one bit should be sent even if there is only one * possible code. So to avoid special checks later on we force at least * two codes of non zero frequency. */ while (state.ts.heap_len < 2) { int newcp = state.ts.heap[++state.ts.heap_len] = (max_code < 2 ? ++max_code : 0); tree[newcp].fc.freq = 1; state.ts.depth[newcp] = 0; state.ts.opt_len--; if (stree) state.ts.static_len -= stree[newcp].dl.len; /* new is 0 or 1 so it does not have extra bits */ } desc->max_code = max_code; /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, * establish sub-heaps of increasing lengths: */ for (n = state.ts.heap_len/2; n >= 1; n--) pqdownheap(state,tree, n); /* Construct the Huffman tree by repeatedly combining the least two * frequent nodes. */ do { pqremove(tree, n); /* n = node of least frequency */ m = state.ts.heap[SMALLEST]; /* m = node of next least frequency */ state.ts.heap[--state.ts.heap_max] = n; /* keep the nodes sorted by frequency */ state.ts.heap[--state.ts.heap_max] = m; /* Create a new node father of n and m */ tree[node].fc.freq = (ush)(tree[n].fc.freq + tree[m].fc.freq); state.ts.depth[node] = (uch) (Max(state.ts.depth[n], state.ts.depth[m]) + 1); tree[n].dl.dad = tree[m].dl.dad = (ush)node; /* and insert the new node in the heap */ state.ts.heap[SMALLEST] = node++; pqdownheap(state,tree, SMALLEST); } while (state.ts.heap_len >= 2); state.ts.heap[--state.ts.heap_max] = state.ts.heap[SMALLEST]; /* At this point, the fields freq and dad are set. We can now * generate the bit lengths. */ gen_bitlen(state,(tree_desc *)desc); /* The field len is now set, we can generate the bit codes */ gen_codes (state,(ct_data *)tree, max_code); } /* =========================================================================== * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. Updates opt_len to take into account the repeat * counts. (The contribution of the bit length codes will be added later * during the construction of bl_tree.) */ void scan_tree (TState &state,ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].dl.len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ if (nextlen == 0) max_count = 138, min_count = 3; tree[max_code+1].dl.len = (ush)-1; /* guard */ for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n+1].dl.len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { state.ts.bl_tree[curlen].fc.freq = (ush)(state.ts.bl_tree[curlen].fc.freq + count); } else if (curlen != 0) { if (curlen != prevlen) state.ts.bl_tree[curlen].fc.freq++; state.ts.bl_tree[REP_3_6].fc.freq++; } else if (count <= 10) { state.ts.bl_tree[REPZ_3_10].fc.freq++; } else { state.ts.bl_tree[REPZ_11_138].fc.freq++; } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ void send_tree (TState &state, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].dl.len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ /* tree[max_code+1].dl.len = -1; */ /* guard already set */ if (nextlen == 0) max_count = 138, min_count = 3; for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n+1].dl.len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { do { send_code(state, curlen, state.ts.bl_tree); } while (--count != 0); } else if (curlen != 0) { if (curlen != prevlen) { send_code(state, curlen, state.ts.bl_tree); count--; } Assert(state,count >= 3 && count <= 6, " 3_6?"); send_code(state,REP_3_6, state.ts.bl_tree); send_bits(state,count-3, 2); } else if (count <= 10) { send_code(state,REPZ_3_10, state.ts.bl_tree); send_bits(state,count-3, 3); } else { send_code(state,REPZ_11_138, state.ts.bl_tree); send_bits(state,count-11, 7); } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ int build_bl_tree(TState &state) { int max_blindex; /* index of last bit length code of non zero freq */ /* Determine the bit length frequencies for literal and distance trees */ scan_tree(state,(ct_data *)state.ts.dyn_ltree, state.ts.l_desc.max_code); scan_tree(state,(ct_data *)state.ts.dyn_dtree, state.ts.d_desc.max_code); /* Build the bit length tree: */ build_tree(state,(tree_desc *)(&state.ts.bl_desc)); /* opt_len now includes the length of the tree representations, except * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. */ /* Determine the number of bit length codes to send. The pkzip format * requires that at least 4 bit length codes be sent. (appnote.txt says * 3 but the actual value used is 4.) */ for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { if (state.ts.bl_tree[bl_order[max_blindex]].dl.len != 0) break; } /* Update opt_len to include the bit length tree and counts */ state.ts.opt_len += 3*(max_blindex+1) + 5+5+4; Trace("\ndyn trees: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len); return max_blindex; } /* =========================================================================== * Send the header for a block using dynamic Huffman trees: the counts, the * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ void send_all_trees(TState &state,int lcodes, int dcodes, int blcodes) { int rank; /* index in bl_order */ Assert(state,lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); Assert(state,lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes"); Trace("\nbl counts: "); send_bits(state,lcodes-257, 5); /* not +255 as stated in appnote.txt 1.93a or -256 in 2.04c */ send_bits(state,dcodes-1, 5); send_bits(state,blcodes-4, 4); /* not -3 as stated in appnote.txt */ for (rank = 0; rank < blcodes; rank++) { Trace("\nbl code %2d ", bl_order[rank]); send_bits(state,state.ts.bl_tree[bl_order[rank]].dl.len, 3); } Trace("\nbl tree: sent %ld", state.bs.bits_sent); send_tree(state,(ct_data *)state.ts.dyn_ltree, lcodes-1); /* send the literal tree */ Trace("\nlit tree: sent %ld", state.bs.bits_sent); send_tree(state,(ct_data *)state.ts.dyn_dtree, dcodes-1); /* send the distance tree */ Trace("\ndist tree: sent %ld", state.bs.bits_sent); } /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static * trees or store, and output the encoded block to the zip file. This function * returns the total compressed length (in bytes) for the file so far. */ ulg flush_block(TState &state,char *buf, ulg stored_len, int eof) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex; /* index of last bit length code of non zero freq */ state.ts.flag_buf[state.ts.last_flags] = state.ts.flags; /* Save the flags for the last 8 items */ /* Check if the file is ascii or binary */ if (*state.ts.file_type == (ush)UNKNOWN) set_file_type(state); /* Construct the literal and distance trees */ build_tree(state,(tree_desc *)(&state.ts.l_desc)); Trace("\nlit data: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len); build_tree(state,(tree_desc *)(&state.ts.d_desc)); Trace("\ndist data: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len); /* At this point, opt_len and static_len are the total bit lengths of * the compressed block data, excluding the tree representations. */ /* Build the bit length tree for the above two trees, and get the index * in bl_order of the last bit length code to send. */ max_blindex = build_bl_tree(state); /* Determine the best encoding. Compute first the block length in bytes */ opt_lenb = (state.ts.opt_len+3+7)>>3; static_lenb = (state.ts.static_len+3+7)>>3; state.ts.input_len += stored_len; /* for debugging only */ Trace("\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", opt_lenb, state.ts.opt_len, static_lenb, state.ts.static_len, stored_len, state.ts.last_lit, state.ts.last_dist); if (static_lenb <= opt_lenb) opt_lenb = static_lenb; // Originally, zip allowed the file to be transformed from a compressed // into a stored file in the case where compression failed, there // was only one block, and it was allowed to change. I've removed this // possibility since the code's cleaner if no changes are allowed. //if (stored_len <= opt_lenb && eof && state.ts.cmpr_bytelen == 0L // && state.ts.cmpr_len_bits == 0L && state.seekable) //{ // && state.ts.file_method != NULL // // Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: // Assert(state,buf!=NULL,"block vanished"); // copy_block(state,buf, (unsigned)stored_len, 0); // without header // state.ts.cmpr_bytelen = stored_len; // Assert(state,false,"unimplemented *state.ts.file_method = STORE;"); // //*state.ts.file_method = STORE; //} //else if (stored_len+4 <= opt_lenb && buf != (char*)NULL) { /* 4: two words for the lengths */ /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. * Otherwise we can't have processed more than WSIZE input bytes since * the last block flush, because compression would have been * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to * transform a block into a stored block. */ send_bits(state,(STORED_BLOCK<<1)+eof, 3); /* send block type */ state.ts.cmpr_bytelen += ((state.ts.cmpr_len_bits + 3 + 7) >> 3) + stored_len + 4; state.ts.cmpr_len_bits = 0L; copy_block(state,buf, (unsigned)stored_len, 1); /* with header */ } else if (static_lenb == opt_lenb) { send_bits(state,(STATIC_TREES<<1)+eof, 3); compress_block(state,(ct_data *)state.ts.static_ltree, (ct_data *)state.ts.static_dtree); state.ts.cmpr_len_bits += 3 + state.ts.static_len; state.ts.cmpr_bytelen += state.ts.cmpr_len_bits >> 3; state.ts.cmpr_len_bits &= 7L; } else { send_bits(state,(DYN_TREES<<1)+eof, 3); send_all_trees(state,state.ts.l_desc.max_code+1, state.ts.d_desc.max_code+1, max_blindex+1); compress_block(state,(ct_data *)state.ts.dyn_ltree, (ct_data *)state.ts.dyn_dtree); state.ts.cmpr_len_bits += 3 + state.ts.opt_len; state.ts.cmpr_bytelen += state.ts.cmpr_len_bits >> 3; state.ts.cmpr_len_bits &= 7L; } Assert(state,((state.ts.cmpr_bytelen << 3) + state.ts.cmpr_len_bits) == state.bs.bits_sent, "bad compressed size"); init_block(state); if (eof) { // Assert(state,input_len == isize, "bad input size"); bi_windup(state); state.ts.cmpr_len_bits += 7; /* align on byte boundary */ } Trace("\n"); return state.ts.cmpr_bytelen + (state.ts.cmpr_len_bits >> 3); } /* =========================================================================== * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ int ct_tally (TState &state,int dist, int lc) { state.ts.l_buf[state.ts.last_lit++] = (uch)lc; if (dist == 0) { /* lc is the unmatched char */ state.ts.dyn_ltree[lc].fc.freq++; } else { /* Here, lc is the match length - MIN_MATCH */ dist--; /* dist = match distance - 1 */ Assert(state,(ush)dist < (ush)MAX_DIST && (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && (ush)d_code(dist) < (ush)D_CODES, "ct_tally: bad match"); state.ts.dyn_ltree[state.ts.length_code[lc]+LITERALS+1].fc.freq++; state.ts.dyn_dtree[d_code(dist)].fc.freq++; state.ts.d_buf[state.ts.last_dist++] = (ush)dist; state.ts.flags |= state.ts.flag_bit; } state.ts.flag_bit <<= 1; /* Output the flags if they fill a byte: */ if ((state.ts.last_lit & 7) == 0) { state.ts.flag_buf[state.ts.last_flags++] = state.ts.flags; state.ts.flags = 0, state.ts.flag_bit = 1; } /* Try to guess if it is profitable to stop the current block here */ if (state.level > 2 && (state.ts.last_lit & 0xfff) == 0) { /* Compute an upper bound for the compressed length */ ulg out_length = (ulg)state.ts.last_lit*8L; ulg in_length = (ulg)state.ds.strstart-state.ds.block_start; int dcode; for (dcode = 0; dcode < D_CODES; dcode++) { out_length += (ulg)state.ts.dyn_dtree[dcode].fc.freq*(5L+extra_dbits[dcode]); } out_length >>= 3; Trace("\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", state.ts.last_lit, state.ts.last_dist, in_length, out_length, 100L - out_length*100L/in_length); if (state.ts.last_dist < state.ts.last_lit/2 && out_length < in_length/2) return 1; } return (state.ts.last_lit == LIT_BUFSIZE-1 || state.ts.last_dist == DIST_BUFSIZE); /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. */ } /* =========================================================================== * Send the block data compressed using the given Huffman trees */ void compress_block(TState &state,ct_data *ltree, ct_data *dtree) { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ unsigned lx = 0; /* running index in l_buf */ unsigned dx = 0; /* running index in d_buf */ unsigned fx = 0; /* running index in flag_buf */ uch flag = 0; /* current flags */ unsigned code; /* the code to send */ int extra; /* number of extra bits to send */ if (state.ts.last_lit != 0) do { if ((lx & 7) == 0) flag = state.ts.flag_buf[fx++]; lc = state.ts.l_buf[lx++]; if ((flag & 1) == 0) { send_code(state,lc, ltree); /* send a literal byte */ } else { /* Here, lc is the match length - MIN_MATCH */ code = state.ts.length_code[lc]; send_code(state,code+LITERALS+1, ltree); /* send the length code */ extra = extra_lbits[code]; if (extra != 0) { lc -= state.ts.base_length[code]; send_bits(state,lc, extra); /* send the extra length bits */ } dist = state.ts.d_buf[dx++]; /* Here, dist is the match distance - 1 */ code = d_code(dist); Assert(state,code < D_CODES, "bad d_code"); send_code(state,code, dtree); /* send the distance code */ extra = extra_dbits[code]; if (extra != 0) { dist -= state.ts.base_dist[code]; send_bits(state,dist, extra); /* send the extra distance bits */ } } /* literal or match pair ? */ flag >>= 1; } while (lx < state.ts.last_lit); send_code(state,END_BLOCK, ltree); } /* =========================================================================== * Set the file type to ASCII or BINARY, using a crude approximation: * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. * IN assertion: the fields freq of dyn_ltree are set and the total of all * frequencies does not exceed 64K (to fit in an int on 16 bit machines). */ void set_file_type(TState &state) { int n = 0; unsigned ascii_freq = 0; unsigned bin_freq = 0; while (n < 7) bin_freq += state.ts.dyn_ltree[n++].fc.freq; while (n < 128) ascii_freq += state.ts.dyn_ltree[n++].fc.freq; while (n < LITERALS) bin_freq += state.ts.dyn_ltree[n++].fc.freq; *state.ts.file_type = (ush)(bin_freq > (ascii_freq >> 2) ? BINARY : ASCII); } /* =========================================================================== * Initialize the bit string routines. */ void bi_init (TState &state,char *tgt_buf, unsigned tgt_size, int flsh_allowed) { state.bs.out_buf = tgt_buf; state.bs.out_size = tgt_size; state.bs.out_offset = 0; state.bs.flush_flg = flsh_allowed; state.bs.bi_buf = 0; state.bs.bi_valid = 0; state.bs.bits_sent = 0L; } /* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ void send_bits(TState &state,int value, int length) { Assert(state,length > 0 && length <= 15, "invalid length"); state.bs.bits_sent += (ulg)length; /* If not enough room in bi_buf, use (bi_valid) bits from bi_buf and * (Buf_size - bi_valid) bits from value to flush the filled bi_buf, * then fill in the rest of (value), leaving (length - (Buf_size-bi_valid)) * unused bits in bi_buf. */ state.bs.bi_buf |= (value << state.bs.bi_valid); state.bs.bi_valid += length; if (state.bs.bi_valid > (int)Buf_size) { PUTSHORT(state,state.bs.bi_buf); state.bs.bi_valid -= Buf_size; state.bs.bi_buf = (unsigned)value >> (length - state.bs.bi_valid); } } /* =========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) * IN assertion: 1 <= len <= 15 */ unsigned bi_reverse(unsigned code, int len) { register unsigned res = 0; do { res |= code & 1; code >>= 1, res <<= 1; } while (--len > 0); return res >> 1; } /* =========================================================================== * Write out any remaining bits in an incomplete byte. */ void bi_windup(TState &state) { if (state.bs.bi_valid > 8) { PUTSHORT(state,state.bs.bi_buf); } else if (state.bs.bi_valid > 0) { PUTBYTE(state,state.bs.bi_buf); } if (state.bs.flush_flg) { state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); } state.bs.bi_buf = 0; state.bs.bi_valid = 0; state.bs.bits_sent = (state.bs.bits_sent+7) & ~7; } /* =========================================================================== * Copy a stored block to the zip file, storing first the length and its * one's complement if requested. */ void copy_block(TState &state, char *block, unsigned len, int header) { bi_windup(state); /* align on byte boundary */ if (header) { PUTSHORT(state,(ush)len); PUTSHORT(state,(ush)~len); state.bs.bits_sent += 2*16; } if (state.bs.flush_flg) { state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); state.bs.out_offset = len; state.flush_outbuf(state.param,block, &state.bs.out_offset); } else if (state.bs.out_offset + len > state.bs.out_size) { Assert(state,false,"output buffer too small for in-memory compression"); } else { memcpy(state.bs.out_buf + state.bs.out_offset, block, len); state.bs.out_offset += len; } state.bs.bits_sent += (ulg)len<<3; } /* =========================================================================== * Prototypes for functions. */ void fill_window (TState &state); ulg deflate_fast (TState &state); int longest_match (TState &state,IPos cur_match); /* =========================================================================== * Update a hash value with the given input byte * IN assertion: all calls to to UPDATE_HASH are made with consecutive * input characters, so that a running hash key can be computed from the * previous key instead of complete recalculation each time. */ #define UPDATE_HASH(h,c) (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK) /* =========================================================================== * Insert string s in the dictionary and set match_head to the previous head * of the hash chain (the most recent string with same hash key). Return * the previous length of the hash chain. * IN assertion: all calls to to INSERT_STRING are made with consecutive * input characters and the first MIN_MATCH bytes of s are valid * (except for the last MIN_MATCH-1 bytes of the input file). */ #define INSERT_STRING(s, match_head) \ (UPDATE_HASH(state.ds.ins_h, state.ds.window[(s) + (MIN_MATCH-1)]), \ state.ds.prev[(s) & WMASK] = match_head = state.ds.head[state.ds.ins_h], \ state.ds.head[state.ds.ins_h] = (s)) /* =========================================================================== * Initialize the "longest match" routines for a new file * * IN assertion: window_size is > 0 if the input file is already read or * mmap'ed in the window[] array, 0 otherwise. In the first case, * window_size is sufficient to contain the whole input file plus * MIN_LOOKAHEAD bytes (to avoid referencing memory beyond the end * of window[] when looking for matches towards the end). */ void lm_init (TState &state, int pack_level, ush *flags) { register unsigned j; Assert(state,pack_level>=1 && pack_level<=8,"bad pack level"); /* Do not slide the window if the whole input is already in memory * (window_size > 0) */ state.ds.sliding = 0; if (state.ds.window_size == 0L) { state.ds.sliding = 1; state.ds.window_size = (ulg)2L*WSIZE; } /* Initialize the hash table (avoiding 64K overflow for 16 bit systems). * prev[] will be initialized on the fly. */ state.ds.head[HASH_SIZE-1] = NIL; memset((char*)state.ds.head, NIL, (unsigned)(HASH_SIZE-1)*sizeof(*state.ds.head)); /* Set the default configuration parameters: */ state.ds.max_lazy_match = configuration_table[pack_level].max_lazy; state.ds.good_match = configuration_table[pack_level].good_length; state.ds.nice_match = configuration_table[pack_level].nice_length; state.ds.max_chain_length = configuration_table[pack_level].max_chain; if (pack_level <= 2) { *flags |= FAST; } else if (pack_level >= 8) { *flags |= SLOW; } /* ??? reduce max_chain_length for binary files */ state.ds.strstart = 0; state.ds.block_start = 0L; j = WSIZE; j <<= 1; // Can read 64K in one step state.ds.lookahead = state.readfunc(state, (char*)state.ds.window, j); if (state.ds.lookahead == 0 || state.ds.lookahead == (unsigned)EOF) { state.ds.eofile = 1, state.ds.lookahead = 0; return; } state.ds.eofile = 0; /* Make sure that we always have enough lookahead. This is important * if input comes from a device such as a tty. */ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state); state.ds.ins_h = 0; for (j=0; j<MIN_MATCH-1; j++) UPDATE_HASH(state.ds.ins_h, state.ds.window[j]); /* If lookahead < MIN_MATCH, ins_h is garbage, but this is * not important since only literal bytes will be emitted. */ } /* =========================================================================== * Set match_start to the longest match starting at the given string and * return its length. Matches shorter or equal to prev_length are discarded, * in which case the result is equal to prev_length and match_start is * garbage. * IN assertions: cur_match is the head of the hash chain for the current * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 */ // For 80x86 and 680x0 and ARM, an optimized version is in match.asm or // match.S. The code is functionally equivalent, so you can use the C version // if desired. Which I do so desire! int longest_match(TState &state,IPos cur_match) { unsigned chain_length = state.ds.max_chain_length; /* max hash chain length */ register uch far *scan = state.ds.window + state.ds.strstart; /* current string */ register uch far *match; /* matched string */ register int len; /* length of current match */ int best_len = state.ds.prev_length; /* best match length so far */ IPos limit = state.ds.strstart > (IPos)MAX_DIST ? state.ds.strstart - (IPos)MAX_DIST : NIL; /* Stop when cur_match becomes <= limit. To simplify the code, * we prevent matches with the string of window index 0. */ // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. // It is easy to get rid of this optimization if necessary. Assert(state,HASH_BITS>=8 && MAX_MATCH==258,"Code too clever"); register uch far *strend = state.ds.window + state.ds.strstart + MAX_MATCH; register uch scan_end1 = scan[best_len-1]; register uch scan_end = scan[best_len]; /* Do not waste too much time if we already have a good match: */ if (state.ds.prev_length >= state.ds.good_match) { chain_length >>= 2; } Assert(state,state.ds.strstart <= state.ds.window_size-MIN_LOOKAHEAD, "insufficient lookahead"); do { Assert(state,cur_match < state.ds.strstart, "no future"); match = state.ds.window + cur_match; /* Skip to next match if the match length cannot increase * or if the match length is less than 2: */ if (match[best_len] != scan_end || match[best_len-1] != scan_end1 || *match != *scan || *++match != scan[1]) continue; /* The check at best_len-1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that * the hash keys are equal and that HASH_BITS >= 8. */ scan += 2, match++; /* We check for insufficient lookahead only every 8th comparison; * the 256th check will be made at strstart+258. */ do { } while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); Assert(state,scan <= state.ds.window+(unsigned)(state.ds.window_size-1), "wild scan"); len = MAX_MATCH - (int)(strend - scan); scan = strend - MAX_MATCH; if (len > best_len) { state.ds.match_start = cur_match; best_len = len; if (len >= state.ds.nice_match) break; scan_end1 = scan[best_len-1]; scan_end = scan[best_len]; } } while ((cur_match = state.ds.prev[cur_match & WMASK]) > limit && --chain_length != 0); return best_len; } #define check_match(state,start, match, length) // or alternatively... //void check_match(TState &state,IPos start, IPos match, int length) //{ // check that the match is indeed a match // if (memcmp((char*)state.ds.window + match, // (char*)state.ds.window + start, length) != EQUAL) { // fprintf(stderr, // " start %d, match %d, length %d\n", // start, match, length); // error("invalid match"); // } // if (state.verbose > 1) { // fprintf(stderr,"\\[%d,%d]", start-match, length); // do { fprintf(stdout,"%c",state.ds.window[start++]); } while (--length != 0); // } //} /* =========================================================================== * Fill the window when the lookahead becomes insufficient. * Updates strstart and lookahead, and sets eofile if end of input file. * * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0 * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD * At least one byte has been read, or eofile is set; file reads are * performed for at least two bytes (required for the translate_eol option). */ void fill_window(TState &state) { register unsigned n, m; unsigned more; /* Amount of free space at the end of the window. */ do { more = (unsigned)(state.ds.window_size - (ulg)state.ds.lookahead - (ulg)state.ds.strstart); /* If the window is almost full and there is insufficient lookahead, * move the upper half to the lower one to make room in the upper half. */ if (more == (unsigned)EOF) { /* Very unlikely, but possible on 16 bit machine if strstart == 0 * and lookahead == 1 (input done one byte at time) */ more--; /* For MMAP or BIG_MEM, the whole input file is already in memory so * we must not perform sliding. We must however call (*read_buf)() in * order to compute the crc, update lookahead and possibly set eofile. */ } else if (state.ds.strstart >= WSIZE+MAX_DIST && state.ds.sliding) { /* By the IN assertion, the window is not empty so we can't confuse * more == 0 with more == 64K on a 16 bit machine. */ memcpy((char*)state.ds.window, (char*)state.ds.window+WSIZE, (unsigned)WSIZE); state.ds.match_start -= WSIZE; state.ds.strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */ state.ds.block_start -= (long) WSIZE; for (n = 0; n < HASH_SIZE; n++) { m = state.ds.head[n]; state.ds.head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); } for (n = 0; n < WSIZE; n++) { m = state.ds.prev[n]; state.ds.prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL); /* If n is not on any hash chain, prev[n] is garbage but * its value will never be used. */ } more += WSIZE; } if (state.ds.eofile) return; /* If there was no sliding: * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && * more == window_size - lookahead - strstart * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) * => more >= window_size - 2*WSIZE + 2 * In the MMAP or BIG_MEM case (not yet supported in gzip), * window_size == input_size + MIN_LOOKAHEAD && * strstart + lookahead <= input_size => more >= MIN_LOOKAHEAD. * Otherwise, window_size == 2*WSIZE so more >= 2. * If there was sliding, more >= WSIZE. So in all cases, more >= 2. */ Assert(state,more >= 2, "more < 2"); n = state.readfunc(state, (char*)state.ds.window+state.ds.strstart+state.ds.lookahead, more); if (n == 0 || n == (unsigned)EOF) { state.ds.eofile = 1; } else { state.ds.lookahead += n; } } while (state.ds.lookahead < MIN_LOOKAHEAD && !state.ds.eofile); } /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. */ #define FLUSH_BLOCK(state,eof) \ flush_block(state,state.ds.block_start >= 0L ? (char*)&state.ds.window[(unsigned)state.ds.block_start] : \ (char*)NULL, (long)state.ds.strstart - state.ds.block_start, (eof)) /* =========================================================================== * Processes a new input file and return its compressed length. This * function does not perform lazy evaluation of matches and inserts * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ ulg deflate_fast(TState &state) { IPos hash_head = NIL; /* head of the hash chain */ int flush; /* set if current block must be flushed */ unsigned match_length = 0; /* length of best match */ state.ds.prev_length = MIN_MATCH-1; while (state.ds.lookahead != 0) { /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (state.ds.lookahead >= MIN_MATCH) INSERT_STRING(state.ds.strstart, hash_head); /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ if (hash_head != NIL && state.ds.strstart - hash_head <= MAX_DIST) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ /* Do not look for matches beyond the end of the input. * This is necessary to make deflate deterministic. */ if ((unsigned)state.ds.nice_match > state.ds.lookahead) state.ds.nice_match = (int)state.ds.lookahead; match_length = longest_match (state,hash_head); /* longest_match() sets match_start */ if (match_length > state.ds.lookahead) match_length = state.ds.lookahead; } if (match_length >= MIN_MATCH) { check_match(state,state.ds.strstart, state.ds.match_start, match_length); flush = ct_tally(state,state.ds.strstart-state.ds.match_start, match_length - MIN_MATCH); state.ds.lookahead -= match_length; /* Insert new strings in the hash table only if the match length * is not too large. This saves time but degrades compression. */ if (match_length <= state.ds.max_insert_length && state.ds.lookahead >= MIN_MATCH) { match_length--; /* string at strstart already in hash table */ do { state.ds.strstart++; INSERT_STRING(state.ds.strstart, hash_head); /* strstart never exceeds WSIZE-MAX_MATCH, so there are * always MIN_MATCH bytes ahead. */ } while (--match_length != 0); state.ds.strstart++; } else { state.ds.strstart += match_length; match_length = 0; state.ds.ins_h = state.ds.window[state.ds.strstart]; UPDATE_HASH(state.ds.ins_h, state.ds.window[state.ds.strstart+1]); Assert(state,MIN_MATCH==3,"Call UPDATE_HASH() MIN_MATCH-3 more times"); } } else { /* No match, output a literal byte */ flush = ct_tally (state,0, state.ds.window[state.ds.strstart]); state.ds.lookahead--; state.ds.strstart++; } if (flush) FLUSH_BLOCK(state,0), state.ds.block_start = state.ds.strstart; /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state); } return FLUSH_BLOCK(state,1); /* eof */ } /* =========================================================================== * Same as above, but achieves better compression. We use a lazy * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ ulg deflate(TState &state) { IPos hash_head = NIL; /* head of hash chain */ IPos prev_match; /* previous match */ int flush; /* set if current block must be flushed */ int match_available = 0; /* set if previous match exists */ register unsigned match_length = MIN_MATCH-1; /* length of best match */ if (state.level <= 3) return deflate_fast(state); /* optimized for speed */ /* Process the input block. */ while (state.ds.lookahead != 0) { /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (state.ds.lookahead >= MIN_MATCH) INSERT_STRING(state.ds.strstart, hash_head); /* Find the longest match, discarding those <= prev_length. */ state.ds.prev_length = match_length, prev_match = state.ds.match_start; match_length = MIN_MATCH-1; if (hash_head != NIL && state.ds.prev_length < state.ds.max_lazy_match && state.ds.strstart - hash_head <= MAX_DIST) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ /* Do not look for matches beyond the end of the input. * This is necessary to make deflate deterministic. */ if ((unsigned)state.ds.nice_match > state.ds.lookahead) state.ds.nice_match = (int)state.ds.lookahead; match_length = longest_match (state,hash_head); /* longest_match() sets match_start */ if (match_length > state.ds.lookahead) match_length = state.ds.lookahead; /* Ignore a length 3 match if it is too distant: */ if (match_length == MIN_MATCH && state.ds.strstart-state.ds.match_start > TOO_FAR){ /* If prev_match is also MIN_MATCH, match_start is garbage * but we will ignore the current match anyway. */ match_length = MIN_MATCH-1; } } /* If there was a match at the previous step and the current * match is not better, output the previous match: */ if (state.ds.prev_length >= MIN_MATCH && match_length <= state.ds.prev_length) { unsigned max_insert = state.ds.strstart + state.ds.lookahead - MIN_MATCH; check_match(state,state.ds.strstart-1, prev_match, state.ds.prev_length); flush = ct_tally(state,state.ds.strstart-1-prev_match, state.ds.prev_length - MIN_MATCH); /* Insert in hash table all strings up to the end of the match. * strstart-1 and strstart are already inserted. */ state.ds.lookahead -= state.ds.prev_length-1; state.ds.prev_length -= 2; do { if (++state.ds.strstart <= max_insert) { INSERT_STRING(state.ds.strstart, hash_head); /* strstart never exceeds WSIZE-MAX_MATCH, so there are * always MIN_MATCH bytes ahead. */ } } while (--state.ds.prev_length != 0); state.ds.strstart++; match_available = 0; match_length = MIN_MATCH-1; if (flush) FLUSH_BLOCK(state,0), state.ds.block_start = state.ds.strstart; } else if (match_available) { /* If there was no match at the previous position, output a * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ if (ct_tally (state,0, state.ds.window[state.ds.strstart-1])) { FLUSH_BLOCK(state,0), state.ds.block_start = state.ds.strstart; } state.ds.strstart++; state.ds.lookahead--; } else { /* There is no previous match to compare with, wait for * the next step to decide. */ match_available = 1; state.ds.strstart++; state.ds.lookahead--; } // Assert(state,strstart <= isize && lookahead <= isize, "a bit too far"); /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state); } if (match_available) ct_tally (state,0, state.ds.window[state.ds.strstart-1]); return FLUSH_BLOCK(state,1); /* eof */ } int putlocal(struct zlist far *z, WRITEFUNC wfunc,void *param) { // Write a local header described by *z to file *f. Return a ZE_ error code. PUTLG(LOCSIG, f); PUTSH(z->ver, f); PUTSH(z->lflg, f); PUTSH(z->how, f); PUTLG(z->tim, f); PUTLG(z->crc, f); PUTLG(z->siz, f); PUTLG(z->len, f); PUTSH(z->nam, f); PUTSH(z->ext, f); size_t res = (size_t)wfunc(param, z->iname, (unsigned int)z->nam); if (res!=z->nam) return ZE_TEMP; if (z->ext) { res = (size_t)wfunc(param, z->extra, (unsigned int)z->ext); if (res!=z->ext) return ZE_TEMP; } return ZE_OK; } int putextended(struct zlist far *z, WRITEFUNC wfunc, void *param) { // Write an extended local header described by *z to file *f. Returns a ZE_ code PUTLG(EXTLOCSIG, f); PUTLG(z->crc, f); PUTLG(z->siz, f); PUTLG(z->len, f); return ZE_OK; } int putcentral(struct zlist far *z, WRITEFUNC wfunc, void *param) { // Write a central header entry of *z to file *f. Returns a ZE_ code. PUTLG(CENSIG, f); PUTSH(z->vem, f); PUTSH(z->ver, f); PUTSH(z->flg, f); PUTSH(z->how, f); PUTLG(z->tim, f); PUTLG(z->crc, f); PUTLG(z->siz, f); PUTLG(z->len, f); PUTSH(z->nam, f); PUTSH(z->cext, f); PUTSH(z->com, f); PUTSH(z->dsk, f); PUTSH(z->att, f); PUTLG(z->atx, f); PUTLG(z->off, f); if ((size_t)wfunc(param, z->iname, (unsigned int)z->nam) != z->nam || (z->cext && (size_t)wfunc(param, z->cextra, (unsigned int)z->cext) != z->cext) || (z->com && (size_t)wfunc(param, z->comment, (unsigned int)z->com) != z->com)) return ZE_TEMP; return ZE_OK; } int putend(int n, ulg s, ulg c, extent m, char *z, WRITEFUNC wfunc, void *param) { // write the end of the central-directory-data to file *f. PUTLG(ENDSIG, f); PUTSH(0, f); PUTSH(0, f); PUTSH(n, f); PUTSH(n, f); PUTLG(s, f); PUTLG(c, f); PUTSH(m, f); // Write the comment, if any if (m && wfunc(param, z, (unsigned int)m) != m) return ZE_TEMP; return ZE_OK; } const ulg crc_table[256] = { 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL }; #define CRC32(c, b) (crc_table[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8)) #define DO1(buf) crc = CRC32(crc, *buf++) #define DO2(buf) DO1(buf); DO1(buf) #define DO4(buf) DO2(buf); DO2(buf) #define DO8(buf) DO4(buf); DO4(buf) ulg crc32(ulg crc, const uch *buf, extent len) { if (buf==NULL) return 0L; crc = crc ^ 0xffffffffL; while (len >= 8) {DO8(buf); len -= 8;} if (len) do {DO1(buf);} while (--len); return crc ^ 0xffffffffL; // (instead of ~c for 64-bit machines) } void update_keys(unsigned long *keys, char c) { keys[0] = CRC32(keys[0],c); keys[1] += keys[0] & 0xFF; keys[1] = keys[1]*134775813L +1; keys[2] = CRC32(keys[2], keys[1] >> 24); } char decrypt_byte(unsigned long *keys) { unsigned temp = ((unsigned)keys[2] & 0xffff) | 2; return (char)(((temp * (temp ^ 1)) >> 8) & 0xff); } char zencode(unsigned long *keys, char c) { int t=decrypt_byte(keys); update_keys(keys,c); return (char)(t^c); } bool HasZipSuffix(const TCHAR *fn) { const TCHAR *ext = fn+_tcslen(fn); while (ext>fn && *ext!='.') ext--; if (ext==fn && *ext!='.') return false; if (_tcsicmp(ext,_T(".Z"))==0) return true; if (_tcsicmp(ext,_T(".zip"))==0) return true; if (_tcsicmp(ext,_T(".zoo"))==0) return true; if (_tcsicmp(ext,_T(".arc"))==0) return true; if (_tcsicmp(ext,_T(".lzh"))==0) return true; if (_tcsicmp(ext,_T(".arj"))==0) return true; if (_tcsicmp(ext,_T(".gz"))==0) return true; if (_tcsicmp(ext,_T(".tgz"))==0) return true; return false; } lutime_t filetime2timet(const FILETIME ft) { __int64 i = *(__int64*)&ft; return (lutime_t)((i-116444736000000000)/10000000); } void filetime2dosdatetime(const FILETIME ft, WORD *dosdate,WORD *dostime) { // date: bits 0-4 are day of month 1-31. Bits 5-8 are month 1..12. Bits 9-15 are year-1980 // time: bits 0-4 are seconds/2, bits 5-10 are minute 0..59. Bits 11-15 are hour 0..23 SYSTEMTIME st; FileTimeToSystemTime(&ft,&st); *dosdate = (WORD)(((st.wYear-1980)&0x7f) << 9); *dosdate |= (WORD)((st.wMonth&0xf) << 5); *dosdate |= (WORD)((st.wDay&0x1f)); *dostime = (WORD)((st.wHour&0x1f) << 11); *dostime |= (WORD)((st.wMinute&0x3f) << 5); *dostime |= (WORD)((st.wSecond*2)&0x1f); } ZRESULT GetFileInfo(HANDLE hf, ulg *attr, long *size, iztimes *times, ulg *timestamp) { // The handle must be a handle to a file // The date and time is returned in a long with the date most significant to allow // unsigned integer comparison of absolute times. The attributes have two // high bytes unix attr, and two low bytes a mapping of that to DOS attr. //struct stat s; int res=stat(fn,&s); if (res!=0) return false; // translate windows file attributes into zip ones. BY_HANDLE_FILE_INFORMATION bhi; BOOL res=GetFileInformationByHandle(hf,&bhi); if (!res) return ZR_NOFILE; DWORD fa=bhi.dwFileAttributes; ulg a=0; // Zip uses the lower word for its interpretation of windows stuff if (fa&FILE_ATTRIBUTE_READONLY) a|=0x01; if (fa&FILE_ATTRIBUTE_HIDDEN) a|=0x02; if (fa&FILE_ATTRIBUTE_SYSTEM) a|=0x04; if (fa&FILE_ATTRIBUTE_DIRECTORY)a|=0x10; if (fa&FILE_ATTRIBUTE_ARCHIVE) a|=0x20; // It uses the upper word for standard unix attr, which we manually construct if (fa&FILE_ATTRIBUTE_DIRECTORY)a|=0x40000000; // directory else a|=0x80000000; // normal file a|=0x01000000; // readable if (fa&FILE_ATTRIBUTE_READONLY) {} else a|=0x00800000; // writeable // now just a small heuristic to check if it's an executable: DWORD red, hsize=GetFileSize(hf,NULL); if (hsize>40) { SetFilePointer(hf,0,NULL,FILE_BEGIN); unsigned short magic; ReadFile(hf,&magic,sizeof(magic),&red,NULL); SetFilePointer(hf,36,NULL,FILE_BEGIN); unsigned long hpos; ReadFile(hf,&hpos,sizeof(hpos),&red,NULL); if (magic==0x54AD && hsize>hpos+4+20+28) { SetFilePointer(hf,hpos,NULL,FILE_BEGIN); unsigned long signature; ReadFile(hf,&signature,sizeof(signature),&red,NULL); if (signature==IMAGE_DOS_SIGNATURE || signature==IMAGE_OS2_SIGNATURE || signature==IMAGE_OS2_SIGNATURE_LE || signature==IMAGE_NT_SIGNATURE) { a |= 0x00400000; // executable } } } // if (attr!=NULL) *attr = a; if (size!=NULL) *size = hsize; if (times!=NULL) { // lutime_t is 32bit number of seconds elapsed since 0:0:0GMT, Jan1, 1970. // but FILETIME is 64bit number of 100-nanosecs since Jan1, 1601 times->atime = filetime2timet(bhi.ftLastAccessTime); times->mtime = filetime2timet(bhi.ftLastWriteTime); times->ctime = filetime2timet(bhi.ftCreationTime); } if (timestamp!=NULL) { WORD dosdate,dostime; filetime2dosdatetime(bhi.ftLastWriteTime,&dosdate,&dostime); *timestamp = (WORD)dostime | (((DWORD)dosdate)<<16); } return ZR_OK; } class TZip { public: TZip(const char *pwd) : hfout(0),mustclosehfout(false),hmapout(0),zfis(0),obuf(0),hfin(0),writ(0),oerr(false),hasputcen(false),ooffset(0),encwriting(false),encbuf(0),password(0), state(0) {if (pwd!=0 && *pwd!=0) {password=new char[strlen(pwd)+1]; strcpy(password,pwd);}} ~TZip() {if (state!=0) delete state; state=0; if (encbuf!=0) delete[] encbuf; encbuf=0; if (password!=0) delete[] password; password=0;} // These variables say about the file we're writing into // We can write to pipe, file-by-handle, file-by-name, memory-to-memmapfile char *password; // keep a copy of the password HANDLE hfout; // if valid, we'll write here (for files or pipes) bool mustclosehfout; // if true, we are responsible for closing hfout HANDLE hmapout; // otherwise, we'll write here (for memmap) unsigned ooffset; // for hfout, this is where the pointer was initially ZRESULT oerr; // did a write operation give rise to an error? unsigned writ; // how far have we written. This is maintained by Add, not write(), to avoid confusion over seeks bool ocanseek; // can we seek? char *obuf; // this is where we've locked mmap to view. unsigned int opos; // current pos in the mmap unsigned int mapsize; // the size of the map we created bool hasputcen; // have we yet placed the central directory? bool encwriting; // if true, then we'll encrypt stuff using 'keys' before we write it to disk unsigned long keys[3]; // keys are initialised inside Add() char *encbuf; // if encrypting, then this is a temporary workspace for encrypting the data unsigned int encbufsize; // (to be used and resized inside write(), and deleted in the destructor) // TZipFileInfo *zfis; // each file gets added onto this list, for writing the table at the end TState *state; // we use just one state object per zip, because it's big (500k) ZRESULT Create(void *z,unsigned int len,DWORD flags); static unsigned sflush(void *param,const char *buf, unsigned *size); static unsigned swrite(void *param,const char *buf, unsigned size); unsigned int write(const char *buf,unsigned int size); bool oseek(unsigned int pos); ZRESULT GetMemory(void **pbuf, unsigned long *plen); ZRESULT Close(); // some variables to do with the file currently being read: // I haven't done it object-orientedly here, just put them all // together, since OO didn't seem to make the design any clearer. ulg attr; iztimes times; ulg timestamp; // all open_* methods set these bool iseekable; long isize,ired; // size is not set until close() on pips ulg crc; // crc is not set until close(). iwrit is cumulative HANDLE hfin; bool selfclosehf; // for input files and pipes const char *bufin; unsigned int lenin,posin; // for memory // and a variable for what we've done with the input: (i.e. compressed it!) ulg csize; // compressed size, set by the compression routines // and this is used by some of the compression routines char buf[16384]; ZRESULT open_file(const TCHAR *fn); ZRESULT open_handle(HANDLE hf,unsigned int len); ZRESULT open_mem(void *src,unsigned int len); ZRESULT open_dir(); static unsigned sread(TState &s,char *buf,unsigned size); unsigned read(char *buf, unsigned size); ZRESULT iclose(); ZRESULT ideflate(TZipFileInfo *zfi); ZRESULT istore(); ZRESULT Add(const TCHAR *odstzn, void *src,unsigned int len, DWORD flags); ZRESULT AddCentral(); }; ZRESULT TZip::Create(void *z,unsigned int len,DWORD flags) { if (hfout!=0 || hmapout!=0 || obuf!=0 || writ!=0 || oerr!=ZR_OK || hasputcen) return ZR_NOTINITED; // if (flags==ZIP_HANDLE) { HANDLE hf = (HANDLE)z; hfout=hf; mustclosehfout=false; #ifdef DuplicateHandle BOOL res = DuplicateHandle(GetCurrentProcess(),hf,GetCurrentProcess(),&hfout,0,FALSE,DUPLICATE_SAME_ACCESS); if (res) mustclosehandle=true; #endif // now we have hfout. Either we duplicated the handle and we close it ourselves // (while the caller closes h themselves), or we couldn't duplicate it. DWORD res = SetFilePointer(hfout,0,0,FILE_CURRENT); ocanseek = (res!=0xFFFFFFFF); if (ocanseek) ooffset=res; else ooffset=0; return ZR_OK; } else if (flags==ZIP_FILENAME) { const TCHAR *fn = (const TCHAR*)z; hfout = CreateFile(fn,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); if (hfout==INVALID_HANDLE_VALUE) {hfout=0; return ZR_NOFILE;} ocanseek=true; ooffset=0; mustclosehfout=true; return ZR_OK; } else if (flags==ZIP_MEMORY) { unsigned int size = len; if (size==0) return ZR_MEMSIZE; if (z!=0) obuf=(char*)z; else { hmapout = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,size,NULL); if (hmapout==NULL) return ZR_NOALLOC; obuf = (char*)MapViewOfFile(hmapout,FILE_MAP_ALL_ACCESS,0,0,size); if (obuf==0) {CloseHandle(hmapout); hmapout=0; return ZR_NOALLOC;} } ocanseek=true; opos=0; mapsize=size; return ZR_OK; } else return ZR_ARGS; } unsigned TZip::sflush(void *param,const char *buf, unsigned *size) { // static if (*size==0) return 0; TZip *zip = (TZip*)param; unsigned int writ = zip->write(buf,*size); if (writ!=0) *size=0; return writ; } unsigned TZip::swrite(void *param,const char *buf, unsigned size) { // static if (size==0) return 0; TZip *zip=(TZip*)param; return zip->write(buf,size); } unsigned int TZip::write(const char *buf,unsigned int size) { const char *srcbuf=buf; if (encwriting) { if (encbuf!=0 && encbufsize<size) {delete[] encbuf; encbuf=0;} if (encbuf==0) {encbuf=new char[size*2]; encbufsize=size;} memcpy(encbuf,buf,size); for (unsigned int i=0; i<size; i++) encbuf[i]=zencode(keys,encbuf[i]); srcbuf=encbuf; } if (obuf!=0) { if (opos+size>=mapsize) {oerr=ZR_MEMSIZE; return 0;} memcpy(obuf+opos, srcbuf, size); opos+=size; return size; } else if (hfout!=0) { DWORD writ; WriteFile(hfout,srcbuf,size,&writ,NULL); return writ; } oerr=ZR_NOTINITED; return 0; } bool TZip::oseek(unsigned int pos) { if (!ocanseek) {oerr=ZR_SEEK; return false;} if (obuf!=0) { if (pos>=mapsize) {oerr=ZR_MEMSIZE; return false;} opos=pos; return true; } else if (hfout!=0) { SetFilePointer(hfout,pos+ooffset,NULL,FILE_BEGIN); return true; } oerr=ZR_NOTINITED; return 0; } ZRESULT TZip::GetMemory(void **pbuf, unsigned long *plen) { // When the user calls GetMemory, they're presumably at the end // of all their adding. In any case, we have to add the central // directory now, otherwise the memory we tell them won't be complete. if (!hasputcen) AddCentral(); hasputcen=true; if (pbuf!=NULL) *pbuf=(void*)obuf; if (plen!=NULL) *plen=writ; if (obuf==NULL) return ZR_NOTMMAP; return ZR_OK; } ZRESULT TZip::Close() { // if the directory hadn't already been added through a call to GetMemory, // then we do it now ZRESULT res=ZR_OK; if (!hasputcen) res=AddCentral(); hasputcen=true; if (obuf!=0 && hmapout!=0) UnmapViewOfFile(obuf); obuf=0; if (hmapout!=0) CloseHandle(hmapout); hmapout=0; if (hfout!=0 && mustclosehfout) CloseHandle(hfout); hfout=0; mustclosehfout=false; return res; } ZRESULT TZip::open_file(const TCHAR *fn) { hfin=0; bufin=0; selfclosehf=false; crc=CRCVAL_INITIAL; isize=0; csize=0; ired=0; if (fn==0) return ZR_ARGS; HANDLE hf = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL); if (hf==INVALID_HANDLE_VALUE) return ZR_NOFILE; ZRESULT res = open_handle(hf,0); if (res!=ZR_OK) {CloseHandle(hf); return res;} selfclosehf=true; return ZR_OK; } ZRESULT TZip::open_handle(HANDLE hf,unsigned int len) { hfin=0; bufin=0; selfclosehf=false; crc=CRCVAL_INITIAL; isize=0; csize=0; ired=0; if (hf==0 || hf==INVALID_HANDLE_VALUE) return ZR_ARGS; DWORD res = SetFilePointer(hfout,0,0,FILE_CURRENT); if (res!=0xFFFFFFFF) { ZRESULT res = GetFileInfo(hf,&attr,&isize,&times,&timestamp); if (res!=ZR_OK) return res; SetFilePointer(hf,0,NULL,FILE_BEGIN); // because GetFileInfo will have screwed it up iseekable=true; hfin=hf; return ZR_OK; } else { attr= 0x80000000; // just a normal file isize = -1; // can't know size until at the end if (len!=0) isize=len; // unless we were told explicitly! iseekable=false; SYSTEMTIME st; GetLocalTime(&st); FILETIME ft; SystemTimeToFileTime(&st,&ft); WORD dosdate,dostime; filetime2dosdatetime(ft,&dosdate,&dostime); times.atime = filetime2timet(ft); times.mtime = times.atime; times.ctime = times.atime; timestamp = (WORD)dostime | (((DWORD)dosdate)<<16); hfin=hf; return ZR_OK; } } ZRESULT TZip::open_mem(void *src,unsigned int len) { hfin=0; bufin=(const char*)src; selfclosehf=false; crc=CRCVAL_INITIAL; ired=0; csize=0; ired=0; lenin=len; posin=0; if (src==0 || len==0) return ZR_ARGS; attr= 0x80000000; // just a normal file isize = len; iseekable=true; SYSTEMTIME st; GetLocalTime(&st); FILETIME ft; SystemTimeToFileTime(&st,&ft); WORD dosdate,dostime; filetime2dosdatetime(ft,&dosdate,&dostime); times.atime = filetime2timet(ft); times.mtime = times.atime; times.ctime = times.atime; timestamp = (WORD)dostime | (((DWORD)dosdate)<<16); return ZR_OK; } ZRESULT TZip::open_dir() { hfin=0; bufin=0; selfclosehf=false; crc=CRCVAL_INITIAL; isize=0; csize=0; ired=0; attr= 0x41C00010; // a readable writable directory, and again directory isize = 0; iseekable=false; SYSTEMTIME st; GetLocalTime(&st); FILETIME ft; SystemTimeToFileTime(&st,&ft); WORD dosdate,dostime; filetime2dosdatetime(ft,&dosdate,&dostime); times.atime = filetime2timet(ft); times.mtime = times.atime; times.ctime = times.atime; timestamp = (WORD)dostime | (((DWORD)dosdate)<<16); return ZR_OK; } unsigned TZip::sread(TState &s,char *buf,unsigned size) { // static TZip *zip = (TZip*)s.param; return zip->read(buf,size); } unsigned TZip::read(char *buf, unsigned size) { if (bufin!=0) { if (posin>=lenin) return 0; // end of input ulg red = lenin-posin; if (red>size) red=size; memcpy(buf, bufin+posin, red); posin += red; ired += red; crc = crc32(crc, (uch*)buf, red); return red; } else if (hfin!=0) { DWORD red; BOOL ok = ReadFile(hfin,buf,size,&red,NULL); if (!ok) return 0; ired += red; crc = crc32(crc, (uch*)buf, red); return red; } else {oerr=ZR_NOTINITED; return 0;} } ZRESULT TZip::iclose() { if (selfclosehf && hfin!=0) CloseHandle(hfin); hfin=0; bool mismatch = (isize!=-1 && isize!=ired); isize=ired; // and crc has been being updated anyway if (mismatch) return ZR_MISSIZE; else return ZR_OK; } ZRESULT TZip::ideflate(TZipFileInfo *zfi) { if (state==0) state=new TState(); // It's a very big object! 500k! We allocate it on the heap, because PocketPC's // stack breaks if we try to put it all on the stack. It will be deleted lazily state->err=0; state->readfunc=sread; state->flush_outbuf=sflush; state->param=this; state->level=8; state->seekable=iseekable; state->err=NULL; // the following line will make ct_init realise it has to perform the init state->ts.static_dtree[0].dl.len = 0; // Thanks to Alvin77 for this crucial fix: state->ds.window_size=0; // I think that covers everything that needs to be initted. // bi_init(*state,buf, sizeof(buf), TRUE); // it used to be just 1024-size, not 16384 as here ct_init(*state,&zfi->att); lm_init(*state,state->level, &zfi->flg); ulg sz = deflate(*state); csize=sz; ZRESULT r=ZR_OK; if (state->err!=NULL) r=ZR_FLATE; return r; } ZRESULT TZip::istore() { ulg size=0; for (;;) { unsigned int cin=read(buf,16384); if (cin<=0 || cin==(unsigned int)EOF) break; unsigned int cout = write(buf,cin); if (cout!=cin) return ZR_MISSIZE; size += cin; } csize=size; return ZR_OK; } bool has_seeded=false; ZRESULT TZip::Add(const TCHAR *odstzn, void *src,unsigned int len, DWORD flags) { if (oerr) return ZR_FAILED; if (hasputcen) return ZR_ENDED; // if we use password encryption, then every isize and csize is 12 bytes bigger int passex=0; if (password!=0 && flags!=ZIP_FOLDER) passex=12; // zip has its own notion of what its names should look like: i.e. dir/file.stuff TCHAR dstzn[MAX_PATH]; _tcscpy(dstzn,odstzn); if (*dstzn==0) return ZR_ARGS; TCHAR *d=dstzn; while (*d!=0) {if (*d=='\\') *d='/'; d++;} bool isdir = (flags==ZIP_FOLDER); bool needs_trailing_slash = (isdir && dstzn[_tcslen(dstzn)-1]!='/'); int method=DEFLATE; if (isdir || HasZipSuffix(dstzn)) method=STORE; // now open whatever was our input source: ZRESULT openres; if (flags==ZIP_FILENAME) openres=open_file((const TCHAR*)src); else if (flags==ZIP_HANDLE) openres=open_handle((HANDLE)src,len); else if (flags==ZIP_MEMORY) openres=open_mem(src,len); else if (flags==ZIP_FOLDER) openres=open_dir(); else return ZR_ARGS; if (openres!=ZR_OK) return openres; // A zip "entry" consists of a local header (which includes the file name), // then the compressed data, and possibly an extended local header. // Initialize the local header TZipFileInfo zfi; zfi.nxt=NULL; strcpy(zfi.name,""); #ifdef UNICODE WideCharToMultiByte(CP_UTF8,0,dstzn,-1,zfi.iname,MAX_PATH,0,0); #else strcpy(zfi.iname,dstzn); #endif zfi.nam=strlen(zfi.iname); if (needs_trailing_slash) {strcat(zfi.iname,"/"); zfi.nam++;} strcpy(zfi.zname,""); zfi.extra=NULL; zfi.ext=0; // extra header to go after this compressed data, and its length zfi.cextra=NULL; zfi.cext=0; // extra header to go in the central end-of-zip directory, and its length zfi.comment=NULL; zfi.com=0; // comment, and its length zfi.mark = 1; zfi.dosflag = 0; zfi.att = (ush)BINARY; zfi.vem = (ush)0xB17; // 0xB00 is win32 os-code. 0x17 is 23 in decimal: zip 2.3 zfi.ver = (ush)20; // Needs PKUNZIP 2.0 to unzip it zfi.tim = timestamp; // Even though we write the header now, it will have to be rewritten, since we don't know compressed size or crc. zfi.crc = 0; // to be updated later zfi.flg = 8; // 8 means 'there is an extra header'. Assume for the moment that we need it. if (password!=0 && !isdir) zfi.flg=9; // and 1 means 'password-encrypted' zfi.lflg = zfi.flg; // to be updated later zfi.how = (ush)method; // to be updated later zfi.siz = (ulg)(method==STORE && isize>=0 ? isize+passex : 0); // to be updated later zfi.len = (ulg)(isize); // to be updated later zfi.dsk = 0; zfi.atx = attr; zfi.off = writ+ooffset; // offset within file of the start of this local record // stuff the 'times' structure into zfi.extra // nb. apparently there's a problem with PocketPC CE(zip)->CE(unzip) fails. And removing the following block fixes it up. char xloc[EB_L_UT_SIZE]; zfi.extra=xloc; zfi.ext=EB_L_UT_SIZE; char xcen[EB_C_UT_SIZE]; zfi.cextra=xcen; zfi.cext=EB_C_UT_SIZE; xloc[0] = 'U'; xloc[1] = 'T'; xloc[2] = EB_UT_LEN(3); // length of data part of e.f. xloc[3] = 0; xloc[4] = EB_UT_FL_MTIME | EB_UT_FL_ATIME | EB_UT_FL_CTIME; xloc[5] = (char)(times.mtime); xloc[6] = (char)(times.mtime >> 8); xloc[7] = (char)(times.mtime >> 16); xloc[8] = (char)(times.mtime >> 24); xloc[9] = (char)(times.atime); xloc[10] = (char)(times.atime >> 8); xloc[11] = (char)(times.atime >> 16); xloc[12] = (char)(times.atime >> 24); xloc[13] = (char)(times.ctime); xloc[14] = (char)(times.ctime >> 8); xloc[15] = (char)(times.ctime >> 16); xloc[16] = (char)(times.ctime >> 24); memcpy(zfi.cextra,zfi.extra,EB_C_UT_SIZE); zfi.cextra[EB_LEN] = EB_UT_LEN(1); // (1) Start by writing the local header: int r = putlocal(&zfi,swrite,this); if (r!=ZE_OK) {iclose(); return ZR_WRITE;} writ += 4 + LOCHEAD + (unsigned int)zfi.nam + (unsigned int)zfi.ext; if (oerr!=ZR_OK) {iclose(); return oerr;} // (1.5) if necessary, write the encryption header keys[0]=305419896L; keys[1]=591751049L; keys[2]=878082192L; for (const char *cp=password; cp!=0 && *cp!=0; cp++) update_keys(keys,*cp); // generate some random bytes if (!has_seeded) srand(GetTickCount()^(unsigned long)GetDesktopWindow()); char encbuf[12]; for (int i=0; i<12; i++) encbuf[i]=(char)((rand()>>7)&0xff); encbuf[11] = (char)((zfi.tim>>8)&0xff); for (int ei=0; ei<12; ei++) encbuf[ei]=zencode(keys,encbuf[ei]); if (password!=0 && !isdir) {swrite(this,encbuf,12); writ+=12;} //(2) Write deflated/stored file to zip file ZRESULT writeres=ZR_OK; encwriting = (password!=0 && !isdir); // an object member variable to say whether we write to disk encrypted if (!isdir && method==DEFLATE) writeres=ideflate(&zfi); else if (!isdir && method==STORE) writeres=istore(); else if (isdir) csize=0; encwriting = false; iclose(); writ += csize; if (oerr!=ZR_OK) return oerr; if (writeres!=ZR_OK) return ZR_WRITE; // (3) Either rewrite the local header with correct information... bool first_header_has_size_right = (zfi.siz==csize+passex); zfi.crc = crc; zfi.siz = csize+passex; zfi.len = isize; if (ocanseek && (password==0 || isdir)) { zfi.how = (ush)method; if ((zfi.flg & 1) == 0) zfi.flg &= ~8; // clear the extended local header flag zfi.lflg = zfi.flg; // rewrite the local header: if (!oseek(zfi.off-ooffset)) return ZR_SEEK; if ((r = putlocal(&zfi, swrite,this)) != ZE_OK) return ZR_WRITE; if (!oseek(writ)) return ZR_SEEK; } else { // (4) ... or put an updated header at the end if (zfi.how != (ush) method) return ZR_NOCHANGE; if (method==STORE && !first_header_has_size_right) return ZR_NOCHANGE; if ((r = putextended(&zfi, swrite,this)) != ZE_OK) return ZR_WRITE; writ += 16L; zfi.flg = zfi.lflg; // if flg modified by inflate, for the central index } if (oerr!=ZR_OK) return oerr; // Keep a copy of the zipfileinfo, for our end-of-zip directory char *cextra = new char[zfi.cext]; memcpy(cextra,zfi.cextra,zfi.cext); zfi.cextra=cextra; TZipFileInfo *pzfi = new TZipFileInfo; memcpy(pzfi,&zfi,sizeof(zfi)); if (zfis==NULL) zfis=pzfi; else {TZipFileInfo *z=zfis; while (z->nxt!=NULL) z=z->nxt; z->nxt=pzfi;} return ZR_OK; } ZRESULT TZip::AddCentral() { // write central directory int numentries = 0; ulg pos_at_start_of_central = writ; //ulg tot_unc_size=0, tot_compressed_size=0; bool okay=true; for (TZipFileInfo *zfi=zfis; zfi!=NULL; ) { if (okay) { int res = putcentral(zfi, swrite,this); if (res!=ZE_OK) okay=false; } writ += 4 + CENHEAD + (unsigned int)zfi->nam + (unsigned int)zfi->cext + (unsigned int)zfi->com; //tot_unc_size += zfi->len; //tot_compressed_size += zfi->siz; numentries++; // TZipFileInfo *zfinext = zfi->nxt; if (zfi->cextra!=0) delete[] zfi->cextra; delete zfi; zfi = zfinext; } ulg center_size = writ - pos_at_start_of_central; if (okay) { int res = putend(numentries, center_size, pos_at_start_of_central+ooffset, 0, NULL, swrite,this); if (res!=ZE_OK) okay=false; writ += 4 + ENDHEAD + 0; } if (!okay) return ZR_WRITE; return ZR_OK; } ZRESULT lasterrorZ=ZR_OK; unsigned int FormatZipMessageZ(ZRESULT code, char *buf,unsigned int len) { if (code==ZR_RECENT) code=lasterrorZ; const char *msg="unknown zip result code"; switch (code) { case ZR_OK: msg="Success"; break; case ZR_NODUPH: msg="Culdn't duplicate handle"; break; case ZR_NOFILE: msg="Couldn't create/open file"; break; case ZR_NOALLOC: msg="Failed to allocate memory"; break; case ZR_WRITE: msg="Error writing to file"; break; case ZR_NOTFOUND: msg="File not found in the zipfile"; break; case ZR_MORE: msg="Still more data to unzip"; break; case ZR_CORRUPT: msg="Zipfile is corrupt or not a zipfile"; break; case ZR_READ: msg="Error reading file"; break; case ZR_ARGS: msg="Caller: faulty arguments"; break; case ZR_PARTIALUNZ: msg="Caller: the file had already been partially unzipped"; break; case ZR_NOTMMAP: msg="Caller: can only get memory of a memory zipfile"; break; case ZR_MEMSIZE: msg="Caller: not enough space allocated for memory zipfile"; break; case ZR_FAILED: msg="Caller: there was a previous error"; break; case ZR_ENDED: msg="Caller: additions to the zip have already been ended"; break; case ZR_ZMODE: msg="Caller: mixing creation and opening of zip"; break; case ZR_NOTINITED: msg="Zip-bug: internal initialisation not completed"; break; case ZR_SEEK: msg="Zip-bug: trying to seek the unseekable"; break; case ZR_MISSIZE: msg="Zip-bug: the anticipated size turned out wrong"; break; case ZR_NOCHANGE: msg="Zip-bug: tried to change mind, but not allowed"; break; case ZR_FLATE: msg="Zip-bug: an internal error during flation"; break; } unsigned int mlen=(unsigned int)strlen(msg); if (buf==0 || len==0) return mlen; unsigned int n=mlen; if (n+1>len) n=len-1; strncpy(buf,msg,n); buf[n]=0; return mlen; } typedef struct { DWORD flag; TZip *zip; } TZipHandleData; HZIP CreateZipInternal(void *z,unsigned int len,DWORD flags, const char *password) { TZip *zip = new TZip(password); lasterrorZ = zip->Create(z,len,flags); if (lasterrorZ!=ZR_OK) {delete zip; return 0;} TZipHandleData *han = new TZipHandleData; han->flag=2; han->zip=zip; return (HZIP)han; } HZIP CreateZipHandle(HANDLE h, const char *password) {return CreateZipInternal(h,0,ZIP_HANDLE,password);} HZIP CreateZip(const TCHAR *fn, const char *password) {return CreateZipInternal((void*)fn,0,ZIP_FILENAME,password);} HZIP CreateZip(void *z,unsigned int len, const char *password) {return CreateZipInternal(z,len,ZIP_MEMORY,password);} ZRESULT ZipAddInternal(HZIP hz,const TCHAR *dstzn, void *src,unsigned int len, DWORD flags) { if (hz==0) {lasterrorZ=ZR_ARGS;return ZR_ARGS;} TZipHandleData *han = (TZipHandleData*)hz; if (han->flag!=2) {lasterrorZ=ZR_ZMODE;return ZR_ZMODE;} TZip *zip = han->zip; lasterrorZ = zip->Add(dstzn,src,len,flags); return lasterrorZ; } ZRESULT ZipAdd(HZIP hz,const TCHAR *dstzn, const TCHAR *fn) {return ZipAddInternal(hz,dstzn,(void*)fn,0,ZIP_FILENAME);} ZRESULT ZipAdd(HZIP hz,const TCHAR *dstzn, void *src,unsigned int len) {return ZipAddInternal(hz,dstzn,src,len,ZIP_MEMORY);} ZRESULT ZipAddHandle(HZIP hz,const TCHAR *dstzn, HANDLE h) {return ZipAddInternal(hz,dstzn,h,0,ZIP_HANDLE);} ZRESULT ZipAddHandle(HZIP hz,const TCHAR *dstzn, HANDLE h, unsigned int len) {return ZipAddInternal(hz,dstzn,h,len,ZIP_HANDLE);} ZRESULT ZipAddFolder(HZIP hz,const TCHAR *dstzn) {return ZipAddInternal(hz,dstzn,0,0,ZIP_FOLDER);} ZRESULT ZipGetMemory(HZIP hz, void **buf, unsigned long *len) { if (hz==0) {if (buf!=0) *buf=0; if (len!=0) *len=0; lasterrorZ=ZR_ARGS;return ZR_ARGS;} TZipHandleData *han = (TZipHandleData*)hz; if (han->flag!=2) {lasterrorZ=ZR_ZMODE;return ZR_ZMODE;} TZip *zip = han->zip; lasterrorZ = zip->GetMemory(buf,len); return lasterrorZ; } ZRESULT CloseZipZ(HZIP hz) { if (hz==0) {lasterrorZ=ZR_ARGS;return ZR_ARGS;} TZipHandleData *han = (TZipHandleData*)hz; if (han->flag!=2) {lasterrorZ=ZR_ZMODE;return ZR_ZMODE;} TZip *zip = han->zip; lasterrorZ = zip->Close(); delete zip; delete han; return lasterrorZ; } bool IsZipHandleZ(HZIP hz) { if (hz==0) return false; TZipHandleData *han = (TZipHandleData*)hz; return (han->flag==2); }
7224287ed3701a803556c3618c13bc2ecd6dd495
cd726912664cea9c458ac8b609dd98bf33e3b9a0
/snippets/cpp/VS_Snippets_CLR/Type_GetInterfaces1/CPP/type_getinterfaces1.cpp
d6ba8989b7265f87352e722a2acc7798e65a215f
[ "MIT", "CC-BY-4.0" ]
permissive
dotnet/dotnet-api-docs
b41fc7fa07aa4d54205df81284bae4f491286ec2
70e7abc4bcd692cb4fb6b4cbcb34bb517261dbaf
refs/heads/main
2023-09-04T07:16:44.908599
2023-09-01T21:46:11
2023-09-01T21:46:11
111,510,915
630
1,856
NOASSERTION
2023-09-14T21:45:33
2017-11-21T06:52:13
C#
UTF-8
C++
false
false
1,030
cpp
// <Snippet1> using namespace System; using namespace System::Collections::Generic; void main() { Console::WriteLine("\r\nInterfaces implemented by Dictionary<int, String^>:\r\n"); for each (Type^ tinterface in Dictionary<int, String^>::typeid->GetInterfaces()) { Console::WriteLine(tinterface->ToString()); } //Console::ReadLine() // Uncomment this line for Visual Studio. } /* This example produces output similar to the following: Interfaces implemented by Dictionary<int, String^>: System.Collections.Generic.IDictionary`2[System.Int32,System.String] System.Collections.Generic.ICollection`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]] System.Collections.Generic.IEnumerable`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]] System.Collection.IEnumerable System.Collection.IDictionary System.Collection.ICollection System.Runtime.Serialization.ISerializable System.Runtime.Serialization.IDeserializationCallback */ // </Snippet1>
961224f0fca0d8138cf22a6201953efa9d9c333f
64d40840ef8f99455534f501b00cc13943ec6787
/testcheck.cc
c008a3adcb461db8b3b9b4782658eea0f1f9304c
[]
no_license
jb548319/CS2401_Project_1
34f4383ea614e96a4a3fe21764375bbf8547f228
ccde86a944d691f7bf93a86dcfb3fc0bf5882e00
refs/heads/main
2023-07-31T04:49:17.930098
2021-09-14T22:54:23
2021-09-14T22:54:23
402,238,887
0
0
null
null
null
null
UTF-8
C++
false
false
1,213
cc
/************************************************************************* The purpose of this little program is allow you to test the input and output functions and operators that you have written for the Check class. You should write these BEFORE you start developing the Checkbook class, and you should test your functions by compiling and running this little main. John Dolan Ohio University EECS September 2019 Patricia Lindner Ohio University EECS August 2021 *************************************************************************/ #include<fstream> #include <string> #include "check.h" using namespace std; int main(){ Check c1, c2; ifstream ifs; ofstream ofs; string file_name; string output_file; cout<<"Enter file name: "; cin >> file_name; ifs.open(file_name); if (ifs.fail()){ cout << "error"; exit(0); } ifs>>c2; ifs.close(); output_file = file_name.insert(file_name.find("."), "output"); ofs.open(output_file); ofs<<c2; ofs.close(); cout << "File " << output_file << " was created." << endl; cout<<"Write a check.\n"; cin>>c1; cout<<c1; return 0; }
51f6f51fd8998320d26223dbea4358f2933dbf01
fcf693cdb557d13a50df61f26952125d13691ec9
/HOMEWORKS/HW03/functions.cpp
83d2f18e830550bf4031e7496bb5aa81be3f2891
[]
no_license
ashrafyawar/CPP-Projects
c0e0db17c87b9392f3d0cad4df81bcd149f41839
07fa929d424dfb595ca9c45dff7e4850b3e6a1ae
refs/heads/master
2022-12-02T03:37:00.577081
2022-11-18T23:38:38
2022-11-18T23:38:38
266,336,478
0
0
null
null
null
null
UTF-8
C++
false
false
15,727
cpp
#include "structs_classes.h" /*function to assing coures to lecturers */ int assignCourses_to_lecturers(Cours& coures_vec,Lecturer& Lec_arr,const int& course_index,const char& one){ int i,a = 0; if(Lec_arr.get_cours_count() >=3){ if(one == 'o'){ cout<<"CAN'T TAKE MORE THAN 3 LECTURES !"<<" "; return 0; } else{ return 0; } } else{ for (i = 0; i < Lec_arr.get_prof_cout(); ++i){ if(coures_vec.field == Lec_arr.professions[i] and coures_vec.is_assigned!=1){ Lec_arr.courses_list.push_back(course_index); a = Lec_arr.get_cours_count(); Lec_arr.set_cours_count(++a); coures_vec.is_assigned = 1; return 1; } } } } /************************************************************************************/ /*lecturer class's related functions*/ Lecturer::Lecturer(){ personal_id = prof_count = cours_count = 0; } int Lecturer:: get_prof_cout(){return prof_count;} string Lecturer:: get_lec_name(){return name;} int Lecturer:: get_cours_count(){return cours_count;} int Lecturer::get_lec_personal_id(){return personal_id;} string Lecturer::get_lec_title(){return title;} void Lecturer:: set_cours_count(int& a){cours_count = a;} void Lecturer:: set_prof_count(int&a){prof_count = a;} bool Lecturer:: is_field_professions_match(const string& cours_field){//checks for matching of the cours field and lectures professions. for (int i = 0; i < get_prof_cout(); ++i){ if (cours_field ==professions[i]){ return true; } } return false; } bool Lecturer:: proposeCourse(vector<Cours>& c_vec,const string& c_name,const int& c_code,const int& c_credit,const int& c_totalhours,const string& c_field){ if((get_cours_count()) < 3){ assignCourse(c_vec,c_name,c_code,c_credit,c_totalhours,c_field); } else{ cout<<"CAN'T TAKE MORE THAN 3 LECTURES!"<<endl; } return true; } void Lecturer:: assignCourse(vector<Cours>& coures_vec,const string& c_name,const int& c_code,const int& c_credit,const int& c_totalhours,const string& c_field){ int a = 0,index; Cours temp_co_vec; bool found = false; for (int i = 0; i < get_prof_cout(); ++i){//check for the existence of the cours field in the professions list. if(c_field == professions[i]){ found = true; break; } } if (found == false){ cout<<"LECTURE OVERLAP!"<<endl; return; } else{ temp_co_vec.name = c_name;//copy elements of one cours to temp cours temp_co_vec.code = c_code;//copy elements of one cours to temp cours temp_co_vec.credit = c_credit;//copy elements of one cours to temp cours temp_co_vec.total_hours = c_totalhours;//copy elements of one cours to temp cours temp_co_vec.field = c_field;//copy elements of one cours to temp cours temp_co_vec.is_Mandatory = 0; temp_co_vec.is_assigned = 1; temp_co_vec.id = (coures_vec.size()+1); a = cours_count; ++a; cours_count = a; coures_vec.push_back(temp_co_vec); courses_list.push_back(temp_co_vec.id); cout<<"DONE!"<<endl; } } void Lecturer:: assignCourse(const vector<Cours>& coures_vec,const int& index){ for (int i = 0; i < coures_vec.size(); ++i){ if(coures_vec[i].id == index){ courses_list.push_back(i); return; } } } void Lecturer:: set_lec(const int& id,const string& name,const string& surename,const string& title){ this->personal_id = id; this->name = name; this->surename = surename; this->title = title; } void Lecturer :: fill_lecturers_professions(const char* st){professions.push_back(st);} void Lecturer::set_courese_Dates(vector<Cours>& coures_vec){ int a; struct daily_classes temp_date; for (int i = 0; i < this->get_cours_count() ; ++i){ for (int j= 0; j < coures_vec.size(); ++j){ if(this->parallel_date_vec[i].name == coures_vec[j].name){ temp_date.day_name = this->parallel_date_vec[i].lecture_dates[0].day_name; temp_date.start_class = this->parallel_date_vec[i].lecture_dates[0].start_class; temp_date.end_class = this->parallel_date_vec[i].lecture_dates[0].end_class; coures_vec[j].lecture_dates.push_back(temp_date); coures_vec[j].is_date_assigned = 1; break; } } } } /*************************************************************************************/ /* some other stand alone and friend functions*/ bool check_lec_exestence(Lecturer Lec_arr[LECTURERS_QUANTITY],const int& index){ for (int i = 0; i < LECTURERS_QUANTITY; ++i){ if(Lec_arr[i].personal_id == index){ return true; } } return false;//looks for the lectures if it exists in the list>> } bool check_cours_existence(const vector<Cours>& coures_vec,const int& course_id){ for (int i = 0; i < coures_vec.size(); ++i){ if(coures_vec[i].id == course_id){ return true; } } return false; } bool check_class_existence(const vector<Classroom>& classes_vec,const int& class_id){ for (int i = 0; i < classes_vec.size(); ++i){ if (classes_vec[i].id == class_id){ return true; } } return false; } void fill_coures(fstream& cr_cl_f,vector<Cours>& coures_vec){ string coures_title; Cours temp_cours; cr_cl_f>>coures_title; for (int i = 0; i < COURS_QUANTITY; ++i){ cr_cl_f >> temp_cours.id >> temp_cours.name >>temp_cours.code;//course name and id cr_cl_f >> temp_cours.credit>>temp_cours.total_hours>>temp_cours.field;//course credit an total hours. temp_cours.is_Mandatory = 1;//means coures is mandatory. coures_vec.push_back(temp_cours); } } void fill_class(fstream& cr_cl_f,vector<Classroom>& classes_vec){ string class_title; Classroom temp_clas; cr_cl_f >> class_title; for (int i = 0; i < CLASS_QUANTITY; ++i){//get info for classroom struct. cr_cl_f >> temp_clas.id >> temp_clas.c_no >>temp_clas.capacity; classes_vec.push_back(temp_clas); } } void fill_lectureres(fstream& Lec_file,Lecturer Lec_arr[LECTURERS_QUANTITY]){ string lecturer_name,lecturer_surename,lecturer_title; char *pointer; char lecturer_profession[LEC_LIMIT]; int j,lec_personal_id,sum =0; for (j = 0; j < LECTURERS_QUANTITY; ++j){ Lec_file >>lec_personal_id>>lecturer_name>>lecturer_surename>>lecturer_title>>lecturer_profession; Lec_arr[j].set_lec(lec_personal_id,lecturer_name,lecturer_surename,lecturer_title); pointer = strtok(lecturer_profession,","); while(pointer!=NULL){//tokinizes the rest part Lec_arr[j].fill_lecturers_professions(pointer); ++sum; pointer = strtok(NULL,","); } Lec_arr[j].set_prof_count(sum); sum = 0; } } bool is_all_assigned(Lecturer Lec_arr[LECTURERS_QUANTITY],int& index){ for(int i = 0; i < LECTURERS_QUANTITY; ++i){ if (Lec_arr[i].get_cours_count() < 3){ index = i; return false; } } return true; } bool is_comma_exist(const string& test_st){ for (int i = 0; i < test_st.length(); ++i){ if (test_st[i]==','){ return true; } } return false; } bool is_cours_assingned_to_class(const vector<Cours>& coures_vec,const int& course_id){ for (int i = 0; i < coures_vec.size(); ++i){ if(coures_vec[i].id == course_id){ if(coures_vec[i].is_assigned_to_class == 1){ return true; } } } return false; } void set_last_cours(Lecturer Lec_arr[LECTURERS_QUANTITY],Lecturer& last_lecturer){ bool flag = true; int i,j,k; string temp_class_name; for (i = 0; i < last_lecturer.get_cours_count(); ++i){//itrtea untill the counts of number of coures's of the last lecturer j = 0; while(j < LECTURERS_QUANTITY-1){//iterates untill the last lecturers if required. flag = true; for(k = 0; k < Lec_arr[i].get_cours_count(); ++k){ if(last_lecturer.parallel_date_vec[i].lecture_dates[0].day_name == Lec_arr[j].parallel_date_vec[k].lecture_dates[0].day_name){ flag = false; break; } } if( true == flag){ last_lecturer.classrooms.push_back(Lec_arr[j].classrooms[0]); Lec_arr[j].classrooms[0].lec_id_list.push_back(last_lecturer.get_lec_personal_id()); Lec_arr[j].classrooms[0].student_inroom += 1; j = LECTURERS_QUANTITY; break; } j++; } } } /*************************************************************************************/ /* Administrator class's related funcitons*/ Administrator:: Administrator(){ pid = 0; password = 0; is_timetable_arranged = 0; } void Administrator::arrangeTimeTable(vector<Cours>& coures_vec,const int& course_id,const char& doit){ int random,limit; struct daily_classes temp_date; for(int i = 0; i < coures_vec.size();++i){ if(coures_vec[i].id == course_id){ if(coures_vec[i].is_date_assigned == 1){//checks if the cours already assgined. cout<<"Assigned Before:"<<"("<<course_id<<")"<<coures_vec[i].name<<" "; for (int j = 0; j < coures_vec[i].lecture_dates.size(); ++j){ cout<<coures_vec[i].lecture_dates[j].day_name<<"_"<<coures_vec[i].lecture_dates[j].start_class<<"-"<<coures_vec[i].lecture_dates[j].end_class<<" "; } return; } else{ random = rand()%5+1; temp_date.day_name = generte_day_name(random);//returns the day name. limit = 17 - coures_vec[i].total_hours; random = rand() % (limit - 9 + 1) + 9; temp_date.start_class = random; temp_date.end_class = random + coures_vec[i].total_hours; if(doit == 'y'){//if doit is equal to yes which is y in this case then keep coures as assigned to a class. coures_vec[i].is_date_assigned = 1; } /*printing the output */ cout << "DONE:" << "(" << course_id << ")"<< coures_vec[i].name << " "; coures_vec[i].lecture_dates.push_back(temp_date); for(int j = 0; j < coures_vec[i].lecture_dates.size(); ++j){ cout<<coures_vec[i].lecture_dates[j].day_name<<"_"<<coures_vec[i].lecture_dates[j].start_class<<"-"<<coures_vec[i].lecture_dates[j].end_class<<" "; } cout<<endl; } break; } } return; } void Administrator::arrangeTimeTable(Lecturer& Lec_arr,const vector<Cours>& coures_vec){//arranges timetable atomatically. int random,limit,a,i,j; struct daily_classes temp_date; struct Cours temp_cours; bool go_on = true; for (i = 0; i < Lec_arr.get_cours_count(); ++i){//asssign appropriate coureses to the lecturers vecotr which holds the courers structure related with it's lecturer. if (Lec_arr.get_lec_name()=="ALI"){ a = Lec_arr.courses_list[i]; temp_cours = coures_vec[a-1]; Lec_arr.parallel_date_vec.push_back(temp_cours); } else{ a = Lec_arr.courses_list[i]; temp_cours = coures_vec[a]; Lec_arr.parallel_date_vec.push_back(temp_cours); } } /*generating random numbers*/ random = rand() % 5 + 1; temp_date.day_name = generte_day_name(random);//deremines the day name according to the input and returns it's corresponding string. limit = 17 - Lec_arr.parallel_date_vec[0].total_hours; random = rand() % (limit - 9 + 1) + 9; temp_date.start_class = random; temp_date.end_class = random + Lec_arr.parallel_date_vec[0].total_hours; Lec_arr.parallel_date_vec[0].lecture_dates.push_back(temp_date); while(go_on == true){ random = rand() % 5 + 1; temp_date.day_name = generte_day_name(random);//deremines the day name according to the input and returns it's corresponding string. limit = 17 - Lec_arr.parallel_date_vec[1].total_hours; random = rand() % (limit - 9 + 1) + 9; temp_date.start_class = random; temp_date.end_class = random + Lec_arr.parallel_date_vec[1].total_hours; if(temp_date.day_name == Lec_arr.parallel_date_vec[0].lecture_dates[0].day_name){ go_on = true; } else{ Lec_arr.parallel_date_vec[1].lecture_dates.push_back(temp_date); go_on = false; } } go_on = true; while(go_on == true){ random = rand() % 5 + 1; temp_date.day_name = generte_day_name(random);//deremines the day name according to the input and returns it's corresponding string. limit = 17 - Lec_arr.parallel_date_vec[2].total_hours; random = rand() % (limit - 9 + 1) + 9; temp_date.start_class = random; temp_date.end_class = random + Lec_arr.parallel_date_vec[2].total_hours; if(temp_date.day_name == Lec_arr.parallel_date_vec[0].lecture_dates[0].day_name || temp_date.day_name == Lec_arr.parallel_date_vec[1].lecture_dates[0].day_name){ go_on = true; } else{ Lec_arr.parallel_date_vec[2].lecture_dates.push_back(temp_date); go_on = false; } } } string generte_day_name(const int& random){ if(random == 1) return("MON"); else if(random == 2) return("TUES"); else if(random == 3) return ("WEDNES"); else if(random == 4) return("TURS"); else if(random == 5) return("FRI"); } void Administrator::print_timetable(Lecturer& Lec_arr){//prints the timetable of one lecturer in one call. for (int i = 0; i <Lec_arr.parallel_date_vec.size(); ++i){ cout<<Lec_arr.parallel_date_vec[i].name<<" "<<Lec_arr.parallel_date_vec[i].lecture_dates[0].day_name <<"_"; cout<<Lec_arr.parallel_date_vec[i].lecture_dates[0].start_class<<"-"<<Lec_arr.parallel_date_vec[i].lecture_dates[0].end_class<<endl; } } void Administrator:: set_timetable_arranged_fun(){ this->is_timetable_arranged = 1; } int Administrator::check_timetable_arranged(){ return is_timetable_arranged; } void Administrator ::arrangeClassroom(vector<Cours>& coures_vec,vector<Classroom>& classes_vec,const int& course_id,const int& class_id,const char& doit){ int temp,random; string temp_St,temp1_St; for(int i = 0; i < coures_vec.size(); ++i){//save the class's id in the corresponding coures if(coures_vec[i].id == course_id){ coures_vec[i].classes_ids_vec.push_back(class_id);//save the id of the class inside coure struct vector coures_vec[i].is_assigned_to_class = 1;//indecator to that that it has been assigned to a class. temp_St = coures_vec[i].lecture_dates[0].day_name; break; } } for (int i = 0; i < classes_vec.size(); ++i){ if(classes_vec[i].id == class_id){ if(classes_vec[i].capacity == classes_vec[i].student_inroom){ cout<<"class is full filled!"<<endl; return;//if class has reached it's max capacity } else{ classes_vec[i].co_id_list.push_back(course_id);//keep the coures id in the class's struct vector classes_vec[i].student_inroom +=1;//increment the student in room; } } } if(doit == 'y'){//this condition only works in the input of doit is y and used in the arrange timetable command in main function. temp1_St = temp_St; while(temp_St == temp1_St){ random = rand()% 5+1; temp1_St = generte_day_name(random); } } /***************************/ /*printing the assigned cours to the appropriate class*/ for (int i = 0; i < coures_vec.size(); ++i){ if(coures_vec[i].id == course_id){ coures_vec[i].lecture_dates[0].day_name = temp1_St; cout<<"DONE:"<<"("<<coures_vec[i].id<<")"<<coures_vec[i].name<<" in "<<class_id<<" at "; for(int j = 0; j < coures_vec[i].lecture_dates.size(); ++j){ cout<<coures_vec[i].lecture_dates[j].day_name<<"_"<<coures_vec[i].lecture_dates[j].start_class<<"-"<<coures_vec[i].lecture_dates[j].end_class<<" "; } cout<<endl; return; } } } void Administrator:: arrangeClassroom(Lecturer& one_lec){ for(int i = 0; i <one_lec.parallel_date_vec.size(); ++i){ cout<<"DONE:"<<"("<<one_lec.parallel_date_vec[i].id<<")"<<one_lec.parallel_date_vec[i].name<<" in "; if(one_lec.get_lec_name() == "ALI") cout<<one_lec.classrooms[i].c_no<<" at "; else cout<<one_lec.classrooms[0].c_no<<" at "; for(int k = 0; k < one_lec.parallel_date_vec[i].lecture_dates.size(); ++k){ cout<<one_lec.parallel_date_vec[i].lecture_dates[k].day_name<<"_" <<one_lec.parallel_date_vec[i].lecture_dates[k].start_class<<"-" <<one_lec.parallel_date_vec[i].lecture_dates[k].end_class<<" "; } cout<<endl; } }
e98c9af0143ef96534ec3859fa7a6a0ce6131daf
32b97a6bcce47ede2f5393d3c7131b0c9d419095
/Exercicio35.cpp
c9b119293c99453faeaa85ed20be925028720d75
[]
no_license
Althieris/Algoritmo_II
3014fe76d7dd114dc7169dccf85ff1040b542d15
786f3b01c6af52198ced3c8bb0d37f76cfa88160
refs/heads/master
2020-03-30T21:50:39.405124
2018-12-06T17:17:57
2018-12-06T17:17:57
151,644,180
0
0
null
2018-11-24T23:46:21
2018-10-04T22:34:36
C++
UTF-8
C++
false
false
1,192
cpp
#include "pch.h" #include <iostream> int main() { int Idade = 1; int Maior_Idade = 0; int Contador = 0; int Opcao_Sexo, Opcao_Cabelo, Opcao_Olhos = 0; printf("Digite idade -1 para encerrar\n"); while (Idade > 0) { printf("Digite sua idade: "); scanf_s("%i", &Idade); printf("\n"); if (Idade < 0) { break; system("cls"); } printf("Sexo \n1-Masculino \n2-Feminino \n Digite: "); scanf_s("%i", &Opcao_Sexo); printf("\n"); printf("Cor dos olhos \n1-azuis \n2-verdes \n3-castanhos \n Digite:"); scanf_s("%i", &Opcao_Olhos); printf("\n"); printf("Cor do cabelo \n1-louros \n2-castanhos \n3-pretos \n Digite:"); scanf_s("%i", &Opcao_Cabelo); printf("\n"); if (Idade > Maior_Idade) { Maior_Idade = Idade; } if ((Opcao_Sexo == 2) && (18 >= Idade) && (Idade <= 35) && (Opcao_Olhos == 2) && (Opcao_Cabelo == 1)) { Contador = Contador++; } printf("Dado armazenado \n"); system("pause"); system("cls"); } printf("A maior idade e %i \n A quantidade de mulheres de idade 18 a 35 de olhos verdes e cablos louros e %i ", Maior_Idade, Contador); system("pause"); return 0; }
c317898e7bde47d63eb3e2b8eed6c459abfb2608
4b19135464a032c1d5271cd1ae58afb21df38584
/Samples/C++/DirectShow/Filters/DSNetwork/Receiver/mspool.h
2022e5302f29bb5c4da419bc1cb0ed77c4a79ae7
[]
no_license
sjk7/DX90SDK
f47cebbba53133923880004bc6e3a33cff1fe895
dd155425badb2cd3993c27f869efc007764e599b
refs/heads/master
2021-08-26T07:47:03.826451
2021-08-12T05:03:03
2021-08-12T05:03:03
253,911,891
3
1
null
null
null
null
UTF-8
C++
false
false
9,735
h
/*++ Copyright (c) Microsoft Corporation. All Rights Reserved. Module Name: mspool.h Abstract: Notes: --*/ #ifndef __mspool_h #define __mspool_h class CTSMediaSamplePool ; class CTSMediaSample ; class CNetworkReceiverFilter ; // media sample flags #define SAMPLE_SYNCPOINT 0x00000001 #define SAMPLE_PREROLL 0x00000002 #define SAMPLE_DISCONTINUITY 0x00000004 #define SAMPLE_TYPECHANGED 0x00000008 #define SAMPLE_TIMEVALID 0x00000010 #define SAMPLE_MEDIATIMEVALID 0x00000020 #define SAMPLE_TIMEDISCONTINUITY 0x00000040 #define SAMPLE_STOPVALID 0x00000080 #define SAMPLE_VALIDFLAGS 0x000000ff class CTSMediaSample : public IMediaSample2 { CTSMediaSamplePool * m_pMSPool ; LONG m_lRef ; DWORD m_dwFlags ; // ORed SAMPLE_* values DWORD m_dwTypeSpecificFlags ; BYTE * m_pbPayload ; LONG m_lActual ; REFERENCE_TIME m_rtStart ; REFERENCE_TIME m_rtEnd ; LONGLONG m_llMediaStart ; LONGLONG m_llMediaEnd ; AM_MEDIA_TYPE * m_pMediaType ; DWORD m_dwStreamId ; // // this media sample always wraps something // CBuffer * m_pBuffer ; // we're wrapping an IO block void ResetMS_ ( ) ; public : LIST_ENTRY m_ListEntry ; CTSMediaSample ( IN CTSMediaSamplePool * ) ; ~CTSMediaSample ( ) ; // ------------------------------------------------------------------- // init HRESULT Init ( IN CBuffer * pBuffer, IN BYTE * pbPayload, IN int iPayloadLength, IN LONGLONG * pllMediaStart, IN LONGLONG * pllMediaEnd, IN REFERENCE_TIME * prtStart, IN REFERENCE_TIME * prtEnd, IN DWORD dwMediaSampleFlags ) ; // ------------------------------------------------------------------- // IUnknown methods STDMETHODIMP QueryInterface ( IN REFIID riid, OUT void ** ppv ) ; STDMETHODIMP_(ULONG) AddRef ( ) ; STDMETHODIMP_(ULONG) Release ( ) ; // ------------------------------------------------------------------- // IMediaSample methods // get me a read/write pointer to this buffer's memory. I will actually // want to use sizeUsed bytes. STDMETHODIMP GetPointer ( OUT BYTE ** ppBuffer ) ; // return the size in bytes of the buffer data area STDMETHODIMP_(LONG) GetSize ( ) ; // get the stream time at which this sample should start and finish. STDMETHODIMP GetTime ( OUT REFERENCE_TIME * pTimeStart, // put time here OUT REFERENCE_TIME * pTimeEnd ) ; // Set the stream time at which this sample should start and finish. // pTimeStart==pTimeEnd==NULL will invalidate the time stamps in // this sample STDMETHODIMP SetTime ( IN REFERENCE_TIME * pTimeStart, // put time here IN REFERENCE_TIME * pTimeEnd ) ; // sync-point property. If true, then the beginning of this // sample is a sync-point. (note that if AM_MEDIA_TYPE.bTemporalCompression // is false then all samples are sync points). A filter can start // a stream at any sync point. S_FALSE if not sync-point, S_OK if true. STDMETHODIMP IsSyncPoint ( ) ; STDMETHODIMP SetSyncPoint ( IN BOOL bIsSyncPoint ) ; // preroll property. If true, this sample is for preroll only and // shouldn't be displayed. STDMETHODIMP IsPreroll ( ) ; STDMETHODIMP SetPreroll ( BOOL bIsPreroll ) ; STDMETHODIMP_(LONG) GetActualDataLength ( ) ; STDMETHODIMP SetActualDataLength ( IN long ) ; // these allow for limited format changes in band - if no format change // has been made when you receive a sample GetMediaType will return S_FALSE STDMETHODIMP GetMediaType ( AM_MEDIA_TYPE ** ppMediaType ) ; STDMETHODIMP SetMediaType( AM_MEDIA_TYPE * pMediaType ) ; // returns S_OK if there is a discontinuity in the data (this frame is // not a continuation of the previous stream of data // - there has been a seek or some dropped samples). STDMETHODIMP IsDiscontinuity ( ) ; // set the discontinuity property - TRUE if this sample is not a // continuation, but a new sample after a seek or a dropped sample. STDMETHODIMP SetDiscontinuity ( BOOL bDiscontinuity ) ; // get the media times for this sample STDMETHODIMP GetMediaTime ( OUT LONGLONG * pTimeStart, OUT LONGLONG * pTimeEnd ) ; // Set the media times for this sample // pTimeStart==pTimeEnd==NULL will invalidate the media time stamps in // this sample STDMETHODIMP SetMediaTime ( IN LONGLONG * pTimeStart, IN LONGLONG * pTimeEnd ) ; // ------------------------------------------------------------------- // IMediaSample methods // Set and get properties (IMediaSample2) STDMETHODIMP GetProperties ( IN DWORD cbProperties, OUT BYTE * pbProperties ) ; STDMETHODIMP SetProperties ( IN DWORD cbProperties, IN const BYTE * pbProperties ) ; } ; class CTSMediaSamplePool { LIST_ENTRY m_leMSPool ; CNetworkReceiverFilter * m_pHostingFilter ; DWORD m_dwPoolSize ; CRITICAL_SECTION m_crt ; HANDLE m_hEvent ; void Lock_ () { EnterCriticalSection (& m_crt) ; } void Unlock_ () { LeaveCriticalSection (& m_crt) ; } HRESULT GetMediaSample_ ( IN CBuffer * pBuffer, IN BYTE * pbPayload, IN int iPayloadLength, IN LONGLONG * pllMediaStart, IN LONGLONG * pllMediaEnd, IN REFERENCE_TIME * prtStart, IN REFERENCE_TIME * prtEnd, IN DWORD dwMediaSampleFlags, OUT IMediaSample2 ** ppMS ) ; public : CTSMediaSamplePool ( IN DWORD dwPoolSize, IN CNetworkReceiverFilter * pHostingFilter, OUT HRESULT * phr ) ; ~CTSMediaSamplePool ( ) ; DWORD GetPoolSize ( ) { return m_dwPoolSize ; } void RecycleMS ( IN CTSMediaSample * ) ; // synchronous HRESULT GetMediaSampleSynchronous ( IN CBuffer * pBuffer, IN BYTE * pbPayload, IN int iPayloadLength, IN LONGLONG * pllMediaStart, IN LONGLONG * pllMediaEnd, IN REFERENCE_TIME * prtStart, IN REFERENCE_TIME * prtEnd, IN DWORD dwMediaSampleFlags, OUT IMediaSample2 ** ppMS ) { return GetMediaSample_ ( pBuffer, pbPayload, iPayloadLength, pllMediaStart, pllMediaEnd, prtStart, prtEnd, dwMediaSampleFlags, ppMS ) ; } HRESULT GetMediaSampleSynchronous ( IN CBuffer * pBuffer, IN BYTE * pbPayload, IN int iPayloadLength, OUT IMediaSample2 ** ppMS ) { LONGLONG llMediaStart ; LONGLONG llMediaEnd ; REFERENCE_TIME rtStart ; REFERENCE_TIME rtEnd ; return GetMediaSample_ ( pBuffer, pbPayload, iPayloadLength, & llMediaStart, // dummy & llMediaEnd, // dummy & rtStart, // dummy & rtEnd, // dummy 0, // no flags (no dummy param gets used) ppMS ) ; } } ; #endif // __mspool_h
025ef13ba6732d96f2c7663e14cf94f9be060684
04c66673a7f8ebdca37e1a28bfdfa9af56716ddc
/02_auto/main.cpp
fd8a935abb472b0f85b2aa94a41b34487084cf94
[]
no_license
mkargi/modern_effective_cpp
14b2e5daaf3811ec657a47ee62f56d45746d90b8
003a586c0c326020ca12eae1d07937eda7142924
refs/heads/master
2023-01-23T04:11:42.522368
2020-12-02T16:38:27
2020-12-02T16:38:27
315,421,352
0
0
null
null
null
null
UTF-8
C++
false
false
249
cpp
#include <iostream> int main() { auto x = 27; // int const auto cx = x; // const int const auto& rx = x; // const int& auto&& uref1 = x; // int& auto&& uref2 = cx; // const int& auto&& uref3 = 27; // int&& return 0; }
e8bd887270f09fd87c7f50e74d880fa70a6f1c04
ab6937915ca4a3a8b95d3021177a752c54157d21
/C/LatihanBahasaC.cpp
f23c0a39c8628d9156c973c9ce96d6839cee6efe
[]
no_license
fitrailyasa/Latihan-Coding
b953ecb8c6f7624d260576c18d8813b9291963f2
f3a211585f8635c2c68b21c41701ee07f5e55d74
refs/heads/main
2023-06-17T01:00:35.471920
2021-07-13T21:47:48
2021-07-13T21:47:48
385,743,161
0
0
null
null
null
null
UTF-8
C++
false
false
241
cpp
#include <stdio.h> //manggil library (Perpustakaan bahasa C) int main(){ // Pintu masuk program int a; // tipe data int = integer (bilangan bulat), float = bilangan pecahan printf("Halo, Dunia"); //output = Halo, Dunia scanf("%d", a); }
63552cb703f5ac6fa59d03f7a704abe26259e9ef
2a0799c18d6e31398c6e0a3aaf614b33762b81b5
/Wheels.cpp
493d98d4bc2048086319ba6a037a513a7b887fa1
[]
no_license
dntAtMe/embedded-2018-2019
eb1d1e41a3a330c7a17c8a1daf41f03413b5e979
e74f6b03da5e50fc4cddfbcb7430f29f6bf4c48f
refs/heads/master
2020-05-30T18:06:50.643721
2019-06-02T20:12:34
2019-06-02T20:12:34
189,890,394
0
0
null
null
null
null
UTF-8
C++
false
false
4,216
cpp
#include <Arduino.h> #include "Wheels.h" #define SET_MOVEMENT(side,f,b) digitalWrite( side[0], f);\ digitalWrite( side[1], b) #define INTINPUT0 A0 #define INTINPUT1 A1 #define BEEPING_PIN 13 volatile int cnt0, cnt1; long int beepingFreq = 250000; void doBeep() { digitalWrite(BEEPING_PIN, digitalRead(BEEPING_PIN) ^ 1); } Wheels::Wheels() { // pinMode(BEEPING_PIN, OUTPUT); // cnt0=0; // cnt1=0; // speedLeft = 255; // speedRight = 255; // PCICR = 0x02; // PCMSK1 = 0x03; } void Wheels::attachRight(int pF, int pB, int pS) { pinMode(pF, OUTPUT); pinMode(pB, OUTPUT); pinMode(pS, OUTPUT); this->pinsRight[0] = pF; this->pinsRight[1] = pB; this->pinsRight[2] = pS; } void Wheels::attachLeft(int pF, int pB, int pS) { pinMode(pF, OUTPUT); pinMode(pB, OUTPUT); pinMode(pS, OUTPUT); this->pinsLeft[0] = pF; this->pinsLeft[1] = pB; this->pinsLeft[2] = pS; } void Wheels::setSpeedRight(uint8_t s) { analogWrite(this->pinsRight[2], s); } void Wheels::setSpeedLeft(uint8_t s) { analogWrite(this->pinsLeft[2], s); } void Wheels::changeSpeedLeft(uint8_t s) { analogWrite(this->pinsLeft[2], (analogRead(this->pinsLeft[2]) + s) % 255); } void Wheels::changeSpeedRight(uint8_t s) { analogWrite(this->pinsRight[2], (analogRead(this->pinsRight[2]) + s) % 255); } void Wheels::setSpeed(uint8_t s) { setSpeedLeft(s); setSpeedRight(s); } void Wheels::attach(int pRF, int pRB, int pRS, int pLF, int pLB, int pLS) { this->attachRight(pRF, pRB, pRS); this->attachLeft(pLF, pLB, pLS); } void Wheels::forwardLeft() { SET_MOVEMENT(pinsLeft, HIGH, LOW); } void Wheels::forwardRight() { SET_MOVEMENT(pinsRight, HIGH, LOW); } void Wheels::backLeft() { SET_MOVEMENT(pinsLeft, LOW, HIGH); } void Wheels::backRight() { SET_MOVEMENT(pinsRight, LOW, HIGH); } void Wheels::forward() { //digitalWrite(BEEPING_PIN, LOW); //Timer1.detachInterrupt(); this->forwardLeft(); this->forwardRight(); } void Wheels::back() { //Timer1.detachInterrupt(); //Timer1.attachInterrupt(doBeep, beepingFreq); this->backLeft(); this->backRight(); } void Wheels::stopLeft() { SET_MOVEMENT(pinsLeft, LOW, LOW); } void Wheels::stopRight() { SET_MOVEMENT(pinsRight, LOW, LOW); } void Wheels::stop() { //digitalWrite(BEEPING_PIN, LOW); //Timer1.detachInterrupt(); this->stopLeft(); this->stopRight(); } void delayCnt(int cnt) { while (cnt0 < cnt && cnt1 < cnt) { } cnt0 = cnt1 = 0; } void Wheels::moveForwardCnt(int cnt) { this->forward(); delayCnt(cnt); } void Wheels::moveBackCnt(int cnt) { this->back(); delayCnt(cnt); } void Wheels::moveForward(int d) { this->forward(); delay(d); } void Wheels::moveBack(int d) { this->back(); delay(d); } void Wheels::turnRightCnt(int cnt) { if (digitalRead(pinsRight[1]) == HIGH && digitalRead(pinsLeft[1]) == HIGH) { this->forwardLeft(); } if (digitalRead(pinsRight[0]) == HIGH && digitalRead(pinsLeft[0]) == HIGH) { this->backLeft(); } delayCnt(cnt); } void Wheels::turnLeftCnt(int cnt) { if (digitalRead(pinsRight[1]) == HIGH && digitalRead(pinsLeft[1]) == HIGH) { this->forwardRight(); } if (digitalRead(pinsRight[0]) == HIGH && digitalRead(pinsLeft[0]) == HIGH) { this->backRight(); } delayCnt(cnt); } void Wheels::test() { Serial.println(cnt0); Serial.println(cnt1); int c = 75; this->forward(); delay(1000); if (cnt0 > c) { cnt0 = 0; this->setSpeedLeft(this->speedLeft - 10); this->speedLeft -= 10; } else if (cnt0 < c) { cnt0 = 0; this->setSpeedLeft(this->speedLeft + 10); this->speedLeft += 10; } if (cnt1 > c) { cnt1 = 0; this->setSpeedRight(this->speedRight - 10); this->speedRight -= 10; } else if (cnt1 < c) { cnt1 = 0; this->setSpeedRight(this->speedRight + 10); this->speedRight += 10; } if ( this->speedRight > 255) this->speedRight = 255; if ( this->speedLeft > 255) this->speedLeft = 255; } //ISR(PCINT1_vect) //{ // if( (PINC & (1 << PC0)) ) // cnt0++; // if( (PINC & (1 << PC1)) ) // cnt1++; //}
4bd2d3863e213b995ce4c797f69651b760fb6ceb
be0db8bf2276da4b71a67723bbe8fb75e689bacb
/Src/App/init.cpp
d888c01b5df8390fb58162ef1efbd36db997300d
[]
no_license
jy02140486/cellwarfare
21a8eb793b94b8472905d793f4b806041baf57bb
85f026efd03f12dd828817159b9821eff4e4aff0
refs/heads/master
2020-12-24T15:22:58.595707
2011-07-24T12:36:45
2011-07-24T12:36:45
32,970,508
0
0
null
null
null
null
UTF-8
C++
false
false
6,030
cpp
#include "app.h" #include "event.h" #include <time.h> bool T_App::init() { try { //initail window description mWinDesc.set_title("CellWarfare"); mWinDesc.set_allow_resize(true); mWinDesc.set_size(CL_Size (800, 600), false); CL_String resource("../Res/GUITheme/resources.xml"); CL_String theme("../Res/GUITheme/theme.css"); //initail resource manager mResManager.load(resource); ////initail gui theme mGUITheme.set_resources(mResManager); //initail gui mpDisplayWindow = new CL_DisplayWindow(mWinDesc); mpWinManager = new CL_GUIWindowManagerTexture(*mpDisplayWindow); mGui.set_window_manager(*mpWinManager); mGui.set_theme(mGUITheme); mGui.set_css_document(theme); mpWinManager->func_repaint().set(this, &T_App::render); //initail GUIComponet window CL_DisplayWindowDescription comWindowDesc; comWindowDesc.show_border(false); comWindowDesc.set_allow_resize(true); comWindowDesc.set_title("settings"); comWindowDesc.set_size(CL_Size(300, 570),false); comWindowDesc.set_allow_resize(true); comWindowDesc.set_layered(true); mpComWindow = new CL_Window(&mGui, comWindowDesc); mpComWindow->set_draggable(false); //initail events mInput = mpDisplayWindow->get_ic(); mKeyboard = mInput.get_keyboard(); mMouse = mInput.get_mouse(); //mJoystick = mInput.get_joystick(); mpConsole = new CL_ConsoleWindow("Console", 80, 100); entites=new EM(); entites->iniLVs(); words=new CL_Font(mpComWindow->get_gc(),"Tahoma",20); offset.x=320; offset.y=420; entites->initScrObjs(); body=new CL_Image(mpDisplayWindow->get_gc(),"../res/body.png"); stage_clear=new CL_Image(mpDisplayWindow->get_gc(),"../res/stage clear.png"); if(RandomVal::randombool()) gameover=new CL_Image(mpDisplayWindow->get_gc(),"../res/gameover2.png"); else gameover=new CL_Image(mpDisplayWindow->get_gc(),"../res/gameover.png"); all_clear=new CL_Image(mpDisplayWindow->get_gc(),"../res/allclear.png"); //init menu items mx=new CL_LineEdit(mpComWindow); mx->set_geometry(CL_Rect(40,40, CL_Size(80, 20))); my=new CL_LineEdit(mpComWindow); my->set_geometry(CL_Rect(40,80, CL_Size(80, 20))); cirfirm=new CL_PushButton(mpComWindow); cirfirm->set_text("enter"); cirfirm->set_geometry(CL_Rect(40,500, CL_Size(150, 30))); cirfirm->func_clicked().set(this,&T_App::ButtonClick); PainKiller=new CL_PushButton(mpComWindow); PainKiller->set_text("PainKiller"); PainKiller->set_geometry(CL_Rect(40,540, CL_Size(100, 20))); PainKiller->func_clicked().set(this,&T_App::takePill); CL_Point lboffset(10,10); CL_Size sspin(80,20); CL_Size slb(80,20); infoBF=new CL_Label(mpComWindow); infoBF->set_geometry(CL_Rect(10,110, CL_Size(290, 300))); infoBF->set_text("infobf"); infoBF->set_visible(false); lbcellsdeployed=new CL_Label(infoBF); lbcellsdeployed->set_geometry(CL_Rect(lboffset.x,lboffset.y+5, slb)); lbcellsdeployed->set_text("Cells deployed"); cellsdeployed=new CL_Spin(infoBF); cellsdeployed->set_geometry(CL_Rect(lboffset.x+80,lboffset.y, sspin)); cellsdeployed->set_step_size(1); cellsdeployed->set_ranges(0,100); cellsdeployed->set_value(entites->curLV->defbfs[0].ImmunityPoints); lbintruders=new CL_Label(infoBF); lbintruders->set_geometry(CL_Rect(lboffset.x,lboffset.y+35, slb)); lbintruders->set_text("Intruders"); intruders=new CL_Spin(infoBF); intruders->set_geometry(CL_Rect(lboffset.x+80,lboffset.y+30, sspin)); lbtimeleft=new CL_Label(infoBF); lbtimeleft->set_geometry(CL_Rect(lboffset.x,lboffset.y+65, slb)); lbtimeleft->set_text("Time left"); timeleft=new CL_ProgressBar(infoBF); timeleft->set_geometry(CL_Rect(lboffset.x+80,lboffset.y+65, slb)); timeleft->set_min(0); timeleft->set_max(40); timeleft->set_position(20); SendingCirfirm=new CL_PushButton(infoBF); SendingCirfirm->set_geometry(CL_Rect(lboffset.x,lboffset.y+95, slb)); SendingCirfirm->set_text("Send"); SendingCirfirm->func_clicked().set(this,&T_App::OnSendingCirfirmClick); //tatical layer TaticalBoard=new CL_Label(mpComWindow); TaticalBoard->set_geometry(CL_Rect(10,310, CL_Size(290, 200))); TaticalBoard->set_text("TaticalBoard"); TaticalBoard->set_visible(true); // TaticalBoard->set_constant_repaint(true); lbTcellsdeployed=new CL_Label(TaticalBoard); lbTcellsdeployed->set_geometry(CL_Rect(lboffset.x,lboffset.y+5, slb)); lbTcellsdeployed->set_text("Cells deployed"); lbTcellsdeployed->set_visible(true); Tcellsdeployed=new CL_Label(TaticalBoard); Tcellsdeployed->set_geometry(CL_Rect(lboffset.x+100,lboffset.y+5, slb)); Tcellsdeployed->set_text("Cells deployed"); Tcellsdeployed->set_visible(true); lbTintruders=new CL_Label(TaticalBoard); lbTintruders->set_geometry(CL_Rect(lboffset.x,lboffset.y+15, slb)); lbTintruders->set_text("Itruders"); lbTintruders->set_visible(true); Tintruders=new CL_Label(TaticalBoard); Tintruders->set_geometry(CL_Rect(lboffset.x+100,lboffset.y+15, slb)); Tintruders->set_text("Itruders"); Tintruders->set_visible(true); entites->hero->eventTimer->func_expired().set(this,&T_App::invading_LogicLayer_Failure); entites->hero->eventTimer->begin(true); //LibDebugOnConsole(); time(&Atime); } catch (CL_Exception &exception) { CL_Console::write_line("Exception:Init error", exception.get_message_and_stack_trace()); // mpConsole->display_close_message(); CL_Console::write_line(exception.get_message_and_stack_trace()); return true; } running=true; T_Event::eventInit(); T_App::eventInit(); // slotMouseDown = mMouse.sig_key_down().connect(this, // &T_App::onMouseDown); return true; } void T_App::OnSendingCirfirmClick() { if (entites->SOselected!=NULL) { entites->SOselected->datas->ImmunityPoints+=cellsdeployed->get_value(); if (entites->hero->ImmunityPoints->minusable(cellsdeployed->get_value())) { entites->hero->ImmunityPoints->minus(cellsdeployed->get_value()); } } }
[ "[email protected]@7e182df5-b8f1-272d-db4e-b61a9d634eb1" ]
[email protected]@7e182df5-b8f1-272d-db4e-b61a9d634eb1
bf740e82c4741a12601505416dc7413a2a228665
1a218c67ad04f99e52c37425fdb933b053af6244
/Ch09/exercise9.49.cpp
5cb899cb17a689aeb2b3a014a43cdfdb11e04bb1
[]
no_license
xiaonengmiao/Cpp_Primer
5a91cd223c9b0870f4ab9a45c6f679333a98fa20
be20a29b49be19f6959b7873077ea698da940bf6
refs/heads/master
2020-12-25T14:23:58.976008
2020-06-18T07:54:43
2020-06-18T07:54:43
66,343,361
1
1
null
null
null
null
UTF-8
C++
false
false
523
cpp
#include<iostream> #include<string> #include<fstream> using namespace std; int main() { string ascdes{"tdhfklbqypgj"}; ifstream ifs("../data/letter.txt"); if (!ifs) return -1; string word; string longword; unsigned len = 0; while (ifs >> word) { if (word.find_first_of(ascdes) == string::npos && word.size() > len) { len = word.size(); longword = word; } } cout << "The Longest word contains neigher ascenders nor descenders is " << longword; cout << endl; return 0; }
b2aa285f9351f27e8cee2375644727e7394f201e
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
/Engine/Plugins/Experimental/AlembicImporter/Source/ThirdParty/Alembic/openexr/OpenEXR/IlmImfTest/testNativeFormat.h
19c9ba673b5774baf1afb9c33174e9b323b70ed3
[ "BSD-3-Clause", "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
windystrife/UnrealEngine_NVIDIAGameWorks
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
b50e6338a7c5b26374d66306ebc7807541ff815e
refs/heads/4.18-GameWorks
2023-03-11T02:50:08.471040
2022-01-13T20:50:29
2022-01-13T20:50:29
124,100,479
262
179
MIT
2022-12-16T05:36:38
2018-03-06T15:44:09
C++
UTF-8
C++
false
false
1,874
h
/////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2003-2012, Industrial Light & Magic, a division of Lucas // Digital Ltd. LLC // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Industrial Light & Magic nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // /////////////////////////////////////////////////////////////////////////// #include <string> void testNativeFormat (const std::string &tempDir);
5f6a7547818f9630d254dd4e5e1a57d6a7e963ab
367fba5df552aef1ee9aa6add6bb512b781bc6d4
/plugins/jsAPI/nodeJsExtension/wrappers/ApeIndexedLineSetGeometryJsBind.h
1e9b9c71a432a5da2fee8f2437daa8d41eac1e8a
[ "LicenseRef-scancode-free-unknown", "MIT" ]
permissive
hamoriakos/ApertusVR
2d3e5736b26404198b222d24388bb3c1c162ee69
14303ab54963e52409ed376cdafae5c43004074b
refs/heads/master
2021-09-16T00:13:48.980732
2017-06-28T18:23:14
2017-06-28T18:23:14
105,749,913
0
1
MIT
2018-06-13T13:54:38
2017-10-04T09:11:13
C++
UTF-8
C++
false
false
4,023
h
/*MIT License Copyright (c) 2016 MTA SZTAKI Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #ifndef APE_INDEXEDLINESETGEOMETRYJSBIND_H #define APE_INDEXEDLINESETGEOMETRYJSBIND_H #include "nbind/nbind.h" #include "nbind/api.h" #include "Ape.h" #include "ApeIIndexedLineSetGeometry.h" #include "ApeJsBindNodeImpl.h" #ifdef NBIND_CLASS class IndexedLineSetJsPtr { private: Ape::IndexedLineSetGeometryWeakPtr mPtr; public: IndexedLineSetJsPtr(Ape::IndexedLineSetGeometryWeakPtr ptr) { mPtr = ptr; } IndexedLineSetJsPtr(Ape::EntityWeakPtr ptr) { mPtr = std::static_pointer_cast<Ape::IIndexedLineSetGeometry>(ptr.lock()); } // Pointers const Ape::EntityWeakPtr getEntityWeakPtr() { return std::static_pointer_cast<Ape::Entity>(mPtr.lock()); } const Ape::EntitySharedPtr getEntitySharedPtr() { return this->getEntityWeakPtr().lock(); } Ape::GeometryWeakPtr getGeometryWeakPtr() { return std::static_pointer_cast<Ape::Geometry>(mPtr.lock()); } Ape::GeometrySharedPtr getGeometrySharedPtr() { return this->getGeometryWeakPtr().lock(); } Ape::IndexedLineSetGeometrySharedPtr getIndexedLineSetGeometrySharedPtr() { return std::static_pointer_cast<Ape::IIndexedLineSetGeometry>(mPtr.lock()); } Ape::IndexedLineSetGeometryWeakPtr getIndexedLineSetGeometryWeakPtr() { return mPtr; } // ParentNode Ape::NodeWeakPtr getParentNodeWeakPtr() { return mPtr.lock()->getParentNode(); } void setParentNodeWeakPtr(Ape::NodeWeakPtr parentNode) { mPtr.lock()->setParentNode(parentNode); } NodeJsPtr getParentNodeJsPtr() { return NodeJsPtr(getParentNodeWeakPtr()); } void setParentNodeJsPtr(NodeJsPtr parentNode) { mPtr.lock()->setParentNode(parentNode.getNodeWeakPtr()); } // Entity const std::string getName() { return mPtr.lock()->getName(); } const Ape::Entity::Type getType() { return mPtr.lock()->getType(); } // IIndexedLineSetGeometry Ape::GeometryIndexedLineSetParameters getParameters() { return mPtr.lock()->getParameters(); } void setParameters(Ape::GeometryCoordinates coordinates, Ape::GeometryIndices indices, Ape::Color color) { mPtr.lock()->setParameters(coordinates, indices, color); } }; using namespace Ape; NBIND_CLASS(GeometryIndexedLineSetParameters) { construct<>(); construct<GeometryCoordinates, GeometryIndices, Color>(); method(getCoordinates); method(getIndices); method(getColor); method(toString); } NBIND_CLASS(IndexedLineSetJsPtr) { construct<Ape::IndexedLineSetGeometryWeakPtr>(); construct<Ape::EntityWeakPtr>(); // Pointers method(getEntityWeakPtr); method(getEntitySharedPtr); method(getGeometryWeakPtr); method(getGeometrySharedPtr); method(getIndexedLineSetGeometryWeakPtr); method(getIndexedLineSetGeometrySharedPtr); // ParentNode method(getParentNodeWeakPtr); method(setParentNodeWeakPtr); method(getParentNodeJsPtr); method(setParentNodeJsPtr); // Entity method(getName); method(getType); // IIndexedLineSetGeometry method(getParameters); method(setParameters); } #endif #endif
7353c3ed56ed21b0b9df018981759d6e716ec9b1
e9ba75ae30fd8af7cb00dc330bae6e5ea9f04043
/src/physicsentity.h
41c416e3bfb5fe60f9d30fce48b35607573d0d47
[ "MIT", "BSD-3-Clause" ]
permissive
adderly/Bacon2D
a4fad8084c75e3dc62e627c382aee969c97ba354
4875cddc1301cae0212ee4e32192bb17821b36f2
refs/heads/master
2021-01-24T23:11:43.345455
2016-10-29T23:06:19
2016-10-29T23:06:19
49,147,938
0
1
null
2016-01-06T16:44:24
2016-01-06T16:44:24
null
UTF-8
C++
false
false
1,193
h
#ifndef PHYSICSENTITY_H #define PHYSICSENTITY_H #include <QObject> #include <entity.h> class QPointF; class Box2DBody; typedef Box2DBody Body; /** * @brief */ class PhysicsEntity : public Entity { Q_OBJECT Q_PROPERTY(Body* body READ body WRITE setBody NOTIFY bodyChanged) public: PhysicsEntity(QQuickItem* parent = nullptr); void setBody(Body* body); Body* body() { return mBody; } public slots: void applyForce(QPointF force,QPointF point); void applyForceToCenter(QPointF force); void applyTorque(qreal torque); void applyLinearImpulse(QPointF impulse, QPointF point); void applyAngularImpulse(qreal torque); QPointF getWorldCenter(); QPointF getLocalCenter(); float getMass(); void resetMassData(); float getInertia(); QPointF toWorldPoint(QPointF localPoint); QPointF toWorldVector(QPointF localVector); QPointF toLocalPoint(QPointF worlPoint); QPointF toLocalVector(QPointF worldVector); QPointF getLinearVelocityFromWorldPoint(QPointF point); QPointF getLinearVelocityFromLocalPoint(QPointF point); signals: void bodyChanged(Body* body); private: Body* mBody; }; #endif // PHYSICSENTITY_H
ad2ae659704b93ab8f922e750cbcb20314bbfc32
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/printscan/faxsrv/src/com/whistler/faxarchiveinner.h
6eb6ac7d7ae679af79b5f936bcca59e5a49c4d5a
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
25,673
h
/*++ Copyright (c) 2000 Microsoft Corporation Module Name: faxarchiveinner.h Abstract: Declaration and Implementation of Fax Archive Inner Template Class. Author: Iv Garber (IvG) May, 2000 Revision History: --*/ #ifndef __FAXARCHIVEINNER_H_ #define __FAXARCHIVEINNER_H_ #include "resource.h" // main symbols #include "FaxCommon.h" // //================ FAX ARCHIVE INNER ========================================= // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> class CFaxArchiveInner : public IDispatchImpl<T, piid, &LIBID_FAXCOMEXLib>, public CFaxInitInner { public: CFaxArchiveInner() : CFaxInitInner(_T("FAX ARCHIVE INNER")) { m_bInitialized = FALSE; } virtual ~CFaxArchiveInner() {}; STDMETHOD(get_SizeLow)(/*[out, retval]*/ long *plSizeLow); STDMETHOD(get_SizeHigh)(/*[out, retval]*/ long *plSizeHigh); STDMETHOD(get_UseArchive)(/*[out, retval]*/ VARIANT_BOOL *pbUseArchive); STDMETHOD(put_UseArchive)(/*[in]*/ VARIANT_BOOL bUseArchive); STDMETHOD(get_ArchiveFolder)(BSTR *pbstrArchiveFolder); STDMETHOD(put_ArchiveFolder)(BSTR bstrArchiveFolder); STDMETHOD(get_SizeQuotaWarning)(VARIANT_BOOL *pbSizeQuotaWarning); STDMETHOD(put_SizeQuotaWarning)(VARIANT_BOOL bSizeQuotaWarning); STDMETHOD(get_HighQuotaWaterMark)(long *plHighQuotaWaterMark); STDMETHOD(put_HighQuotaWaterMark)(long lHighQuotaWaterMark); STDMETHOD(get_LowQuotaWaterMark)(long *plLowQuotaWaterMark); STDMETHOD(put_LowQuotaWaterMark)(long lLowQuotaWaterMark); STDMETHOD(get_AgeLimit)(long *plAgeLimit); STDMETHOD(put_AgeLimit)(long lAgeLimit); STDMETHOD(Refresh)(); STDMETHOD(Save)(); STDMETHOD(GetMessage)(BSTR bstrMessageId, MsgIfc **ppFaxMessage); STDMETHOD(GetMessages)(long lPrefetchSize, IteratorIfc **ppFaxMessageIterator); private: bool m_bInitialized; VARIANT_BOOL m_bUseArchive; CComBSTR m_bstrArchiveFolder; VARIANT_BOOL m_bSizeQuotaWarning; long m_lHighQuotaWaterMark; long m_lLowQuotaWaterMark; long m_lAgeLimit; ULARGE_INTEGER m_uliSize; }; // //========================= REFRESH ==================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::Refresh( ) /*++ Routine name : CFaxArchiveInner::Refresh Routine description: Retrieve Current Configuration of the Incoming / Outgoing Archive on Fax Server Author: Iv Garber (IvG), Apr, 2000 Arguments: Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::Refresh"), hr); // // Get Fax Server Handle // HANDLE hFaxHandle = NULL; hr = GetFaxHandle(&hFaxHandle); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } CFaxPtr<FAX_ARCHIVE_CONFIG> pFaxArchiveConfig; if ( 0 == ::FaxGetArchiveConfiguration(hFaxHandle, ArchiveType, &pFaxArchiveConfig)) { // // Failed to Get Archive Configuration // hr = Fax_HRESULT_FROM_WIN32(GetLastError()); AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("::FaxGetArchiveConfiguration()"), hr); return hr; } if (!pFaxArchiveConfig || pFaxArchiveConfig->dwSizeOfStruct != sizeof(FAX_ARCHIVE_CONFIG)) { // // Failed to Get Archive Configuration // hr = E_FAIL; AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("Invalid pFaxArchiveConfig"), hr); return hr; } m_bUseArchive = bool2VARIANT_BOOL(pFaxArchiveConfig->bUseArchive); m_bSizeQuotaWarning = bool2VARIANT_BOOL(pFaxArchiveConfig->bSizeQuotaWarning); m_lHighQuotaWaterMark = pFaxArchiveConfig->dwSizeQuotaHighWatermark; m_lLowQuotaWaterMark = pFaxArchiveConfig->dwSizeQuotaLowWatermark; m_lAgeLimit = pFaxArchiveConfig->dwAgeLimit; m_uliSize.QuadPart = pFaxArchiveConfig->dwlArchiveSize; m_bstrArchiveFolder = pFaxArchiveConfig->lpcstrFolder; if (!m_bstrArchiveFolder && pFaxArchiveConfig->lpcstrFolder) { hr = E_OUTOFMEMORY; AtlReportError(*pcid, IDS_ERROR_OUTOFMEMORY, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(MEM_ERR, _T("CComBSTR& operator=()"), hr); return hr; } m_bInitialized = TRUE; return hr; } // //==================== USE ARCHIVE ==================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_UseArchive( VARIANT_BOOL *pbUseArchive ) /*++ Routine name : CFaxArchiveInner::get_UseArchive Routine description: Return Flag indicating whether or not to Archive the Fax Messages Author: Iv Garber (IvG), Apr, 2000 Arguments: pbUseArchive [out] - Ptr to the Place to put Current value of the Flag Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_UseArchive"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetVariantBool(pbUseArchive, m_bUseArchive); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType>:: put_UseArchive( VARIANT_BOOL bUseArchive ) /*++ Routine name : CFaxArchiveInner::put_UseArchive Routine description: Set new Use Archive Flag Author: Iv Garber (IvG), Apr, 2000 Arguments: bUseArchive [in] - the new Value for the Use Archive Flag Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_UseArchive"), hr, _T("%ld"), bUseArchive); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_bUseArchive = bUseArchive; return hr; } // //==================== ARCHIVE FOLDER ==================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_ArchiveFolder( BSTR *pbstrArchiveFolder ) /*++ Routine name : CFaxArchiveInner::get_ArchiveFolder Routine description: return Archive Folder on Server Author: Iv Garber (IvG), Apr, 2000 Arguments: pbstrArchiveFolder [out] - the Archive Folder Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_ArchiveFolder"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetBstr(pbstrArchiveFolder, m_bstrArchiveFolder); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_ArchiveFolder ( BSTR bstrArchiveFolder ) /*++ Routine name : CFaxArchiveInner::put_ArchiveFolder Routine description: Set Archive Folder Author: Iv Garber (IvG), Apr, 2000 Arguments: bstrArchiveFolder [in] - new Archive Folder on Server Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_ArchiveFolder"), hr, _T("%s"), bstrArchiveFolder); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_bstrArchiveFolder = bstrArchiveFolder; if (bstrArchiveFolder && !m_bstrArchiveFolder) { // // Not enough memory // hr = E_OUTOFMEMORY; AtlReportError(*pcid, IDS_ERROR_OUTOFMEMORY, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(MEM_ERR, _T("CComBSTR::operator="), hr); return hr; } return hr; } // //==================== SIZE QUOTA WARNING ================================ // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_SizeQuotaWarning( VARIANT_BOOL *pbSizeQuotaWarning ) /*++ Routine name : CFaxArchiveInner::get_SizeQuotaWarning Routine description: Return Flag indicating whether or not to issue event log warning when watermarks are crossed Author: Iv Garber (IvG), Apr, 2000 Arguments: pbSizeQuotaWarning [out] - ptr to place where to put the Current value of the Flag Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_SizeQuotaWarning"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetVariantBool(pbSizeQuotaWarning, m_bSizeQuotaWarning); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_SizeQuotaWarning( VARIANT_BOOL bSizeQuotaWarning ) /*++ Routine name : CFaxArchiveInner::put_SizeQuotaWarning Routine description: Set new SizeQuotaWarning Flag Author: Iv Garber (IvG), Apr, 2000 Arguments: bSizeQuotaWarning [in] - the new Value for the SizeQuotaWarning Flag Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_SizeQuotaWarning"), hr, _T("%ld"), bSizeQuotaWarning); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_bSizeQuotaWarning = bSizeQuotaWarning; return hr; } // //================= QUOTA WATER MARKS =============================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_HighQuotaWaterMark( long *plHighQuotaWaterMark ) /*++ Routine name : CFaxArchiveInner::get_HighQuotaWaterMark Routine description: Return HighQuotaWaterMark Author: Iv Garber (IvG), Apr, 2000 Arguments: plHighQuotaWaterMark [out] - HighQuotaWaterMark Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_HighQuotaWaterMark"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plHighQuotaWaterMark , m_lHighQuotaWaterMark); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_HighQuotaWaterMark( long lHighQuotaWaterMark ) /*++ Routine name : CFaxArchiveInner::put_HighQuotaWaterMark Routine description: Set HighQuotaWaterMark Author: Iv Garber (IvG), Apr, 2000 Arguments: lHighQuotaWaterMark [in] - HighQuotaWaterMark to Set Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_HighQuotaWaterMark"), hr, _T("%ld"), lHighQuotaWaterMark); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_lHighQuotaWaterMark = lHighQuotaWaterMark; return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_LowQuotaWaterMark( long *plLowQuotaWaterMark ) /*++ Routine name : CFaxArchiveInner::get_LowQuotaWaterMark Routine description: Return LowQuotaWaterMark Author: Iv Garber (IvG), Apr, 2000 Arguments: plLowQuotaWaterMark [out] - LowQuotaWaterMark Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_LowQuotaWaterMark"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plLowQuotaWaterMark , m_lLowQuotaWaterMark); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_LowQuotaWaterMark( long lLowQuotaWaterMark ) /*++ Routine name : CFaxArchiveInner::put_LowQuotaWaterMark Routine description: Set LowQuotaWaterMark Author: Iv Garber (IvG), Apr, 2000 Arguments: lLowQuotaWaterMark [in] - LowQuotaWaterMark to Set Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_LowQuotaWaterMark"), hr, _T("%ld"), lLowQuotaWaterMark); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_lLowQuotaWaterMark = lLowQuotaWaterMark; return hr; } // //================= AGE LIMIT =============================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_AgeLimit( long *plAgeLimit ) /*++ Routine name : CFaxArchiveInner::get_AgeLimit Routine description: Return how long in days Fax Message is stored at Fax Server Author: Iv Garber (IvG), Apr, 2000 Arguments: plAgeLimit [out] - AgeLimit Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_AgeLimit"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plAgeLimit, m_lAgeLimit); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::put_AgeLimit( long lAgeLimit ) /*++ Routine name : CFaxArchiveInner::put_AgeLimit Routine description: Set AgeLimit Author: Iv Garber (IvG), Apr, 2000 Arguments: lAgeLimit [in] - AgeLimit to Set Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (_T("CFaxArchiveInner::put_AgeLimit"), hr, _T("%ld"), lAgeLimit); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } m_lAgeLimit = lAgeLimit; return hr; } // //================= SIZE ============================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_SizeLow( long *plSizeLow ) /*++ Routine name : CFaxArchiveInner::get_SizeLow Routine description: Return Size in Bytes of the Archive Author: Iv Garber (IvG), May, 2000 Arguments: plSizeLow [out] - Ptr to the place to put the Size in Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_SizeLow"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plSizeLow, long(m_uliSize.LowPart)); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::get_SizeHigh( long *plSizeHigh ) /*++ Routine name : CFaxArchiveInner::get_SizeHigh Routine description: Return Size in Bytes of the Archive Author: Iv Garber (IvG), May, 2000 Arguments: plSizeHigh [out] - Ptr to the place to put the Size in Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::get_SizeHigh"), hr); // // Initialize before first use // if (!m_bInitialized) { hr = Refresh(); if (FAILED(hr)) { return hr; } } hr = GetLong(plSizeHigh, long(m_uliSize.HighPart)); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } // //========================= SAVE ==================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::Save( ) /*++ Routine name : CFaxArchiveInner::Save Routine description: Save the Archive's Configuration Author: Iv Garber (IvG), Apr, 2000 Arguments: Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; HANDLE hFaxHandle = NULL; FAX_ARCHIVE_CONFIG FaxArchiveConfig; DBG_ENTER (_T("CFaxArchiveInner::Save"), hr); // // Get Fax Server Handle // hr = GetFaxHandle(&hFaxHandle); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } if (hFaxHandle == NULL) { // // Fax Server Is Not Connected // hr = E_HANDLE; AtlReportError(*pcid, IDS_ERROR_SERVER_NOT_CONNECTED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("hFaxHandle == NULL"), hr); return hr; } // // FaxArchiveConfig.dwlArchiveSize is ignored for SetConfiguration() // FaxArchiveConfig.dwSizeOfStruct = sizeof(FAX_ARCHIVE_CONFIG); FaxArchiveConfig.bUseArchive = VARIANT_BOOL2bool(m_bUseArchive); FaxArchiveConfig.bSizeQuotaWarning = VARIANT_BOOL2bool(m_bSizeQuotaWarning); FaxArchiveConfig.dwSizeQuotaHighWatermark = m_lHighQuotaWaterMark; FaxArchiveConfig.dwSizeQuotaLowWatermark = m_lLowQuotaWaterMark; FaxArchiveConfig.dwAgeLimit = m_lAgeLimit; FaxArchiveConfig.lpcstrFolder = m_bstrArchiveFolder; if ( 0 == ::FaxSetArchiveConfiguration(hFaxHandle, ArchiveType, &FaxArchiveConfig)) { // // Failed to Set Archive Configuration // hr = Fax_HRESULT_FROM_WIN32(GetLastError()); AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("::FaxSetArchiveConfiguration()"), hr); return hr; } return hr; } // //=============== GET MESSAGE ======================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::GetMessage( BSTR bstrMessageId, MsgIfc **ppFaxMessage ) /*++ Routine name : CFaxArchiveInner::GetMessage Routine description: Return Message by given Id Author: Iv Garber (IvG), May, 2000 Arguments: bstrMessageId [in] - Id of the Message to return ppFaxMessage [out] - Ptr to the place to put the Message Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::GetMessage"), hr, _T("%s"), bstrMessageId); // // Check that we can write to the given pointer // if (::IsBadWritePtr(ppFaxMessage, sizeof(MsgIfc *))) { // // Got Bad Return Pointer // hr = E_POINTER; AtlReportError(*pcid, IDS_ERROR_INVALID_ARGUMENT, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("::IsBadWritePtr"), hr); return hr; } // // Get Fax Server Handle // HANDLE hFaxHandle = NULL; hr = GetFaxHandle(&hFaxHandle); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } // // convert Message Id that we've got to hexadecimal DWORDLONG // DWORDLONG dwlMsgId; int iParsed = _stscanf (bstrMessageId, _T("%I64x"), &dwlMsgId); if ( iParsed != 1) { // // Failed to conver the number // hr = E_INVALIDARG; CALL_FAIL(GENERAL_ERR, _T("_stscanf()"), hr); AtlReportError(*pcid, IDS_ERROR_INVALIDMSGID, *piid, hr, _Module.GetResourceInstance()); return hr; } CFaxPtr<FAX_MESSAGE> pFaxPtrMessage; if (!FaxGetMessage(hFaxHandle, dwlMsgId, ArchiveType, &pFaxPtrMessage)) { // // Failed to retrieve the Message // hr = Fax_HRESULT_FROM_WIN32(GetLastError()); AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("FaxGetMessage()"), hr); return hr; } // // Check that pFaxPtrMessage is valid // if (!pFaxPtrMessage || pFaxPtrMessage->dwSizeOfStruct != sizeof(FAX_MESSAGE)) { // // Failed to Get Message // hr = E_FAIL; AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("Invalid pFaxMessage"), hr); return hr; } // // Create Message Object // CComPtr<MsgIfc> pTmpMessage; hr = MsgType::Create(&pTmpMessage); if (FAILED(hr)) { // // Failed to create the Message object // AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("MsgType::Create()"), hr); return hr; } // // Initialize the Message Object // hr = ((MsgType *)((MsgIfc *)pTmpMessage))->Init(pFaxPtrMessage, m_pIFaxServerInner); if (FAILED(hr)) { // // Failed to Init the Message Object // AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("<casted>pTmpMessage->Init(pFaxMessage, m_pIFaxServerInner)"), hr); return hr; } // // Return Message Object to the Caller // hr = pTmpMessage.CopyTo(ppFaxMessage); if (FAILED(hr)) { // // Failed to Copy Interface // AtlReportError(*pcid, IDS_ERROR_OPERATION_FAILED, *piid, hr, _Module.GetResourceInstance()); CALL_FAIL(GENERAL_ERR, _T("CComPtr::CopyTo"), hr); return hr; } return hr; } // //========================= GET MESSAGES ============================================== // template <class T, const IID* piid, const CLSID* pcid, FAX_ENUM_MESSAGE_FOLDER ArchiveType, class MsgIfc, class MsgType, class IteratorIfc, class IteratorType> STDMETHODIMP CFaxArchiveInner<T, piid, pcid, ArchiveType, MsgIfc, MsgType, IteratorIfc, IteratorType> ::GetMessages( long lPrefetchSize, IteratorIfc **ppFaxMessageIterator ) /*++ Routine name : CFaxArchiveInner::GetMessages Routine description: Return Iterator on Archive's Messages. Author: Iv Garber (IvG), May, 2000 Arguments: lPrefetchSize [in] - Size of Prefetch Buffer for Messages. ppFaxMessageIterator [out] - Ptr to place to put Iterator Object Return Value: Standard HRESULT code --*/ { HRESULT hr = S_OK; DBG_ENTER (TEXT("CFaxArchiveInner::GetMessages"), hr); CObjectHandler<IteratorType, IteratorIfc> objectCreator; hr = objectCreator.GetObject(ppFaxMessageIterator, m_pIFaxServerInner); if (FAILED(hr)) { AtlReportError(*pcid, GetErrorMsgId(hr), *piid, hr, _Module.GetResourceInstance()); return hr; } return hr; } #endif //__FAXARCHIVEINNER_H_
3ac1a8c5d1c21ca940a0c014311ea5ce09865c82
1af49694004c6fbc31deada5618dae37255ce978
/chrome/browser/signin/e2e_tests/test_accounts_util.cc
c533ea0fb3cebc945a426009d85557f095096d58
[ "BSD-3-Clause" ]
permissive
sadrulhc/chromium
59682b173a00269ed036eee5ebfa317ba3a770cc
a4b950c23db47a0fdd63549cccf9ac8acd8e2c41
refs/heads/master
2023-02-02T07:59:20.295144
2020-12-01T21:32:32
2020-12-01T21:32:32
317,678,056
3
0
BSD-3-Clause
2020-12-01T21:56:26
2020-12-01T21:56:25
null
UTF-8
C++
false
false
2,396
cc
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/signin/e2e_tests/test_accounts_util.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_reader.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" using base::Value; namespace signin { namespace test { #if defined(OS_WIN) std::string kPlatform = "win"; #elif defined(OS_MAC) std::string kPlatform = "mac"; #elif BUILDFLAG(IS_CHROMEOS_ASH) std::string kPlatform = "chromeos"; #elif defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS) std::string kPlatform = "linux"; #elif defined(OS_ANDROID) std::string kPlatform = "android"; #else std::string kPlatform = "all_platform"; #endif TestAccountsUtil::TestAccountsUtil() = default; TestAccountsUtil::~TestAccountsUtil() = default; bool TestAccountsUtil::Init(const base::FilePath& config_path) { int error_code = 0; std::string error_str; JSONFileValueDeserializer deserializer(config_path); std::unique_ptr<Value> content_json = deserializer.Deserialize(&error_code, &error_str); CHECK(error_code == 0) << "Error reading json file. Error code: " << error_code << " " << error_str; CHECK(content_json); // Only store platform specific users. If an account does not have // platform specific user, try to use all_platform user. for (auto account : content_json->DictItems()) { const Value* platform_account = account.second.FindDictKey(kPlatform); if (platform_account == nullptr) { platform_account = account.second.FindDictKey("all_platform"); if (platform_account == nullptr) { continue; } } TestAccount ta(*(platform_account->FindStringKey("user")), *(platform_account->FindStringKey("password"))); all_accounts_.insert( std::pair<std::string, TestAccount>(account.first, ta)); } return true; } bool TestAccountsUtil::GetAccount(const std::string& name, TestAccount& out_account) const { auto it = all_accounts_.find(name); if (it == all_accounts_.end()) { return false; } out_account = it->second; return true; } } // namespace test } // namespace signin
8df1f80cbf39d16c93339251558049793177ad65
733da9a1460ea0fbddcfb2723ef5737ed5157796
/01/test1.cpp
7aff96da34f0aa4f0f7fce95a98dd707ccc569ee
[]
no_license
RuslanNarziev/msu_cpp_spring_2020
6d6d71e57b8e27a365f02e52071290f853e1abea
848d742d536e41a9b1280ebc0931a6e7bfbd5d86
refs/heads/master
2022-10-23T20:00:39.960559
2020-06-11T16:48:00
2020-06-11T16:48:00
246,590,206
0
0
null
null
null
null
UTF-8
C++
false
false
232
cpp
#include "task1.h" int main() { Allocator al; al.MakeAllocator(1000); if(al.Get_startptr() != NULL) std::cout << "Memory has allocated"; else std::cout << "Memory has not allocated"; return 0; }
c3d3b121b6bf6728a4e2a66a38b6931eb7ba741e
afa181dce5c4f77a4f7bbc2740fc5063a018f694
/main.cpp
81e31978b7bf261a51fd73a18b95448d3abcf082
[]
no_license
romkas/UniRank
e9058d1a9ae60226a4bb032664ff5be6f1c81eea
4243bdf6317633904d618bf581a07a621df0502e
refs/heads/master
2021-01-10T04:22:58.599093
2018-02-04T12:51:37
2018-02-04T12:51:37
46,122,121
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,617
cpp
#include "Interface.h" #define DEBUG 0 using namespace std; int main() { setlocale(LC_ALL, "Russian"); list<VUZ> vList; const char* source = "C:\\Users\\ROM\\Desktop\\practise-2\\Source list.txt", * res = "C:\\Users\\ROM\\Desktop\\practise-2\\07-07-unite\\results_07-07-unite.txt", * res_baas = "C:\\Users\\ROM\\Desktop\\practise-2\\07-07-unite\\results_baas_07-07-unite.txt"; char c; cout<<"Reading file\n"; Readfile(source, vList); cout<<"Reading completed\n"; cout<<"Preparing\n"; Prepare(vList); cout<<"Prepared\n"; #if DEBUG == 1 const char filename[NUMSPECS + 1][STRLENG] = {"C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_common_07-04.txt", "C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_econom_07-04.txt", "C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_manag_07-04.txt", "C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_controls_07-04.txt", "C:\\Users\\ROM\\Desktop\\practise-2\\07-04\\testhist_inform_07-04.txt"}; cout<<"Recording histograms\n"; for(int k = 0;k < NUMSPECS + 1;k ++) for(Iter it = vList.begin(); it != vList.end(); it ++) if(it->h[k].numstudents > STUD_LIMIT) PrintHistogram(filename[k], *it, k); cout<<"Recorded\nEnd of debugging\n"; cin.get(); return 0; #else int histnum, indexnum; int mode,& m = mode; float** matrix = 0,**& mtx = matrix; PrintMenu(); while(true) { cout<<"<SELECT> "; cin>>c; cin.ignore(100, '\n'); switch( int(c)-int('0') ) { case(1): histnum = OnCountingJager(vList); indexnum = 0; SortJager(vList, histnum); PrintIndex(res, vList, histnum, indexnum); break; case(2): histnum = OnCountingCentroid(vList); indexnum = 1; SortCentr(vList, histnum); PrintIndex(res, vList, histnum, indexnum); break; case(3): histnum = OnCountingKerre(vList, m); // m = 2 или m = 3 SortmaxKerre(vList, histnum); PrintIndex(res, vList, histnum, mode); break; case(4): histnum = OnCountingBaas(vList, mtx); RangingBaas(vList, histnum, mtx); indexnum = 4; SortBaas(vList, histnum); PrintMatrix(res_baas, mtx, vList.size(), histnum); PrintIndex(res, vList, histnum, indexnum); DeleteBaasMatrix(mtx, vList.size()); break; case(5): histnum = OnCountingAvGrade(vList); indexnum = 5; SortAvGrade(vList, histnum); PrintIndex(res, vList, histnum, indexnum); break; case(6): histnum = OnCountingNumStud(vList); SortNumStud(vList, histnum); PrintNumStud(res, vList, histnum); break; case( int('q')-int('0') ): return 0; default: cout<<"Unknown option\n"; } } #endif }
4e1d0c0f373ee0028f2f7971539ab7acdf83d84c
077700c6755d112f7d22559eaec319ec049bb8ba
/Practise/Basic C++/Ch 6/Overloaded Constructures.cpp
93b1099e3dc1863e1d5c57febaebe924877fce2c
[]
no_license
vaibhavdangayachvd/CPP-Programming
ce106daec0380c64edc101dc5c21b31ea708e75f
1882814699c62f89ceee2826d15fa51a8410db6c
refs/heads/master
2020-04-07T16:25:54.854692
2019-05-28T00:06:18
2019-05-28T00:06:18
158,522,795
0
0
null
null
null
null
UTF-8
C++
false
false
624
cpp
#include<iostream> using namespace std; class complex_ { float x,y; public: complex_(){} complex_(float a){x=y=a;} complex_(float rear,float imag){x=rear,y=imag;} friend complex_ sum(complex_,complex_); friend void show(complex_); }; complex_ sum(complex_ c1,complex_ c2) { complex_ c3; c3.x=c1.x+c2.x; c3.y=c1.y+c3.y; return c3; } inline void show(complex_ c) { cout<<c.x<<" + j"<<c.y<<endl; } int main() { complex_ a(3.7,3.5); complex_ b(1.6); complex_ c; c=sum(a,b); cout<<"A = ";show(a); cout<<"B = ";show(b); cout<<"C = ";show(c); return 0; }
e9787321b56bcf364d58477b4f13ba8a4ac71ac0
6e3e4f6b43d308ca742d40acfec84e9985e75355
/动规/拆分问题/343_Integer Break.cpp
5016b1ce79410ea7680a5bcefad6439c3a8b135b
[]
no_license
HannahTin/Leetcode
a4a32700125333a10209f4401eec38d372aff1d4
6febfc026bf9b584e7b482b435dac7689fa2aa33
refs/heads/master
2022-05-28T16:04:51.393960
2022-03-20T08:22:57
2022-03-20T08:22:57
205,310,250
0
0
null
null
null
null
UTF-8
C++
false
false
1,338
cpp
/* 343. 整数拆分 给定一个正整数 n ,将其拆分为 k 个 正整数 的和( k >= 2 ),并使这些整数的乘积最大化。 返回 你可以获得的最大乘积 。 示例 1: 输入: n = 2 输出: 1 解释: 2 = 1 + 1, 1 × 1 = 1。 示例 2: 输入: n = 10 输出: 36 解释: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36。 */ using namespace std; #include <vector> class Solution { public: // 其实可以从1遍历j,然后有两种渠道得到dp[i]. // 一个是j * (i - j) 直接相乘。 // 一个是j * dp[i - j],相当于是拆分(i - j),对这个拆分不理解的话,可以回想dp数组的定义。 int integerBreak(int n) { vector<int> dp(n+1); dp[2]=1; for(int i=3;i<=n;i++){ for(int j=1;j<i-1;j++){ dp[i]=max(dp[i],max(dp[i-j]*j,j*(i-j))); } } return dp[n]; } }; class Solution { public: // 本题也可以用贪心,每次拆成n个3,如果剩下是4,则保留4,然后相乘,但是这个结论需要数学证明其合理性! int integerBreak(int n) { if (n == 2) return 1; if (n == 3) return 2; if (n == 4) return 4; int result = 1; while (n > 4) { result *= 3; n -= 3; } result *= n; return result; } };
7c27560a0c49fa5c6b919193f4ded9873816fd49
3a17418505f5c68564100f03caa789db2e214477
/testCases/Cavity/Hanhoun/non-ideality-comparison/cavity_stoich_MAPST_Gamma/435860/NH4
9b3012f38ec8ca2b420df5925a97c6d00771b868
[]
no_license
BJankauskas/mapFoam
2554798c7a4435c90e3f269e84c1c6e6109bb1e7
06200cf3a51da3e9a8d284d9df18f8634964dc1a
refs/heads/master
2020-05-24T16:31:26.833077
2019-05-21T18:40:15
2019-05-21T18:40:15
187,356,603
1
0
null
null
null
null
UTF-8
C++
false
false
1,139
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 4.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "435860"; object NH4; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField uniform 1.24819e-05; boundaryField { fixedWalls { type zeroGradient; } frontAndBack { type empty; } movingWall { type zeroGradient; } } // ************************************************************************* //
68464369f577cad7d0a68a563fd62aa5c208355b
8a75a84761d998fccb34f2d3b182c221ba01dbd5
/Other leetCode codes/4Sum/main.cpp
35b659d35cdeaa5ae2626f8c91bb76b7082e209f
[]
no_license
danqiuBear/Cplusplus-Demo
18eeda35585f4f6216605699043460f11ad941a6
37ffebbfbb231aca56753bbf78a9ecad506c63a2
refs/heads/master
2020-06-13T19:45:26.454893
2019-08-23T08:59:29
2019-08-23T08:59:29
194,769,443
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
4,210
cpp
#include"iostream" #include"vector" #include"algorithm" #include"unordered_map" using namespace std; class Solution{ public: vector<vector<int>> fourSum(vector<int> &nums, int target){ vector < vector<int>> result; if (nums.size() < 4) return result; sort(nums.begin(), nums.end()); unordered_map<int, vector<pair<int, int>>> cache; for (size_t a = 0; a < nums.size(); ++a){ for (size_t b = a + 1; b < nums.size(); ++b){ cache[nums[a] + nums[b]].push_back(pair<int, int>(a, b)); } } for (int c = 0; c < nums.size(); ++c){ for (size_t d = c + 1; d < nums.size(); ++d){ const int key = target - nums[c] - nums[d]; if (cache.find(key) == cache.end()) continue; const auto&vec = cache[key]; for (size_t k = 0; k < vec.size(); ++k){ if (c <= vec[k].second) continue;//ÓÐÖØµþ result.push_back({ nums[vec[k].first], nums[vec[k].second], nums[c], nums[d] }); } } } sort(result.begin(), result.end()); result.erase(unique(result.begin(), result.end()), result.end()); return result; } public: vector<vector<int>> fourSum2(vector<int> &nums, int target){ vector < vector<int>> result; if (nums.size() < 4) return result; sort(nums.begin(), nums.end()); unordered_multimap<int, pair<int, int>> cache; for (size_t i = 0; i < nums.size() - 1; ++i){ for (size_t j = i + 1; j < nums.size(); ++j){ cache.insert(make_pair(nums[i] + nums[j], make_pair(i, j))); } } for (unordered_multimap<int, pair<int, int>>::iterator i = cache.begin(); i != cache.end(); ++i){ int x = target - i->first; /* _Pairii equal_range(const key_type& _Keyval) { // find range equivalent to _Keyval in mutable hash table size_type _Bucket = _Hashval(_Keyval); for (_Unchecked_iterator _Where = _Begin(_Bucket); _Where != _End(_Bucket); ++_Where) if (!((_Traits&)*this)(this->_Kfn(*_Where), _Keyval)) { // found _First, look for end of range _Unchecked_iterator _First = _Where; for (; _Where != _End(_Bucket); ++_Where) if (((_Traits&)*this)(_Keyval, this->_Kfn(*_Where))) break; if (_First == _Where) break; return (_Pairii(_Make_iter(_First), _Make_iter(_Where))); } return (_Pairii(end(), end())); } */ //typedef pair<iterator, iterator> _Pairii; pair<unordered_multimap<int, pair<int, int>>::iterator, unordered_multimap<int, pair<int, int>>::iterator> range = cache.equal_range(x); for (auto j = range.first; j != range.second; ++j){ auto a = i->second.first; auto b = i->second.second; auto c = j->second.first; auto d = j->second.second; if (a != c && a != d && b != c && b != d){ vector<int> vec = { nums[a], nums[b], nums[c], nums[d] }; sort(vec.begin(), vec.end()); result.push_back(vec); } } } sort(result.begin(), result.end()); result.erase(unique(result.begin(), result.end()), result.end()); return result; } }; int main01() { Solution s; vector<int> v; v.push_back(1); v.push_back(0); v.push_back(-1); v.push_back(0); v.push_back(-2); v.push_back(2); int target = 0; vector<vector<int>> result = s.fourSum2(v, target); for (vector<vector<int>>::iterator i = result.begin(); i != result.end(); ++i){ for (int j = 0; j < (*i).size();++j){ cout << (*i)[j] << " "; } cout << endl; } system("pause"); return 1; } int main() { Solution s; vector<int> v; v.push_back(1); v.push_back(2); v.push_back(2); v.push_back(3); v.push_back(4); v.push_back(4); v.push_back(4); v.push_back(4); v.push_back(5); v.push_back(6); v.push_back(7); v.push_back(9); v.push_back(9); v.push_back(10); vector<int>::iterator i = prev(v.end()); cout <<"prev(v.end()) equals to :"<<(*i) << " "<< endl; vector<int>::iterator j = prev(v.end(),4); cout << "prev(v.end(),4) equals to :" << (*j) << " "<< endl; vector<int>::iterator k = lower_bound(v.begin(), v.end(), 4); cout << "lower_bound(v.begin(), v.end(), 4) equals to :" << (*k) << " "<< endl; cout << *(k + 4)<<endl; vector<int>::iterator m = upper_bound(v.begin(), v.end(), 4); cout << "upper_bound(v.begin(), v.end(), 4) equals to :" << (*m) << " " << endl; system("pause"); return 1; }
fac73cb7690518efa4dd0364f40d6fe5daa3fb19
667786dd8dacdf6828ff329419f377f9a2112c0b
/Problems/HackerRank/Algorithms/Implementation/Kangaroo.cpp
c7d2d203ddd445ca8b9ae3ccf8f44fec2001d201
[]
no_license
BedirT/Algorithms_and_DS
50de96c8e707422f51510eda0e155880d76eed0e
083a6325b8be70108832eda1bf43eb9f3b9eb011
refs/heads/master
2022-09-09T22:29:55.090031
2022-09-06T22:04:06
2022-09-06T22:04:06
51,181,386
45
27
null
2020-03-06T10:36:26
2016-02-05T23:46:56
C++
UTF-8
C++
false
false
556
cpp
//https://www.hackerrank.com/challenges/kangaroo #include <iostream> using namespace std; int main(){ int x1; int v1; int x2; int v2; cin >> x1 >> v1 >> x2 >> v2; set<int> st; int count = 0; bool did = false; if((v1 >= v2 && x1 > x2) || (v1 <= v2 && x1 < x2)); else{ for(int i = 1; i <= 10000 ; ++i){ if(x1 + v1*i == x2 + v2*i){ did = true; break; } } } if(did) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
38eab113c40502febb90a0b732cd993ab9ac75cf
640e4a63662602237df205f403f469819b960b3e
/ykt/src/upayposvr/ecardmain.pc
2fe2529d1f7805397009bf6950111f21d9de6da0
[]
no_license
paipeng/bank_interface
9663972170ca3340326e7a65bf8f2406532515b2
060faf778bbb084a5aa921b2b1d9d165968f1703
refs/heads/master
2023-03-20T10:36:46.112213
2014-04-14T10:03:59
2014-04-14T10:03:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,410
pc
#include <stdio.h> #include <iostream> #include <fstream> #include "logger_imp.h" #include "config_imp.h" #include "unitfunc.h" #include "unitprocess.h" #include<iostream> #include<string> #include<sstream> #include "ks_8583_reader.h" using namespace std; int main(int argc, char* argv[]) { char szVersion[64]; sprintf(szVersion, "ecardsvr %s (%s %s)", YKT_VERSION, __DATE__, __TIME__); const char short_opts[] = "vs"; int option; while((option = getopt(argc, argv, short_opts)) != -1) { switch(option) { case 'v': cout << szVersion << endl; return 0; case 's': break; default: cout << "invalid option" << endl; return -1; } } string conf = argv[0]; conf = conf + ".conf"; if(!init_config(conf)) { cout << "init config file "<<conf<<" faild" << endl; return -1; } if(!init_logger(config_obj.log_conf)) { cout << "log config file "<<config_obj.log_conf <<" "<< endl; return -2; } LOG(DEBUG, "init log OK"); char parserName[128]={0}; int ret=Ks8583Parser::Load8583Define("unionpaypos.dat",parserName); if(ret) { LOG(ERROR,"load unionpaypos.dat configfile failed! ret="<<ret); return ret; } LOG(DEBUG,"load "<<parserName<<" 8583 configfile OK"); LOG(INFO, "version:" << szVersion); UnitProcess Process; LOG(DEBUG, "start service"); Process.run(); return 0; } // vim: ts=2 et ft=cpp
053b8cc331fbaeaeb235e57d0d6a4c7f9797d3f3
a37c5c59364f16db8475db8a3bf237abcb12702f
/Part3/Chap07/07.QuadTree+FixCrack/Dib.cpp
9f6c76a68c872ce88357d58ef19013228d7f565b
[]
no_license
blastingzone/ComputerGraphicsAdvenced
915d3cab0375b4beb6cfad347fb5746f848eb77c
95c4b33c316a60e58754dfb4e873f49397aadbd1
refs/heads/master
2021-01-18T16:13:07.001810
2014-06-22T17:13:39
2014-06-22T17:13:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,426
cpp
// DIB module #include <windows.h> #include <stdio.h> #include <math.h> #include "dib.h" #define DEFAULT_XPIXELSPERMETER 3000 #define DEFAULT_YPIXELSPERMETER 3000 //////////////////////////////////////////////////////////////////////////////// // file io LPBYTE DibLoadHandle( LPSTR lpFileName ) { FILE *fp; BITMAPFILEHEADER bmfh; HGLOBAL hDib; LPBYTE lpDib; int nSize; fopen_s( &fp, lpFileName, "rb" ); if ( !fp ) return NULL; fread( &bmfh, sizeof(BITMAPFILEHEADER), 1, fp ); nSize = bmfh.bfSize - sizeof(BITMAPFILEHEADER); hDib = (HGLOBAL) GlobalAlloc( GMEM_FIXED, nSize ); lpDib = (LPBYTE) GlobalLock( hDib ); if ( !lpDib ) { fclose( fp ); return NULL; } fread( lpDib, nSize, 1, fp ); fclose( fp ); return lpDib; } bool DibSave( LPBYTE lpDib, LPSTR lpFileName ) { FILE *fp; BITMAPFILEHEADER bmfh; if ( !lpDib || !lpFileName ) return false; fopen_s( &fp, lpFileName, "wb" ); if ( !fp ) return false; bmfh.bfType = 0x4d42; bmfh.bfSize = sizeof(BITMAPFILEHEADER) + DIB_SIZE( lpDib ); bmfh.bfReserved1 = 0; bmfh.bfReserved2 = 0; bmfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + DIB_PALSIZE( lpDib ); fwrite( &bmfh, sizeof(BITMAPFILEHEADER), 1, fp ); fwrite( lpDib, DIB_SIZE( lpDib ), 1, fp ); fclose( fp ); return true; } //////////////////////////////////////////////////////////////////////////////// // creation LPBYTE DibCreateEmpty( int nBitsPerPixel, int nWidth, int nHeight ) { LPBITMAPINFOHEADER lpBMIH; LPBYTE lpDib; int nPal = nBitsPerPixel == 24 ? 0 : 1 << nBitsPerPixel; int nPalSize = sizeof(RGBQUAD) * nPal; int nLineSize = ALIGN_4B(nWidth * nBitsPerPixel / 8); DWORD dwSize = sizeof(BITMAPINFOHEADER) + nPalSize + nLineSize * nHeight; lpDib = new BYTE [dwSize]; memset( lpDib, 0xff, dwSize ); lpBMIH = DIB_HEADER(lpDib); lpBMIH->biSize = sizeof(BITMAPINFOHEADER); lpBMIH->biWidth = nWidth; lpBMIH->biHeight = nHeight; lpBMIH->biPlanes = 1; lpBMIH->biBitCount = nBitsPerPixel; lpBMIH->biCompression = BI_RGB; lpBMIH->biSizeImage = 0; lpBMIH->biXPelsPerMeter = DEFAULT_XPIXELSPERMETER; lpBMIH->biYPelsPerMeter = DEFAULT_YPIXELSPERMETER; lpBMIH->biClrUsed = nPal; lpBMIH->biClrImportant = nPal; RGBQUAD rgbQuad; int i; for ( i = 0; i < nPal; i++ ) { rgbQuad.rgbBlue = i; rgbQuad.rgbGreen = i; rgbQuad.rgbRed = i; rgbQuad.rgbReserved = 0; DIB_BMI( lpDib )->bmiColors[i] = rgbQuad; } return lpDib; } // WIN 16 버젼 라이브러리들과의 호환으로 준비. LPBYTE DibCreateEmptyHandle( int nBitsPerPixel, int nWidth, int nHeight ) { LPBITMAPINFOHEADER lpBMIH; HGLOBAL hDib; LPBYTE lpDib; int nPal = nBitsPerPixel == 24 ? 0 : 1 << nBitsPerPixel; int nPalSize = sizeof(RGBQUAD) * nPal; int nLineSize = ALIGN_4B(nWidth * nBitsPerPixel / 8); DWORD dwSize = sizeof(BITMAPINFOHEADER) + nPalSize + nLineSize * nHeight; hDib = (HGLOBAL) GlobalAlloc( GMEM_FIXED, dwSize ); lpDib = (LPBYTE) GlobalLock( hDib ); memset( lpDib, 0xff, dwSize ); lpBMIH = (LPBITMAPINFOHEADER) lpDib; lpBMIH->biSize = sizeof(BITMAPINFOHEADER); lpBMIH->biWidth = nWidth; lpBMIH->biHeight = nHeight; lpBMIH->biPlanes = 1; lpBMIH->biBitCount = nBitsPerPixel; lpBMIH->biCompression = BI_RGB; lpBMIH->biSizeImage = 0; lpBMIH->biXPelsPerMeter = DEFAULT_XPIXELSPERMETER; lpBMIH->biYPelsPerMeter = DEFAULT_YPIXELSPERMETER; lpBMIH->biClrUsed = nPal; lpBMIH->biClrImportant = nPal; RGBQUAD rgbQuad; int i; for ( i = 0; i < nPal; i++ ) { rgbQuad.rgbBlue = i; rgbQuad.rgbGreen = i; rgbQuad.rgbRed = i; rgbQuad.rgbReserved = 0; DIB_BMI( lpDib )->bmiColors[i] = rgbQuad; } return lpDib; } void DibDeleteHandle( LPBYTE lpSrc ) { if ( lpSrc ) { GlobalUnlock( lpSrc ); GlobalFree( lpSrc ); } } //////////////////////////////////////////////////////////////////////////////// // copy LPBYTE DibDuplicate( LPBYTE lpSrc ) { if ( !lpSrc ) return NULL; LPBYTE lpDib; DWORD dwSize = DIB_SIZE( lpSrc ); lpDib = new BYTE [dwSize]; if ( lpDib ) memcpy( lpDib, lpSrc, dwSize ); return lpDib; } LPBYTE DibDuplicateHandle( LPBYTE lpSrc ) { if ( !lpSrc ) return NULL; HGLOBAL hDib; LPBYTE lpDib; DWORD dwSize = DIB_SIZE( lpSrc ); hDib = (HGLOBAL) GlobalAlloc( GMEM_FIXED, dwSize ); lpDib = (LPBYTE) GlobalLock( hDib ); if ( lpDib ) memcpy( lpDib, lpSrc, dwSize ); return lpDib; } bool DibCopyRect( LPBYTE lpDstDib, int dstx, int dsty, LPBYTE lpSrcDib, LPRECT prSrc1 ) { if ( !lpDstDib || !lpSrcDib || DIB_BPP( lpDstDib ) != DIB_BPP( lpSrcDib ) ) return false; RECT rDst, rDst1, rDst2, rSrc2, rSrc; SetRect( &rSrc2, 0, 0, DIB_CX( lpSrcDib ), DIB_CY( lpSrcDib ) ); IntersectRect( &rSrc, prSrc1, &rSrc2 ); SetRect( &rDst1, 0, 0, rSrc.right - rSrc.left, rSrc.bottom - rSrc.top ); OffsetRect( &rDst1, dstx, dsty ); SetRect( &rDst2, 0, 0, DIB_CX( lpDstDib ), DIB_CY( lpDstDib ) ); IntersectRect( &rDst, &rDst1, &rDst2 ); LPBYTE lpSrc, lpDst; int y, nWidth = (rDst.right - rDst.left) * DIB_BPP( lpSrcDib ) / 8; for ( y = rDst.top; y < rDst.bottom; y++ ) { lpSrc = DIB_DATAXY_INV( lpSrcDib, rSrc.left, rSrc.top + y - rDst.top ); lpDst = DIB_DATAXY_INV( lpDstDib, rDst.left, y ); memcpy( lpDst, lpSrc, nWidth ); } return true; } bool DibCopyRectROP( LPBYTE lpDstDib, int dstx, int dsty, LPBYTE lpSrcDib, LPRECT prSrc1, DWORD dwROP ) { if ( !lpDstDib || !lpSrcDib || DIB_BPP( lpDstDib ) != DIB_BPP( lpSrcDib ) ) return false; RECT rDst, rDst1, rDst2, rSrc2, rSrc; SetRect( &rSrc2, 0, 0, DIB_CX( lpSrcDib ), DIB_CY( lpSrcDib ) ); IntersectRect( &rSrc, prSrc1, &rSrc2 ); SetRect( &rDst1, 0, 0, rSrc.right - rSrc.left, rSrc.bottom - rSrc.top ); OffsetRect( &rDst1, dstx, dsty ); SetRect( &rDst2, 0, 0, DIB_CX( lpDstDib ), DIB_CY( lpDstDib ) ); IntersectRect( &rDst, &rDst1, &rDst2 ); LPBYTE lpSrc, lpDst; int y, i, nWidth = (rDst.right - rDst.left) * DIB_BPP( lpSrcDib ) / 8; for ( y = rDst.top; y < rDst.bottom; y++ ) { lpSrc = DIB_DATAXY_INV( lpSrcDib, rSrc.left, rSrc.top + y - rDst.top ); lpDst = DIB_DATAXY_INV( lpDstDib, rDst.left, y ); switch ( dwROP ) { case SRCAND: for ( i = 0; i < nWidth; i++ ) { *lpDst = *lpDst & *lpSrc; lpDst++; lpSrc++; } break; case SRCPAINT: for ( i = 0; i < nWidth; i++ ) { *lpDst = *lpDst | *lpSrc; lpDst++; lpSrc++; } break; case SRCCOPY: memcpy( lpDst, lpSrc, nWidth ); break; default: break; } } return true; } bool DibCopy( LPBYTE lpDst, LPBYTE lpSrc ) { if ( !lpSrc || !lpDst || DIB_BPP( lpSrc ) != DIB_BPP( lpDst ) ) return false; if ( DIB_CX( lpSrc ) != DIB_CX( lpDst ) || DIB_CY( lpSrc ) != DIB_CY( lpDst ) ) return false; memcpy( DIB_DATA( lpDst ), DIB_DATA( lpSrc ), DIB_DATASIZE( lpSrc ) ); return true; } bool DibTile( LPBYTE lpSrcDib, LPBYTE lpTileDib ) { LPBYTE lpSrc, lpTile; int y, cx, cy, tcx, tcy, n, i, bytesps; if ( !lpSrcDib || !lpTileDib || DIB_BPP( lpSrcDib ) != DIB_BPP( lpTileDib ) ) return false; bytesps = DIB_BPP( lpSrcDib ) / 8; cx = DIB_CX( lpSrcDib ); cy = DIB_CY( lpSrcDib ); tcx = DIB_CX( lpTileDib ); tcy = DIB_CY( lpTileDib ); for ( y = 0; y < cy; y++ ) { lpTile = DIB_DATAXY_INV( lpTileDib, 0, y % tcy ); if ( cx > tcx ) { n = cx / tcx + (cx % tcx ? 1 : 0); for ( i = 0; i < n; i++ ) { lpSrc = DIB_DATAXY_INV( lpSrcDib, i * tcx, y ); memcpy( lpSrc, lpTile, min(cx - (i * tcx), tcx) * bytesps ); } } else { lpSrc = DIB_DATAXY_INV( lpSrcDib, 0, y ); memcpy( lpSrc, lpTile, cx * bytesps ); } } return true; } //////////////////////////////////////////////////////////////////////////////// // geometry LPBYTE DibFlipHandle( LPBYTE lpDib ) { if ( !lpDib ) return NULL; LPBYTE lpNewDib; int y; lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), DIB_CX( lpDib ), DIB_CY( lpDib ) ) ); if ( lpNewDib ) { for ( y = 0; y < DIB_CY( lpDib ); y++ ) { memcpy( DIB_DATAXY( lpNewDib, 0, y ), DIB_DATAXY_INV( lpDib, 0, y ), DIB_LINESIZE( lpDib ) ); } } return lpNewDib; } LPBYTE DibReverseHandle( LPBYTE lpDib ) { if ( !lpDib ) return NULL; LPBYTE lpNewDib, lpNewData, lpData; int x, y; lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), DIB_CX( lpDib ), DIB_CY( lpDib ) ) ); if ( lpNewDib ) { for ( y = 0; y < DIB_CY( lpDib ); y++ ) { lpData = DIB_DATAXY( lpDib, 0, y ); lpNewData = DIB_DATAXY( lpNewDib, DIB_CX( lpNewDib ) - 1, y ); if ( DIB_BPP( lpDib ) == 8 ) { for ( x = 0; x < DIB_CX( lpDib ); x++ ) *lpNewData-- = *lpData++; } else if ( DIB_BPP( lpDib ) == 24 ) { for ( x = 0; x < DIB_CX( lpDib ); x++ ) { *lpNewData = *lpData++; *(lpNewData + 1) = *lpData++; *(lpNewData + 2) = *lpData++; lpNewData -= 3; } } } } return lpNewDib; } LPBYTE DibRotateHandle( LPBYTE lpDib, float fDegree ) { if ( !lpDib ) return NULL; LPBYTE lpNewDib = NULL, lpNewData, lpData; int x, y, cx, cy; cx = DIB_CX( lpDib ); cy = DIB_CY( lpDib ); if ( fDegree == 90.0f ) { if ( !(lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), cy, cx ) )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpData = DIB_DATAXY( lpDib, 0, y ); lpNewData = DIB_DATAXY( lpNewDib, y, cx - 1 ); if ( DIB_BPP( lpDib ) == 8 ) { for ( x = 0; x < cx; x++, lpNewData -= ALIGN_4B( cy ) ) *lpNewData = *lpData++; } else if ( DIB_BPP( lpDib ) == 24 ) { for ( x = 0; x < cx; x++, lpNewData -= ALIGN_4B( cy * 3 ) ) { *lpNewData = *lpData++; *(lpNewData + 1) = *lpData++; *(lpNewData + 2) = *lpData++; } } } } else if ( fDegree == 180.0f ) { if ( !(lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), cx, cy ) )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpData = DIB_DATAXY( lpDib, 0, y ); lpNewData = DIB_DATAXY( lpNewDib, cx - 1, cy - 1 - y ); if ( DIB_BPP( lpDib ) == 8 ) { for ( x = 0; x < cx; x++, lpNewData-- ) *lpNewData = *lpData++; } else if ( DIB_BPP( lpDib ) == 24 ) { for ( x = 0; x < cx; x++, lpNewData -= 3 ) { *lpNewData = *lpData++; *(lpNewData + 1) = *lpData++; *(lpNewData + 2) = *lpData++; } } } } else if ( fDegree == 270.0f ) { if ( !(lpNewDib = (LPBYTE) GlobalLock( DibCreateEmptyHandle( DIB_BPP( lpDib ), cy, cx ) )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpData = DIB_DATAXY( lpDib, 0, y ); lpNewData = DIB_DATAXY( lpNewDib, cy - 1 - y, 0 ); if ( DIB_BPP( lpDib ) == 8 ) { for ( x = 0; x < cx; x++, lpNewData += ALIGN_4B( cy ) ) *lpNewData = *lpData++; } else if ( DIB_BPP( lpDib ) == 24 ) { for ( x = 0; x < cx; x++, lpNewData += ALIGN_4B( cy * 3 ) ) { *lpNewData = *lpData++; *(lpNewData + 1) = *lpData++; *(lpNewData + 2) = *lpData++; } } } } else // free angle { /* CLeadBitmap lBitmap; lBitmap.ConvertFromDIB( (LPBITMAPINFO)lpDib, lpDib ); lBitmap.Rotate( nNewWidth, nNewHeight ); lpNewDib = (LPBYTE) GlobalLock( lBitmap.ConvertToDIB() ); */ } return lpNewDib; } LPBYTE DibResizeHandle( LPBYTE lpDib, int nNewWidth, int nNewHeight ) { if ( !lpDib || nNewWidth <= 0 || nNewHeight <= 0 ) return NULL; return NULL; } LPBYTE DibReduce( LPBYTE lpSrcDib, int newCx, int newCy ) { LPBYTE lpDstDib, lpSrc, lpDst, lpTemp; float fXratio, fYratio; int x, y, cx, cy, nBps; if ( !lpSrcDib || newCx <= 0 || newCy <= 0 ) return NULL; cx = DIB_CX( lpSrcDib ); cy = DIB_CY( lpSrcDib ); nBps = DIB_BPP( lpSrcDib ); if ( nBps != 24 && nBps != 8 ) return NULL; fXratio = (float)cx / newCx; fYratio = (float)cy / newCy; if ( (lpDstDib = DibCreateEmpty( nBps, newCx, newCy )) == NULL ) return NULL; if ( nBps == 8 ) { for ( y = 0; y < newCy; y++ ) { lpSrc = DIB_ALPHAXY( lpSrcDib, 0, ((int)(y * fYratio)) ); lpDst = DIB_ALPHAXY( lpDstDib, 0, y ); for ( x = 0; x < newCx; x++ ) *lpDst++ = *(lpSrc + (int)(x * fXratio)); } } else if ( nBps == 24 ) { for ( y = 0; y < newCy; y++ ) { lpSrc = DIB_IMAGEXY( lpSrcDib, 0, ((int)(y * fYratio)) ); lpDst = DIB_IMAGEXY( lpDstDib, 0, y ); for ( x = 0; x < newCx; x++ ) { lpTemp = lpSrc + (int)(x * fXratio) * 3; *lpDst++ = *lpTemp++; *lpDst++ = *lpTemp++; *lpDst++ = *lpTemp++; } } } return lpDstDib; } //////////////////////////////////////////////////////////////////////////////// // convert format LPBYTE DibRGB2GRAYHandle( LPBYTE lpRgbDib ) { LPBYTE lpGrayDib, lpSrc, lpDst; int x, y, cx, cy; if ( !lpRgbDib || DIB_BPP( lpRgbDib ) != 24 ) return NULL; cx = DIB_CX( lpRgbDib ); cy = DIB_CY( lpRgbDib ); if ( !(lpGrayDib = DibCreateEmptyHandle( 8, cx, cy )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpSrc = DIB_DATA24XY( lpRgbDib, 0, y ); lpDst = DIB_DATA8XY( lpGrayDib, 0, y ); for ( x = 0; x < cx; x++ ) { *lpDst++ = (*lpSrc + *(lpSrc+1) + *(lpSrc+2))/3; lpSrc += 3; } } return lpGrayDib; } LPBYTE DibGRAY2RGBHandle( LPBYTE lpGrayDib ) { LPBYTE lpRgbDib, lpSrc, lpDst; int x, y, cx, cy; if ( !lpGrayDib || DIB_BPP( lpGrayDib ) != 8 ) return NULL; cx = DIB_CX( lpGrayDib ); cy = DIB_CY( lpGrayDib ); if ( !(lpRgbDib = DibCreateEmptyHandle( 24, cx, cy )) ) return NULL; for ( y = 0; y < cy; y++ ) { lpSrc = DIB_DATA8XY( lpGrayDib, 0, y ); lpDst = DIB_DATA24XY( lpRgbDib, 0, y ); for ( x = 0; x < cx; x++ ) { *lpDst++ = *lpSrc; *lpDst++ = *lpSrc; *lpDst++ = *lpSrc; lpSrc ++; } } return lpRgbDib; } //////////////////////////////////////////////////////////////////////////////// // etc bool DibPrint( HWND hwnd, LPBYTE lpDib, LPSTR lpszDevice, int nDevide ) { /* BITMAPHANDLE LBitmap; // Bitmap handle for the image HDC PrinterDC; // DC for the printer int nWidthAllowed, nHeightAllowed, nWidthFactor, nHeightFactor; // For size calculations int nWidthPrint, nHeightPrint; // nWidth and height of the printed image DOCINFO DocInfo; // Document information structure if ( !lpDib ) return false; PrinterDC = CreateDC( NULL, lpszDevice, NULL, NULL ); if ( !PrinterDC ) return false; L_InitBitmap( &LBitmap, 0, 0, DIB_BPP( lpDib ) ); L_ConvertFromDIB( &LBitmap, (LPBITMAPINFO)lpDib, DIB_DATA( lpDib ) ); // Initialize the document to be printed memset( &DocInfo, 0, sizeof(DocInfo) ); DocInfo.cbSize = sizeof(DocInfo); DocInfo.lpszDocName = "Portrait or Caricature"; // Initialize variables for fitting the image on half a page nWidthAllowed = GetDeviceCaps( PrinterDC, HORZRES ); nHeightAllowed = GetDeviceCaps( PrinterDC, VERTRES ); nHeightFactor = BITMAPHEIGHT( &LBitmap ); nWidthFactor = BITMAPWIDTH( &LBitmap ); // See if using the maximum width will make the image too tall if ( ((nWidthAllowed * nHeightFactor) / nWidthFactor) < nHeightAllowed ) { // Use the maximum width, and calculate the height value nWidthPrint = nWidthAllowed; nHeightPrint = nWidthPrint * nHeightFactor / nWidthFactor; } else { // Use the maximum height, and calculate the width value nHeightPrint = nHeightAllowed; nWidthPrint = nHeightPrint * nWidthFactor / nHeightFactor; } // Start the print job if ( StartDoc( PrinterDC, &DocInfo ) <= 0 ) { DeleteDC( PrinterDC ); return false; } StartPage( PrinterDC ); // Print image switch ( nDevide ) { case 4: case 9: case 16: { int n, x, y, cx, cy, m; n = (int)sqrt( (double)nDevide ); // devide number m = nWidthPrint/40; // margin cx = (nWidthPrint - m * 2)/n; cy = (nHeightPrint - m * 2)/n; for ( y = 0; y < n; y++ ) { for ( x = 0; x < n; x++ ) { L_PrintBitmapFast( PrinterDC, &LBitmap, x * cx + m, y * cy + m, cx, cy, FALSE ); } } // 재단선 그리기 HPEN hOldPen; hOldPen = (HPEN)SelectObject( PrinterDC, GetStockObject( BLACK_PEN ) ); for ( x = 0; x <= n; x++ ) { MoveToEx( PrinterDC, x * cx + m, 0, NULL ); // LineTo( PrinterDC, x * cx + m, m ); // MoveToEx( PrinterDC, x * cx + m, nHeightPrint - m, NULL ); LineTo( PrinterDC, x * cx + m, nHeightPrint ); } for ( y = 0; y <= n; y++ ) { MoveToEx( PrinterDC, 0, y * cy + m, NULL ); // LineTo( PrinterDC, m, y * cy + m ); // MoveToEx( PrinterDC, nWidthPrint - m, y * cy + m, NULL ); LineTo( PrinterDC, nWidthPrint, y * cy + m ); } SelectObject( PrinterDC, hOldPen ); } break; default: L_PrintBitmapFast( PrinterDC, &LBitmap, 1, 1, nWidthPrint, nHeightPrint, FALSE ); break; } L_FreeBitmap( &LBitmap ); // Flush the page and finish the print job EndPage( PrinterDC ); EndDoc( PrinterDC ); DeleteDC( PrinterDC ); return true; */ return false; } HRGN DibCreateRegion( LPBYTE lpDib, BYTE byColor ) { LPBYTE lpData; int x, y, cx, cy; DWORD dwMaxRect; RECT r; RGNDATA *pRd; HGLOBAL hMem; HRGN hRgn; if ( !lpDib || DIB_BPP( lpDib ) != 8 ) return NULL; cx = DIB_CX( lpDib ); cy = DIB_CY( lpDib ); dwMaxRect = 3000; hMem = GlobalAlloc( GMEM_FIXED, sizeof(RGNDATAHEADER) + sizeof(RECT) * dwMaxRect ); pRd = (RGNDATA *)GlobalLock( hMem ); pRd->rdh.dwSize = sizeof(RGNDATAHEADER); pRd->rdh.iType = RDH_RECTANGLES; pRd->rdh.nCount = 0; pRd->rdh.nRgnSize = 0; SetRect( &(pRd->rdh.rcBound), cx, cy, 0, 0 ); for ( y = 0; y < cy; y++ ) { lpData = DIB_DATA8XY_INV( lpDib, 0, y ); for ( x = 0; x < cx; x++ ) { if ( *lpData == byColor ) { // get run length rect r.left = x; r.top = r.bottom = y; while ( *lpData == byColor && x < cx ) { x++; lpData++; } r.right = x; // update bound rect if ( r.left < pRd->rdh.rcBound.left ) pRd->rdh.rcBound.left = r.left; if ( r.top < pRd->rdh.rcBound.top ) pRd->rdh.rcBound.top = r.top; if ( r.right > pRd->rdh.rcBound.right ) pRd->rdh.rcBound.right = r.right; if ( r.bottom > pRd->rdh.rcBound.bottom ) pRd->rdh.rcBound.bottom = r.bottom; memcpy( &pRd->Buffer[pRd->rdh.nCount++], &r, sizeof(RECT) ); if ( pRd->rdh.nCount >= dwMaxRect ) goto exitLoop; } lpData++; } } exitLoop: pRd->rdh.nRgnSize = sizeof(RECT) * pRd->rdh.nCount; hRgn = ExtCreateRegion( NULL, sizeof(RGNDATAHEADER) + sizeof(RECT) * pRd->rdh.nCount, pRd ); GlobalUnlock( hMem ); GlobalFree( hMem ); return hRgn; } bool DibAlphaMasking( LPBYTE lpDstDib, LPBYTE lpSrcDib, LPBYTE lpMaskDib ) { if ( !lpDstDib || !lpSrcDib || !lpMaskDib || DIB_BPP( lpSrcDib ) != DIB_BPP( lpMaskDib ) || DIB_BPP( lpDstDib ) != DIB_BPP( lpMaskDib ) || DIB_BPP( lpMaskDib ) != 8 ) return false; LPBYTE lpSrc, lpDst, lpMask; int x, y, cx, cy; cx = DIB_CX( lpMaskDib ); cy = DIB_CY( lpMaskDib ); if ( cx != DIB_CX( lpSrcDib ) || cy != DIB_CY( lpSrcDib ) || cx != DIB_CX( lpDstDib ) || cy != DIB_CY( lpDstDib ) ) return false; for ( y = 0; y < cy; y++ ) { lpSrc = DIB_DATAXY( lpSrcDib, 0, y ); lpDst = DIB_DATAXY( lpDstDib, 0, y ); lpMask = DIB_DATAXY( lpMaskDib, 0, y ); for ( x = 0; x < cx; x++ ) { *lpDst += (255 - *lpSrc) * *lpMask / 255; lpSrc++; lpDst++; lpMask++; } } return true; } //////////////////////////////////////////////////////////////////////////////// // filter bool DibInvert( LPBYTE lpSrcDib ) { LPBYTE lpSrc; int nSize, i; if ( !lpSrcDib ) return false; nSize = DIB_DATASIZE( lpSrcDib ); lpSrc = DIB_DATA( lpSrcDib ); for ( i = 0; i < nSize; i++, lpSrc++ ) *lpSrc = 0xff - *lpSrc; return true; }
853274b10388c9a87dae29e7c593aad1b110beb8
948f4e13af6b3014582909cc6d762606f2a43365
/testcases/juliet_test_suite/testcases/CWE36_Absolute_Path_Traversal/s04/testcases.h
2053b3349e375c5c71ecdc93ffbe03e9d64f9086
[]
no_license
junxzm1990/ASAN--
0056a341b8537142e10373c8417f27d7825ad89b
ca96e46422407a55bed4aa551a6ad28ec1eeef4e
refs/heads/master
2022-08-02T15:38:56.286555
2022-06-16T22:19:54
2022-06-16T22:19:54
408,238,453
74
13
null
2022-06-16T22:19:55
2021-09-19T21:14:59
null
UTF-8
C++
false
false
108,786
h
// NOTE - eventually this file will be automatically updated using a Perl script that understand // the naming of test case files, functions, and namespaces. #ifndef _TESTCASES_H #define _TESTCASES_H #ifdef __cplusplus extern "C" { #endif // declare C good and bad functions #ifndef OMITGOOD /* BEGIN-AUTOGENERATED-C-GOOD-FUNCTION-DECLARATIONS */ /* END-AUTOGENERATED-C-GOOD-FUNCTION-DECLARATIONS */ #endif // OMITGOOD #ifndef OMITBAD /* BEGIN-AUTOGENERATED-C-BAD-FUNCTION-DECLARATIONS */ /* END-AUTOGENERATED-C-BAD-FUNCTION-DECLARATIONS */ #endif // OMITBAD #ifdef __cplusplus } // end extern "C" #endif #ifdef __cplusplus // declare C++ namespaces and good and bad functions #ifndef OMITGOOD /* BEGIN-AUTOGENERATED-CPP-GOOD-FUNCTION-DECLARATIONS */ namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_01 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_02 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_03 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_04 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_05 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_06 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_07 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_08 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_09 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_10 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_11 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_12 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_13 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_14 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_15 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_16 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_17 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_18 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_21 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_22 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_31 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_32 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_33 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_34 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_41 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_42 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_43 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_44 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_45 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_51 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_52 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_53 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_54 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_61 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_62 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_63 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_64 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_65 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_66 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_67 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_68 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_72 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_73 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_74 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_81 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_82 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_83 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_84 { void good();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_84 { void good();} /* END-AUTOGENERATED-CPP-GOOD-FUNCTION-DECLARATIONS */ #endif // OMITGOOD #ifndef OMITBAD /* BEGIN-AUTOGENERATED-CPP-BAD-FUNCTION-DECLARATIONS */ namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_open_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_environment_w32CreateFile_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_fopen_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_open_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ifstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_01 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_02 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_03 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_04 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_05 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_06 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_07 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_08 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_09 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_10 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_11 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_12 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_13 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_14 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_15 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_16 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_17 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_18 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_21 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_22 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_31 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_32 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_33 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_34 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_41 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_42 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_43 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_44 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_45 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_51 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_52 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_53 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_54 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_61 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_62 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_63 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_64 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_65 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_66 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_67 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_68 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_72 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_73 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_74 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_81 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_82 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_83 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_84 { void bad();} namespace CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_ofstream_84 { void bad();} /* END-AUTOGENERATED-CPP-BAD-FUNCTION-DECLARATIONS */ #endif // OMITBAD #endif // __cplusplus #endif // _TESTCASES_H
04ed465116ac0efb1d47a98946432b12767dc9b7
d62df1592c497496d776c09b7394bc1a430d8f29
/src/client/TcpUser.cpp
af0ece6e23fa117697306f60809f69f9168fe9be
[ "MIT" ]
permissive
silent1603/boost-asio-udp-holepunching
0c9d23adf292fac9a4abc2151efbcdb37fd2dced
10acfa70ee23c0b9468ced7ceed935edf7c51aaf
refs/heads/main
2023-03-18T11:11:10.705038
2021-01-30T13:38:50
2021-01-30T13:38:50
null
0
0
null
null
null
null
ISO-8859-7
C++
false
false
2,023
cpp
/*****************************************************************//** * \file TcpUser.cpp * \brief * * \author wjden * \date January 2021 *********************************************************************/ #include "TcpUser.h" #include "network/UdpSocket.h" #include "server/SignalServerProtocol.h" static std::string GetIPString( UInt32 ip ) { unsigned char bytes[ 4 ]; bytes[ 0 ] = ip & 0xFF; bytes[ 1 ] = ( ip >> 8 ) & 0xFF; bytes[ 2 ] = ( ip >> 16 ) & 0xFF; bytes[ 3 ] = ( ip >> 24 ) & 0xFF; int ipString[ 4 ] = { bytes[ 3 ], bytes[ 2 ], bytes[ 1 ], bytes[ 0 ] }; return std::to_string( ipString[ 0 ] ) + "." + std::to_string( ipString[ 1 ] ) + "." + std::to_string( ipString[ 2 ] ) + "." + std::to_string( ipString[ 3 ] ); } TcpUser::TcpUser( boost::asio::io_context& ioContext, const tcp::resolver::results_type& endpoints ) : m_ioContext( ioContext ), m_tcpClient( std::make_shared< TcpClient >( ioContext, endpoints ) ) { m_tcpClient->SetReadCallback( std::bind( &TcpUser::OnRead, this, std::placeholders::_1 ) ); } void TcpUser::Write( const NetworkMessage& msg ) { m_tcpClient->Write( msg ); } void TcpUser::Close() { m_tcpClient->Close(); } void TcpUser::OnRead( NetworkMessage& networkMessage ) { networkMessage.ReadyToRead(); ProtocolId protocol = networkMessage.Read< ProtocolId >(); switch ( protocol ) { case ProtocolId::ProtocolUserAddressNotify: { UInt32 ip = networkMessage.Read< UInt32 >(); UInt32 port = networkMessage.Read< UInt16 >(); //ip port Γί°‘ std::string ipString = GetIPString( ip ); std::string portString = std::to_string( port ); UdpSocket udpSocket( m_ioContext, ipString, portString ); m_othersMutex.lock(); m_others.push_back( std::move( udpSocket ) ); m_othersMutex.unlock(); } break; default: break; } } void TcpUser::Broadcast( std::string msg ) { m_othersMutex.lock(); for ( auto& other : m_others ) { other.SendTo( msg.c_str(), msg.size() ); } m_othersMutex.unlock(); }
35d5e9313b6bad6f757846d58b00f4db7d3b06d2
d66dcbaa2d13697d67f750fd28b48a020ea66cc8
/sql_functions.cpp
92df7b9346d53974cb8058e99f06fb4b1b2955c3
[]
no_license
huhongbo/ospfscan
f61726bd34914ec2f6294b61adbda85484991160
10ca7c28033a40796f43dfdb7eac219da47db93f
refs/heads/master
2020-07-10T06:34:13.025195
2012-10-11T00:02:21
2012-10-11T00:02:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,908
cpp
#include "591.h" int insert_router(sqlite3 *db, ospf_t *ospf, ospf_lsa_t *lsa) { char sql[1024]; snprintf(sql, sizeof(sql), "INSERT OR REPLACE INTO routers (router_id, area) VALUES ('%s',%i)", inet_ntoa(lsa->ospf_lsa_adv_router),ospf->ospf_area.s_addr); char *error; int res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } sqlite3_free(error); return res; } int check_router_interface(sqlite3 *db, in_addr id, list<in_addr> links) { char query[1024] = "("; list<in_addr>::iterator it; char adv_router[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &id, adv_router, INET_ADDRSTRLEN); char lsa_ls_id[INET_ADDRSTRLEN]; for(it=links.begin(); it != links.end(); it++) { if(it != links.begin()) { strcat(query, ","); } inet_ntop(AF_INET, &(*it), lsa_ls_id, INET_ADDRSTRLEN); strcat(query, "'"); strcat(query, lsa_ls_id); strcat(query, "'"); } strcat(query, ")"); char sql[2048] = ""; snprintf(sql, sizeof(sql), "UPDATE interfaces SET valid = '0' WHERE router_id='%s' AND interface_id NOT IN %s", adv_router, query); printf("SQL: %s\n", sql); char *error; int res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } sqlite3_free(error); return res; } int insert_external_route(sqlite3 *db, ospf_lsa_t *lsa, ospf_as_external_lsa_t *external) { char sql[1024] = ""; char adv_router[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_adv_router), adv_router, INET_ADDRSTRLEN); char lsa_ls_id[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_ls_id), lsa_ls_id, INET_ADDRSTRLEN); char network[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(external->ospf_as_external_network), network, INET_ADDRSTRLEN); snprintf(sql, sizeof(sql), "SELECT count(*) FROM external WHERE router_id='%s' AND prefix='%s' AND prefix_mask='%s'", adv_router, lsa_ls_id, network); printf("%s\n", sql); char **results; int rows; int cols; char *err; //printf("%s\n", sql); int res = sqlite3_get_table(db, sql, &results, &rows, &cols, &err); if(atoi(results[1]) == 0) { snprintf(sql, sizeof(sql), "INSERT OR REPLACE INTO external (router_id, prefix, prefix_mask) VALUES ('%s','%s','%s')", adv_router, lsa_ls_id, network); char *error; res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } sqlite3_free(error); } sqlite3_free_table(results); return res; } int update_external_route(sqlite3 *db, ospf_lsa_t *lsa, ospf_as_external_lsa_t *external) { char sql[1024] = ""; char adv_router[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_adv_router), adv_router, INET_ADDRSTRLEN); char lsa_ls_id[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_ls_id), lsa_ls_id, INET_ADDRSTRLEN); char network[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(external->ospf_as_external_network), network, INET_ADDRSTRLEN); snprintf(sql, sizeof(sql), "UPDATE external SET expiry = '%i' WHERE router_id = '%s' AND prefix = '%s' AND prefix_mask = '%s'", (int)(time(NULL) + htons(lsa->ospf_lsa_age)), adv_router, lsa_ls_id, network); printf("SQL: %s\n", sql); printf("Current Time: %i \t Expiry Time: %i\n", (int)time(NULL), (int)(time(NULL) + htons(lsa->ospf_lsa_age))); char *error; int res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } sqlite3_free(error); return res; } int invalidateRoutes(sqlite3 *db, ospf_lsa_t *lsa, list<in_addr> routes) { return 0; } int numberOfResults(sqlite3 *db, char *zSQL) { int rows; sqlite3_get_table(db, zSQL, NULL, &rows, NULL, NULL); return rows; } int insert_router_interface(sqlite3 *db, ospf_lsa_t *lsa, ospf_link_t *link) { char sql[1024] = ""; char adv_router[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(lsa->ospf_lsa_adv_router), adv_router, INET_ADDRSTRLEN); char lsa_link_id[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(link->ospf_router_lsa_link_id), lsa_link_id, INET_ADDRSTRLEN); snprintf(sql, sizeof(sql), "SELECT count(*) FROM interfaces WHERE router_id='%s' AND interface_id='%s'", adv_router, lsa_link_id); char **results; int rows; int cols; char *err; //printf("%s\n", sql); int res = sqlite3_get_table(db, sql, &results, &rows, &cols, &err); if(atoi(results[1]) == 0) { snprintf(sql, sizeof(sql), "INSERT OR REPLACE INTO interfaces (router_id, interface_id, valid) VALUES ('%s','%s',1)", adv_router, lsa_link_id); char *error; res = sqlite3_exec(db, sql, NULL, NULL, &error); if(error != NULL) { printf("ERROR: %s\n", error); } printf("%s\n", sql); sqlite3_free(error); } sqlite3_free_table(results); return res; }
321c839042a0dd04e458296cbfd67dae77592e5f
81522472404dea65d77488778fa7e89990bf3453
/moveit_control/src/arm_moveit.cpp
b5bf9ba635d2c24f82da692ed033d643aac6d0dc
[ "MIT" ]
permissive
I-Quotient-Robotics/iqr_dual_jaco
b8a27a72943b4a3b179f2e90d2b30ecc70f4f90f
60e9d2de9eeb2f87b73c0eb6169b521b8d5bfc82
refs/heads/main
2023-08-22T23:58:29.452996
2021-03-24T06:14:04
2021-03-24T06:14:04
319,181,820
3
0
null
null
null
null
UTF-8
C++
false
false
5,052
cpp
#include <ros/ros.h> #include <string> #include <thread> #include <geometry_msgs/PoseStamped.h> #include <kinova_msgs/ArmPoseAction.h> #include <actionlib/client/simple_action_client.h> #include <std_msgs/Float64.h> #include <sensor_msgs/JointState.h> #include <geometry_msgs/Pose.h> #include <geometry_msgs/Twist.h> #include <geometry_msgs/PoseStamped.h> #include <geometry_msgs/TransformStamped.h> #include <kinova_msgs/ArmPoseAction.h> #include <actionlib/client/simple_action_client.h> #include <tf2/LinearMath/Quaternion.h> #include <tf2_ros/transform_listener.h> #include <tf2_ros/transform_broadcaster.h> #include <tf2_geometry_msgs/tf2_geometry_msgs.h> #include <moveit/move_group_interface/move_group_interface.h> #include <moveit/planning_scene_interface/planning_scene_interface.h> typedef actionlib::SimpleActionClient<kinova_msgs::ArmPoseAction> PoseClient; class PickTaskAction { public: ros::NodeHandle nh_; PoseClient pc_left_, pc_right_; moveit::planning_interface::PlanningSceneInterface planning_scene_interface; moveit::planning_interface::MoveGroupInterface robot_group; PickTaskAction(std::string name) : robot_group("robot_group"), pc_left_("left_arm_driver/pose_action/tool_pose", true), pc_right_("right_arm_driver/pose_action/tool_pose", true) { robot_group.setPlanningTime(5.0); } ~PickTaskAction(void) { } void ExcuteThread() { ros::AsyncSpinner spinner(3); spinner.start(); kinova_msgs::ArmPoseGoal eff_pose; // 末端沿z轴方向前移3cm eff_pose.pose.header.frame_id = "right_arm_end_effector"; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.03; eff_pose.pose.pose.position.z = 0.05; eff_pose.pose.pose.position.z = 0.05; eff_pose.pose.pose.orientation.w = 1.0; pc_right_.sendGoal(eff_pose); pc_right_.waitForResult(ros::Duration(0.0)); ros::WallDuration(1.0).sleep(); // 末端沿z轴方向后移5cm eff_pose.pose.header.frame_id = "right_arm_end_effector"; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = -0.03; eff_pose.pose.pose.position.z = -0.05; eff_pose.pose.pose.position.z = -0.05; eff_pose.pose.pose.orientation.w = 1.0; pc_right_.sendGoal(eff_pose); pc_right_.waitForResult(ros::Duration(0.0)); ros::WallDuration(1.0).sleep(); return; } void SetArmPose(moveit::planning_interface::MoveGroupInterface& move_group, std::vector<double>& joint_value) { move_group.setJointValueTarget(joint_value); move_group.move(); } void SetGripper(moveit::planning_interface::MoveGroupInterface& move_group, double value) { std::vector<double> gripper_pose(2); gripper_pose[0] = value; gripper_pose[1] = value; // gripper_pose[2] = value; move_group.setJointValueTarget(gripper_pose); move_group.move(); } void moveit() { ros::AsyncSpinner spinner(3); spinner.start(); // 从config.yaml参数表中读取预设关节位置 std::vector<double> arm_standby_pose_right(12); nh_.getParam("arm_pose/home", arm_standby_pose_right); std::vector<double> arm_place_pose_right(12); nh_.getParam("arm_pose/pick", arm_place_pose_right); // 收回到standby位置 ROS_INFO("joint control standby"); robot_group.setJointValueTarget(arm_standby_pose_right); robot_group.move(); ros::WallDuration(1.0).sleep(); // 抓取位置 ROS_INFO("joint control pick"); robot_group.setJointValueTarget(arm_place_pose_right); robot_group.move(); ros::WallDuration(1.0).sleep(); // 开启新线程,独立完成右臂的位置控制 std::thread thread(&PickTaskAction::ExcuteThread, this); thread.detach(); kinova_msgs::ArmPoseGoal eff_pose; // 末端沿z轴方向前移3cm eff_pose.pose.header.frame_id = "left_arm_end_effector"; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.03; eff_pose.pose.pose.orientation.w = 1.0; pc_left_.sendGoal(eff_pose); pc_left_.waitForResult(ros::Duration(0.0)); ros::WallDuration(1.0).sleep(); // 末端沿z轴方向后移3cm eff_pose.pose.header.frame_id = "left_arm_end_effector"; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = 0.0; eff_pose.pose.pose.position.z = -0.03; eff_pose.pose.pose.orientation.w = 1.0; pc_left_.sendGoal(eff_pose); pc_left_.waitForResult(ros::Duration(0.0)); ros::WallDuration(1.0).sleep(); // 收回到standby位置 ROS_INFO("joint control standby"); robot_group.setJointValueTarget(arm_standby_pose_right); robot_group.move(); ros::WallDuration(1.0).sleep(); return; } }; int main(int argc, char** argv) { ros::init(argc, argv, "arm_control_node"); ros::NodeHandle nh; PickTaskAction pick("pick_task"); pick.moveit(); ros::waitForShutdown(); return 0; }
2d851542da8912c2371ab40a785173ed3b026ac8
6831e4284e70cd4c05c6fb5c7c6ff64352a4b674
/kopt/swap/SimpleSegment.h
85f3fa5f176f63b3629dac49ac703155aff7142d
[]
no_license
wangshgeo/2opt
7b0e8b8d4ed95123b637ad2cc0573d3200cb6150
bb9199f669a0ed427c23d83d9935c0715ef9bd24
refs/heads/master
2020-12-27T23:49:29.703294
2020-02-04T19:57:46
2020-02-04T19:57:46
238,109,691
0
0
null
2020-02-04T02:52:32
2020-02-04T02:52:31
null
UTF-8
C++
false
false
187
h
#pragma once // The two ints represent city IDs that make up a segment. // The IDs are in no particular order. #include <array> using SimpleSegment = std::array<std::size_t, 2>;
1285ce7885120d7c1e312694f65dfaffc293ee3b
3c288a663126e0b920e1c281396ca650ce7b36d6
/RGB_2_LED/RGB_2_LED.ino
a0b923e1c4bc28df27959d7080bd612f727f6952
[]
no_license
enzoyoung1/L4
c743dec47b44ba54fcba7e6aa2ad01492edf3df6
ebe37784d524d86d9e6f9a0144389adad15e90b0
refs/heads/main
2023-04-20T16:53:17.866526
2021-05-14T19:27:27
2021-05-14T19:27:27
360,953,061
0
0
null
null
null
null
UTF-8
C++
false
false
443
ino
void setup() { Serial.begin(9600); } void loop() { int potenPin = A0; int ldrPin = A1; int potenValue = analogRead(potenPin); int ldrValue = analogRead(ldrPin); int poten = map(potenValue,0,1023,255,0); int ldr = map(ldrValue,0,950,255,0); if(poten > 10){ analogWrite(8, poten); }else{ digitalWrite(5,LOW); } analogWrite(9, ldr); Serial.println(ldrValue); Serial.println(potenValue); delay(2); }
c29d28ea6df51822aba67f69dd0959d578eeee7f
bb3d0592b9cdc7821b37ff3db2db764e8d15f83a
/Src/VkWrapper/Fence.cpp
f75a6626444f358e63150bf4c2f2d4f184a7bea9
[]
no_license
Vismar/Conure2D
7a464a24407d301f76fcd7ddfc1f7de8c30e4b54
e7f4a311a1096a10d465755b176ffc336c4d9f15
refs/heads/master
2022-05-01T22:42:32.973420
2021-02-27T20:17:13
2021-02-27T20:17:13
114,643,545
4
0
null
2019-03-12T12:20:29
2017-12-18T13:20:04
C++
UTF-8
C++
false
false
1,092
cpp
#include "Fence.hpp" #include <Utility/Assert.hpp> #include <Tracer/TraceScopeTimer.hpp> using namespace VkWrapper; // --------------------------------------------------------------------------------------------------------------------- Fence::Fence(VkDevice lDevice) : _lDevice(lDevice) , _fence(nullptr) { TraceIt; VkFenceCreateInfo createInfo = { .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .flags = VK_FENCE_CREATE_SIGNALED_BIT }; Assert(vkCreateFence(_lDevice, &createInfo, nullptr, &_fence) == VK_SUCCESS, "Failed to create fence"); } // --------------------------------------------------------------------------------------------------------------------- Fence::~Fence() { vkDestroyFence(_lDevice, _fence, nullptr); } // --------------------------------------------------------------------------------------------------------------------- const VkFence& Fence::GetHandle() const { return _fence; } // ---------------------------------------------------------------------------------------------------------------------
488ceaa61531dd92df1624e573d3e2a6bf248e97
98f10c77b9932915eb9f37d9cf79a83094342444
/URI/2018.cpp
b4171ffab5649ef7291300def7340fa6a5611583
[]
no_license
lucianovr/competitive-programming
b5ba55a5055e486862c0c8b62e61c86e41b8f2b8
bd95492bb8a14563603a5a2d74e3c1676a4a61e6
refs/heads/master
2022-09-10T04:54:07.417831
2020-05-28T00:33:36
2020-05-28T00:33:36
267,455,557
0
0
null
null
null
null
UTF-8
C++
false
false
3,081
cpp
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i(a); i < (b); i++) #define all(c) c.begin(), c.end() #define UNIQUE(c) \ { sort(ALL(c); (c).resize( unique(ALL(c))-c.begin() ); \ } #define pb push_back #define D(x) \ if (1) \ cout << __LINE__ << " " << #x " = " << (x) << endl; #define DVEC(v, n) \ { \ cout << #v << "[] ={ "; \ rep(i, 0, n) cout << v[i] << " "; \ cout << "}\n"; \ } #define mp make_pair #define fst first #define snd second typedef pair<int, int> ii; typedef long long ll; typedef vector<int> vi; typedef vector<ii> vii; const int INF = 0x3f3f3f3f; const double EPS = 1e-9; struct pais { string nome; int o, p, b; pais(){}; pais(string _nome, int _o, int _p, int _b) { nome = _nome; o = _o; p = _p; b = _b; } }; vector<pais> R; // ranking dos paises bool comp(pais A, pais B) { if (A.o > B.o) return true; if (A.o < B.o) return false; if (A.p > B.p) return true; if (A.p < B.p) return false; if (A.b > B.b) return true; if (A.b < B.b) return false; if (A.nome < B.nome) return true; if (A.nome > B.nome) return false; } int main() { string tipo, A, B, C; map<string, int> mapa; int id = 0; while (getline(cin, tipo)) { getline(cin, A); if (mapa.count(A) == 0) { mapa[A] = id; R.pb(pais(A, 1, 0, 0)); id++; } else R[mapa[A]].o++; getline(cin, B); if (mapa.count(B) == 0) { mapa[B] = id; R.pb(pais(B, 0, 1, 0)); id++; } else R[mapa[B]].p++; getline(cin, C); if (mapa.count(C) == 0) { mapa[C] = id; R.pb(pais(C, 0, 0, 1)); id++; } else R[mapa[C]].b++; } sort(R.begin(), R.end(), comp); cout << "Quadro de Medalhas\n"; rep(i, 0, R.size()) { cout << R[i].nome << " " << R[i].o << " " << R[i].p << " " << R[i].b << "\n"; } return 0; }
4fc3a19787a2d9eaaaab824a82e7d3902df045be
69ed1447b867b11b3ff841aeb10550fe138a2246
/SDK/Headers/CppDynamic/libamcf_dynamic - Copy.hpp
ff5328d7ff63bf5b5a68da62fa8e615058e13059
[ "BSD-3-Clause" ]
permissive
jakeread/AutodeskMachineControlFramework
926d492390773b57b64aee910412ee29db13a055
288b07db3df7b72b67f98040ccf6da9889123469
refs/heads/master
2023-08-23T03:07:07.311759
2021-08-06T17:35:16
2021-08-06T17:35:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
58,900
hpp
/*++ Copyright (C) 2021 Autodesk Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Autodesk Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTODESK INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This file has been generated by the Automatic Component Toolkit (ACT) version 1.7.0-develop. Abstract: This is an autogenerated C++-Header file in order to allow an easy use of Autodesk Machine Control Framework SDK Interface version: 1.0.0 */ #ifndef __LIBAMCF_CPPHEADER_DYNAMIC_CPP #define __LIBAMCF_CPPHEADER_DYNAMIC_CPP #include "libamcf_types.hpp" #include "libamcf_dynamic.h" #ifdef _WIN32 #include <windows.h> #else // _WIN32 #include <dlfcn.h> #endif // _WIN32 #include <string> #include <memory> #include <vector> #include <exception> #include <future> #include <mutex> namespace LibAMCF { /************************************************************************************************************************* Forward Declaration of all classes **************************************************************************************************************************/ class CWrapper; class CBase; class COperationResult; class CDataStream; class CStreamUpload; class CConnection; /************************************************************************************************************************* Declaration of deprecated class types **************************************************************************************************************************/ typedef CWrapper CLibAMCFWrapper; typedef CBase CLibAMCFBase; typedef COperationResult CLibAMCFOperationResult; typedef CDataStream CLibAMCFDataStream; typedef CStreamUpload CLibAMCFStreamUpload; typedef CConnection CLibAMCFConnection; /************************************************************************************************************************* Declaration of shared pointer types **************************************************************************************************************************/ typedef std::shared_ptr<CWrapper> PWrapper; typedef std::shared_ptr<CBase> PBase; typedef std::shared_ptr<COperationResult> POperationResult; typedef std::shared_ptr<CDataStream> PDataStream; typedef std::shared_ptr<CStreamUpload> PStreamUpload; typedef std::shared_ptr<CConnection> PConnection; /************************************************************************************************************************* Declaration of deprecated shared pointer types **************************************************************************************************************************/ typedef PWrapper PLibAMCFWrapper; typedef PBase PLibAMCFBase; typedef POperationResult PLibAMCFOperationResult; typedef PDataStream PLibAMCFDataStream; typedef PStreamUpload PLibAMCFStreamUpload; typedef PConnection PLibAMCFConnection; /************************************************************************************************************************* classParam Definition **************************************************************************************************************************/ template<class T> class classParam { private: const T* m_ptr; public: classParam(const T* ptr) : m_ptr (ptr) { } classParam(std::shared_ptr <T> sharedPtr) : m_ptr (sharedPtr.get()) { } LibAMCFHandle GetHandle() { if (m_ptr != nullptr) return m_ptr->handle(); return nullptr; } }; /************************************************************************************************************************* Class ELibAMCFException **************************************************************************************************************************/ class ELibAMCFException : public std::exception { protected: /** * Error code for the Exception. */ LibAMCFResult m_errorCode; /** * Error message for the Exception. */ std::string m_errorMessage; public: /** * Exception Constructor. */ ELibAMCFException(LibAMCFResult errorCode, const std::string & sErrorMessage) : m_errorMessage("LibAMCF Error " + std::to_string(errorCode) + " (" + sErrorMessage + ")") { m_errorCode = errorCode; } /** * Returns error code */ LibAMCFResult getErrorCode() const noexcept { return m_errorCode; } /** * Returns error message */ const char* what() const noexcept { return m_errorMessage.c_str(); } }; /************************************************************************************************************************* Class CInputVector **************************************************************************************************************************/ template <typename T> class CInputVector { private: const T* m_data; size_t m_size; public: CInputVector( const std::vector<T>& vec) : m_data( vec.data() ), m_size( vec.size() ) { } CInputVector( const T* in_data, size_t in_size) : m_data( in_data ), m_size(in_size ) { } const T* data() const { return m_data; } size_t size() const { return m_size; } }; // declare deprecated class name template<typename T> using CLibAMCFInputVector = CInputVector<T>; /************************************************************************************************************************* Class CWrapper **************************************************************************************************************************/ class CWrapper { public: CWrapper(void* pSymbolLookupMethod) { CheckError(nullptr, initWrapperTable(&m_WrapperTable)); CheckError(nullptr, loadWrapperTableFromSymbolLookupMethod(&m_WrapperTable, pSymbolLookupMethod)); CheckError(nullptr, checkBinaryVersion()); } CWrapper(const std::string &sFileName) { CheckError(nullptr, initWrapperTable(&m_WrapperTable)); CheckError(nullptr, loadWrapperTable(&m_WrapperTable, sFileName.c_str())); CheckError(nullptr, checkBinaryVersion()); } static PWrapper loadLibrary(const std::string &sFileName) { return std::make_shared<CWrapper>(sFileName); } static PWrapper loadLibraryFromSymbolLookupMethod(void* pSymbolLookupMethod) { return std::make_shared<CWrapper>(pSymbolLookupMethod); } ~CWrapper() { releaseWrapperTable(&m_WrapperTable); } inline void CheckError(CBase * pBaseClass, LibAMCFResult nResult); inline void GetVersion(LibAMCF_uint32 & nMajor, LibAMCF_uint32 & nMinor, LibAMCF_uint32 & nMicro); inline bool GetLastError(classParam<CBase> pInstance, std::string & sErrorMessage); inline void ReleaseInstance(classParam<CBase> pInstance); inline void AcquireInstance(classParam<CBase> pInstance); inline void InjectComponent(const std::string & sNameSpace, const LibAMCF_pvoid pSymbolAddressMethod); inline LibAMCF_pvoid GetSymbolLookupMethod(); inline PConnection CreateConnection(const std::string & sBaseURL); private: sLibAMCFDynamicWrapperTable m_WrapperTable; LibAMCFResult checkBinaryVersion() { LibAMCF_uint32 nMajor, nMinor, nMicro; GetVersion(nMajor, nMinor, nMicro); if ( (nMajor != LIBAMCF_VERSION_MAJOR) || (nMinor < LIBAMCF_VERSION_MINOR) ) { return LIBAMCF_ERROR_INCOMPATIBLEBINARYVERSION; } return LIBAMCF_SUCCESS; } LibAMCFResult initWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable); LibAMCFResult releaseWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable); LibAMCFResult loadWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName); LibAMCFResult loadWrapperTableFromSymbolLookupMethod(sLibAMCFDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod); friend class CBase; friend class COperationResult; friend class CDataStream; friend class CStreamUpload; friend class CConnection; }; /************************************************************************************************************************* Class CBase **************************************************************************************************************************/ class CBase { public: protected: /* Wrapper Object that created the class. */ CWrapper * m_pWrapper; /* Handle to Instance in library*/ LibAMCFHandle m_pHandle; std::mutex m_InstanceMutex; /* Checks for an Error code and raises Exceptions */ void CheckError(LibAMCFResult nResult) { if (m_pWrapper != nullptr) m_pWrapper->CheckError(this, nResult); } public: /** * CBase::CBase - Constructor for Base class. */ CBase(CWrapper * pWrapper, LibAMCFHandle pHandle) : m_pWrapper(pWrapper), m_pHandle(pHandle) { } /** * CBase::~CBase - Destructor for Base class. */ virtual ~CBase() { if (m_pWrapper != nullptr) m_pWrapper->ReleaseInstance(this); m_pWrapper = nullptr; } /** * CBase::handle - Returns handle to instance. */ LibAMCFHandle handle() const { return m_pHandle; } /** * CBase::wrapper - Returns wrapper instance. */ CWrapper * wrapper() const { return m_pWrapper; } friend class CWrapper; }; /************************************************************************************************************************* Class COperationResult **************************************************************************************************************************/ class COperationResult : public CBase { public: /** * COperationResult::COperationResult - Constructor for OperationResult class. */ COperationResult(CWrapper* pWrapper, LibAMCFHandle pHandle) : CBase(pWrapper, pHandle) { } inline bool WaitFor(const LibAMCF_uint32 nTimeOut); inline bool InProgress(); inline bool Success(); inline std::string GetErrorMessage(); }; /************************************************************************************************************************* Class CDataStream **************************************************************************************************************************/ class CDataStream : public CBase { public: /** * CDataStream::CDataStream - Constructor for DataStream class. */ CDataStream(CWrapper* pWrapper, LibAMCFHandle pHandle) : CBase(pWrapper, pHandle) { } inline std::string GetUUID(); inline std::string GetContextUUID(); inline std::string GetName(); inline std::string GetMimeType(); inline LibAMCF_uint64 GetSize(); }; /************************************************************************************************************************* Class CStreamUpload **************************************************************************************************************************/ class CStreamUpload : public CBase { public: /** * CStreamUpload::CStreamUpload - Constructor for StreamUpload class. */ CStreamUpload(CWrapper* pWrapper, LibAMCFHandle pHandle) : CBase(pWrapper, pHandle) { } inline POperationResult UploadData(const CInputVector<LibAMCF_uint8> & DataBuffer, const LibAMCF_uint32 nChunkSize); inline POperationResult UploadFile(const std::string & sFileName, const LibAMCF_uint32 nChunkSize); inline void BeginChunking(const LibAMCF_uint64 nDataSize); inline POperationResult UploadChunk(const CInputVector<LibAMCF_uint8> & DataBuffer); inline POperationResult FinishChunking(const CInputVector<LibAMCF_uint8> & DataBuffer); inline void GetStatus(LibAMCF_uint64 & nUploadSize, LibAMCF_uint64 & nUploadedBytes, bool & bFinished); inline PDataStream GetDataStream(); }; /************************************************************************************************************************* Class CConnection **************************************************************************************************************************/ class CConnection : public CBase { public: /** * CConnection::CConnection - Constructor for Connection class. */ CConnection(CWrapper* pWrapper, LibAMCFHandle pHandle) : CBase(pWrapper, pHandle) { } inline std::string GetBaseURL(); inline void SetTimeouts(const LibAMCF_uint32 nTimeout, const LibAMCF_uint32 nRetryCount); inline LibAMCF_uint32 GetTimeout(); inline LibAMCF_uint32 GetRetryCount(); inline POperationResult AuthenticateWithPassword(const std::string & sUserName, const std::string & sPassword); std::future<bool> asyncAuthenticateWithPassword(const std::string& sUserName, const std::string& sPassword); inline bool IsAuthenticated(); inline POperationResult RefreshAuthentication(); inline POperationResult Ping(); inline std::string GetAuthToken(); inline PStreamUpload CreateUpload(const std::string & sName, const std::string & sMimeType, const std::string & sUsageContext); }; /** * CWrapper::GetVersion - retrieves the binary version of this library. * @param[out] nMajor - returns the major version of this library * @param[out] nMinor - returns the minor version of this library * @param[out] nMicro - returns the micro version of this library */ inline void CWrapper::GetVersion(LibAMCF_uint32 & nMajor, LibAMCF_uint32 & nMinor, LibAMCF_uint32 & nMicro) { CheckError(nullptr,m_WrapperTable.m_GetVersion(&nMajor, &nMinor, &nMicro)); } /** * CWrapper::GetLastError - Returns the last error recorded on this object * @param[in] pInstance - Instance Handle * @param[out] sErrorMessage - Message of the last error * @return Is there a last error to query */ inline bool CWrapper::GetLastError(classParam<CBase> pInstance, std::string & sErrorMessage) { LibAMCFHandle hInstance = pInstance.GetHandle(); LibAMCF_uint32 bytesNeededErrorMessage = 0; LibAMCF_uint32 bytesWrittenErrorMessage = 0; bool resultHasError = 0; CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, 0, &bytesNeededErrorMessage, nullptr, &resultHasError)); std::vector<char> bufferErrorMessage(bytesNeededErrorMessage); CheckError(nullptr,m_WrapperTable.m_GetLastError(hInstance, bytesNeededErrorMessage, &bytesWrittenErrorMessage, &bufferErrorMessage[0], &resultHasError)); sErrorMessage = std::string(&bufferErrorMessage[0]); return resultHasError; } /** * CWrapper::ReleaseInstance - Releases shared ownership of an Instance * @param[in] pInstance - Instance Handle */ inline void CWrapper::ReleaseInstance(classParam<CBase> pInstance) { LibAMCFHandle hInstance = pInstance.GetHandle(); CheckError(nullptr,m_WrapperTable.m_ReleaseInstance(hInstance)); } /** * CWrapper::AcquireInstance - Acquires shared ownership of an Instance * @param[in] pInstance - Instance Handle */ inline void CWrapper::AcquireInstance(classParam<CBase> pInstance) { LibAMCFHandle hInstance = pInstance.GetHandle(); CheckError(nullptr,m_WrapperTable.m_AcquireInstance(hInstance)); } /** * CWrapper::InjectComponent - Injects an imported component for usage within this component * @param[in] sNameSpace - NameSpace of the injected component * @param[in] pSymbolAddressMethod - Address of the SymbolAddressMethod of the injected component */ inline void CWrapper::InjectComponent(const std::string & sNameSpace, const LibAMCF_pvoid pSymbolAddressMethod) { CheckError(nullptr,m_WrapperTable.m_InjectComponent(sNameSpace.c_str(), pSymbolAddressMethod)); bool bNameSpaceFound = false; if (!bNameSpaceFound) throw ELibAMCFException(LIBAMCF_ERROR_COULDNOTLOADLIBRARY, "Unknown namespace " + sNameSpace); } /** * CWrapper::GetSymbolLookupMethod - Returns the address of the SymbolLookupMethod * @return Address of the SymbolAddressMethod */ inline LibAMCF_pvoid CWrapper::GetSymbolLookupMethod() { LibAMCF_pvoid resultSymbolLookupMethod = 0; CheckError(nullptr,m_WrapperTable.m_GetSymbolLookupMethod(&resultSymbolLookupMethod)); return resultSymbolLookupMethod; } /** * CWrapper::CreateConnection - Creates a AMCF connection instance. * @param[in] sBaseURL - Base URL of the AMCF Instance. * @return New Connection instance */ inline PConnection CWrapper::CreateConnection(const std::string & sBaseURL) { LibAMCFHandle hInstance = nullptr; CheckError(nullptr,m_WrapperTable.m_CreateConnection(sBaseURL.c_str(), &hInstance)); if (!hInstance) { CheckError(nullptr,LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<CConnection>(this, hInstance); } inline void CWrapper::CheckError(CBase * pBaseClass, LibAMCFResult nResult) { if (nResult != 0) { std::string sErrorMessage; if (pBaseClass != nullptr) { GetLastError(pBaseClass, sErrorMessage); } throw ELibAMCFException(nResult, sErrorMessage); } } inline LibAMCFResult CWrapper::initWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable) { if (pWrapperTable == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; pWrapperTable->m_LibraryHandle = nullptr; pWrapperTable->m_OperationResult_WaitFor = nullptr; pWrapperTable->m_OperationResult_InProgress = nullptr; pWrapperTable->m_OperationResult_Success = nullptr; pWrapperTable->m_OperationResult_GetErrorMessage = nullptr; pWrapperTable->m_DataStream_GetUUID = nullptr; pWrapperTable->m_DataStream_GetContextUUID = nullptr; pWrapperTable->m_DataStream_GetName = nullptr; pWrapperTable->m_DataStream_GetMimeType = nullptr; pWrapperTable->m_DataStream_GetSize = nullptr; pWrapperTable->m_StreamUpload_UploadData = nullptr; pWrapperTable->m_StreamUpload_UploadFile = nullptr; pWrapperTable->m_StreamUpload_BeginChunking = nullptr; pWrapperTable->m_StreamUpload_UploadChunk = nullptr; pWrapperTable->m_StreamUpload_FinishChunking = nullptr; pWrapperTable->m_StreamUpload_GetStatus = nullptr; pWrapperTable->m_StreamUpload_GetDataStream = nullptr; pWrapperTable->m_Connection_GetBaseURL = nullptr; pWrapperTable->m_Connection_SetTimeouts = nullptr; pWrapperTable->m_Connection_GetTimeout = nullptr; pWrapperTable->m_Connection_GetRetryCount = nullptr; pWrapperTable->m_Connection_AuthenticateWithPassword = nullptr; pWrapperTable->m_Connection_IsAuthenticated = nullptr; pWrapperTable->m_Connection_RefreshAuthentication = nullptr; pWrapperTable->m_Connection_Ping = nullptr; pWrapperTable->m_Connection_GetAuthToken = nullptr; pWrapperTable->m_Connection_CreateUpload = nullptr; pWrapperTable->m_GetVersion = nullptr; pWrapperTable->m_GetLastError = nullptr; pWrapperTable->m_ReleaseInstance = nullptr; pWrapperTable->m_AcquireInstance = nullptr; pWrapperTable->m_InjectComponent = nullptr; pWrapperTable->m_GetSymbolLookupMethod = nullptr; pWrapperTable->m_CreateConnection = nullptr; return LIBAMCF_SUCCESS; } inline LibAMCFResult CWrapper::releaseWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable) { if (pWrapperTable == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; if (pWrapperTable->m_LibraryHandle != nullptr) { #ifdef _WIN32 HMODULE hModule = (HMODULE) pWrapperTable->m_LibraryHandle; FreeLibrary(hModule); #else // _WIN32 dlclose(pWrapperTable->m_LibraryHandle); #endif // _WIN32 return initWrapperTable(pWrapperTable); } return LIBAMCF_SUCCESS; } inline LibAMCFResult CWrapper::loadWrapperTable(sLibAMCFDynamicWrapperTable * pWrapperTable, const char * pLibraryFileName) { if (pWrapperTable == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; if (pLibraryFileName == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; #ifdef _WIN32 // Convert filename to UTF16-string int nLength = (int)strlen(pLibraryFileName); int nBufferSize = nLength * 2 + 2; std::vector<wchar_t> wsLibraryFileName(nBufferSize); int nResult = MultiByteToWideChar(CP_UTF8, 0, pLibraryFileName, nLength, &wsLibraryFileName[0], nBufferSize); if (nResult == 0) return LIBAMCF_ERROR_COULDNOTLOADLIBRARY; HMODULE hLibrary = LoadLibraryW(wsLibraryFileName.data()); if (hLibrary == 0) return LIBAMCF_ERROR_COULDNOTLOADLIBRARY; #else // _WIN32 void* hLibrary = dlopen(pLibraryFileName, RTLD_LAZY); if (hLibrary == 0) return LIBAMCF_ERROR_COULDNOTLOADLIBRARY; dlerror(); #endif // _WIN32 #ifdef _WIN32 pWrapperTable->m_OperationResult_WaitFor = (PLibAMCFOperationResult_WaitForPtr) GetProcAddress(hLibrary, "libamcf_operationresult_waitfor"); #else // _WIN32 pWrapperTable->m_OperationResult_WaitFor = (PLibAMCFOperationResult_WaitForPtr) dlsym(hLibrary, "libamcf_operationresult_waitfor"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_OperationResult_WaitFor == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_OperationResult_InProgress = (PLibAMCFOperationResult_InProgressPtr) GetProcAddress(hLibrary, "libamcf_operationresult_inprogress"); #else // _WIN32 pWrapperTable->m_OperationResult_InProgress = (PLibAMCFOperationResult_InProgressPtr) dlsym(hLibrary, "libamcf_operationresult_inprogress"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_OperationResult_InProgress == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_OperationResult_Success = (PLibAMCFOperationResult_SuccessPtr) GetProcAddress(hLibrary, "libamcf_operationresult_success"); #else // _WIN32 pWrapperTable->m_OperationResult_Success = (PLibAMCFOperationResult_SuccessPtr) dlsym(hLibrary, "libamcf_operationresult_success"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_OperationResult_Success == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_OperationResult_GetErrorMessage = (PLibAMCFOperationResult_GetErrorMessagePtr) GetProcAddress(hLibrary, "libamcf_operationresult_geterrormessage"); #else // _WIN32 pWrapperTable->m_OperationResult_GetErrorMessage = (PLibAMCFOperationResult_GetErrorMessagePtr) dlsym(hLibrary, "libamcf_operationresult_geterrormessage"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_OperationResult_GetErrorMessage == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetUUID = (PLibAMCFDataStream_GetUUIDPtr) GetProcAddress(hLibrary, "libamcf_datastream_getuuid"); #else // _WIN32 pWrapperTable->m_DataStream_GetUUID = (PLibAMCFDataStream_GetUUIDPtr) dlsym(hLibrary, "libamcf_datastream_getuuid"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetUUID == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetContextUUID = (PLibAMCFDataStream_GetContextUUIDPtr) GetProcAddress(hLibrary, "libamcf_datastream_getcontextuuid"); #else // _WIN32 pWrapperTable->m_DataStream_GetContextUUID = (PLibAMCFDataStream_GetContextUUIDPtr) dlsym(hLibrary, "libamcf_datastream_getcontextuuid"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetContextUUID == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetName = (PLibAMCFDataStream_GetNamePtr) GetProcAddress(hLibrary, "libamcf_datastream_getname"); #else // _WIN32 pWrapperTable->m_DataStream_GetName = (PLibAMCFDataStream_GetNamePtr) dlsym(hLibrary, "libamcf_datastream_getname"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetName == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetMimeType = (PLibAMCFDataStream_GetMimeTypePtr) GetProcAddress(hLibrary, "libamcf_datastream_getmimetype"); #else // _WIN32 pWrapperTable->m_DataStream_GetMimeType = (PLibAMCFDataStream_GetMimeTypePtr) dlsym(hLibrary, "libamcf_datastream_getmimetype"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetMimeType == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_DataStream_GetSize = (PLibAMCFDataStream_GetSizePtr) GetProcAddress(hLibrary, "libamcf_datastream_getsize"); #else // _WIN32 pWrapperTable->m_DataStream_GetSize = (PLibAMCFDataStream_GetSizePtr) dlsym(hLibrary, "libamcf_datastream_getsize"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_DataStream_GetSize == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_UploadData = (PLibAMCFStreamUpload_UploadDataPtr) GetProcAddress(hLibrary, "libamcf_streamupload_uploaddata"); #else // _WIN32 pWrapperTable->m_StreamUpload_UploadData = (PLibAMCFStreamUpload_UploadDataPtr) dlsym(hLibrary, "libamcf_streamupload_uploaddata"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_UploadData == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_UploadFile = (PLibAMCFStreamUpload_UploadFilePtr) GetProcAddress(hLibrary, "libamcf_streamupload_uploadfile"); #else // _WIN32 pWrapperTable->m_StreamUpload_UploadFile = (PLibAMCFStreamUpload_UploadFilePtr) dlsym(hLibrary, "libamcf_streamupload_uploadfile"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_UploadFile == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_BeginChunking = (PLibAMCFStreamUpload_BeginChunkingPtr) GetProcAddress(hLibrary, "libamcf_streamupload_beginchunking"); #else // _WIN32 pWrapperTable->m_StreamUpload_BeginChunking = (PLibAMCFStreamUpload_BeginChunkingPtr) dlsym(hLibrary, "libamcf_streamupload_beginchunking"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_BeginChunking == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_UploadChunk = (PLibAMCFStreamUpload_UploadChunkPtr) GetProcAddress(hLibrary, "libamcf_streamupload_uploadchunk"); #else // _WIN32 pWrapperTable->m_StreamUpload_UploadChunk = (PLibAMCFStreamUpload_UploadChunkPtr) dlsym(hLibrary, "libamcf_streamupload_uploadchunk"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_UploadChunk == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_FinishChunking = (PLibAMCFStreamUpload_FinishChunkingPtr) GetProcAddress(hLibrary, "libamcf_streamupload_finishchunking"); #else // _WIN32 pWrapperTable->m_StreamUpload_FinishChunking = (PLibAMCFStreamUpload_FinishChunkingPtr) dlsym(hLibrary, "libamcf_streamupload_finishchunking"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_FinishChunking == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_GetStatus = (PLibAMCFStreamUpload_GetStatusPtr) GetProcAddress(hLibrary, "libamcf_streamupload_getstatus"); #else // _WIN32 pWrapperTable->m_StreamUpload_GetStatus = (PLibAMCFStreamUpload_GetStatusPtr) dlsym(hLibrary, "libamcf_streamupload_getstatus"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_GetStatus == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_StreamUpload_GetDataStream = (PLibAMCFStreamUpload_GetDataStreamPtr) GetProcAddress(hLibrary, "libamcf_streamupload_getdatastream"); #else // _WIN32 pWrapperTable->m_StreamUpload_GetDataStream = (PLibAMCFStreamUpload_GetDataStreamPtr) dlsym(hLibrary, "libamcf_streamupload_getdatastream"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_StreamUpload_GetDataStream == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_GetBaseURL = (PLibAMCFConnection_GetBaseURLPtr) GetProcAddress(hLibrary, "libamcf_connection_getbaseurl"); #else // _WIN32 pWrapperTable->m_Connection_GetBaseURL = (PLibAMCFConnection_GetBaseURLPtr) dlsym(hLibrary, "libamcf_connection_getbaseurl"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_GetBaseURL == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_SetTimeouts = (PLibAMCFConnection_SetTimeoutsPtr) GetProcAddress(hLibrary, "libamcf_connection_settimeouts"); #else // _WIN32 pWrapperTable->m_Connection_SetTimeouts = (PLibAMCFConnection_SetTimeoutsPtr) dlsym(hLibrary, "libamcf_connection_settimeouts"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_SetTimeouts == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_GetTimeout = (PLibAMCFConnection_GetTimeoutPtr) GetProcAddress(hLibrary, "libamcf_connection_gettimeout"); #else // _WIN32 pWrapperTable->m_Connection_GetTimeout = (PLibAMCFConnection_GetTimeoutPtr) dlsym(hLibrary, "libamcf_connection_gettimeout"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_GetTimeout == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_GetRetryCount = (PLibAMCFConnection_GetRetryCountPtr) GetProcAddress(hLibrary, "libamcf_connection_getretrycount"); #else // _WIN32 pWrapperTable->m_Connection_GetRetryCount = (PLibAMCFConnection_GetRetryCountPtr) dlsym(hLibrary, "libamcf_connection_getretrycount"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_GetRetryCount == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_AuthenticateWithPassword = (PLibAMCFConnection_AuthenticateWithPasswordPtr) GetProcAddress(hLibrary, "libamcf_connection_authenticatewithpassword"); #else // _WIN32 pWrapperTable->m_Connection_AuthenticateWithPassword = (PLibAMCFConnection_AuthenticateWithPasswordPtr) dlsym(hLibrary, "libamcf_connection_authenticatewithpassword"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_AuthenticateWithPassword == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_IsAuthenticated = (PLibAMCFConnection_IsAuthenticatedPtr) GetProcAddress(hLibrary, "libamcf_connection_isauthenticated"); #else // _WIN32 pWrapperTable->m_Connection_IsAuthenticated = (PLibAMCFConnection_IsAuthenticatedPtr) dlsym(hLibrary, "libamcf_connection_isauthenticated"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_IsAuthenticated == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_RefreshAuthentication = (PLibAMCFConnection_RefreshAuthenticationPtr) GetProcAddress(hLibrary, "libamcf_connection_refreshauthentication"); #else // _WIN32 pWrapperTable->m_Connection_RefreshAuthentication = (PLibAMCFConnection_RefreshAuthenticationPtr) dlsym(hLibrary, "libamcf_connection_refreshauthentication"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_RefreshAuthentication == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_Ping = (PLibAMCFConnection_PingPtr) GetProcAddress(hLibrary, "libamcf_connection_ping"); #else // _WIN32 pWrapperTable->m_Connection_Ping = (PLibAMCFConnection_PingPtr) dlsym(hLibrary, "libamcf_connection_ping"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_Ping == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_GetAuthToken = (PLibAMCFConnection_GetAuthTokenPtr) GetProcAddress(hLibrary, "libamcf_connection_getauthtoken"); #else // _WIN32 pWrapperTable->m_Connection_GetAuthToken = (PLibAMCFConnection_GetAuthTokenPtr) dlsym(hLibrary, "libamcf_connection_getauthtoken"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_GetAuthToken == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_Connection_CreateUpload = (PLibAMCFConnection_CreateUploadPtr) GetProcAddress(hLibrary, "libamcf_connection_createupload"); #else // _WIN32 pWrapperTable->m_Connection_CreateUpload = (PLibAMCFConnection_CreateUploadPtr) dlsym(hLibrary, "libamcf_connection_createupload"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_Connection_CreateUpload == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_GetVersion = (PLibAMCFGetVersionPtr) GetProcAddress(hLibrary, "libamcf_getversion"); #else // _WIN32 pWrapperTable->m_GetVersion = (PLibAMCFGetVersionPtr) dlsym(hLibrary, "libamcf_getversion"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_GetVersion == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_GetLastError = (PLibAMCFGetLastErrorPtr) GetProcAddress(hLibrary, "libamcf_getlasterror"); #else // _WIN32 pWrapperTable->m_GetLastError = (PLibAMCFGetLastErrorPtr) dlsym(hLibrary, "libamcf_getlasterror"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_GetLastError == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_ReleaseInstance = (PLibAMCFReleaseInstancePtr) GetProcAddress(hLibrary, "libamcf_releaseinstance"); #else // _WIN32 pWrapperTable->m_ReleaseInstance = (PLibAMCFReleaseInstancePtr) dlsym(hLibrary, "libamcf_releaseinstance"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_ReleaseInstance == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_AcquireInstance = (PLibAMCFAcquireInstancePtr) GetProcAddress(hLibrary, "libamcf_acquireinstance"); #else // _WIN32 pWrapperTable->m_AcquireInstance = (PLibAMCFAcquireInstancePtr) dlsym(hLibrary, "libamcf_acquireinstance"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_AcquireInstance == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_InjectComponent = (PLibAMCFInjectComponentPtr) GetProcAddress(hLibrary, "libamcf_injectcomponent"); #else // _WIN32 pWrapperTable->m_InjectComponent = (PLibAMCFInjectComponentPtr) dlsym(hLibrary, "libamcf_injectcomponent"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_InjectComponent == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_GetSymbolLookupMethod = (PLibAMCFGetSymbolLookupMethodPtr) GetProcAddress(hLibrary, "libamcf_getsymbollookupmethod"); #else // _WIN32 pWrapperTable->m_GetSymbolLookupMethod = (PLibAMCFGetSymbolLookupMethodPtr) dlsym(hLibrary, "libamcf_getsymbollookupmethod"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_GetSymbolLookupMethod == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; #ifdef _WIN32 pWrapperTable->m_CreateConnection = (PLibAMCFCreateConnectionPtr) GetProcAddress(hLibrary, "libamcf_createconnection"); #else // _WIN32 pWrapperTable->m_CreateConnection = (PLibAMCFCreateConnectionPtr) dlsym(hLibrary, "libamcf_createconnection"); dlerror(); #endif // _WIN32 if (pWrapperTable->m_CreateConnection == nullptr) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; pWrapperTable->m_LibraryHandle = hLibrary; return LIBAMCF_SUCCESS; } inline LibAMCFResult CWrapper::loadWrapperTableFromSymbolLookupMethod(sLibAMCFDynamicWrapperTable * pWrapperTable, void* pSymbolLookupMethod) { if (pWrapperTable == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; if (pSymbolLookupMethod == nullptr) return LIBAMCF_ERROR_INVALIDPARAM; typedef LibAMCFResult(*SymbolLookupType)(const char*, void**); SymbolLookupType pLookup = (SymbolLookupType)pSymbolLookupMethod; LibAMCFResult eLookupError = LIBAMCF_SUCCESS; eLookupError = (*pLookup)("libamcf_operationresult_waitfor", (void**)&(pWrapperTable->m_OperationResult_WaitFor)); if ( (eLookupError != 0) || (pWrapperTable->m_OperationResult_WaitFor == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_operationresult_inprogress", (void**)&(pWrapperTable->m_OperationResult_InProgress)); if ( (eLookupError != 0) || (pWrapperTable->m_OperationResult_InProgress == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_operationresult_success", (void**)&(pWrapperTable->m_OperationResult_Success)); if ( (eLookupError != 0) || (pWrapperTable->m_OperationResult_Success == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_operationresult_geterrormessage", (void**)&(pWrapperTable->m_OperationResult_GetErrorMessage)); if ( (eLookupError != 0) || (pWrapperTable->m_OperationResult_GetErrorMessage == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getuuid", (void**)&(pWrapperTable->m_DataStream_GetUUID)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetUUID == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getcontextuuid", (void**)&(pWrapperTable->m_DataStream_GetContextUUID)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetContextUUID == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getname", (void**)&(pWrapperTable->m_DataStream_GetName)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetName == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getmimetype", (void**)&(pWrapperTable->m_DataStream_GetMimeType)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetMimeType == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_datastream_getsize", (void**)&(pWrapperTable->m_DataStream_GetSize)); if ( (eLookupError != 0) || (pWrapperTable->m_DataStream_GetSize == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_uploaddata", (void**)&(pWrapperTable->m_StreamUpload_UploadData)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_UploadData == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_uploadfile", (void**)&(pWrapperTable->m_StreamUpload_UploadFile)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_UploadFile == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_beginchunking", (void**)&(pWrapperTable->m_StreamUpload_BeginChunking)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_BeginChunking == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_uploadchunk", (void**)&(pWrapperTable->m_StreamUpload_UploadChunk)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_UploadChunk == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_finishchunking", (void**)&(pWrapperTable->m_StreamUpload_FinishChunking)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_FinishChunking == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_getstatus", (void**)&(pWrapperTable->m_StreamUpload_GetStatus)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_GetStatus == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_streamupload_getdatastream", (void**)&(pWrapperTable->m_StreamUpload_GetDataStream)); if ( (eLookupError != 0) || (pWrapperTable->m_StreamUpload_GetDataStream == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_getbaseurl", (void**)&(pWrapperTable->m_Connection_GetBaseURL)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetBaseURL == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_settimeouts", (void**)&(pWrapperTable->m_Connection_SetTimeouts)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_SetTimeouts == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_gettimeout", (void**)&(pWrapperTable->m_Connection_GetTimeout)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetTimeout == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_getretrycount", (void**)&(pWrapperTable->m_Connection_GetRetryCount)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetRetryCount == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_authenticatewithpassword", (void**)&(pWrapperTable->m_Connection_AuthenticateWithPassword)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_AuthenticateWithPassword == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_isauthenticated", (void**)&(pWrapperTable->m_Connection_IsAuthenticated)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_IsAuthenticated == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_refreshauthentication", (void**)&(pWrapperTable->m_Connection_RefreshAuthentication)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_RefreshAuthentication == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_ping", (void**)&(pWrapperTable->m_Connection_Ping)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_Ping == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_getauthtoken", (void**)&(pWrapperTable->m_Connection_GetAuthToken)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_GetAuthToken == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_connection_createupload", (void**)&(pWrapperTable->m_Connection_CreateUpload)); if ( (eLookupError != 0) || (pWrapperTable->m_Connection_CreateUpload == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_getversion", (void**)&(pWrapperTable->m_GetVersion)); if ( (eLookupError != 0) || (pWrapperTable->m_GetVersion == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_getlasterror", (void**)&(pWrapperTable->m_GetLastError)); if ( (eLookupError != 0) || (pWrapperTable->m_GetLastError == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_releaseinstance", (void**)&(pWrapperTable->m_ReleaseInstance)); if ( (eLookupError != 0) || (pWrapperTable->m_ReleaseInstance == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_acquireinstance", (void**)&(pWrapperTable->m_AcquireInstance)); if ( (eLookupError != 0) || (pWrapperTable->m_AcquireInstance == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_injectcomponent", (void**)&(pWrapperTable->m_InjectComponent)); if ( (eLookupError != 0) || (pWrapperTable->m_InjectComponent == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_getsymbollookupmethod", (void**)&(pWrapperTable->m_GetSymbolLookupMethod)); if ( (eLookupError != 0) || (pWrapperTable->m_GetSymbolLookupMethod == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; eLookupError = (*pLookup)("libamcf_createconnection", (void**)&(pWrapperTable->m_CreateConnection)); if ( (eLookupError != 0) || (pWrapperTable->m_CreateConnection == nullptr) ) return LIBAMCF_ERROR_COULDNOTFINDLIBRARYEXPORT; return LIBAMCF_SUCCESS; } /** * Method definitions for class CBase */ /** * Method definitions for class COperationResult */ /** * COperationResult::WaitFor - Waits for operation to be finished. * @param[in] nTimeOut - Timeout value in Milliseconds. 0 means forever. * @return Returns if operation has been finished. */ bool COperationResult::WaitFor(const LibAMCF_uint32 nTimeOut) { bool resultOperationFinished = 0; CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_WaitFor(m_pHandle, nTimeOut, &resultOperationFinished)); return resultOperationFinished; } /** * COperationResult::InProgress - Checks if operation is in progress. * @return Flag if operation is in progress. */ bool COperationResult::InProgress() { bool resultOperationIsInProgress = 0; CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_InProgress(m_pHandle, &resultOperationIsInProgress)); return resultOperationIsInProgress; } /** * COperationResult::Success - Checks if operation has been finished successfully. Waits for operation to finish. * @return Flag if operation has been finished successful. */ bool COperationResult::Success() { bool resultOperationSuccess = 0; CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_Success(m_pHandle, &resultOperationSuccess)); return resultOperationSuccess; } /** * COperationResult::GetErrorMessage - Returns the error message, if the operation has not been successful. Fails if operation is in progress. * @return Returns error message of failed operation. */ std::string COperationResult::GetErrorMessage() { LibAMCF_uint32 bytesNeededErrorMessage = 0; LibAMCF_uint32 bytesWrittenErrorMessage = 0; CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_GetErrorMessage(m_pHandle, 0, &bytesNeededErrorMessage, nullptr)); std::vector<char> bufferErrorMessage(bytesNeededErrorMessage); CheckError(m_pWrapper->m_WrapperTable.m_OperationResult_GetErrorMessage(m_pHandle, bytesNeededErrorMessage, &bytesWrittenErrorMessage, &bufferErrorMessage[0])); return std::string(&bufferErrorMessage[0]); } /** * Method definitions for class CDataStream */ /** * CDataStream::GetUUID - Returns the stream UUID. * @return Stream UUID String. */ std::string CDataStream::GetUUID() { LibAMCF_uint32 bytesNeededUUID = 0; LibAMCF_uint32 bytesWrittenUUID = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetUUID(m_pHandle, 0, &bytesNeededUUID, nullptr)); std::vector<char> bufferUUID(bytesNeededUUID); CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetUUID(m_pHandle, bytesNeededUUID, &bytesWrittenUUID, &bufferUUID[0])); return std::string(&bufferUUID[0]); } /** * CDataStream::GetContextUUID - Returns the stream's context UUID. * @return Stream Context UUID String. */ std::string CDataStream::GetContextUUID() { LibAMCF_uint32 bytesNeededContextUUID = 0; LibAMCF_uint32 bytesWrittenContextUUID = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetContextUUID(m_pHandle, 0, &bytesNeededContextUUID, nullptr)); std::vector<char> bufferContextUUID(bytesNeededContextUUID); CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetContextUUID(m_pHandle, bytesNeededContextUUID, &bytesWrittenContextUUID, &bufferContextUUID[0])); return std::string(&bufferContextUUID[0]); } /** * CDataStream::GetName - Returns the stream name. * @return Stream Name. */ std::string CDataStream::GetName() { LibAMCF_uint32 bytesNeededName = 0; LibAMCF_uint32 bytesWrittenName = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetName(m_pHandle, 0, &bytesNeededName, nullptr)); std::vector<char> bufferName(bytesNeededName); CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetName(m_pHandle, bytesNeededName, &bytesWrittenName, &bufferName[0])); return std::string(&bufferName[0]); } /** * CDataStream::GetMimeType - Returns the stream's mime type. * @return Mime Type string. */ std::string CDataStream::GetMimeType() { LibAMCF_uint32 bytesNeededMimeType = 0; LibAMCF_uint32 bytesWrittenMimeType = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetMimeType(m_pHandle, 0, &bytesNeededMimeType, nullptr)); std::vector<char> bufferMimeType(bytesNeededMimeType); CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetMimeType(m_pHandle, bytesNeededMimeType, &bytesWrittenMimeType, &bufferMimeType[0])); return std::string(&bufferMimeType[0]); } /** * CDataStream::GetSize - Returns the stream size. * @return Stream size. */ LibAMCF_uint64 CDataStream::GetSize() { LibAMCF_uint64 resultStreamSize = 0; CheckError(m_pWrapper->m_WrapperTable.m_DataStream_GetSize(m_pHandle, &resultStreamSize)); return resultStreamSize; } /** * Method definitions for class CStreamUpload */ /** * CStreamUpload::UploadData - uploads the passed data to the server. MUST only be called once. * @param[in] DataBuffer - Data to be uploaded. * @param[in] nChunkSize - Chunk size to use in bytes. MUST be at least 64kB. * @return Returns if upload was successful. */ POperationResult CStreamUpload::UploadData(const CInputVector<LibAMCF_uint8> & DataBuffer, const LibAMCF_uint32 nChunkSize) { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_UploadData(m_pHandle, (LibAMCF_uint64)DataBuffer.size(), DataBuffer.data(), nChunkSize, &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CStreamUpload::UploadFile - uploads a file to the server. MUST only be called once. * @param[in] sFileName - File to be uploaded. * @param[in] nChunkSize - Chunk size to use in bytes. MUST be at least 64kB. * @return Returns if upload was successful. */ POperationResult CStreamUpload::UploadFile(const std::string & sFileName, const LibAMCF_uint32 nChunkSize) { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_UploadFile(m_pHandle, sFileName.c_str(), nChunkSize, &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CStreamUpload::BeginChunking - Starts a chunked upload. MUST not be used together with uploadData or uploadFile * @param[in] nDataSize - Full data size to be uploaded. */ void CStreamUpload::BeginChunking(const LibAMCF_uint64 nDataSize) { CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_BeginChunking(m_pHandle, nDataSize)); } /** * CStreamUpload::UploadChunk - Uploads another chunk to the server. Chunks are added sequentially together. * @param[in] DataBuffer - Data to be uploaded. * @return Returns if upload was successful. */ POperationResult CStreamUpload::UploadChunk(const CInputVector<LibAMCF_uint8> & DataBuffer) { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_UploadChunk(m_pHandle, (LibAMCF_uint64)DataBuffer.size(), DataBuffer.data(), &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CStreamUpload::FinishChunking - MUST only be called after all chunks have been uploaded. * @param[in] DataBuffer - Data to be uploaded. * @return Returns if upload was successful. */ POperationResult CStreamUpload::FinishChunking(const CInputVector<LibAMCF_uint8> & DataBuffer) { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_FinishChunking(m_pHandle, (LibAMCF_uint64)DataBuffer.size(), DataBuffer.data(), &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CStreamUpload::GetStatus - Retrieves current upload status. * @param[out] nUploadSize - Total size of the upload. * @param[out] nUploadedBytes - Current uploaded data. * @param[out] bFinished - Upload has been finished. */ void CStreamUpload::GetStatus(LibAMCF_uint64 & nUploadSize, LibAMCF_uint64 & nUploadedBytes, bool & bFinished) { CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_GetStatus(m_pHandle, &nUploadSize, &nUploadedBytes, &bFinished)); } /** * CStreamUpload::GetDataStream - Retrieves the uploaded data stream object. Upload must have finished successfully. * @return Data stream instance. */ PDataStream CStreamUpload::GetDataStream() { LibAMCFHandle hDataStream = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_StreamUpload_GetDataStream(m_pHandle, &hDataStream)); if (!hDataStream) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<CDataStream>(m_pWrapper, hDataStream); } /** * Method definitions for class CConnection */ /** * CConnection::GetBaseURL - returns the base url of the AMCF instance * @return Base URL of the AMCF instance. */ std::string CConnection::GetBaseURL() { LibAMCF_uint32 bytesNeededBaseURL = 0; LibAMCF_uint32 bytesWrittenBaseURL = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetBaseURL(m_pHandle, 0, &bytesNeededBaseURL, nullptr)); std::vector<char> bufferBaseURL(bytesNeededBaseURL); CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetBaseURL(m_pHandle, bytesNeededBaseURL, &bytesWrittenBaseURL, &bufferBaseURL[0])); return std::string(&bufferBaseURL[0]); } /** * CConnection::SetTimeouts - sets the timeout behaviour of the connection. * @param[in] nTimeout - Request timeout in milliseconds. Default is 1000. * @param[in] nRetryCount - How many retries should be done in an error case. Default is 3. */ void CConnection::SetTimeouts(const LibAMCF_uint32 nTimeout, const LibAMCF_uint32 nRetryCount) { CheckError(m_pWrapper->m_WrapperTable.m_Connection_SetTimeouts(m_pHandle, nTimeout, nRetryCount)); } /** * CConnection::GetTimeout - gets the timeout behaviour of the connection. * @return Request timeout in milliseconds */ LibAMCF_uint32 CConnection::GetTimeout() { LibAMCF_uint32 resultTimeout = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetTimeout(m_pHandle, &resultTimeout)); return resultTimeout; } /** * CConnection::GetRetryCount - gets the timeout behaviour of the connection. * @return How many retries should be done in an error case. */ LibAMCF_uint32 CConnection::GetRetryCount() { LibAMCF_uint32 resultRetryCount = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetRetryCount(m_pHandle, &resultRetryCount)); return resultRetryCount; } /** * CConnection::AuthenticateWithPassword - Authenticates with the remote instance with username and password. * @param[in] sUserName - User name for authentication. * @param[in] sPassword - Password for authentication. * @return Returns if authentication was successful. */ POperationResult CConnection::AuthenticateWithPassword(const std::string & sUserName, const std::string & sPassword) { std::lock_guard<std::mutex> lockGuard(m_InstanceMutex); LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_Connection_AuthenticateWithPassword(m_pHandle, sUserName.c_str(), sPassword.c_str(), &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CConnection::IsAuthenticated - Authenticates with the remote instance with username and password * @return Returns if connection is authenticated. */ bool CConnection::IsAuthenticated() { bool resultIsAuthenticated = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_IsAuthenticated(m_pHandle, &resultIsAuthenticated)); return resultIsAuthenticated; } /** * CConnection::RefreshAuthentication - Refreshes authentication with server. * @return Returns if authentication refresh was successful. */ POperationResult CConnection::RefreshAuthentication() { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_Connection_RefreshAuthentication(m_pHandle, &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CConnection::Ping - Detects if server is still reachable. Non-Blocking. * @return Returns if server is still reachable. */ POperationResult CConnection::Ping() { LibAMCFHandle hSuccess = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_Connection_Ping(m_pHandle, &hSuccess)); if (!hSuccess) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<COperationResult>(m_pWrapper, hSuccess); } /** * CConnection::GetAuthToken - Returns the authentication token of the current connection. * @return Token string. */ std::string CConnection::GetAuthToken() { LibAMCF_uint32 bytesNeededToken = 0; LibAMCF_uint32 bytesWrittenToken = 0; CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetAuthToken(m_pHandle, 0, &bytesNeededToken, nullptr)); std::vector<char> bufferToken(bytesNeededToken); CheckError(m_pWrapper->m_WrapperTable.m_Connection_GetAuthToken(m_pHandle, bytesNeededToken, &bytesWrittenToken, &bufferToken[0])); return std::string(&bufferToken[0]); } /** * CConnection::CreateUpload - Creates a file upload instance. Must be authenticated to make it work. * @param[in] sName - Name of the file to be uploaded. * @param[in] sMimeType - Mimetype of the file to be uploaded. * @param[in] sUsageContext - Context string for the usage type of the file. * @return File upload instance. */ PStreamUpload CConnection::CreateUpload(const std::string & sName, const std::string & sMimeType, const std::string & sUsageContext) { LibAMCFHandle hInstance = nullptr; CheckError(m_pWrapper->m_WrapperTable.m_Connection_CreateUpload(m_pHandle, sName.c_str(), sMimeType.c_str(), sUsageContext.c_str(), &hInstance)); if (!hInstance) { CheckError(LIBAMCF_ERROR_INVALIDPARAM); } return std::make_shared<CStreamUpload>(m_pWrapper, hInstance); } } // namespace LibAMCF #endif // __LIBAMCF_CPPHEADER_DYNAMIC_CPP
070b0619c62ced0bbff5fee1a731803f3ba54872
cb0d7ae2349adae7cb9d2463eabd1f79ee35b9b7
/Longest Common Prefix.cpp
e5fc1640205d419a126800f1d5109f4c03ec01f6
[]
no_license
eric0716336/leetcode
f32449d174033117ea65964ed37cde26d317a037
5613af945d8afa4a2e86ee37695f7190478a01ff
refs/heads/main
2023-06-06T07:12:08.308701
2021-07-02T05:32:23
2021-07-02T05:32:23
382,240,539
0
0
null
null
null
null
UTF-8
C++
false
false
1,390
cpp
//Longest Common Prefix class Solution { public: string longestCommonPrefix(vector<string>& strs) { int common_count=0; if(strs.size()==0){ return ""; } int len = strs[0].length(); int flag=0; for(int i=0;i<len;i++){ string s=strs[0]; // char cur = s[i]; for(int j=0;j<strs.size();j++){ string ev=strs[j]; if(i==ev.length()){ flag=1; common_count=i; break; } if(s[i]==ev[i]){ continue; } else{ flag=1; break; } } if(flag==1){ common_count=i; break; } else if(i==len-1){ common_count=i+1; break; } } if(strs.size()==0){ return ""; } else if(strs.size()==1){ return strs[0]; } string ret=""; string curr=strs[0]; ret=curr.substr(0,common_count); return ret; } };
1c143f84fa880dd048605f74a0979ff1f4c67cf8
9bb1ca65690b12cfaaac3a851958b1c5d1f6d520
/Utilities/ThreadSafePointer/thread_safe_ptr.cpp
8b9754ff58b791d27c0bb5353e781e38047ca13f
[]
no_license
MohitBhola/CPP
bb972327025493e879a20d2cf42b9e953d944b5b
18e9c4e492d85d8d264bf1ce5238f6ee1d3e857c
refs/heads/master
2022-05-01T07:57:50.220698
2022-04-09T10:25:28
2022-04-09T10:25:28
206,759,223
0
0
null
null
null
null
UTF-8
C++
false
false
22,148
cpp
#include <iostream> #include <memory> #include <mutex> #include <map> #include <string> #include <thread> // a manual replacement for std::void_t (available since C++17) template< typename...> using VoidT = void; template< typename T, typename = VoidT<>> struct DisableIfIndirection : std::false_type {}; template< typename T> struct DisableIfIndirection<T, VoidT<decltype(std::declval<T>().operator->())>> : std::true_type {}; // the primary template // later specialized for underlying types that are wrappers themselves, that is, types that implement operator->() // please read more comments elsewhere template< typename Resource, typename mutex_t = std::recursive_mutex, typename lock_t = std::unique_lock<mutex_t>, bool = DisableIfIndirection<Resource>::value> class thread_safe_ptr { /* A thread_safe_ptr object *owns* an underlying object. There could be 2 types of underlyings: 1. A normal, regular type that isn't providing wrapper semantics. That is, a type that doesn't overloads the indirection operator. This includes both fundamental types and most user defined types. For such types, a thread_safe_ptr could be created as follows: a. Pass (to a thread_safe_ptr ctor) no arguments / all arguments necessary to invoke the default / user defined ctor of the underlying. b. Pass (to a thread_safe_ptr ctor) an lvalue / rvalue reference to the underlying. As usual, lvalues would be copied in, and rvalues would be moved in. c. Invoke thread_safe_ptr's copy construction / assignment. The thread_safe_ptr object thus constructed shall aggregate a shared_ptr to the underlying. As such, each such thread_safe_ptr object shall *always* have an underlying, and clients need not check them for NULL prior to dereferencing. As aforementioned in # c, it is possible to copy a thread_safe_ptr object. Each such copy shall contain its own shared_ptr to the *same* underlying, and would provide thread-safe access to that *same* underlying. It isn't possible to move a thread_safe_ptr object, though. Why? If move semantics are supported, the moved-from thread_safe_ptr object shall lose its underlying, and thus couldn't be dereferenced. This would necessitate the client code to first check for NULL prior to dereferencing. 2. A *wrapper*, such as a shared_ptr<T>, or an IRef (in the DVA world). That is, something that has an underlying of its own, and could be detected at compile time (SFINAE) via the availability of an overloaded indirection operator (operator->()). As an aside, note that as per classic C++ language rules, the result of an indirection should either result in a raw pointer, or should result in an object of a class that itself overloads the indirection operator. The process continues until the compiler arrives at a raw pointer. If not, the compile emits an error. For such types, a thread_safe_ptr could be created as follows: a. Pass (to the thread_safe_ptr ctor) no arguments / all arguments necessary to invoke the default / user defined ctor of the underlying wrapper. b. Pass (to the thread_safe_ptr ctor) an rvalue reference to the underlying, which would be moved in. Note that lvalue references are disallowed here. More on this below. c. Invoke thread_safe_ptr's copy/move construction or copy/move assignment. For such *wrapper* underlyings, the thread_safe_ptr object shall *directly* aggregate them. Note that we would like to access both the underlying wrapper, and the underlying wrapper's underlying. For example, if the underlying wrapper is shared_ptr<Foo>, we would like access the public interface of both shared_ptr<Foo> (to invoke, for example, its reset() API), and the underlying Foo as well! The former requirement implies that clients of such thread_safe_ptr objects should be prepared to check the wrapper underlying to be NULL prior to accessing the real underlying. This also implies that such thread_safe_ptr objects are both copyable and moveable. [SUBTLE] Why can't we create a thread_safe_ptr object via an lvalue reference to a wrapper underlying? Because the ownership group of the real underlying needs to be a closed one. If there remains an lvalue reference to a wrapper underlying after having constructed one or more thread_safe_ptr's from it, the access to the real underlying from that lvalue reference shall *NOT* be thread safe. Hence it is forbidden. */ std::shared_ptr<Resource> ptr{}; // the underlying std::shared_ptr<mutex_t> mtx{}; // the protection // The Surrogate // What's this? // // To access the underlying shared resource, clients *always* need to invoke the Lock() API on the thread_safe_ptr // This invocation returns a proxy object which provides for the thread safe access to the underlying. // The associated mutex of the shared resource gets locked (explicitly) in the proxy's ctor, and the same gets released (implicitly) in its dtor. // The proxy objects are thus used in an RAII based manner in client code. // It also provides for an implicit conversion to the underlying. template< typename ResourceT, typename requested_lock_t> class proxy { ResourceT* pUnderlying{nullptr}; requested_lock_t lock{}; public: // by default, the underlying isn't available and thus the lock on the underlying isn't acquired proxy() = default; // when the proxy object is created, acquire a lock on the underlying *explicitly* proxy(ResourceT* const p, mutex_t& mtx) : pUnderlying(p), lock(mtx) /* HERE */ {} proxy(proxy&& rhs) : pUnderlying(std::move(rhs.pUnderlying)), lock(std::move(rhs.lock)) {} // when the proxy object is destroyed, release the lock on the underlying *implicitly* ~proxy() noexcept = default; // overload the indirection operator to reach out to the underlying ResourceT* operator->() { return pUnderlying; } ResourceT const* operator->() const { return pUnderlying; } // overload the dereference operator to reach out to the underlying ResourceT& operator*() { return *pUnderlying; } ResourceT const& operator*() const { return *pUnderlying; } }; public: // default constructing a thread_safe_ptr assumes that it is possible to default construct the underlying thread_safe_ptr() : ptr(std::make_unique<Resource>()), mtx(std::make_shared<mutex_t>()) {} // universal ctor // intended to construct the underlying by invoking a viable ctor of the underlying using the parameters of this universal ctor // such viable ctors include normal ctors taking multiple arguments as well as copy / move ctors // // [SUBTLE] // this ctor would shadow the normal copy ctor of thread_safe_ptr while trying to create a copy of a thread_safe_ptr // thus disabled for such scenarios template< typename T, typename... Args, typename = std::enable_if_t<!std::is_same<std::decay_t<T>, thread_safe_ptr>::value>> thread_safe_ptr(T&& t, Args&&... args) : ptr(std::make_shared<Resource>(std::forward<T>(t), std::forward<Args>(args)...)), mtx(std::make_shared<mutex_t>()) {} // copy construction / assignment thread_safe_ptr(thread_safe_ptr const& source) = default; thread_safe_ptr& operator=(thread_safe_ptr const&) = default; // *don't* provide move semantics thread_safe_ptr(thread_safe_ptr const&&) = delete; thread_safe_ptr& operator=(thread_safe_ptr&&) = delete; // implement the *BasicLockable* interface // enables thread_safe_ptr objects to be used in the std::lock(...) API // helps to acquire a lock on multiple thread_safe_ptr objects in different threads without risking a deadlock void lock() { mtx->lock(); } bool try_lock() { return mtx->try_lock(); } void unlock() { mtx->unlock(); } // ALL and ANY access to the underlying is via the Lock() API // helps to eliminate the class of bugs arising out of locking the wrong mutex or forgetting to lock a mutex while trying to access the shared underlying auto Lock() { return ptr ? proxy<Resource, lock_t>(ptr.get(), *mtx) : proxy<Resource, lock_t>(); } auto Lock() const { return ptr ? proxy<Resource const, lock_t>(ptr.get(), *mtx) : proxy<Resource const, lock_t>(); } }; // thread_safe_ptr specialized for *wrapper* underlyings // note that we would like to access the public interface of both the wrapper underlying, as well as the wrapper underlying's underlying template< typename Resource, typename mutex_t, typename lock_t> class thread_safe_ptr<Resource, mutex_t, lock_t, true> { Resource res; // the underlying (note direct aggregation!) std::shared_ptr<mutex_t> mtx; // the protection template< typename ResourceT, typename requested_lock_t> class proxy { ResourceT * const pUnderlying{nullptr}; requested_lock_t lock {}; public: // when the proxy object is created, acquire a lock on the underlying *explicitly* proxy(ResourceT* const p, mutex_t& mtx) : pUnderlying(p), lock(mtx) /* HERE */ {} proxy(proxy&& rhs) : pUnderlying(std::move(rhs.pUnderlying)), lock(std::move(rhs.lock)) {} // when the proxy object is destroyed, release the lock on the underlying *implicitly* ~proxy() noexcept = default; // [SUBTLE] // *wrapper* underlyings may get reset // thus, we need to provide a way for the clients to check for the same (via an implicit conversion to bool) prior to dereferencing it operator bool() const { return static_cast<bool>(pUnderlying ? *pUnderlying : 0); } // (special) overloaded indirection to the wrapper underlying's underlying // this let's the client code to access the public interface of the wrapper underlying's underlying via a consistent syntax auto* operator->() { return pUnderlying->operator->(); } auto const* operator->() const { return pUnderlying->operator->(); } // overload the dereference operator to reach out to the *wrapper's underlying* // this lets the clients to access the public interface of the wrapper underlying itself // for example, to access the reset() API of the underlying shared_ptr<Foo> ResourceT& operator*() { return *pUnderlying; } ResourceT const& operator*() const { return *pUnderlying; } }; public: // universal ctor // intended to construct the underlying by invoking a viable ctor of the underlying using the parameters of this universal ctor // such viable ctors include normal ctors taking multiple arguments as well as copy / move ctors // // [SUBTLE] // this ctor would shadow the normal copy ctor of thread_safe_ptr while trying to create a copy of a thread_safe_ptr // thus disabled for such scenarios template< typename T, typename... Args, typename = std::enable_if_t<!(std::is_lvalue_reference<T>::value && std::is_same<Resource, std::decay_t<T>>::value)>, typename = std::enable_if_t<!std::is_same<std::decay_t<T>, thread_safe_ptr>::value>> thread_safe_ptr(T&& t, Args&&... args) : res(std::forward<T>(t), std::forward<Args>(args)...), mtx(std::make_shared<mutex_t>()) {} // provide for copy construction / assignment thread_safe_ptr(thread_safe_ptr const& source) = default; thread_safe_ptr& operator=(thread_safe_ptr const&) = default; // provide for move construction / assignment thread_safe_ptr(thread_safe_ptr const&&) = delete; thread_safe_ptr& operator=(thread_safe_ptr&&) = delete; // implement the *BasicLockable* interface // enables thread_safe_ptr objects to be used in the std::lock(...) API // helps to acquire a lock on multiple thread_safe_ptr objects in different threads without risking a deadlock void lock() { mtx->lock(); } bool try_lock() { return mtx->try_lock(); } void unlock() { mtx->unlock(); } // ALL and ANY access to the underlying is via the Lock() API // helps to eliminate the class of bugs arising out of locking the wrong mutex or forgetting to lock a mutex while trying to access the shared underlying auto Lock() { return proxy<Resource, lock_t>(std::addressof(res), *mtx); } auto const Lock() const { return proxy<Resource const, lock_t>(std::addressof(res), *mtx); } }; struct Foo { Foo() = default; void doSomething1() { std::cout << "Foo::doSomething1()\n"; } void doSomething2() { std::cout << "Foo::doSomething2()\n"; } void doSomething3() { std::cout << "Foo::doSomething3()\n"; } int i{42}; float f{42.0}; char c{'a'}; }; // works with fundamental types thread_safe_ptr<int> safeInt(42); // works with user defined types thread_safe_ptr<Foo> safeFoo{}; // works with library types thread_safe_ptr<std::map<int, int>> safeMap{}; thread_safe_ptr<std::map<int, int>> safeMap_copy{}; thread_safe_ptr<std::string> safeStr1{"abc"}; thread_safe_ptr<std::string> safeStr2{"xyz"}; // works with *wrapper* types (that provide indirection) too! thread_safe_ptr<std::shared_ptr<Foo>> safeSP{std::make_shared<Foo>()}; void f1() { { // in order to do anything with the underlying, clients first need to invoke the Lock() API on the synchronized ptr // otherwise, the code won't compile // this would prevent the class of bugs arising out of having locked a wrong mutex or forgotten to lock a mutex at all // while trying to access the shared resource auto intRef = safeInt.Lock(); // once we have obtained the proxy to an underlying, clients need to dereference it to do a thread safe access to that underlying *intRef += 42; } // the proxy goes out of scope here and releases the lock on the underlying // this covers both normal returns and exceptions as well // performing a thread safe singular operation // indirection is *natural*; just use operator-> on the proxy returned by the thread_safe_ptr, and it seamlessly redirects to the underlying { auto fooRef = safeFoo.Lock(); fooRef->doSomething1(); } // performing a thread safe transaction { auto fooRef = safeFoo.Lock(); fooRef->doSomething2(); fooRef->doSomething3(); } } void f2() { { // accessing the safeInt in a thread safe manner along with such an access in function f1() auto intRef = safeInt.Lock(); *intRef += 42; // a thread safe increment } // a thread safe singular operation, as in function f1() { auto fooRef = safeFoo.Lock(); fooRef->doSomething2(); } // a thread safe transaction, as in function f1() { auto fooRef = safeFoo.Lock(); fooRef->doSomething2(); fooRef->doSomething3(); } } // the functions f3() and f4() below are made to run on different threads, and each tries to copy assign to safeMap_copy from safeMap // either f3() or f4() does the copy assignment, depending on which of them successfully acquires a lock on *both* safeMap and safeMap_copy first // [SUBTLE] // this is an example of a transaction that involves two shared resources: safeMap_copy and safeMap // we need to acquire a lock on *both* of them // but different threads may try to acquire those locks in different orders which is a classic recipe for a deadlock! // for example, note that functions f3() and f4() below acquire those locks in different orders // we need to acquire these locks atomically // thankfully, std::lock() allows just that! void f3() { // avoid risking a deadlock while acquiring multiple locks by leveraging the std::lock(...) API (since C++11) // since a thread_safe_ptr implements the BasicLockable interface, they could be used with this API! // NOTE: from C++17 onwards, we should be using std::scoped_lock here, else we need to explicitly unlock the thread_safe_ptrs as below std::lock(safeMap, safeMap_copy); { // acquiring the proxies to access the public API of the underlying // this would acquire the locks again, so the mutex better be recursive auto mapRef = safeMap.Lock(); auto mapCopyRef = safeMap_copy.Lock(); if (mapCopyRef->empty()) { *mapCopyRef = *mapRef; } } // since we locked the thread_safe_ptrs explicitly, we need to unlock them explicitly too! // from C++17 onwards, this wouldn't be necessary by using std::scoped_lock to acquire the locks safeMap.unlock(); safeMap_copy.unlock(); } void f4() { // note different order of arguments to the std::lock(...) API than in f3() // this is the kind of mistake that is too easy to make by having to lock multiple mutexes manually // since thread_safe_ptr objects implement the BasicLockable interface, we avoid this risk altogether // developers just need to follow the rule of thumb that if a CriticalSection requires locking multiple thread_safe_ptr objects, // they should do so via std::lock(...) API; the order of argument(s) to this API doesn't matter std::lock(safeMap_copy, safeMap); { auto mapRef = safeMap.Lock(); auto mapCopyRef = safeMap_copy.Lock(); if (mapCopyRef->empty()) { *mapCopyRef = *mapRef; } } safeMap.unlock(); safeMap_copy.unlock(); } int main() { std::thread t1(f1); std::thread t2(f2); t1.join(); t2.join(); // thread_safe_ptr<int> allows access to the underlying shared resource (int) via dereferencing // this is guaranteed to print 126 since increments happen in a thread safe manner in threads t1 and t2 // NOTE: the proxy is an rvalue here and it gets destroyed (and this releases the lock on the underlying) at the end of the statement std::cout << *safeInt.Lock() << '\n'; // thread_safe_ptr<Foo> allows for transparent indirection to access the public API of the underlying std::cout << safeFoo.Lock()->c << '\n'; // populate safeMap in a thread safe manner { auto mapRef = safeMap.Lock(); (*mapRef)[1] = 1; (*mapRef)[2] = 2; std::cout << (*mapRef)[1] << '\n'; std::cout << (*mapRef)[2] << '\n'; } std::thread t3(f3); std::thread t4(f4); t3.join(); t4.join(); // safeMap_copy got populated in a thread safe manner // in either thread t3 or thread t4 (depending upon which was able to acquire a lock (atomically) on both safeMap and safeMap_copy) { auto mapCopyRef = safeMap_copy.Lock(); std::cout << (*mapCopyRef)[1] << '\n'; std::cout << (*mapCopyRef)[2] << '\n'; } { // use std::scoped_lock from C++17 onwards... std::lock(safeStr1, safeStr2); auto str1Ref = safeStr1.Lock(); auto str2Ref = safeStr2.Lock(); std::cout << std::boolalpha << (*str1Ref > *str2Ref) << '\n'; std::cout << std::boolalpha << (*str1Ref != *str2Ref) << '\n'; // ...to avoid this safeStr1.unlock(); safeStr2.unlock(); } // sp is a *wrapper* underlying std::shared_ptr<int> sp(new int(9999)); // ERROR: cannot create thread_safe_ptr objects from lvalues of wrapper underlyings. // Why? Because the ownership group of thread_safe_ptr objects needs to be a closed one. // If allowed, access to the underlying would NOT be thread safe. //thread_safe_ptr<std::shared_ptr<int>> ts_sp{sp}; // can create thread_safe_ptr objects from rvalues of wrapper underlyings thread_safe_ptr<std::shared_ptr<int>> ts_sp1{std::move(sp)}; // NOTE *double* indirection to access the wrapper underlying's underlying { auto sp1Ref = ts_sp1.Lock(); **sp1Ref *= 2; // access the real underlying int std::cout << **sp1Ref << '\n'; } { // can create thread_safe_ptr objects from rvalues of wrapper underlyings thread_safe_ptr<std::shared_ptr<Foo>> ts_sp2{std::make_shared<Foo>()}; // indirection is *natural*; just use operator->() on the proxy, // and it redirects all the way to the wrapper underlying's underlying auto sp2Ref = ts_sp2.Lock(); sp2Ref->doSomething1(); // actually invoke Foo::doSomething1() } { // can create copies of thread_safe_ptrs thread_safe_ptr<std::shared_ptr<int>> ts_sp3{ts_sp1}; auto sp3Ref = ts_sp3.Lock(); // NOTE *double* dereference to access the wrapper underlying's underlying **sp3Ref *= 2; std::cout << **sp3Ref << '\n'; // NOTE *single* dereference to the wrapper underlying itself (*sp3Ref).reset(); // proxy's implicit conversion to bool to indicate whether the wrapper underlying / wrapper underlying's underlying exists or not if (!sp3Ref) { std::cout << "ts_sp3's underlying is now indeed NULL\n\n"; } } return 0; } /* OUTPUT (-std=c++14) Foo::doSomething1() Foo::doSomething2() Foo::doSomething3() Foo::doSomething2() Foo::doSomething2() Foo::doSomething3() 126 a 1 2 1 2 false true 19998 Foo::doSomething1() 39996 ts_sp3's underlying is now indeed NULL */
407e620acc78923922702020f0c47acb9b165fc4
6d03fbf380c7c501e448cd3df7747b311f599c26
/Lab04/Timer.h
cac9d0225a4e76dd7ba95a09e456945bb0235322
[]
no_license
ashlimosiman/EECS_560
cb3e2ac4acead16e304896fb29c2cce02c7b0302
00f292096785495e21907a8279e25c067f36b59a
refs/heads/master
2021-01-11T16:10:20.560114
2017-04-19T04:16:42
2017-04-19T04:16:42
80,026,482
0
0
null
null
null
null
UTF-8
C++
false
false
560
h
#include <stdio.h> #include <stdlib.h> #include <sys/time.h> using namespace std; class Timer { private: timeval startTime; timeval endTime; public: void start(){ gettimeofday(&startTime, NULL); } double stop(){ long seconds, nseconds; double duration; gettimeofday(&endTime, NULL); seconds = endTime.tv_sec - startTime.tv_sec; nseconds = endTime.tv_usec - startTime.tv_usec; duration = seconds + nseconds/1000000.0; return duration; } void printTime(double duration){ printf("%5.6f seconds\n", duration); } };
957ab7501e88b40aec241ffa33b02c33875aa3e0
293902682d7ee13be81ada6c28ef6b840983ac33
/Tests/Integration_ConnectionService_ConnectionPool/src/main.cpp
836c84dfe574722e1164e418681f45eb61ffddb9
[]
no_license
cms-externals/coral
d17cba45fff7f34d7a1ba13ab3bb371e0696c1af
a879b41c994fa956ff0ae78e3410bb409582ad20
refs/heads/cms/CORAL_2_3_21py3
2022-02-26T18:51:25.258362
2022-02-23T13:19:11
2022-02-23T13:19:11
91,173,895
0
4
null
2022-02-14T13:20:11
2017-05-13T12:47:54
C++
UTF-8
C++
false
false
389
cpp
#include "TestApp.h" #include "CoralBase/Exception.h" #include <iostream> #include <exception> #include <cstdlib> int main(int argc, char *argv[]) { TestApp app("CS_CPOOL"); if(app.check(argc, argv)) { app.addServiceName(TEST_CORE_SCHEME_ADMIN); app.addServiceName(TEST_CORE_SERVICE_2); try { app.run(); } TESTCORE_FETCHERRORS } return 1; }
cd4fd92f7bf50f60a6009a036cd4dca724277b73
1851d92ec009599f979ff68440cea9a220d263d4
/src/qt/bitcoingui.h
0fe986d7b388f058d012efab18fd74f298ebbb1a
[ "MIT" ]
permissive
stintcoin/StintCoin
f7e8d3411f2de38bda93f1bbfdb551616fb3ca78
75b9fc740ed1929bde1f142502f9adbbb630d812
refs/heads/master
2020-04-09T01:21:18.148125
2018-12-13T22:08:30
2018-12-13T22:08:30
159,900,937
3
0
null
null
null
null
UTF-8
C++
false
false
8,987
h
// Copyright (c) 2011-2014 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_QT_BITCOINGUI_H #define BITCOIN_QT_BITCOINGUI_H #if defined(HAVE_CONFIG_H) #include "config/stintcoin-config.h" #endif #include "amount.h" #include <QLabel> #include <QMainWindow> #include <QMap> #include <QMenu> #include <QPoint> #include <QPushButton> #include <QSystemTrayIcon> // class ClientModel; class NetworkStyle; class Notificator; class OptionsModel; class BlockExplorer; class RPCConsole; class SendCoinsRecipient; class UnitDisplayStatusBarControl; class WalletFrame; class WalletModel; class MasternodeList; class CWallet; QT_BEGIN_NAMESPACE class QAction; class QProgressBar; class QProgressDialog; QT_END_NAMESPACE /** Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and wallet models to give the user an up-to-date view of the current core state. */ class BitcoinGUI : public QMainWindow { Q_OBJECT public: static const QString DEFAULT_WALLET; explicit BitcoinGUI(const NetworkStyle* networkStyle, QWidget* parent = 0); ~BitcoinGUI(); /** Set the client model. The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic. */ void setClientModel(ClientModel* clientModel); #ifdef ENABLE_WALLET /** Set the wallet model. The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending functionality. */ bool addWallet(const QString& name, WalletModel* walletModel); bool setCurrentWallet(const QString& name); void removeAllWallets(); #endif // ENABLE_WALLET bool enableWallet; bool fMultiSend = false; protected: void changeEvent(QEvent* e); void closeEvent(QCloseEvent* event); void dragEnterEvent(QDragEnterEvent* event); void dropEvent(QDropEvent* event); bool eventFilter(QObject* object, QEvent* event); private: ClientModel* clientModel; WalletFrame* walletFrame; UnitDisplayStatusBarControl* unitDisplayControl; QLabel* labelStakingIcon; QLabel* labelEncryptionIcon; QPushButton* labelConnectionsIcon; QLabel* labelBlocksIcon; QLabel* progressBarLabel; QProgressBar* progressBar; QProgressDialog* progressDialog; QMenuBar* appMenuBar; QAction* overviewAction; QAction* historyAction; QAction* masternodeAction; QAction* quitAction; QAction* sendCoinsAction; QAction* usedSendingAddressesAction; QAction* usedReceivingAddressesAction; QAction* signMessageAction; QAction* verifyMessageAction; QAction* bip38ToolAction; QAction* aboutAction; QAction* receiveCoinsAction; QAction* optionsAction; QAction* toggleHideAction; QAction* encryptWalletAction; QAction* backupWalletAction; QAction* changePassphraseAction; QAction* unlockWalletAction; QAction* lockWalletAction; QAction* lockWalletAction2; QAction* aboutQtAction; QAction* openInfoAction; QAction* openRPCConsoleAction; QAction* openNetworkAction; QAction* openPeersAction; QAction* openRepairAction; QAction* openConfEditorAction; QAction* openMNConfEditorAction; QAction* showBackupsAction; QAction* openAction; QAction* openBlockExplorerAction; QAction* showHelpMessageAction; QAction* multiSendAction; QSystemTrayIcon* trayIcon; QMenu* trayIconMenu; Notificator* notificator; RPCConsole* rpcConsole; BlockExplorer* explorerWindow; /** Keep track of previous number of blocks, to detect progress */ int prevBlocks; int spinnerFrame; /** Create the main UI actions. */ void createActions(const NetworkStyle* networkStyle); /** Create the menu bar and sub-menus. */ void createMenuBar(); /** Create the toolbars */ void createToolBars(); /** Create system tray icon and notification */ void createTrayIcon(const NetworkStyle* networkStyle); /** Create system tray menu (or setup the dock menu) */ void createTrayIconMenu(); /** Enable or disable all wallet-related actions */ void setWalletActionsEnabled(bool enabled); /** Connect core signals to GUI client */ void subscribeToCoreSignals(); /** Disconnect core signals from GUI client */ void unsubscribeFromCoreSignals(); signals: /** Signal raised when a URI was entered or dragged to the GUI */ void receivedURI(const QString& uri); /** Restart handling */ void requestedRestart(QStringList args); public slots: /** Set number of connections shown in the UI */ void setNumConnections(int count); /** Set number of blocks shown in the UI */ void setNumBlocks(int count); /** Get restart command-line parameters and request restart */ void handleRestart(QStringList args); /** Notify the user of an event from the core network or transaction handling code. @param[in] title the message box / notification title @param[in] message the displayed text @param[in] style modality and style definitions (icon and used buttons - buttons only for message boxes) @see CClientUIInterface::MessageBoxFlags @param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only) */ void message(const QString& title, const QString& message, unsigned int style, bool* ret = NULL); void setStakingStatus(); #ifdef ENABLE_WALLET /** Set the encryption status as shown in the UI. @param[in] status current encryption status @see WalletModel::EncryptionStatus */ void setEncryptionStatus(int status); bool handlePaymentRequest(const SendCoinsRecipient& recipient); /** Show incoming transaction notification for new transactions. */ void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address); #endif // ENABLE_WALLET private slots: #ifdef ENABLE_WALLET /** Switch to overview (home) page */ void gotoOverviewPage(); /** Switch to history (transactions) page */ void gotoHistoryPage(); /** Switch to Explorer Page */ void gotoBlockExplorerPage(); /** Switch to masternode page */ void gotoMasternodePage(); /** Switch to receive coins page */ void gotoReceiveCoinsPage(); /** Switch to send coins page */ void gotoSendCoinsPage(QString addr = ""); /** Show Sign/Verify Message dialog and switch to sign message tab */ void gotoSignMessageTab(QString addr = ""); /** Show Sign/Verify Message dialog and switch to verify message tab */ void gotoVerifyMessageTab(QString addr = ""); /** Show MultiSend Dialog */ void gotoMultiSendDialog(); /** Show BIP 38 tool - default to Encryption tab */ void gotoBip38Tool(); /** Show open dialog */ void openClicked(); #endif // ENABLE_WALLET /** Show configuration dialog */ void optionsClicked(); /** Show about dialog */ void aboutClicked(); /** Show help message dialog */ void showHelpMessageClicked(); #ifndef Q_OS_MAC /** Handle tray icon clicked */ void trayIconActivated(QSystemTrayIcon::ActivationReason reason); #endif /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */ void showNormalIfMinimized(bool fToggleHidden = false); /** Simply calls showNormalIfMinimized(true) for use in SLOT() macro */ void toggleHidden(); /** called by a timer to check if fRequestShutdown has been set **/ void detectShutdown(); /** Show progress dialog e.g. for verifychain */ void showProgress(const QString& title, int nProgress); }; class UnitDisplayStatusBarControl : public QLabel { Q_OBJECT public: explicit UnitDisplayStatusBarControl(); /** Lets the control know about the Options Model (and its signals) */ void setOptionsModel(OptionsModel* optionsModel); protected: /** So that it responds to left-button clicks */ void mousePressEvent(QMouseEvent* event); private: OptionsModel* optionsModel; QMenu* menu; /** Shows context menu with Display Unit options by the mouse coordinates */ void onDisplayUnitsClicked(const QPoint& point); /** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */ void createContextMenu(); private slots: /** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */ void updateDisplayUnit(int newUnits); /** Tells underlying optionsModel to update its current display unit. */ void onMenuSelection(QAction* action); }; #endif // BITCOIN_QT_BITCOINGUI_H
7a39a64cfa11459597063a213dfe00b18e43e368
cdab2ef737a481a92fee3e08bbdb7227adbb4259
/typecd/udev_monitor.h
d1fed9c3a1672dbfdea9c20fe92d36f64934efe8
[ "BSD-3-Clause" ]
permissive
manduSry/platform2
a2c1c829e45356b920e6c7ba546324e6d6decfdf
58ede23d2f4cd5651b7afaae5c78893cc836f01d
refs/heads/main
2023-04-06T19:06:50.384147
2020-12-30T04:41:55
2021-01-20T04:53:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,366
h
// Copyright 2020 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef TYPECD_UDEV_MONITOR_H_ #define TYPECD_UDEV_MONITOR_H_ #include <libudev.h> #include <map> #include <memory> #include <string> #include <utility> #include <base/files/file_descriptor_watcher_posix.h> #include <base/files/file_path.h> #include <base/observer_list.h> #include <base/observer_list_types.h> #include <brillo/udev/mock_udev.h> #include <gtest/gtest_prod.h> namespace typecd { constexpr char kTypeCSubsystem[] = "typec"; constexpr char kUdevMonitorName[] = "udev"; // Class to monitor udev events on the Type C subsystem and inform other // objects / classes of these events. class UdevMonitor { public: UdevMonitor() = default; // Create a Udev device for enumeration and monitoring. bool InitUdev(); // Enumerate all existing events/devices, and send the appropriate // notifications to other classes. bool ScanDevices(); // Start monitoring udev for typec events. bool BeginMonitoring(); class Observer : public base::CheckedObserver { public: virtual ~Observer() {} // Callback that is executed when a port is connected or disconnected. // // The |path| argument refers to the sysfs device path of the port. // The |port_num| argmnet refers to the port's index number. // The |added| argument is set to true if the port was added, and false // otherwise. virtual void OnPortAddedOrRemoved(const base::FilePath& path, int port_num, bool added) = 0; // Callback that is executed when a port partner is connected or // disconnected. // // The |path| argument refers to the sysfs device path of the port partner. // The |port_num| argument refers to the port's index number. // The |added| argument is set to true if the partner was added, and false // otherwise. virtual void OnPartnerAddedOrRemoved(const base::FilePath& path, int port_num, bool added) = 0; // Callback that is executed when a port partner alt mode is registered or // removed. // // The |path| argument refers to the sysfs device path of the partner alt // mode. The |port_num| argmnet refers to the port's index number. The // |added| argument is set to true if the alt mode was added, and false // otherwise. virtual void OnPartnerAltModeAddedOrRemoved(const base::FilePath& path, int port_num, bool added) = 0; // Callback that is executed when a port cable is connected or // disconnected. // // The |path| argument refers to the sysfs device path of the port cable. // The |port_num| argument refers to the port's index number. // The |added| argument is set to true if the cable was added, and false // otherwise. virtual void OnCableAddedOrRemoved(const base::FilePath& path, int port_num, bool added) = 0; // Callback that is executed when a cable plug (SOP') device is registered. // // The |path| argument refers to the sysfs device path of the cable plug // (SOP'). The |port_num| argument refers to the port's index number. virtual void OnCablePlugAdded(const base::FilePath& path, int port_num) = 0; // Callback that is executed when a cable (SOP') alternate mode is // registered. // // The |path| argument refers to the sysfs device path of the cable (SOP') // alternate mode. The |port_num| argument refers to the port's index // number. virtual void OnCableAltModeAdded(const base::FilePath& path, int port_num) = 0; // Callback that is executed when a partner "change" event is received. // // The |port_num| argument refers to the port's index number. virtual void OnPartnerChanged(int port_num) = 0; }; void AddObserver(Observer* obs); void RemoveObserver(Observer* obs); private: friend class UdevMonitorTest; FRIEND_TEST(UdevMonitorTest, TestBasic); FRIEND_TEST(UdevMonitorTest, TestHotplug); FRIEND_TEST(UdevMonitorTest, TestInvalidPortSyspath); FRIEND_TEST(UdevMonitorTest, TestCableAndAltModeAddition); FRIEND_TEST(UdevMonitorTest, TestPartnerChanged); // Set the |udev_| pointer to a MockUdev device. *Only* used by unit tests. void SetUdev(std::unique_ptr<brillo::MockUdev> udev) { udev_ = std::move(udev); } // Handle a udev event which causes a Type C device to be added/removed. bool HandleDeviceAddedRemoved(const base::FilePath& path, bool added); // Handle a udev "change" event for a Type C device. void HandleDeviceChange(const base::FilePath& path); // Handle Udev events emanating from |udev_monitor_watcher_|. void HandleUdevEvent(); std::unique_ptr<brillo::Udev> udev_; std::unique_ptr<brillo::UdevMonitor> udev_monitor_; std::unique_ptr<base::FileDescriptorWatcher::Controller> udev_monitor_watcher_; base::ObserverList<Observer> observer_list_; }; } // namespace typecd #endif // TYPECD_UDEV_MONITOR_H_
4430eaf28a36cd2a2d4428597d0db2484ca95e01
cb6b7e15efd75a696f5144701e584f734ff1b713
/chapter 1/1.8.3 买房子.cpp
c2b3eb4e1d7473e138cd14730f0ea27831433e19
[]
no_license
Zhulinjiuying/C-Plus-homework
7d9d523eb282c996b7a176f0c8ca7d44997114d2
74aaef369e280c028f7bdc86528c6eb30e23c9e3
refs/heads/master
2021-08-07T05:02:48.054957
2017-11-07T15:58:07
2017-11-07T15:58:07
109,857,223
0
0
null
null
null
null
UTF-8
C++
false
false
778
cpp
#include <iostream> using namespace std; int main() { int m, flag, a[100], b[100]; int i = 0; double sum = 200.0; flag = 0; m = 1; while (cin >> a[i] >> b[i]) i++; for (int j = 0; j < i; j++) { if (a[j] < 10 || a[j] > 50 || b[j] < 1 || b[j] > 20) { return -1; } if (a[j] == sum) { cout << m << endl; return 0; } m = 2; while (m <= 20) { if (a[j] * m >= sum * (1 + b[j] * 0.01)) { flag = 1; break; } sum *= (1 + b[j] * 0.01); m++; } if (flag == 1) cout << m << endl; else cout << "Impossible" << endl; flag = 0; sum = 200.0; } return 0; }
8d9276b8322f20927a57d9a6545c83b05e40f2ac
2a89e46324a6e0dfa5cad89801379d593a12a4c1
/lua/models/onnx/lua_onnx_runtime_builder_factory.cc
d4654f6c7649227204da2a0a874c5cce0a337726
[ "Apache-2.0" ]
permissive
fzhsbc/ppl.nn
16ca2a4991316cfee2eb40a48a3003caf5dfac70
370a3ff5296b3c2d8768bb2f5220eaa5e65a94a7
refs/heads/master
2023-09-03T18:40:29.524548
2021-11-09T07:59:04
2021-11-09T08:45:10
426,165,992
0
0
Apache-2.0
2021-11-09T09:26:13
2021-11-09T09:26:13
null
UTF-8
C++
false
false
2,262
cc
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. #include "../../engines/lua_engine.h" #include "ppl/nn/models/onnx/onnx_runtime_builder_factory.h" #include "../../runtime/lua_runtime_builder.h" #include "luacpp.h" using namespace std; using namespace luacpp; namespace ppl { namespace nn { namespace lua { void RegisterOnnxRuntimeBuilderFactory(const shared_ptr<LuaState>& lstate, const shared_ptr<LuaTable>& lmodule) { auto builder_class = LuaClass<LuaRuntimeBuilder>(lmodule->Get("RuntimeBuilder")); auto lclass = lstate->CreateClass<OnnxRuntimeBuilderFactory>() .DefStatic("CreateFromFile", [builder_class, lstate](const char* model_file, const LuaTable& engines) -> LuaObject { vector<shared_ptr<Engine>> engine_list; engines.ForEach([&engine_list](uint32_t, const LuaObject& value) -> bool { engine_list.push_back(LuaUserData(value).Get<LuaEngine>()->ptr); return true; }); vector<Engine*> engine_ptrs(engine_list.size()); for (uint32_t i = 0; i < engine_list.size(); ++i) { engine_ptrs[i] = engine_list[i].get(); } auto builder = OnnxRuntimeBuilderFactory::Create(model_file, engine_ptrs.data(), engine_ptrs.size()); if (!builder) { return lstate->CreateNil(); } return builder_class.CreateUserData(engine_list, builder); }); lmodule->Set("OnnxRuntimeBuilderFactory", lclass); } }}}
1be66b82af907107c2e41e4c6fa213ec8220eeaa
f0cd5d5b2e4eeedb40003aeab11bd96ed6230c3d
/GeometricFormGL/triangle.cpp
6b164486f857ce8e40cdd2ef2134034fde2c7fff
[]
no_license
ELezov/OpenGL-glut
3e322b0dac4e26a78dcd9e492abbe5662e1aec4d
1095a4499f5f3b171caca800c7db23e7569b87d0
refs/heads/master
2020-04-06T04:05:02.624739
2016-06-15T23:59:18
2016-06-15T23:59:18
58,453,787
0
0
null
null
null
null
UTF-8
C++
false
false
621
cpp
#include "triangle.h" Triangle::Triangle(QGLWidget *parent) : x0(-200.0f), y0(0.0f), t(10.1f) { } void Triangle::setX0() { if(x0>201) { t=-t; } if(x0<-201) { t=-t; } x0=x0+t+100; // qDebug() << x0 ; a++; } void Triangle::setY0() { y0=cos(x0/5)*5; } void Triangle::slotMove() { setX0(); setY0(); glBegin(GL_TRIANGLES); glColor3d(0,0,1); glVertex3d(x0,y0,0); glColor3d(0,1,0); glVertex3d(x0+15.5,y0+15.5,0); glColor3d(1,0,0); glVertex3d(x0,y0+15.5,0); glEnd(); //updateGL(); }
1d4219028925a2f80c41055005c6ffcdb6762f48
147d96bfb1b03af681db9ae1dd44d495e57b5b45
/samples/strsvsample08/strsvsample08.cpp
747377eb687c0ed5ba9022eda9e0f7962753ef2b
[ "Apache-2.0" ]
permissive
tlk00/BitMagic
fe40d4344895303767aa3a1f3b260b0eaff0e6d4
fa1afb29fefa6a886980b90f72af71f530d5cb5d
refs/heads/master
2023-07-22T04:06:38.272848
2023-07-08T01:13:21
2023-07-08T01:13:21
101,114,435
389
49
NOASSERTION
2023-02-10T19:14:47
2017-08-22T22:54:04
C++
UTF-8
C++
false
false
6,094
cpp
/* Copyright(c) 2002-2022 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com) 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. For more information please visit: http://bitmagic.io */ /** \example strsvsample08.cpp Succinct container binary search \sa bm::str_sparse_vector \sa bm::sparse_vector_scanner \sa bm::sparse_vector_scanner::bind \sa bm::sparse_vector_scanner::bfind_eq_str \sa bm::str_sparse_vector::freeze \sa bm::str_sparse_vector::remap \sa bm::str_sparse_vector::optimize */ /*! \file strsvsample06.cpp \brief Example: Succinct container binary search */ #include <iostream> #include <string> #include <vector> #include <algorithm> #include <random> #include <cassert> #include "bm.h" #include "bmstrsparsevec.h" #include "bmsparsevec_algo.h" #include "bmtimer.h" #include "bmundef.h" /* clear the pre-proc defines from BM */ using namespace std; typedef bm::bvector<> bvector_type; typedef bm::str_sparse_vector<char, bvector_type, 16> str_sv_type; static void GenerateTestStrCollection(std::vector<string>& str_coll, unsigned max_coll) { string prefix = "az"; string str; for (unsigned i = 0; i < max_coll; ++i) { str = prefix; str.append(to_string(i)); str_coll.emplace_back(str); if (i % 1024 == 0) // generate new prefix { prefix.clear(); unsigned prefix_len = (unsigned)rand() % 5; for (unsigned j = 0; j < prefix_len; ++j) { char cch = char('a' + (unsigned)rand() % 26); prefix.push_back(cch); } // for j } } // for i } int main(void) { const unsigned max_coll = 30000000; try { std::vector<string> str_coll; str_sv_type str_sv; cout << "Prepare test data" << endl; cout << " generation ..." << endl; GenerateTestStrCollection(str_coll, max_coll); cout << " sort..." << endl; std::sort(str_coll.begin(), str_coll.end()); str_sv_type str_sv_srt; // sorted succinct vector // fill in using back-insert iterator (fastest mathod to fill in) { auto bi = str_sv_srt.get_back_inserter(); for (auto str : str_coll) bi = str; // important to explicitly flush // ( because destruction flush is not exception safe ) bi.flush(); } cout << " remap-optimize-freeze..." << endl; str_sv_srt.remap(); // apply remapping compression str_sv_srt.optimize(); // RLE compression str_sv_srt.freeze(); // turn into read-only mode // pick the test sets std::vector<string> str_coll_test1; { const unsigned pick_factor = 5; for (size_t i = 0; i < size_t(str_coll.size()); i+=pick_factor) { const string& s = str_coll[i]; str_coll_test1.push_back(s); } // for i std::random_device rd; std::mt19937 g(rd()); std::shuffle(str_coll_test1.begin(), str_coll_test1.end(), g); } cout << "Run test" << endl; size_t sum_pos4=0, sum_pos32=0; // code below illustrates bm::sparse_vector_scanner<> search sampling // parameters: 4 and 32 where 32 offers better performance. // // the use case here is to create a vector-scanner pair, bind then // and repeat multiple searches to vector using its scanner // (scanner maintains the sampled search index (for sorted searches). // // Sampling approach works well, because BM uses hybrid binary search // first narrowing down the seach using uncomprssed samples O(Nlog(N)) // then at the end running a vector search using logical ops with // search space prunning. // // all of the above implements fast search in sorted-compressed array // without decompression // { str_sv_type::size_type pos; bm::sparse_vector_scanner<str_sv_type, 4> scanner; scanner.bind(str_sv_srt, true); // bind sorted vector bm::chrono_taker tt(cout, "bm::sparse_vector_scanner<>::bfind_eq_str() [4] ", 1); for (unsigned i = 0; i < unsigned(str_coll_test1.size()); ++i) { const string& s = str_coll_test1[i]; bool found = scanner.bfind_eq_str(s.c_str(), pos); if (!found) { cerr << "String bfind_eq_str() failure!" << endl; assert(0); exit(1); } sum_pos4 += pos; } // for } { str_sv_type::size_type pos; bm::sparse_vector_scanner<str_sv_type, 32> scanner; scanner.bind(str_sv_srt, true); // bind sorted vector bm::chrono_taker tt(cout, "bm::sparse_vector_scanner<>::bfind_eq_str() [32] ", 1); for (unsigned i = 0; i < unsigned(str_coll_test1.size()); ++i) { const string& s = str_coll_test1[i]; bool found = scanner.bfind_eq_str(s.c_str(), pos); if (!found) { cerr << "String bfind_eq_str() failure!" << endl; assert(0); exit(1); } sum_pos32 += pos; } // for } assert(sum_pos4 == sum_pos32); } catch(std::exception& ex) { std::cerr << ex.what() << std::endl; return 1; } return 0; }
64a0862b5a50f5574ecd519f2a445e884f3aa0ba
fe39e4d1bca62d7bff7b6713b8b596d88f8aa354
/src/plugins/3rdparty/LLVM/include/llvm/Intrinsics.h
3f56bbdae24c5c632f92e975464bbb4b308d100a
[]
no_license
panpanSun/opencor
a29a806475f43adb0f64047631d4dc044f05e030
71449e1ecaa988ea8b6cfea7875d9f3593a8dc26
refs/heads/master
2020-12-24T11:53:33.902565
2013-04-20T18:59:29
2013-04-20T18:59:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,094
h
//===-- llvm/Instrinsics.h - LLVM Intrinsic Function Handling ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines a set of enums which allow processing of intrinsic // functions. Values of these enum types are returned by // Function::getIntrinsicID. // //===----------------------------------------------------------------------===// #ifndef LLVM_INTRINSICS_H #define LLVM_INTRINSICS_H #include "llvm/ADT/ArrayRef.h" #include <string> namespace llvm { class Type; class FunctionType; class Function; class LLVMContext; class Module; class AttrListPtr; /// Intrinsic Namespace - This namespace contains an enum with a value for /// every intrinsic/builtin function known by LLVM. These enum values are /// returned by Function::getIntrinsicID(). /// namespace Intrinsic { enum ID { not_intrinsic = 0, // Must be zero // Get the intrinsic enums generated from Intrinsics.td #define GET_INTRINSIC_ENUM_VALUES #include "llvm/Intrinsics.gen" #undef GET_INTRINSIC_ENUM_VALUES , num_intrinsics }; /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as /// "llvm.ppc.altivec.lvx". std::string getName(ID id, ArrayRef<Type*> Tys = ArrayRef<Type*>()); /// Intrinsic::getType(ID) - Return the function type for an intrinsic. /// FunctionType *getType(LLVMContext &Context, ID id, ArrayRef<Type*> Tys = ArrayRef<Type*>()); /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be /// overloaded. bool isOverloaded(ID id); /// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic. /// AttrListPtr getAttributes(LLVMContext &C, ID id); /// Intrinsic::getDeclaration(M, ID) - Create or insert an LLVM Function /// declaration for an intrinsic, and return it. /// /// The Tys and numTys parameters are for intrinsics with overloaded types /// (e.g., those using iAny, fAny, vAny, or iPTRAny). For a declaration for an /// overloaded intrinsic, Tys should point to an array of numTys pointers to /// Type, and must provide exactly one type for each overloaded type in the /// intrinsic. Function *getDeclaration(Module *M, ID id, ArrayRef<Type*> Tys = ArrayRef<Type*>()); /// Map a GCC builtin name to an intrinsic ID. ID getIntrinsicForGCCBuiltin(const char *Prefix, const char *BuiltinName); /// IITDescriptor - This is a type descriptor which explains the type /// requirements of an intrinsic. This is returned by /// getIntrinsicInfoTableEntries. struct IITDescriptor { enum IITDescriptorKind { Void, MMX, Metadata, Float, Double, Integer, Vector, Pointer, Struct, Argument, ExtendVecArgument, TruncVecArgument } Kind; union { unsigned Integer_Width; unsigned Float_Width; unsigned Vector_Width; unsigned Pointer_AddressSpace; unsigned Struct_NumElements; unsigned Argument_Info; }; enum ArgKind { AK_AnyInteger, AK_AnyFloat, AK_AnyVector, AK_AnyPointer }; unsigned getArgumentNumber() const { assert(Kind == Argument || Kind == ExtendVecArgument || Kind == TruncVecArgument); return Argument_Info >> 2; } ArgKind getArgumentKind() const { assert(Kind == Argument || Kind == ExtendVecArgument || Kind == TruncVecArgument); return (ArgKind)(Argument_Info&3); } static IITDescriptor get(IITDescriptorKind K, unsigned Field) { IITDescriptor Result = { K, { Field } }; return Result; } }; /// getIntrinsicInfoTableEntries - Return the IIT table descriptor for the /// specified intrinsic into an array of IITDescriptors. /// void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl<IITDescriptor> &T); } // End Intrinsic namespace } // End llvm namespace #endif
572281e44ec6cf8712204058a049758592c9c54f
d1f5cbc5b9a9c9d9aa8a9d8e34c6c4857f893d9e
/src/libtid/sdl_tid_client.h
7d68f723eb0ca9828f6a947309f02501d4ccdd43
[]
no_license
tools4BCI/core
fcdc3abd57c49281247c5801a7c092fdda3d4447
2aee8c29334e6e00a375b86235bf27cbbc284dc5
refs/heads/master
2020-09-26T07:59:55.079724
2017-04-24T17:18:18
2017-04-24T17:18:18
66,266,070
1
1
null
null
null
null
UTF-8
C++
false
false
1,760
h
/* This file is part of TOBI Interface D (TiD). TOBI Interface D (TiD) is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. TOBI Interface D (TiD) 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 TOBI Interface D (TiD). If not, see <http://www.gnu.org/licenses/>. Copyright 2012 Christian Breitwieser Contact: [email protected] */ #ifndef SDL_TID_CLIENT_H #define SDL_TID_CLIENT_H #include "tid_client_base.h" #include <SDL/SDL_thread.h> //----------------------------------------------------------------------------- namespace TiD { class SDLTiDClient : public TiDClientBase { public: SDLTiDClient(); virtual ~SDLTiDClient(); virtual void startReceiving( bool throw_on_error = 0 ); virtual void stopReceiving(); private: static int run_io_service(void* instance); //static int SDLreceive(void *instance); private: SDL_Thread* receive_thread_; SDL_Thread* io_service_thread_; SDL_Thread* io_service_thread_2_; }; //----------------------------------------------------------------------------- } //TiD #endif // SDL_TID_CLIENT_H
6a125acb890ca39a86ccad40c3af812ad283e8a0
d87d113b55091f8674146d56d8d46d7eba6b2ee6
/StrongItem.cpp
8b5b42fdc66fc3f5a639bfe9504c7f97e0b2e8b0
[]
no_license
IuliaCristea/TheWalk
7716b1965098c1df95d38780df58d2693e06c43a
24bf70689fac8e839b6d25a91c01a4f7003129a0
refs/heads/master
2020-03-14T08:42:06.473126
2018-04-29T21:17:05
2018-04-29T21:17:05
130,861,290
0
0
null
null
null
null
UTF-8
C++
false
false
427
cpp
#include "StrongItem.hpp" void StrongItem::useItem(SmartRobot &smR) { std::cout << "Smart Robot cannot use Strong Item.\n"; } void StrongItem::useItem(StrongRobot &stR) { stR.UpdateNoOfItems(1); stR.isItemActive(true); std::cout << "Strong Robot cannot be affected by the next trap.\n"; } void StrongItem::useItem(ComplexRobot &cR) { std::cout << "Complex Robot cannot use Strong Item.\n"; }
31118192114c0b455970a9a836d6bc77ff6b3cb3
b126a8248240fd71653159beeccc732ca49f49c2
/OpenCascade/BRepPrimAPI_MakeOneAxis.hxx
fdb2829030d532c08ce3299c9399884c9c10e270
[]
no_license
jicc/3rdpartyincludes
90fd194a37082027482043c56e66cfdafa386d2b
f790f816dc2c4ef5868189b87cb6edb65a755538
refs/heads/master
2021-01-14T13:39:24.774980
2013-07-26T08:15:01
2013-07-26T08:15:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,075
hxx
// This file is generated by WOK (CPPExt). // Please do not edit this file; modify original file instead. // The copyright and license terms as defined for the original file apply to // this header file considered to be the "object code" form of the original source. #ifndef _BRepPrimAPI_MakeOneAxis_HeaderFile #define _BRepPrimAPI_MakeOneAxis_HeaderFile #ifndef _Standard_HeaderFile #include <Standard.hxx> #endif #ifndef _Standard_Macro_HeaderFile #include <Standard_Macro.hxx> #endif #ifndef _BRepBuilderAPI_MakeShape_HeaderFile #include <BRepBuilderAPI_MakeShape.hxx> #endif #ifndef _Standard_Address_HeaderFile #include <Standard_Address.hxx> #endif class StdFail_NotDone; class TopoDS_Face; class TopoDS_Shell; class TopoDS_Solid; //! The abstract class MakeOneAxis is the root class of <br> //! algorithms used to construct rotational primitives. <br> class BRepPrimAPI_MakeOneAxis : public BRepBuilderAPI_MakeShape { public: void* operator new(size_t,void* anAddress) { return anAddress; } void* operator new(size_t size) { return Standard::Allocate(size); } void operator delete(void *anAddress) { if (anAddress) Standard::Free((Standard_Address&)anAddress); } //! The inherited commands should provide the algorithm. <br> //! Returned as a pointer. <br> Standard_EXPORT virtual Standard_Address OneAxis() = 0; //! Stores the solid in myShape. <br> Standard_EXPORT virtual void Build() ; //! Returns the lateral face of the rotational primitive. <br> //! <br> Standard_EXPORT const TopoDS_Face& Face() ; Standard_EXPORT operator TopoDS_Face(); //! Returns the constructed rotational primitive as a shell. <br> Standard_EXPORT const TopoDS_Shell& Shell() ; Standard_EXPORT operator TopoDS_Shell(); //! Returns the constructed rotational primitive as a solid. <br> Standard_EXPORT const TopoDS_Solid& Solid() ; Standard_EXPORT operator TopoDS_Solid(); protected: private: }; // other Inline functions and methods (like "C++: function call" methods) #endif
6ee5ffab95f62ad749fc33d154e757c38f35be6d
dc38c8a3b0e9b13afb83fbe78269638c60bd32cd
/91. Decode Ways/main.cpp
0bdeb3b2070f7851522f168ecc93d3ef9b85a4cb
[]
no_license
TG-yang/LeetCode
603da8e8121ad2ed7d05bac0d4ee6d61378eeff3
1749b35170636830b3f91777ac57d049278b2b2e
refs/heads/master
2020-04-09T09:20:13.129761
2019-08-16T17:10:42
2019-08-16T17:10:42
160,229,673
0
1
null
null
null
null
UTF-8
C++
false
false
718
cpp
#include <iostream> #include <string> #include <vector> using namespace std; class Solution { public: int numDecodings(string s) { if(s.size() == 0 || s[0] == '0') return 0; vector<int>dp(s.size() + 1, 0); dp[0] = 1; dp[1] = 1; for(int i = 1; i < s.size(); ++i){ int tmp = (int)atoi(s.substr(i - 1, 2).c_str()); //c_str()函数返回一个指向正规C字符串的指针常量 if(tmp >= 10 && tmp <= 26) dp[i + 1] += dp[i - 1]; if(tmp % 10 != 0) dp[i + 1] += dp[i]; } return dp[s.size()]; } }; int main() { std::cout << "Hello, World!" << std::endl; return 0; }
b64e6c627c1549955cf70a36441289321168540a
bc407d25aa3da4babdb9762f53a201a7ea84b976
/ArquitecturaDeComputadoras/7segments/sys/module.h
e5f750f7d665130624d7a499f5e6227b1ca7fe46
[]
no_license
YurleySolimer/ULA
e91344815d32175a13b7cd7ee153f16a1b237580
57c2caa895e0635f215d9f98e9fad05227bf5f90
refs/heads/master
2020-04-14T19:30:26.932376
2019-01-04T05:07:30
2019-01-04T05:07:30
164,060,266
0
0
null
null
null
null
UTF-8
C++
false
false
1,798
h
# ifndef MODULE_H_ # define MODULE_H_ # include<systemc.h> # include<string> class SevenSegments:public sc_module{ public: sc_in<sc_uint<4> > x_in; sc_out<bool > z_out[7]; SC_CTOR(SevenSegments){ SC_METHOD(operation); sensitive<<x_in; } ~SevenSegments(){} private: void operation(){ if(x_in.read()==0){ for(int i=0;i<7;i++){ if(i!=5) z_out[i].write(1); else z_out[i].write(0); } return; } else if(x_in.read()==1){ for(int i=0;i<7;i++){ if(i==1 or i==2) z_out[i].write(1); else z_out[i].write(0); } return; } else if(x_in.read()==2){ for(int i=0;i<7;i++){ if(i==2 or i==6) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==3){ for(int i=0;i<7;i++){ if(i==4 or i==6) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==4){ for(int i=0;i<7;i++){ if(i==0 or i==3 or i==4) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==5){ for(int i=0;i<7;i++){ if(i==1 or i==4) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==6){ for(int i=0;i<7;i++){ if(i==1) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==7){ for(int i=0;i<7;i++){ if(i==3 or i==4 or i==6) z_out[i].write(0); else z_out[i].write(1); } return; } else if(x_in.read()==8){ for(int i=0;i<7;i++) z_out[i].write(1); return; } else if(x_in.read()==9){ for(int i=0;i<7;i++){ if(i==3 or i==4) z_out[i].write(0); else z_out[i].write(1); } return; } } };/*end of class SevenSegments*/ #endif/*end of SEVENSEGMENTS_H*/
7b49be857fc0a0d279f1daa26b81aec28da0ce35
b6a885754d36f6d7507433536090d54ee9890e52
/ch13/No.4/No.4/main.cpp
481308358cedf0e606e345e62fc20ce824149760
[]
no_license
szw-20731/CPrimerPlus
841bdfa5d04080e8ffdba1db6baac07a13456725
9cb038164feda21389501329652028b17caae63b
refs/heads/master
2022-12-09T18:27:21.683546
2020-09-07T02:08:28
2020-09-07T02:08:28
286,395,009
1
0
null
null
null
null
UTF-8
C++
false
false
303
cpp
#include "port.h" int main() { port *list[2]; list[0] = new port("Brand", "ruby", 10); list[1] = new vintageport("VBrand", 10, "szw", 2020); list[0]->show(); cout << *list[0] << endl; list[1]->show(); cout << *list[1] << endl; list[0] = list[1]; list[0]->show(); system("pause"); return 0; }
842d4df2c4e0d18721f5aae7b135fa3f1d3afe1d
fae551eb54ab3a907ba13cf38aba1db288708d92
/android_webview/browser/page_load_metrics/aw_page_load_metrics_memory_tracker_factory.cc
f6fa46af4978e76325c494c6b713bceee6af1973
[ "BSD-3-Clause" ]
permissive
xtblock/chromium
d4506722fc6e4c9bc04b54921a4382165d875f9a
5fe0705b86e692c65684cdb067d9b452cc5f063f
refs/heads/main
2023-04-26T18:34:42.207215
2021-05-27T04:45:24
2021-05-27T04:45:24
371,258,442
2
1
BSD-3-Clause
2021-05-27T05:36:28
2021-05-27T05:36:28
null
UTF-8
C++
false
false
1,815
cc
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "android_webview/browser/page_load_metrics/aw_page_load_metrics_memory_tracker_factory.h" #include "base/memory/singleton.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" #include "components/page_load_metrics/browser/page_load_metrics_memory_tracker.h" namespace android_webview { page_load_metrics::PageLoadMetricsMemoryTracker* AwPageLoadMetricsMemoryTrackerFactory::GetForBrowserContext( content::BrowserContext* context) { return static_cast<page_load_metrics::PageLoadMetricsMemoryTracker*>( GetInstance()->GetServiceForBrowserContext(context, true)); } AwPageLoadMetricsMemoryTrackerFactory* AwPageLoadMetricsMemoryTrackerFactory::GetInstance() { return base::Singleton<AwPageLoadMetricsMemoryTrackerFactory>::get(); } AwPageLoadMetricsMemoryTrackerFactory::AwPageLoadMetricsMemoryTrackerFactory() : BrowserContextKeyedServiceFactory( "PageLoadMetricsMemoryTracker", BrowserContextDependencyManager::GetInstance()) {} bool AwPageLoadMetricsMemoryTrackerFactory::ServiceIsCreatedWithBrowserContext() const { return base::FeatureList::IsEnabled(features::kV8PerFrameMemoryMonitoring); } KeyedService* AwPageLoadMetricsMemoryTrackerFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { return new page_load_metrics::PageLoadMetricsMemoryTracker(); } content::BrowserContext* AwPageLoadMetricsMemoryTrackerFactory::GetBrowserContextToUse( content::BrowserContext* context) const { return context; } } // namespace android_webview
2053f82eae2982ae0df5fc7e240259c0a24f7576
9168a725fa2682e533d4d5aa66453b4322926c32
/src/includes/Head.h
a37759cb43b5682ddecb065f68ca0afb51e6443c
[]
no_license
Technohacker/lpmln
01a8999dd4c2073cea56141f9d00d44a041046d2
0008244e23d49860d09f2e3077cbbb3b6e85b39b
refs/heads/master
2023-08-23T16:35:50.494206
2017-01-18T23:27:33
2017-01-18T23:27:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,993
h
#pragma once #include "Predicate.h" class Head { public: Head(Predicate _p){ predList.push_back(_p); } ~Head(); Head(std::vector<Predicate> _predList):predList(_predList){} inline Predicate getPredicate() { return predList.at(0); } inline std::vector<Predicate> getPredicateList() { return predList; } void addPredicate(Predicate _p) { predList.push_back(_p); } inline std::string toString() const{ // return predList.at(0).toString(); return headStr; } std::string toString(const std::set<std::string>& domainList) const{ std::string str; for (unsigned int i = 0; i < predList.size(); ++i){ str += predList.at(i).toString(domainList); str += " ; "; } str = str.substr(0,str.size()-3); return str; } inline std::string getExtra(const std::set<Variable>& variable){ std::string str; for (std::vector<Predicate>::iterator i = predList.begin(); i != predList.end(); ++i){ std::string s = i->getExtra(variable); if(s.length() != 0){ str += s; str += " , "; } } if(str.length() > 3) str = str.substr(0,str.size()-3); return str; } void appendStr(std::string, bool, bool, bool); inline void setDisjunction(bool val){ isDisjunction = val; } inline bool getDisjunction(){ return isDisjunction; } std::set<std::string> getConstantSet(){ std::set<std::string> intermediateSet; for (unsigned int i = 0; i < predList.size(); ++i){ if(!predList.at(i).getConstants().empty()){ for(auto it : predList.at(i).getConstants()){ intermediateSet.insert(it); } } } return intermediateSet; } std::string toNNFString(const std::set<std::string>& domainList){ std::string str; for (unsigned int i = 0; i < predList.size(); ++i){ str += "not "; str += predList.at(i).toString(domainList); str += " , "; } str = str.substr(0,str.size()-3); return str; } private: std::vector<Predicate> predList; bool isDisjunction = false; Predicate p; std::string headStr; };
d066ed3355e74b5aae573a376fb99a31de6e46fa
5b5d0480d61746875d8694182f291911b415fab4
/335_012/Matrix.cpp
8a91809c8104a5917fec5c88dd9574109db45350
[ "FSFAP" ]
permissive
joseluisrojas12/CSCI335-Project
9008d494081054754734d261b6508bf7dece4412
6dc8db526126ec2fefa54b1362c0543cc80c1e64
refs/heads/master
2022-10-07T19:02:15.421048
2020-06-03T02:48:27
2020-06-03T02:48:27
268,955,444
0
0
null
null
null
null
UTF-8
C++
false
false
1,371
cpp
#include "Matrix.h" // template specialization for the float type, it compares the values up to a given tolerance // since float equality is not possible template<> bool Matrix<float>::equals(Matrix<float> mat) { if (m!=mat.getM() || n!=mat.getN()) // if the dimensions are not equal return false; // the matrices are not equal for (int row=0; row<mat.getM(); row++) // go through all the matrix elements for(int col=0; col<mat.getN(); col++) if(std::abs(this->mat[row][col]-mat[row][col])>TOL) // if any element is different, return false; return true; // if we reach this point the matrices are equal } // template specialization for the double type, it compares the values up to a given tolerance // since double number equality is not possible template<> bool Matrix<double>::equals(Matrix<double> mat) { if (m!=mat.getM() || n!=mat.getN()) // if the dimensions are not equal return false; // the matrices are not equal for (int row=0; row<mat.getM(); row++) // go through all the matrix elements for(int col=0; col<mat.getN(); col++) if(std::abs(this->mat[row][col]-mat[row][col])>TOL) // if any element is different, return false; // the matrices are not equal return true; // if we reach this point the matrices are equal }
a661ea609463490b04edd08dddcfb5af33834a8d
5a2349399fa9d57c6e8cc6e0f7226d683391a362
/src/qt/qtbase/src/plugins/platforms/android/qandroidplatformmenu.cpp
1ecabb25e2c0f41e14c3f1587793a4d5744e9fec
[ "LGPL-2.1-only", "GPL-3.0-only", "LicenseRef-scancode-digia-qt-commercial", "Qt-LGPL-exception-1.1", "LicenseRef-scancode-digia-qt-preview", "LGPL-2.0-or-later", "GFDL-1.3-only", "BSD-3-Clause" ]
permissive
aharthcock/phantomjs
e70f3c379dcada720ec8abde3f7c09a24808154c
7d7f2c862347fbc7215c849e790290b2e07bab7c
refs/heads/master
2023-03-18T04:58:32.428562
2023-03-14T05:52:52
2023-03-14T05:52:52
24,828,890
0
0
BSD-3-Clause
2023-03-14T05:52:53
2014-10-05T23:38:56
C++
UTF-8
C++
false
false
5,172
cpp
/**************************************************************************** ** ** Copyright (C) 2012 BogDan Vatra <[email protected]> ** Contact: http://www.qt-project.org/legal ** ** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and Digia. For licensing terms and ** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional ** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qandroidplatformmenu.h" #include "qandroidplatformmenuitem.h" #include "androidjnimenu.h" QAndroidPlatformMenu::QAndroidPlatformMenu() { m_tag = reinterpret_cast<quintptr>(this); // QMenu will overwrite this later, but we need a unique ID for QtQuick m_enabled = true; m_isVisible = true; } QAndroidPlatformMenu::~QAndroidPlatformMenu() { QtAndroidMenu::androidPlatformMenuDestroyed(this); } void QAndroidPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) { QMutexLocker lock(&m_menuItemsMutex); m_menuItems.insert(qFind(m_menuItems.begin(), m_menuItems.end(), static_cast<QAndroidPlatformMenuItem *>(before)), static_cast<QAndroidPlatformMenuItem *>(menuItem)); } void QAndroidPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem) { QMutexLocker lock(&m_menuItemsMutex); PlatformMenuItemsType::iterator it = qFind(m_menuItems.begin(), m_menuItems.end(), static_cast<QAndroidPlatformMenuItem *>(menuItem)); if (it != m_menuItems.end()) m_menuItems.erase(it); } void QAndroidPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem) { PlatformMenuItemsType::iterator it; for (it = m_menuItems.begin(); it != m_menuItems.end(); ++it) { if ((*it)->tag() == menuItem->tag()) break; } if (it != m_menuItems.end()) QtAndroidMenu::syncMenu(this); } void QAndroidPlatformMenu::syncSeparatorsCollapsible(bool enable) { Q_UNUSED(enable) } void QAndroidPlatformMenu::setTag(quintptr tag) { m_tag = tag; } quintptr QAndroidPlatformMenu::tag() const { return m_tag; } void QAndroidPlatformMenu::setText(const QString &text) { m_text = text; } QString QAndroidPlatformMenu::text() const { return m_text; } void QAndroidPlatformMenu::setIcon(const QIcon &icon) { m_icon = icon; } QIcon QAndroidPlatformMenu::icon() const { return m_icon; } void QAndroidPlatformMenu::setEnabled(bool enabled) { m_enabled = enabled; } bool QAndroidPlatformMenu::isEnabled() const { return m_enabled; } void QAndroidPlatformMenu::setVisible(bool visible) { m_isVisible = visible; } bool QAndroidPlatformMenu::isVisible() const { return m_isVisible; } void QAndroidPlatformMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item) { Q_UNUSED(parentWindow); Q_UNUSED(pos); Q_UNUSED(item); setVisible(true); QtAndroidMenu::showContextMenu(this); } QPlatformMenuItem *QAndroidPlatformMenu::menuItemAt(int position) const { if (position < m_menuItems.size()) return m_menuItems[position]; return 0; } QPlatformMenuItem *QAndroidPlatformMenu::menuItemForTag(quintptr tag) const { foreach (QPlatformMenuItem *menuItem, m_menuItems) { if (menuItem->tag() == tag) return menuItem; } return 0; } QAndroidPlatformMenu::PlatformMenuItemsType QAndroidPlatformMenu::menuItems() const { return m_menuItems; } QMutex *QAndroidPlatformMenu::menuItemsMutex() { return &m_menuItemsMutex; }
53f7fb763db9343529a6fe628fedc13011357353
e6063f71497be719a76f0ae9f1f7dbcfda1988c6
/tree/173_BST_iterator/work.cc
72b33d1ebac40f7adae1fea49feb95be7abe252f
[]
no_license
uangyy/leetcode
f308672a662fa1e881230b31b7674160d45c2494
912b683db040a9efbe5b58c329e2978097207ab0
refs/heads/master
2021-01-09T21:57:21.758043
2017-08-04T08:21:09
2017-08-04T08:21:09
36,731,293
1
0
null
null
null
null
UTF-8
C++
false
false
1,319
cc
#include <iostream> #include <vector> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class BSTIterator { public: vector<TreeNode *> stack; TreeNode *current; BSTIterator(TreeNode *root) { current = root; while (current) { stack.push_back(current); current = current->left; } } /** @return whether we have a next smallest number */ bool hasNext() { return !stack.empty() || current; } /** @return the next smallest number */ int next() { current = *stack.rbegin(); stack.pop_back(); int res = current->val; current = current->right; while (current) { stack.push_back(current); current = current->left; } return res; } }; /* * Your BSTIterator will be called like this: * BSTIterator i = BSTIterator(root); * while (i.hasNext()) cout << i.next(); */ int main(int argc, char **argv) { TreeNode n1(1), n2(2), n3(3), n4(4); n2.left = &n1; n2.right = &n3; n3.right = &n4; BSTIterator i = BSTIterator(&n2); while (i.hasNext()) cout << i.next() << " "; cout << endl; return 0; }
6faf68ca1aeedfe57ef226b324b6ba48fc0c21fb
14d143bdce06a43565034aa6e6cf072ee6648f31
/include/orwell/proxy/SimpleTeam.hpp
e77c91d4c421778817a610ddc5ecbf48e53c6fde
[ "BSD-3-Clause" ]
permissive
orwell-int/server-game
599a5c86330947ba830efe33bec5489f81b28c25
d3c410ff734a6f32de0303b25d816ae392df8a18
refs/heads/master
2021-01-18T22:44:47.807869
2020-11-16T13:00:31
2020-11-16T13:00:31
9,554,529
0
2
BSD-3-Clause
2020-11-16T13:00:32
2013-04-19T21:01:01
C++
UTF-8
C++
false
false
444
hpp
#pragma once #include <memory> #include <string> #include <vector> #include <nlohmann/json_fwd.hpp> namespace orwell { namespace game { class Team; } namespace proxy { struct SimpleTeam { SimpleTeam(game::Team const & iTeam); SimpleTeam(SimpleTeam const & iOther); std::string const m_name; uint32_t const m_score; std::vector< std::string > const m_robots; }; void to_json(nlohmann::json & oJson, SimpleTeam const & iTeam); } }
80b2e30aca84e8387c6fe493989e0629d9681e18
7fcef731b4054ca365062b19f90840c69ed35071
/mainwindow.cpp
8b2adf9ac753dac3e325e8100cb2e973e9f74b82
[]
no_license
kacpwoja/EGUI_Calendar_Qt
b40f49de5b44d4b4ef9f6f37ba951dbcfb4347af
45d4942c0c9a3232cfe192de0c86cd093f3137ff
refs/heads/master
2022-04-11T00:20:20.457625
2020-04-09T18:06:32
2020-04-09T18:06:32
249,783,068
0
0
null
null
null
null
UTF-8
C++
false
false
3,279
cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QCalendarWidget> #include <QTextCharFormat> #include <QVector> #include <QFile> #include <QJsonDocument> #include "daywindow.h" #include "eventwindow.h" #include "eventbase.h" #define FILENAME "events.json" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); //READ FROM FILE QFile loadFile(QStringLiteral(FILENAME)); if(!loadFile.open(QIODevice::ReadOnly)) { qWarning("File was not read."); EventDB.clear(); } else { QJsonDocument doc = QJsonDocument::fromJson(loadFile.readAll()); EventDB.read(doc.object()); } loadFile.close(); formatCalendar(); connect(ui->todayButton, &QPushButton::released, this, &MainWindow::selectToday); connect(ui->newEventButton, &QPushButton::released, this, &MainWindow::newEvent); connect(ui->calendar, &QCalendarWidget::selectionChanged, this, &MainWindow::updateTopText); connect(ui->calendar, &QCalendarWidget::activated, this, &MainWindow::viewDay); connect(&EventDB, &EventBase::baseUpdated, this, &MainWindow::formatCalendar); connect(ui->calendar, &QCalendarWidget::currentPageChanged, this, &MainWindow::formatCalendar); } MainWindow::~MainWindow() { //SAVE TO FILE QFile saveFile(QStringLiteral(FILENAME)); if(!saveFile.open(QIODevice::WriteOnly)) qWarning("File was not saved."); QJsonObject obj; EventDB.write(obj); QJsonDocument doc(obj); saveFile.write(doc.toJson()); saveFile.close(); delete ui; } void MainWindow::selectToday() { ui->calendar->setSelectedDate(QDate::currentDate()); } void MainWindow::formatCalendar() { updateTopText(); // Reset format for all days ui->calendar->setDateTextFormat(QDate(), QTextCharFormat()); // Format for event days QTextCharFormat eventFormat; auto palette = qApp->palette(); eventFormat.setBackground(palette.brush(QPalette::Mid)); // Setting format for all event days QDate it = QDate(ui->calendar->yearShown(), ui->calendar->monthShown(), 1); while(it.month() == ui->calendar->monthShown()) { if(EventDB.count(it) > 0) { ui->calendar->setDateTextFormat(it, eventFormat); } it = it.addDays(1); } } void MainWindow::updateTopText() { QString dateText; QString pluralSuffix = ""; QString eventText; // Getting date if(ui->calendar->selectedDate() == QDate::currentDate()) dateText = "today"; else dateText = "on " + ui->calendar->selectedDate().toString("d MMMM yyyy"); // Getting event count int events = EventDB.count(ui->calendar->selectedDate()); if(events != 1) pluralSuffix = "s"; if(events == 0) eventText = "no"; else eventText = QString::number(events); ui->dayEventsLabel->setText("You have " + eventText + " event" + pluralSuffix + " " + dateText + "."); } void MainWindow::viewDay(const QDate& date) { DayWindow* dayWin = new DayWindow(date, this); dayWin->exec(); } void MainWindow::newEvent() { EventWindow* eventWin = new EventWindow(ui->calendar->selectedDate(), this); eventWin->exec(); }
b3b9530ab97cdb6ebe7ddc5c15e675cf96d9df5e
a9e079d6f99d83a4e1f4ae2c426654119d867518
/plant_watering_code.ino
3d120e9eaf76cc0d44138172198900a80d86644f
[]
no_license
ravikumar752/plant-water-code-using-arduino-
14764958748af0bf705c96005fc06bcb78b0e7d0
7849258675c46598a0352f88a230fc29579a2f21
refs/heads/main
2023-05-02T14:38:28.356234
2021-05-19T16:28:24
2021-05-19T16:28:24
368,933,623
0
0
null
null
null
null
UTF-8
C++
false
false
533
ino
const int analogInPin = A5; //Sensor pin int relay = 2; //Relay Pin int sensorValue = 0; int outputValue = 0; void setup() { Serial.begin(9600); pinMode(relay,OUTPUT); } void loop() { sensorValue = analogRead(analogInPin); //Read sesnor value Serial.print("sensor = "); Serial.println(sensorValue); //Display the sensor value in serial monitor if (sensorValue >= 350) { digitalWrite(relay,HIGH); //Relay ON } else if (sensorValue <= 250) { digitalWrite(relay,LOW); //Relay OFF } }
ff8ea931404a23537871eee18d88d7c6b8afe0de
0c7e20a002108d636517b2f0cde6de9019fdf8c4
/Sources/Elastos/External/conscrypt/src/org/conscrypt/COpenSSLServerSocketFactoryImpl.cpp
82c1ce7df4bc5066f977763f52c104c8bfa7f239
[ "Apache-2.0" ]
permissive
kernal88/Elastos5
022774d8c42aea597e6f8ee14e80e8e31758f950
871044110de52fcccfbd6fd0d9c24feefeb6dea0
refs/heads/master
2021-01-12T15:23:52.242654
2016-10-24T08:20:15
2016-10-24T08:20:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
194
cpp
#include "org/conscrypt/COpenSSLServerSocketFactoryImpl.h" namespace Org { namespace Conscrypt { CAR_OBJECT_IMPL(COpenSSLServerSocketFactoryImpl) } // namespace Conscrypt } // namespace Org
a1a9d822c2575811f5e9e25eb492c9194cb1a987
a4ebc4a5f5d25480b875bba7e288bda9686ee0e3
/WorldMT/main.cpp
fb23afe815d6791fd0fa5fd501d3b03164d0def9
[]
no_license
shikazu/AthenaMT
e82f6860b8e002e581a4fe46f1b412e366a6e867
b04c97afe2267c27e99fe2f2ffc284f81773ad61
refs/heads/master
2021-01-10T04:18:35.534972
2015-10-28T11:03:11
2015-10-28T11:03:11
44,395,864
6
0
null
null
null
null
UTF-8
C++
false
false
223
cpp
#include <iostream> #include <thread> #include "World\WorldMain.h" int main(int argc, char **argv) { World::WorldMain world_main; while (true) { std::this_thread::sleep_for(std::chrono::seconds(1)); } return 0; }
bc11c519dbd8362cbcd4ada4658dc411d186c86d
ef9c90197796606ee5d3d800d9823f2b332070a6
/hw04/src/mygl.cpp
49c4d8755316f7e412c3807e8df8a5e5a1e4d315
[]
no_license
hehehaha12139/CIS-460-560
d5af73f7091389040e3e0c962af55052a026679c
b76be1eb5c5f7085e6669059399520576a69e07b
refs/heads/master
2020-09-06T08:58:13.030233
2017-02-21T17:40:48
2017-02-21T17:40:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,952
cpp
#include "mygl.h" #include <la.h> #include <iostream> #include <QApplication> #include <QKeyEvent> MyGL::MyGL(QWidget *parent) : GLWidget277(parent), geom_cylinder(this), geom_sphere(this), geom_cube(this), geom_cone(this), geom_pipe(this), //TODO: When you make your Cube instance, add it to this init list prog_lambert(this), prog_flat(this) { } MyGL::~MyGL() { makeCurrent(); glDeleteVertexArrays(1, &vao); geom_cylinder.destroy(); geom_sphere.destroy(); geom_cube.destroy(); geom_cone.destroy(); geom_pipe.destroy(); } void MyGL::initializeGL() { // Create an OpenGL context using Qt's QOpenGLFunctions_3_2_Core class // If you were programming in a non-Qt context you might use GLEW (GL Extension Wrangler)instead initializeOpenGLFunctions(); // Print out some information about the current OpenGL context debugContextVersion(); // Set a few settings/modes in OpenGL rendering glEnable(GL_DEPTH_TEST); glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); // Set the size with which points should be rendered glPointSize(5); // Set the color with which the screen is filled at the start of each render call. glClearColor(0.5, 0.5, 0.5, 1); printGLErrorLog(); // Create a Vertex Attribute Object glGenVertexArrays(1, &vao); //Create the instances of Cylinder Sphere and cube. geom_cylinder.create(); geom_sphere.create(); geom_cube.create(); geom_cone.create(); geom_pipe.create(); Root = new Node(); // lower limb should rotate around its joint // this step is to move the rotation pivot from its geometry center to its edge center. TranslateNode LowerLimbTranslate_1(0,0.5f,0); // We need to rotate 180 degrees so that the vertex part should be facing downwards. // FOR TAs: make changes to the degree and you can rotate this part, e.c 150 degrees. RotateNode LowerLimbRotate(180,1,0,0); ScaleNode LowerLimbScale(1.0f,2.0f,1.0f); // move this geometry back to the position it should be, which connects with upper limb. TranslateNode LowerLimbTranslate_2(0.0f,1.0f,0.0f); LowerLimb = new Node(LowerLimbTranslate_1.MatrixStored() * LowerLimbRotate.MatrixStored() * \ LowerLimbScale.MatrixStored() * LowerLimbTranslate_2.MatrixStored(), \ QString("LowerLimb")); LowerLimb->setGeomColor(glm::vec4(0,1,0,1)); LowerLimb->setGeometry(&geom_cone); TranslateNode UpperLimbTranslate(0,-1.0f,0); RotateNode UpperLimbRotate(0,0,0,0); ScaleNode UpperLimbScale(1.0f,1.0f,0.5f); UpperLimb = new Node(UpperLimbTranslate.MatrixStored() * UpperLimbRotate.MatrixStored() * UpperLimbScale.MatrixStored(), \ QString("UpperLimb")); UpperLimb->setGeomColor(glm::vec4(1,1,0,1)); UpperLimb->setGeometry(&geom_cylinder); UpperLimb->addChild(LowerLimb); TranslateNode HeadTranslate(0,1.0f,0); RotateNode HeadRotate(0,0,0,0); ScaleNode HeadScale(1,1,0.5f); Head = new Node(HeadTranslate.MatrixStored() * HeadRotate.MatrixStored() * HeadScale.MatrixStored(), \ QString("Head")); Head->setGeomColor(glm::vec4(0,0,1,1)); Head->setGeometry(&geom_sphere); TranslateNode BodyTranslate(0,0,0); RotateNode BodyRotate(0,0,0,0); ScaleNode BodyScale(1,1,2); Body = new Node(BodyTranslate.MatrixStored() * BodyRotate.MatrixStored() * BodyScale.MatrixStored(), \ QString("Body")); Body->setGeometry(&geom_cube); Body->setGeomColor(glm::vec4(0.5,0.5,0.5,1)); Body->addChild(Head); Body->addChild(UpperLimb); TranslateNode RootTranslate(0,0,0); RotateNode RootRotate(0,0,0,0); ScaleNode RootScale(1,1,1); Root = new Node(RootTranslate.MatrixStored() * RootRotate.MatrixStored() * RootScale.MatrixStored(), \ QString("Root")); Root->addChild(Body); // Create and set up the diffuse shader prog_lambert.create(":/glsl/lambert.vert.glsl", ":/glsl/lambert.frag.glsl"); // Create and set up the flat lighting shader prog_flat.create(":/glsl/flat.vert.glsl", ":/glsl/flat.frag.glsl"); // Set a color with which to draw geometry since you won't have one // defined until you implement the Node classes. // This makes your geometry render green. // prog_lambert.setGeometryColor(glm::vec4(0,1,0,1)); // We have to have a VAO bound in OpenGL 3.2 Core. But if we're not // using multiple VAOs, we can just bind one once. // vao.bind(); glBindVertexArray(vao); emit sig_scenegraph(this->Root); } void MyGL::resizeGL(int w, int h) { //This code sets the concatenated view and perspective projection matrices used for //our scene's camera view. glm::vec4 c1(1.1933f, 0, 1.1933f, 0); glm::vec4 c2(0.9856f, 1.9712f, -0.9856f, 0); glm::vec4 c3(0.5785f, -0.5785f, -0.5785f, 11.9484f); glm::vec4 c4(0.5774f, -0.5774f, -0.5774f, 12.1244f); glm::mat4 viewproj(c1, c2, c3, c4); //Transpose since GLM is column major and I wrote out the rows of the matrix viewproj = glm::transpose(viewproj); // Upload the view-projection matrix to our shaders (i.e. onto the graphics card) prog_lambert.setViewProjMatrix(viewproj); prog_flat.setViewProjMatrix(viewproj); printGLErrorLog(); } //This function is called by Qt any time your GL window is supposed to update //For example, when the function updateGL is called, paintGL is called implicitly. //DO NOT CONSTRUCT YOUR SCENE GRAPH IN THIS FUNCTION! void MyGL::paintGL() { // Clear the screen so that we only see newly drawn images glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //VVV CLEAR THIS CODE WHEN YOU IMPLEMENT SCENE GRAPH TRAVERSAL VVV/////////////////// #define NOPE #ifdef NOPE //Create a model matrix. This one scales the sphere uniformly by 3, then translates it by <-2,0,0>. //Note that we have to transpose the model matrix before passing it to the shader //This is because OpenGL expects column-major matrices, but you've //implemented row-major matrices. // glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(-2,0,0)) * glm::scale(glm::mat4(1.0f), glm::vec3(3,3,3)); // //Send the geometry's transformation matrix to the shader // prog_lambert.setModelMatrix(model); // //Draw the example sphere using our lambert shader // prog_lambert.draw(geom_sphere); //Now do the same to render the cylinder //We've rotated it -45 degrees on the Z axis, then translated it to the point <2,2,0> // model = glm::translate(glm::mat4(1.0f), glm::vec3(2,2,0)) * glm::rotate(glm::mat4(1.0f), glm::radians(-45.0f), glm::vec3(0,0,1)); // prog_lambert.setModelMatrix(model); // prog_lambert.draw(geom_cylinder); // model = glm::translate(glm::mat4(1.0f), glm::vec3(0,0,0)) * glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0,0,1)) \ // * glm::scale(glm::mat4(1.0f), glm::vec3(2,2,2));; // prog_lambert.setModelMatrix(model); // prog_lambert.draw(geom_cube); // glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(0,0,0)) * glm::scale(glm::mat4(1.0f), glm::vec3(2,2,2)); // prog_lambert.setModelMatrix(model); // prog_lambert.draw(geom_cone); // glm::mat4 model = glm::rotate(glm::mat4(1.0f), glm::radians(-90.0f), glm::vec3(0,0,1)) * glm::scale(glm::mat4(1.0f), glm::vec3(2,2,2)); // prog_lambert.setModelMatrix(model); // prog_lambert.draw(geom_pipe); #endif //^^^ CLEAR THIS CODE WHEN YOU IMPLEMENT SCENE GRAPH TRAVERSAL ^^^///////////////// //Here is a good spot to call your scene graph traversal function. traverse(Root, Root->MatrixStored(), prog_lambert); } void MyGL::keyPressEvent(QKeyEvent *e) { // http://doc.qt.io/qt-5/qt.html#Key-enum if (e->key() == Qt::Key_Escape) { QApplication::quit(); } } void MyGL::traverse(Node* N, glm::mat4 T, ShaderProgram p) { T = T * N->MatrixStored(); for (int i = 0; i < (int)N->children.size(); i++) { traverse(N->children[i], T, p); } if (N->geometry != NULL) { p.setModelMatrix(T); prog_lambert.setGeometryColor(N->color); p.draw(*(N->geometry)); } } // ItemClicked's slot void MyGL::slot_changeGeometry(QTreeWidgetItem* p, int n) { Head->setGeomColor(Head_color); Body->setGeomColor(Body_color); UpperLimb->setGeomColor(UpperLimb_color); LowerLimb->setGeomColor(LowerLimb_color); if (p->text(n) == "Head") Head->setGeomColor(glm::vec4(1,1,1,1)); else if (p->text(n) == "Body") Body->setGeomColor(glm::vec4(1,1,1,1)); else if (p->text(n) == "UpperLimb") UpperLimb->setGeomColor(glm::vec4(1,1,1,1)); else if (p->text(n) == "LowerLimb") LowerLimb->setGeomColor(glm::vec4(1,1,1,1)); else; }
14b37f3398520580ea80bf0fb8ee0e3d84b39168
63a22dd17235ee7a5289665cf3678c5f53492f68
/ServerCore/ServerLibrary/Net/Packet/PacketFactory.h
ac04ca8ae9176f4e2602599eaf0c64252a59ff3e
[]
no_license
githubzon/RoseServer
00df2d0f3a5d1c332b5e957d51ce0afd9ea3bfe7
6c0d2d54de7607d8cc822cac5e0e4d0009170a9a
refs/heads/master
2021-01-16T23:21:49.677968
2017-06-17T11:26:44
2017-06-17T11:26:44
95,739,207
1
0
null
2017-06-29T04:41:32
2017-06-29T04:41:32
null
UTF-8
C++
false
false
1,467
h
#pragma once #include "stdafx.h" #include "packetHeader.h" #include "packetClass.h" class PacketFactory : public Singleton<PacketFactory> { public: Packet* getPacket(Int64 packetType) { switch (packetType) { case E_C_REQ_EXIT: return new PK_C_REQ_EXIT(); case E_S_ANS_EXIT: return new PK_S_ANS_EXIT(); case E_I_NOTIFY_TERMINAL: return new PK_I_NOTIFY_TERMINAL(); case E_C_NOTIFY_HEARTBEAT: return new PK_C_NOTIFY_HEARTBEAT(); case E_C_REQ_ID_PW: return new PK_C_REQ_ID_PW(); case E_S_ANS_ID_PW_FAIL: return new PK_S_ANS_ID_PW_FAIL(); case E_S_ANS_ID_PW_SUCCESS: return new PK_S_ANS_ID_PW_SUCCESS(); case E_I_DB_REQ_ID_PW: return new PK_I_DB_REQ_ID_PW(); case E_I_DB_ANS_ID_PW: return new PK_I_DB_ANS_ID_PW(); case E_I_CHTTING_NOTIFY_ID: return new PK_I_CHTTING_NOTIFY_ID(); case E_I_DB_REQ_LOAD_DATA: return new PK_I_DB_REQ_LOAD_DATA(); case E_I_DB_ANS_PARSE_DATA: return new PK_I_DB_ANS_PARSE_DATA(); case E_I_LOGIN_NOTIFY_ID_LOADED: return new PK_I_LOGIN_NOTIFY_ID_LOADED(); case E_C_REQ_REGIST_CHATTING_NAME: return new PK_C_REQ_REGIST_CHATTING_NAME(); case E_C_REQ_CHATTING: return new PK_C_REQ_CHATTING(); case E_S_ANS_CHATTING: return new PK_S_ANS_CHATTING(); } return nullptr; } };
36bf98ae9b02ba605dc64c6e4f89d4686a39185e
c7d2b58db791dc900250a613b1d93dd84c9cd87b
/PopcornTorrent/Source/torrent/crc32c.cpp
9c558b0fb996dfabe37d08fc57ac89e49a6d9f77
[ "MIT" ]
permissive
tommy071/PopcornTorrent
3f0e4232a9b28cfc39b790129467f6b7b5c2feea
88a1a4371d58e9d81839754d2eae079197dee5c5
refs/heads/master
2020-07-30T03:36:05.567943
2020-02-07T09:30:55
2020-02-07T09:30:55
238,165,009
0
0
MIT
2020-02-04T09:10:23
2020-02-04T09:10:22
null
UTF-8
C++
false
false
4,479
cpp
/* Copyright (c) 2014-2018, Arvid Norberg All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/config.hpp" #include "libtorrent/crc32c.hpp" #include "libtorrent/aux_/cpuid.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" #include <boost/crc.hpp> #if (defined _MSC_VER && _MSC_VER >= 1600 && (defined _M_IX86 || defined _M_X64)) #include <nmmintrin.h> #endif #include "libtorrent/aux_/disable_warnings_pop.hpp" #if TORRENT_HAS_ARM_CRC32 #include <arm_acle.h> #endif namespace libtorrent { std::uint32_t crc32c_32(std::uint32_t v) { #if TORRENT_HAS_SSE if (aux::sse42_support) { std::uint32_t ret = 0xffffffff; #ifdef __GNUC__ // we can't use these because then we'd have to tell // -msse4.2 to gcc on the command line // return __builtin_ia32_crc32si(ret, v) ^ 0xffffffff; asm ("crc32l\t" "(%1), %0" : "=r"(ret) : "r"(&v), "0"(ret)); return ret ^ 0xffffffff; #else return _mm_crc32_u32(ret, v) ^ 0xffffffff; #endif } #endif #if TORRENT_HAS_ARM_CRC32 if (aux::arm_crc32c_support) { std::uint32_t ret = 0xffffffff; return __crc32cw(ret, v) ^ 0xffffffff; } #endif boost::crc_optimal<32, 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true> crc; crc.process_bytes(&v, 4); return crc.checksum(); } std::uint32_t crc32c(std::uint64_t const* buf, int num_words) { #if TORRENT_HAS_SSE if (aux::sse42_support) { #if defined _M_AMD64 || defined __x86_64__ \ || defined __x86_64 || defined _M_X64 || defined __amd64__ std::uint64_t ret = 0xffffffff; for (int i = 0; i < num_words; ++i) { #ifdef __GNUC__ // we can't use these because then we'd have to tell // -msse4.2 to gcc on the command line // ret = __builtin_ia32_crc32di(ret, buf[i]); __asm__("crc32q\t" "(%1), %0" : "=r"(ret) : "r"(buf+i), "0"(ret)); #else ret = _mm_crc32_u64(ret, buf[i]); #endif } return std::uint32_t(ret) ^ 0xffffffff; #else std::uint32_t ret = 0xffffffff; std::uint32_t const* buf0 = reinterpret_cast<std::uint32_t const*>(buf); for (int i = 0; i < num_words; ++i) { #ifdef __GNUC__ // we can't use these because then we'd have to tell // -msse4.2 to gcc on the command line // ret = __builtin_ia32_crc32si(ret, buf0[i*2]); // ret = __builtin_ia32_crc32si(ret, buf0[i*2+1]); asm ("crc32l\t" "(%1), %0" : "=r"(ret) : "r"(buf0+i*2), "0"(ret)); asm ("crc32l\t" "(%1), %0" : "=r"(ret) : "r"(buf0+i*2+1), "0"(ret)); #else ret = _mm_crc32_u32(ret, buf0[i*2]); ret = _mm_crc32_u32(ret, buf0[i*2+1]); #endif } return ret ^ 0xffffffff; #endif // amd64 or x86 } #endif // x86 or amd64 and gcc or msvc #if TORRENT_HAS_ARM_CRC32 if (aux::arm_crc32c_support) { std::uint32_t ret = 0xffffffff; for (int i = 0; i < num_words; ++i) { ret = __crc32cd(ret, buf[i]); } return ret ^ 0xffffffff; } #endif boost::crc_optimal<32, 0x1EDC6F41, 0xFFFFFFFF, 0xFFFFFFFF, true, true> crc; crc.process_bytes(buf, std::size_t(num_words) * 8); return crc.checksum(); } }
e41ab484fe8f8aa1953fd6c598bff43dcd510596
70441dcb7a8917a5574dd74c5afdeeaed3672a7a
/AtCoder Beginner Contest 161/D - Lunlun Number/main.cpp
54aa3c04c2882a7ee90d0491604ca2470406434d
[]
no_license
tmyksj/atcoder
f12ecf6255b668792d83621369194195f06c10f6
419165e85d8a9a0614e5544232da371d8a2f2f85
refs/heads/master
2023-03-05T12:14:14.945257
2023-02-26T10:10:20
2023-02-26T10:10:20
195,034,198
0
0
null
null
null
null
UTF-8
C++
false
false
834
cpp
#include <algorithm> #include <iostream> #include <set> using namespace std; int main() { int k; cin >> k; set<long long> cur; for (int i = 1; i <= 9; i++) { cur.insert(i); } set<long long> s; while (static_cast<int>(s.size()) < k) { for (set<long long>::iterator j = cur.begin(); j != cur.end(); j++) { s.insert(*j); } set<long long> next; for (set<long long>::iterator j = cur.begin(); j != cur.end(); j++) { next.insert(10 * *j + max((*j % 10) - 1, 0LL)); next.insert(10 * *j + (*j % 10)); next.insert(10 * *j + min((*j % 10) + 1, 9LL)); } cur = next; } set<long long>::iterator res = s.begin(); for (int i = 0; i < k - 1; i++) { res++; } cout << *res << endl; }
0002e2b03df56b4e01b4444b08719633c0bbbcca
92533544158e118276103d99be5ec1388d12737e
/app/src/main/cpp/context/RenderContext.h
f3b39ef98e96760f89aa1448bc7bdebbc33da645
[ "Apache-2.0" ]
permissive
githubhaohao/OpenGLCamera2
49efaf2dd09853000c11ad2eb20d6a17bf333721
82bea3e6fbce76f597d75a66456bbbda8d1a7191
refs/heads/master
2022-08-03T18:13:39.884775
2022-06-29T10:18:29
2022-06-29T10:18:29
216,771,928
884
195
null
2022-01-24T02:31:50
2019-10-22T09:15:28
C++
UTF-8
C++
false
false
1,990
h
/** * * Created by 公众号:字节流动 on 2021/3/16. * https://github.com/githubhaohao/OpenGLCamera2 * 最新文章首发于公众号:字节流动,有疑问或者技术交流可以添加微信 Byte-Flow ,领取视频教程, 拉你进技术交流群 * * */ #ifndef OPENGLCAMERA2_BYTEFLOWRENDERCONTEXT_H #define OPENGLCAMERA2_BYTEFLOWRENDERCONTEXT_H #include <cstdint> #include <jni.h> #include <ByteFlowRender.h> #include <vec2.hpp> #include "GLExampleBase.h" #define GL_RENDER_TYPE 0 #define CL_RENDER_TYPE 1 #define PARAM_TYPE_SET_SHADER_INDEX 201 #define PARAM_TYPE_SET_EXAMPLE 202 using namespace glm; class ByteFlowRenderContext { public: ByteFlowRenderContext(int renderType); ~ByteFlowRenderContext(); static void CreateRenderContext(JNIEnv *env, jobject instance, jint renderType); static void StoreRenderContext(JNIEnv *env, jobject instance, ByteFlowRenderContext *pContext); static void DeleteRenderContext(JNIEnv *env, jobject instance); static ByteFlowRenderContext* GetRenderContext(JNIEnv *env, jobject instance); int Init(int initType); int UnInit(); void UpdateFrame(int format, uint8_t *pBuffer, int width, int height); void LoadLutImageData(int index, int format, int width, int height, uint8_t *pData); void LoadFragShaderScript(int shaderIndex, char *pShaderStr, int strLen); void SetTransformMatrix(float translateX, float translateY, float scaleX, float scaleY, int degree, int mirror); void SetParamsInt(int paramType, int param); int GetParamsInt(int paramType); void OnSurfaceCreated(); void OnSurfaceChanged(int width, int height); void OnDrawFrame(); private: void CreateExample(int exampleIndex); static jfieldID s_ContextHandle; ByteFlowRender *m_pByteFlowRender; GLExampleBase *m_pCurGlFilter; GLExampleBase *m_pBeforeGlFilter; volatile bool m_bIsExampleMode; vec2 m_ViewPort; TransformMatrix m_TransformMatrix; }; #endif //OPENGLCAMERA2_BYTEFLOWRENDERCONTEXT_H
03f86b0c1bd02799b8f29207e99bd3cd8ddf3d99
85b690ce5b5952b6d886946e0bae43b975004a11
/Application/Input/openfoam-org/processor1/0.75/k
832730ed5b0151cd14532c068fbcf97a582bdc1b
[]
no_license
pace-gt/PACE-ProvBench
c89820cf160c0577e05447d553a70b0e90d54d45
4c55dda0e9edb4a381712a50656855732af3e51a
refs/heads/master
2023-03-12T06:56:30.228126
2021-02-25T22:49:07
2021-02-25T22:49:07
257,307,245
1
0
null
null
null
null
UTF-8
C++
false
false
20,014
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 5.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.75"; object k; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 1915 ( 0.0103557 0.00632709 0.0216763 0.0112849 0.0300745 0.0151149 0.0379233 0.0186765 0.045495 0.0221578 0.0530902 0.0258093 0.0612001 0.0301585 0.0708027 0.0361357 0.0831663 0.0465169 0.0995633 0.0694583 0.211428 0.356731 0.41958 0.438639 0.417181 0.369517 0.317492 0.27603 0.24728 0.228002 0.215589 0.208046 0.204055 0.202742 0.203518 0.205813 0.209366 0.214176 0.220306 0.227834 0.236926 0.246429 0.254912 0.261076 0.263392 0.260784 0.253197 0.241492 0.22694 0.210798 0.194072 0.17743 0.161202 0.145426 0.129872 0.113976 0.0962727 0.0748654 0.0492487 0.0297688 0.516816 0.897343 1.07553 1.19951 1.20759 1.09146 0.90779 0.730031 0.594242 0.503379 0.446494 0.412466 0.393629 0.384789 0.382252 0.383621 0.387531 0.393485 0.401411 0.411314 0.422672 0.435062 0.448787 0.46212 0.471456 0.473059 0.465315 0.44902 0.426249 0.399318 0.370209 0.340317 0.310404 0.280661 0.250753 0.219739 0.185819 0.145895 0.097219 0.0390926 0.691262 1.31029 1.74377 2.12531 2.30593 2.20342 1.86383 1.44576 1.08577 0.8352 0.680457 0.589174 0.537175 0.510282 0.499353 0.49729 0.499374 0.503164 0.508014 0.51377 0.520197 0.52829 0.539151 0.551868 0.562259 0.564988 0.557137 0.539043 0.512858 0.481198 0.446412 0.410207 0.373548 0.336747 0.299579 0.261265 0.220274 0.174129 0.119713 0.043787 0.750019 1.56373 2.34022 3.21141 3.87787 4.05302 3.64304 2.86366 2.03581 1.4124 1.03042 0.814176 0.691827 0.62587 0.596424 0.586249 0.584585 0.585654 0.586539 0.586901 0.587041 0.588206 0.593301 0.602454 0.61148 0.614031 0.60608 0.587372 0.559837 0.526069 0.488539 0.449114 0.408866 0.368198 0.327054 0.28498 0.240919 0.192679 0.135438 0.0511079 0.700055 1.54016 2.2403 3.28272 4.11451 4.79307 5.09164 4.60925 3.4146 2.2524 1.49843 1.08965 0.872603 0.751369 0.692103 0.668811 0.661356 0.658619 0.653577 0.648923 0.64175 0.633115 0.630537 0.634503 0.640525 0.641703 0.633238 0.614268 0.586359 0.551884 0.513297 0.472536 0.430697 0.388188 0.345051 0.301105 0.255755 0.20718 0.149419 0.0586114 0.64177 1.47557 1.99806 2.35284 2.66428 3.27069 3.87595 4.2404 3.87219 2.73758 1.77812 1.24126 0.967862 0.828194 0.755326 0.723668 0.710963 0.708233 0.708557 0.708706 0.692858 0.668812 0.65757 0.655912 0.658128 0.657131 0.647786 0.628663 0.600894 0.566527 0.52793 0.48708 0.445024 0.40206 0.358198 0.313335 0.267072 0.21794 0.159835 0.0644549 0.589793 1.45743 1.48004 1.36247 1.55618 2.13101 2.84058 3.41797 3.60491 2.95283 1.92639 1.29895 0.977147 0.822837 0.752944 0.723608 0.712389 0.711265 0.71765 0.722734 0.714964 0.693677 0.677649 0.671476 0.669604 0.665913 0.655421 0.63614 0.608736 0.574869 0.536823 0.496615 0.45519 0.412645 0.368848 0.323618 0.276462 0.225845 0.166172 0.068227 0.518247 1.26888 1.02119 0.904895 1.04115 1.50529 2.18515 2.81628 3.19494 2.89433 1.9874 1.32139 0.969118 0.800902 0.726934 0.698464 0.690795 0.691902 0.696498 0.700792 0.703181 0.700809 0.692953 0.684728 0.679017 0.672304 0.660387 0.640814 0.613733 0.580417 0.543091 0.503814 0.463395 0.421684 0.378374 0.333176 0.28543 0.233197 0.170434 0.0716986 0.410701 0.770002 0.645292 0.66547 0.834434 1.21448 1.80715 2.42586 2.85212 2.702 1.94749 1.31196 0.952409 0.776393 0.698832 0.670413 0.665422 0.670347 0.67917 0.689265 0.699255 0.708335 0.709308 0.698412 0.689181 0.679543 0.666007 0.645889 0.618852 0.585871 0.549148 0.510732 0.47126 0.430362 0.387601 0.342621 0.294681 0.241645 0.176944 0.0760098 0.268957 0.409231 0.465767 0.607675 0.804608 1.11584 1.61795 2.17751 2.5677 2.46461 1.84569 1.27449 0.926806 0.750756 0.67248 0.64517 0.643307 0.653071 0.667827 0.684964 0.702986 0.721948 0.727611 0.713189 0.701457 0.689696 0.674673 0.653755 0.626333 0.593305 0.556878 0.51896 0.47999 0.439491 0.397001 0.352118 0.304068 0.250715 0.185315 0.0806179 0.118308 0.110038 0.135843 0.13676 0.151931 0.157327 0.167169 0.175666 0.182326 0.193768 0.198095 0.212773 0.214838 0.23297 0.232689 0.254176 0.251576 0.275977 0.271228 0.297828 0.319269 0.340139 0.360489 0.380324 0.399431 0.417472 0.434313 0.450274 0.46411 0.47108 0.468526 0.462006 0.453804 0.445718 0.439673 0.436758 0.437579 0.442307 0.450774 0.462529 0.476882 0.492977 0.509867 0.078188 0.074275 0.0778668 0.0955165 0.138338 0.146963 0.165219 0.201498 0.167207 0.184351 0.214153 0.264027 0.190375 0.214944 0.255573 0.317421 0.213261 0.245193 0.295917 0.366918 0.237445 0.276991 0.336531 0.414272 0.263127 0.31035 0.378583 0.463446 0.289611 0.344024 0.420272 0.511185 0.315967 0.376679 0.459371 0.5551 0.341106 0.406244 0.493153 0.592751 0.36426 0.431241 0.520695 0.622628 0.385358 0.452181 0.542437 0.644779 0.404455 0.469332 0.558706 0.660716 0.421456 0.482312 0.569361 0.67062 0.436589 0.491654 0.573862 0.67196 0.449857 0.497308 0.56841 0.662931 0.462019 0.501918 0.560333 0.645275 0.473722 0.506972 0.553767 0.61935 0.485294 0.513349 0.551279 0.601242 0.497814 0.521977 0.553535 0.593266 0.505722 0.53317 0.560523 0.594032 0.504048 0.541226 0.571504 0.601854 0.497679 0.540238 0.580283 0.614333 0.489514 0.534563 0.580093 0.624262 0.482488 0.527711 0.575662 0.625064 0.478668 0.523479 0.572042 0.623691 0.479155 0.523848 0.572778 0.625708 0.484284 0.529563 0.579384 0.633736 0.493865 0.540466 0.591901 0.648268 0.507319 0.55583 0.609459 0.668349 0.523763 0.574543 0.63067 0.692275 0.542118 0.595267 0.653894 0.71807 0.561215 0.616592 0.677458 0.743785 0.207081 0.329582 0.477024 0.691649 0.878488 1.1203 1.53918 2.01357 2.31979 2.2212 1.71912 1.21689 0.893077 0.723742 0.647929 0.623098 0.624982 0.639911 0.660596 0.683994 0.70864 0.735297 0.743068 0.728314 0.716456 0.703989 0.687935 0.666064 0.637836 0.604345 0.567734 0.529648 0.490402 0.449616 0.406898 0.361746 0.31333 0.259559 0.193531 0.0849362 0.266347 0.384464 0.577153 0.80264 0.954661 1.16907 1.52915 1.88753 2.09137 1.99542 1.58166 1.14696 0.853489 0.695845 0.625248 0.604134 0.61017 0.630131 0.656328 0.685047 0.714814 0.74587 0.75467 0.744548 0.735074 0.723263 0.706701 0.683816 0.654449 0.620039 0.582601 0.543425 0.502894 0.461042 0.417521 0.371637 0.322437 0.267925 0.201151 0.0886923 0.339439 0.458457 0.660907 0.851634 1.02396 1.22352 1.50358 1.76287 1.88458 1.78939 1.44429 1.07206 0.810968 0.66816 0.605018 0.588755 0.59933 0.624238 0.655659 0.689293 0.723584 0.755527 0.766228 0.76388 0.758194 0.747757 0.730983 0.707017 0.6762 0.640272 0.601252 0.560087 0.51743 0.473822 0.428958 0.381905 0.331498 0.275807 0.20796 0.091766 0.400958 0.521825 0.707847 0.914312 1.0995 1.26442 1.44454 1.62762 1.69613 1.6032 1.3146 0.997528 0.768023 0.641828 0.587995 0.577737 0.593438 0.623529 0.660272 0.698949 0.737473 0.768967 0.783585 0.788368 0.786465 0.777379 0.760324 0.73506 0.702419 0.664436 0.623045 0.579202 0.533947 0.488049 0.441352 0.392788 0.340874 0.283533 0.213932 0.0941611 0.4569 0.584161 0.76287 0.974412 1.15082 1.26858 1.37713 1.48955 1.52649 1.43802 1.19562 0.925517 0.726084 0.617797 0.574908 0.571888 0.593547 0.629375 0.671846 0.715859 0.757923 0.790255 0.809327 0.819105 0.82 0.811698 0.793983 0.767083 0.732268 0.691855 0.647578 0.6007 0.552467 0.50379 0.45484 0.404609 0.351161 0.291793 0.21929 0.0960331 0.511703 0.645764 0.822041 1.0155 1.15872 1.23707 1.29802 1.35902 1.37523 1.29086 1.08462 0.854346 0.684322 0.596329 0.566158 0.571757 0.600401 0.642698 0.691371 0.74091 0.786048 0.820104 0.84303 0.855939 0.858354 0.850039 0.831132 0.802226 0.765043 0.721967 0.674653 0.624546 0.573 0.521129 0.469547 0.41776 0.363267 0.301817 0.224998 0.0979138 0.568269 0.708594 0.871976 1.03216 1.13459 1.17741 1.20599 1.23664 1.23778 1.15588 0.977566 0.78001 0.641511 0.577373 0.56196 0.577593 0.614349 0.663869 0.71908 0.774009 0.821892 0.857865 0.883483 0.898002 0.90072 0.891582 0.870957 0.839742 0.800125 0.754305 0.703926 0.650511 0.595519 0.540217 0.485619 0.432244 0.377946 0.315306 0.23339 0.100956 0.624067 0.765242 0.905488 1.02395 1.08638 1.10152 1.10955 1.12149 1.10967 1.02684 0.866693 0.70254 0.601438 0.562324 0.562534 0.589542 0.635479 0.692847 0.754683 0.814098 0.864565 0.902372 0.929323 0.94417 0.946159 0.935479 0.912671 0.879017 0.836927 0.788371 0.734961 0.678304 0.619938 0.5612 0.503266 0.447311 0.393413 0.332713 0.247174 0.106489 0.675022 0.810307 0.919704 0.99417 1.02185 1.01842 1.01477 1.01398 0.990098 0.900398 0.754753 0.631952 0.568779 0.552867 0.56859 0.607973 0.663822 0.729331 0.797598 0.860724 0.913182 0.952027 0.979216 0.993306 0.993745 0.980941 0.955589 0.91948 0.874909 0.823644 0.767307 0.707584 0.646046 0.584011 0.522569 0.462727 0.405374 0.347685 0.262274 0.115206 0.717372 0.841554 0.917662 0.950847 0.950095 0.935379 0.925225 0.9145 0.878003 0.782958 0.659729 0.575741 0.545101 0.55008 0.581402 0.633507 0.699414 0.772841 0.846867 0.913245 0.966467 1.0054 1.03193 1.0444 1.04264 1.02726 0.999189 0.9606 0.913533 0.859609 0.800503 0.737965 0.673548 0.608443 0.54349 0.479184 0.415578 0.351484 0.275022 0.123374 0.748423 0.859158 0.902897 0.901637 0.880401 0.858673 0.844477 0.825765 0.777561 0.683174 0.587692 0.53565 0.531046 0.555649 0.602386 0.666782 0.742216 0.822743 0.901246 0.970815 1.02315 1.06136 1.0864 1.09658 1.09211 1.07378 1.04297 1.00186 0.952266 0.895755 0.834076 0.769049 0.702144 0.634325 0.566093 0.497482 0.427912 0.356119 0.280317 0.128887 0.766585 0.860334 0.877136 0.854191 0.821035 0.793789 0.776541 0.752172 0.694745 0.607452 0.538664 0.512948 0.528884 0.571357 0.632618 0.708182 0.792057 0.878403 0.959745 1.03095 1.08135 1.11882 1.14171 1.14911 1.14157 1.12005 1.08642 1.0427 0.990573 0.931565 0.867548 0.800441 0.731557 0.661523 0.590449 0.518005 0.443256 0.363733 0.271292 0.121857 0.773107 0.84782 0.850041 0.817546 0.776473 0.744021 0.723911 0.695803 0.631516 0.557465 0.512259 0.508535 0.541614 0.599068 0.672668 0.757645 0.848495 0.939378 1.02299 1.09315 1.14128 1.17692 1.19711 1.20139 1.19046 1.16559 1.12901 1.08257 1.02793 0.96657 0.90048 0.831795 0.761562 0.689925 0.616521 0.540715 0.46157 0.376272 0.275558 0.122401 0.770888 0.83715 0.834077 0.79601 0.749064 0.71243 0.689712 0.657325 0.589931 0.531709 0.507876 0.522663 0.569682 0.638593 0.721904 0.814395 0.910623 1.00495 1.09122 1.15617 1.20209 1.23502 1.25199 1.25283 1.23816 1.20989 1.17018 1.12089 1.06384 1.00037 0.932513 0.862871 0.792041 0.71952 0.644287 0.565343 0.482194 0.392582 0.287471 0.127502 0.763621 0.834788 0.831772 0.791095 0.740227 0.699928 0.674775 0.634797 0.571711 0.53013 0.52393 0.553339 0.611353 0.689061 0.779512 0.877294 0.976936 1.0736 1.1587 1.21703 1.26228 1.29233 1.30575 1.3028 1.28424 1.25239 1.20932 1.1571 1.09769 1.03225 0.963289 0.893525 0.822995 0.750481 0.673927 0.591637 0.504151 0.410403 0.3015 0.135492 0.752384 0.831739 0.840168 0.801082 0.749182 0.705383 0.672503 0.624383 0.574581 0.54886 0.557397 0.598461 0.664871 0.74865 0.843654 0.944717 1.0469 1.14552 1.22446 1.27884 1.32164 1.34829 1.35795 1.35079 1.32821 1.29254 1.24589 1.19065 1.12871 1.0616 0.992521 0.923466 0.854302 0.783105 0.706044 0.61963 0.526656 0.428073 0.314566 0.143114 0.737517 0.813676 0.847674 0.820246 0.771684 0.724545 0.676573 0.626986 0.592469 0.583287 0.605363 0.655943 0.727922 0.81489 0.91214 1.01523 1.12112 1.21791 1.28518 1.33935 1.37943 1.40244 1.40807 1.39648 1.36959 1.32975 1.27938 1.22111 1.15691 1.0886 1.01963 0.951958 0.885443 0.817616 0.741956 0.649544 0.549048 0.444695 0.326122 0.14936 0.710121 0.790409 0.834791 0.832333 0.793738 0.742368 0.68716 0.645671 0.626006 0.632234 0.666105 0.723233 0.797705 0.885332 0.982785 1.08684 1.19498 1.28419 1.34573 1.39819 1.43527 1.45463 1.45581 1.43954 1.40799 1.36365 1.30931 1.24791 1.18174 1.11242 1.04379 0.978102 0.915727 0.854218 0.783875 0.680201 0.570097 0.459273 0.335487 0.15409 0.66856 0.754735 0.819432 0.82987 0.802251 0.755038 0.710642 0.683096 0.677064 0.695252 0.737019 0.797349 0.872078 0.958678 1.0553 1.16152 1.26654 1.34087 1.40402 1.455 1.48914 1.50475 1.50111 1.47973 1.44314 1.39404 1.33557 1.27073 1.20211 1.13188 1.06392 1.00079 0.944185 0.89255 0.826671 0.708643 0.587886 0.470826 0.342448 0.157638 0.643611 0.70673 0.776457 0.817854 0.814146 0.782298 0.753636 0.738869 0.743057 0.768844 0.814674 0.875767 0.949612 1.03447 1.12938 1.23429 1.32904 1.39877 1.46142 1.51035 1.54157 1.55293 1.54395 1.51698 1.4749 1.4208 1.35802 1.28956 1.21804 1.14652 1.0791 1.01891 0.96952 0.92916 0.840651 0.730668 0.600872 0.479261 0.347838 0.160674 0.634797 0.682704 0.732225 0.776314 0.798931 0.802003 0.799923 0.801973 0.816468 0.847258 0.894606 0.95509 1.02813 1.11187 1.20592 1.30348 1.38406 1.45682 1.51871 1.56522 1.59332 1.5995 1.58432 1.55116 1.50315 1.44379 1.37655 1.30438 1.22964 1.15601 1.0883 1.02991 0.980598 0.923996 0.827732 0.737628 0.60767 0.485313 0.352772 0.163786 0.637957 0.679104 0.720308 0.757533 0.786316 0.809844 0.829948 0.85058 0.879771 0.920177 0.971466 1.03315 1.10607 1.18841 1.27704 1.36435 1.44571 1.51813 1.57761 1.62084 1.64494 1.6447 1.62242 1.58218 1.52765 1.4627 1.39097 1.31533 1.23723 1.16017 1.08924 1.0254 0.961751 0.888811 0.808506 0.725872 0.609561 0.490281 0.357645 0.167279 0.649644 0.689056 0.728728 0.766591 0.800682 0.83226 0.863638 0.89798 0.939559 0.990509 1.04645 1.11086 1.1842 1.26524 1.35083 1.43573 1.51497 1.58426 1.63974 1.67828 1.69699 1.68884 1.65832 1.60986 1.548 1.47699 1.40072 1.32154 1.23941 1.15741 1.0802 1.00835 0.936858 0.861571 0.786497 0.709677 0.608539 0.495283 0.363215 0.171558 0.665304 0.708327 0.749534 0.790962 0.831214 0.871002 0.91197 0.955979 1.00553 1.06175 1.12407 1.19333 1.26946 1.35083 1.4345 1.51633 1.59176 1.65642 1.70643 1.73799 1.74803 1.73298 1.69223 1.63375 1.56343 1.48568 1.40436 1.3186 1.22961 1.14318 1.06208 0.985922 0.911609 0.837593 0.766504 0.693753 0.604571 0.499754 0.371305 0.177232 0.676243 0.727431 0.777803 0.824609 0.871599 0.919673 0.969259 1.02196 1.07944 1.14246 1.21103 1.28508 1.36378 1.44533 1.52705 1.60555 1.67671 1.73596 1.77906 1.80037 1.79856 1.77535 1.72396 1.65273 1.57267 1.48745 1.39727 1.30053 1.20713 1.11872 1.03631 0.95938 0.885946 0.815476 0.748699 0.681909 0.60257 0.508239 0.385321 0.18511 0.680286 0.740119 0.799599 0.858786 0.918137 0.975075 1.0325 1.09385 1.15986 1.2306 1.30583 1.38503 1.46666 1.54865 1.62858 1.70379 1.77077 1.82439 1.85777 1.86259 1.8485 1.8116 1.74774 1.66349 1.57117 1.47371 1.37063 1.26966 1.17489 1.08682 1.00561 0.930625 0.860556 0.794711 0.732909 0.672193 0.603724 0.521426 0.404092 0.195571 0.685317 0.750965 0.817706 0.884695 0.954155 1.0248 1.0954 1.16849 1.24479 1.32448 1.40726 1.49276 1.5784 1.66141 1.73945 1.81057 1.87032 1.91084 1.92343 1.91399 1.88357 1.82846 1.74783 1.64989 1.54169 1.43348 1.32775 1.22788 1.13536 1.05031 0.972586 0.901535 0.836046 0.775161 0.717987 0.662014 0.60127 0.531371 0.408015 0.200363 0.695765 0.76544 0.838329 0.913412 0.990371 1.06834 1.14861 1.23178 1.31755 1.40595 1.49636 1.58736 1.67551 1.75733 1.82913 1.89011 1.93428 1.95331 1.95185 1.92828 1.88103 1.80938 1.71299 1.60131 1.4865 1.3769 1.27418 1.17903 1.09163 1.01182 0.939287 0.873317 0.812817 0.756618 0.703489 0.651228 0.595142 0.52651 0.406341 0.202971 0.713022 0.786483 0.864473 0.94596 1.03 1.11554 1.20248 1.29116 1.38134 1.47256 1.5637 1.65234 1.73459 1.8067 1.86502 1.90912 1.93547 1.9417 1.92768 1.89045 1.8304 1.74797 1.64317 1.52858 1.41606 1.31117 1.2149 1.12685 1.04652 0.973431 0.907067 0.84662 0.790978 0.738919 0.689259 0.640497 0.589123 0.52373 0.403056 0.200707 0.736193 0.813509 0.896067 0.982731 1.07218 1.163 1.25433 1.34556 1.43579 1.52387 1.60851 1.68698 1.75556 1.81221 1.85552 1.88395 1.8954 1.8883 1.86157 1.814 1.74529 1.6556 1.55034 1.44148 1.33729 1.2412 1.15366 1.07423 1.00213 0.936581 0.876802 0.821765 0.770494 0.721793 0.67463 0.628173 0.580092 0.519096 0.396293 0.194154 0.763217 0.844088 0.930452 1.02102 1.11415 1.20804 1.30108 1.39137 1.47762 1.55858 1.63262 1.69724 1.7507 1.79183 1.82008 1.83373 1.83147 1.81166 1.77398 1.71786 1.64243 1.55089 1.45128 1.35141 1.25712 1.17121 1.09364 1.02349 0.959972 0.902058 0.848754 0.798975 0.7515 0.705377 0.65962 0.613606 0.565939 0.506144 0.386982 0.187155 0.791736 0.875434 0.964441 1.0573 1.15214 1.24681 1.33849 1.42514 1.50515 1.57711 1.63935 1.69036 1.72964 1.75654 1.77055 1.77075 1.75599 1.7252 1.67849 1.61539 1.53692 1.44812 1.3558 1.26558 1.18155 1.10558 1.03769 0.976712 0.921435 0.870712 0.823414 0.778415 0.734536 0.690636 0.64598 0.599823 0.551295 0.492733 0.379779 0.186001 0.819519 0.905056 0.995363 1.08882 1.18338 1.27613 1.36421 1.44551 1.51822 1.58069 1.63168 1.67079 1.69759 1.71184 1.71324 1.7015 1.67586 1.63609 1.58261 1.51585 1.43805 1.35389 1.26924 1.18841 1.11414 1.04745 0.98823 0.935513 0.887688 0.84336 0.801395 0.760664 0.720084 0.678618 0.635481 0.590155 0.541435 0.482039 0.384129 0.19292 ) ; boundaryField { leftWall { type kqRWallFunction; value nonuniform 0(); } rightWall { type kqRWallFunction; value nonuniform List<scalar> 43 ( 0.0297688 0.0390926 0.043787 0.0511079 0.0586114 0.0644549 0.068227 0.0716986 0.0760098 0.0806179 0.0849362 0.0886923 0.091766 0.0941611 0.0960331 0.0979138 0.100956 0.106489 0.115206 0.123374 0.128887 0.121857 0.122401 0.127502 0.135492 0.143114 0.14936 0.15409 0.157638 0.160674 0.163786 0.167279 0.171558 0.177232 0.18511 0.195571 0.200363 0.202971 0.200707 0.194154 0.187155 0.186001 0.19292 ) ; } lowerWall { type kqRWallFunction; value nonuniform List<scalar> 66 ( 0.0103557 0.00632709 0.00632709 0.0112849 0.0151149 0.0186765 0.0221578 0.0258093 0.0301585 0.0361357 0.0465169 0.0694583 0.078188 0.074275 0.0778668 0.0955165 0.211428 0.516816 0.691262 0.750019 0.700055 0.64177 0.589793 0.518247 0.410701 0.268957 0.211428 0.356731 0.41958 0.438639 0.417181 0.369517 0.317492 0.27603 0.24728 0.228002 0.215589 0.208046 0.204055 0.202742 0.203518 0.205813 0.209366 0.214176 0.220306 0.227834 0.236926 0.246429 0.254912 0.261076 0.263392 0.260784 0.253197 0.241492 0.22694 0.210798 0.194072 0.17743 0.161202 0.145426 0.129872 0.113976 0.0962727 0.0748654 0.0492487 0.0297688 ) ; } atmosphere { type inletOutlet; inletValue nonuniform 0(); value nonuniform 0(); } defaultFaces { type empty; } procBoundary1to0 { type processor; value nonuniform List<scalar> 44 ( 0.0130339 0.0282347 0.0385723 0.0477944 0.0565887 0.0653398 0.0744607 0.084425 0.0956676 0.108329 0.121887 0.135576 0.148973 0.162142 0.175417 0.189207 0.20388 0.21973 0.236899 0.255283 0.291326 0.291326 0.311732 0.332555 0.354039 0.375576 0.396756 0.416487 0.430189 0.435842 0.432552 0.426464 0.41906 0.411258 0.404582 0.399966 0.398086 0.399317 0.403765 0.411295 0.421559 0.434024 0.448018 0.46279 ) ; } procBoundary1to3 { type processor; value nonuniform List<scalar> 45 ( 0.526587 0.579901 0.637167 0.699809 0.767683 0.844668 0.930957 1.02123 1.11373 1.20605 1.29496 1.37803 1.45304 1.51811 1.57166 1.61293 1.64181 1.65794 1.66121 1.65192 1.63009 1.5956 1.54899 1.49119 1.42354 1.34882 1.27083 1.19404 1.122 1.05658 0.998264 0.946715 0.901035 0.859544 0.820695 0.783327 0.746332 0.708706 0.669565 0.628163 0.584094 0.536405 0.477777 0.377226 0.190981 ) ; } } // ************************************************************************* //
ab67d302a9b3628e6ae186ff8ec4408a4b29bba3
4bca7d575cfe53aef88c18c8c80aaff71553b878
/RpiPower.cpp
50e3989f7abc0459b1c16d6a4b91d555ff2490e8
[]
no_license
treii28/RpiPower
0c26d2a0a0ead16a58fae33d828d25eb5a0dcfaf
3eb1ea589bee416fbc4d6d50ff1e3de22bfe410d
refs/heads/master
2021-07-17T00:15:29.015037
2017-10-23T01:56:11
2017-10-23T01:56:11
107,892,433
0
0
null
null
null
null
UTF-8
C++
false
false
1,853
cpp
/* RpiPower.cpp - Library defining a Raspberry Pi power connection Created by Scott Webster Wood, August 7, 2016 Released into the public domain. */ #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif #include "RpiPower.h" RpiPower::RpiPower() { initRelay(0, false); _idc1 = 0b00000000; _idc2 = 0b00000000; setUndefined(); } RpiPower::RpiPower(uint8_t pin, uint8_t id1, uint8_t id2, const char *id, const char *name) { initRelay(pin, false); _idc1 = id1; _idc2 = id2; strncpy(_id, id, 2); _id[2] = 0; strncpy(_name, name, 8); _name[8] = 0; setDefined(); } String RpiPower::getInfoJSON() { String relInfo = "{pin:" + String(_pin) + ",idc1:" + String(_idc1) + ",idc2:" + String(_idc2) + ",id:\"" + String(_id) + "\",name:\"" + String(_name) + "\",state:" + String(_relayState) + "}"; return relInfo; }; String RpiPower::getStatus() { String _status = String(_name) + " is "; _status += (getRelayState()) ? "'on'" : "'off'"; return _status; } uint8_t RpiPower::getStatusDigit() { return 0b01100011; if (_relayState == true) { return SEG_DIP_ON; } else { return SEG_DIP_OFF; } } // relay related methods void RpiPower::initRelay(uint8_t rPin, bool rState) { _pin = rPin; pinMode(rPin, OUTPUT); if (rState != 0) { turnRelayOn(); } else { turnRelayOff(); } } void RpiPower::turnRelayOn() { digitalWrite(_pin, LOW); _relayState = true; } void RpiPower::turnRelayOff() { digitalWrite(_pin, HIGH); _relayState = false; } void RpiPower::toggleRelay() { if (_relayState == true) { turnRelayOff(); } else { turnRelayOn(); } }
d76eef8a29762e993b9c7c3146e4424e74d5473e
a33aac97878b2cb15677be26e308cbc46e2862d2
/program_data/PKU_raw/84/1170.c
1d0ecc79aaf109cb5c875fb1d566dbf8bb8d61dc
[]
no_license
GabeOchieng/ggnn.tensorflow
f5d7d0bca52258336fc12c9de6ae38223f28f786
7c62c0e8427bea6c8bec2cebf157b6f1ea70a213
refs/heads/master
2022-05-30T11:17:42.278048
2020-05-02T11:33:31
2020-05-02T11:33:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
276
c
int main() { int n,i,a,max=0,max2=0; scanf("%d",&n); scanf("%d",&a); max=a,max2=a; for(i=2;i<=n;i++) { scanf("%d",&a); if(a>max) { max=a; } else { if(a>max2) { max2=a; } } } printf("%d\n%d",max,max2); return 0; }
50b596d4d47010c4c5b5d1ee29e273ac47faf9b3
ed1624411040501c67c2f6c5c626348d9806d968
/Ocean/network/server.h
f364b76665ff1e021a7ca2b5a544c010a8671d5e
[]
no_license
bogdyname/Ocean
a1e7364d2142dfac8907aac9319a6133305ad279
ca8cba4c1472ca46945a9dda4550f39065551b3e
refs/heads/master
2023-02-06T13:45:13.806885
2020-10-25T18:14:57
2020-10-25T18:14:57
174,801,662
0
0
null
2020-12-14T19:25:17
2019-03-10T09:18:34
C++
UTF-8
C++
false
false
677
h
/* ***Copyleft (C) 2020 Softwater, Inc ***Contact: [email protected] ***Contact: [email protected] ***Created by bogdyname */ #ifndef SERVER_H #define SERVER_H #include <QTcpServer> #include <QTcpSocket> #include <QByteArray> #include <QDataStream> class Server : public QTcpServer { Q_OBJECT Q_CLASSINFO("Version", "0.5") public: explicit Server(QObject *parent = nullptr); ~Server(); /* 1) Read client data 2) Send response to client about receiving */ private slots: void Receiver(); void Sender(); private: qint64 nextBlockSize; QTcpServer *server = nullptr; QTcpSocket *socket = nullptr; }; #endif
1eff4e3abd4126b813d4243ed6f25383478e094a
a369b0b66c01c9db9768bf94c685a70f14256761
/examples/B_charsets/B_charsets.ino
b09064021d513aa60b60008eab8dfa078d64fad8
[ "MIT" ]
permissive
gdsports/USBPrinter_uhls
7ff7156bb3dae68d80b57f5344b171394238454e
5ca7cb94486dc9eff85d1dd19442145a0b3f7e86
refs/heads/master
2020-06-12T22:49:15.681202
2019-07-11T08:09:45
2019-07-11T08:09:45
194,451,706
2
1
null
null
null
null
UTF-8
C++
false
false
2,342
ino
/*------------------------------------------------------------------------ Demoonstrate different character sets on ESC POS printers connecting to SAMD USB host port Based on Adafruit Thermal printer library. ------------------------------------------------------------------------*/ #include "ESC_POS_Printer.h" #include "USBPrinter.h" class PrinterOper : public USBPrinterAsyncOper { public: uint8_t OnInit(USBPrinter *pPrinter); }; uint8_t PrinterOper::OnInit(USBPrinter *pPrinter) { Serial.println(F("USB Printer OnInit")); Serial.print(F("Bidirectional=")); Serial.println(pPrinter->isBidirectional()); return 0; } USBHost myusb; PrinterOper AsyncOper; USBPrinter uprinter(&myusb, &AsyncOper); ESC_POS_Printer printer(&uprinter); // ----------------------------------------------------------------------- void setup() { Serial.begin(115200); while (!Serial && millis() < 3000) delay(1); Serial.println(F("Character set demo")); } // Print charset map to printer void dump() { uint8_t major, minor, c; printer.println(F(" 01234567 89ABCDEF")); for(major=0; major<16; major++) { printer.print(F(" ")); printer.print(major, HEX); printer.print(F("- ")); for(minor=0; minor<16; minor++) { c = (major << 4) | minor; if(c < 32) c = ' '; // Skip control codes! printer.write(c); if(minor == 7) printer.print(F(" ")); } printer.println(); } } void print_character_set() { printer.underlineOn(); printer.println(F("Character set demo\n")); printer.underlineOff(); printer.println(F("Default")); printer.setCharset(0); printer.setCodePage(0); dump(); printer.println(F("\nFrench char set with")); printer.println(F("Multilingual CP850 code page")); // Charset selection alters a few chars in ASCII 0x23-0x7E range. printer.setCharset(CHARSET_FRANCE); // Code page selects alt symbols for 'upper' ASCII 0x80-0xFF. printer.setCodePage(CODEPAGE_CP850); dump(); printer.feed(2); printer.setDefault(); // Restore printer to defaults } void loop() { myusb.Task(); // Make sure USB printer found and ready if (uprinter.isReady()) { printer.begin(); Serial.println(F("Init ESC POS printer")); print_character_set(); // Do this one time to avoid wasting paper while (1) delay(1); } }
b489eb3f4075584b4c4a9cfe864dc2298cadc78a
186466242e6bf012ea0480c770481f885677c48e
/PBL/Lista/Exercício2.cpp
e7a64da856a8fec0aa84293bb99494d31836ec90
[]
no_license
Marcelo396/Faculdade
cda008a3eb0e16ed023f0e6625e5f6d27869a266
341d3c6b96d772c257f708d1789852f860a83ec5
refs/heads/master
2020-06-16T21:43:44.724468
2019-07-08T01:07:14
2019-07-08T01:07:14
195,590,375
0
0
null
null
null
null
UTF-8
C++
false
false
484
cpp
/*2. Crie um programa que le 6 valores inteiros e, em seguida, mostre na tela os valores lidos.*/ #include<iostream> #include<locale.h> using namespace std; int main() { int i, vetor[6]; setlocale(LC_ALL,"pt-Br"); cout<<"Insira 6 valores inteiros."<<endl; for(i=0;i<6;i++) { cin>>vetor[i]; } cout<<"\nOs valores digitados são:"<<' '; for(i=0;i<6;i++) { cout<<vetor[i]<<' '; } cout<<endl; return 0; }
f7e67f2e788acef2f14a20c8c500f978583069ae
af8ed09e1e0186a09c0328b8cb2b1f0a04d488d5
/wav_recorder.h
24b7cab2f614a50e1022280877c2aaecb3a1d143
[]
no_license
FeZar97/DK
b5c5b325881f13c3ad55f6a709fdd54b88413d9b
52708c6fb80a8b4dd61f4002611c133c137e0dcf
refs/heads/master
2020-04-01T18:18:35.750852
2019-07-28T23:11:40
2019-07-28T23:11:40
153,484,100
2
1
null
null
null
null
UTF-8
C++
false
false
1,331
h
/* This file is part of DigitalKalmar(Кальмар-SDR) DigitalKalmar 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. DigitalKalmar 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 DigitalKalmar. If not, see <https://www.gnu.org/licenses/>. */ #ifndef WAV_RECORDER_H #define WAV_RECORDER_H #include <definitions.h> class WAV_RECORDER : public QObject { Q_OBJECT public: WAV_params *params; WAV_RECORDER(); ~WAV_RECORDER(); void prepair_memory(size_t cell_size); void make_wav_header(int sample_rate, int channel_number); bool open_file(); void close_file(int sample_rate, int chan_num); QString size_to_str(); public slots: void get_write_step_32f(Ipp32f *cell, int cell_size); void get_write_step_16s(Ipp16s *cell, int cell_size); signals: void update_size_label(); }; #endif // WAV_RECORDER_H
ee000adcae59a066742ef168b15e402d1a0254f8
ee7c00a7a90e89e2984a6c922a8704390e680c06
/cs103_hws/PA/PA5/network1_redo/user.cpp
3cd3779f3b5c7a8772481114b49c83e4674144a2
[]
no_license
summerys/cs103
8630506e77f8b878f57b5c9bfdd0e4c2d0551d9e
2b16fe82c5cb0140f2db675fb63a67b91c6693d5
refs/heads/master
2021-01-12T08:46:01.770785
2016-12-21T03:28:06
2016-12-21T03:28:06
76,682,366
0
0
null
null
null
null
UTF-8
C++
false
false
869
cpp
#include "user.h" #include <string> using namespace std; User::User(string name_full, int id_num, int year_born, int zipcode){ name = name_full; id = id_num; year = year_born; zip = zipcode; } User::~User(){}; void User::add_friend(int other_user){ for (int i = 0; i < friends.size(); ++i){ if (friends[i] == other_user) { return; } }//for friends.push_back(other_user); }//add_friend void User::delete_friend(int other_user_d){ for(int i=0; i < friends.size(); i++){ if(friends[i] == other_user_d){ friends.erase ( friends.begin() + i ); }//if }//for }//void int User::id_num(){ return id; } string User::name_full(){ return name; } int User::year_born(){ return year;; } int User::zipcode(){ return zip; } //accessor vector<int> User::getFriends(){ return friends; }
d09ae779e09674942523ba814ed0a332983437ca
16288c0fb3a712150c715ddd0c9843e75f69034b
/cpp01/ex06/main.cpp
b049b16b7a1e231cc0b15c7d1914d65ab59c2b08
[]
no_license
brian-xu-vlt/42_CPP_PISCINE
3c6cb8ce224e53335b3e53cd24c97dc867c2d9f0
bda1f5834649e50012d0153c3cdd28769280fc9d
refs/heads/main
2023-02-25T23:17:43.176521
2021-02-03T07:12:22
2021-02-03T07:12:22
323,266,501
1
0
null
null
null
null
UTF-8
C++
false
false
419
cpp
#include "Weapon.hpp" #include "HumanA.hpp" #include "HumanB.hpp" int main( void ) { { Weapon club = Weapon("crude spiked club"); HumanA bob("Bob", club); bob.attack(); club.setType("some other type of club"); bob.attack(); } { Weapon club = Weapon("crude spiked club"); HumanB jim("Jim"); jim.setWeapon(club); jim.attack(); club.setType("some other type of club"); jim.attack(); } }
4c2fcdeb53c97a09f5d903151180a82fd9592574
95e7e2c5fab1fb70729f98ecc3def2134c2d3e38
/src/interpreter/visitor/expr/BooleanExprVisitor.cpp
97a6407d56fa19c2a580436d12f24989025a96be
[ "MIT" ]
permissive
CrackerCat/kaprino
f9f697c7cfda148b2f840a311fab3b5f3529aea9
06dcf193a6d3b496708775b763b8684612851556
refs/heads/master
2022-09-27T11:53:56.788665
2020-06-08T00:59:29
2020-06-08T00:59:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
865
cpp
#include <stdlib.h> #include "../../../parser/KaprinoParserBaseVisitor.h" #include "../../abstructs/ExprObject.h" #include "../../KaprinoAccelerator.h" #include "../../StatementVisitor.h" class BooleanExprObject : ExprObject { public: bool value; virtual llvm::Value* codegen(llvm::IRBuilder<>* builder, llvm::Module* module) override { auto boolVal = llvm::ConstantInt::get(KAPRINO_BOOL_TY(module), value); return boolVal; } }; antlrcpp::Any StatementVisitor::visitBooleanExpr(KaprinoParser::BooleanExprContext* ctx) { auto exprObj = new BooleanExprObject(); auto boolean = ctx->getText(); std::transform(boolean.begin(), boolean.end(), boolean.begin(), (int (*)(int))std::tolower); exprObj->value = boolean == "true"; KAPRINO_LOG("Static value ditected: " << boolean); return (ExprObject*)exprObj; }
1729f4e3f393715c70b5774836e1d06104fd9ee3
5d65f88109cfa941b6c592389bc4daf93bde1745
/Cpp_Basic-Opdrachten/Sokken.cpp
430f6051984a382c801a06324ac5083e7f252c9c
[]
no_license
Selawen/Cpp_Basic-Opdrachten
c125e4b6c1c72093567d0cf9030932e01e6f4fc0
fc8803855a824319f31f6b9609f4560feda5e519
refs/heads/master
2023-01-01T11:48:57.739419
2020-10-23T14:26:45
2020-10-23T14:26:45
298,239,095
0
0
null
2020-10-23T14:26:46
2020-09-24T10:02:30
C++
UTF-8
C++
false
false
427
cpp
#include "Sokken.h" Sokken::Sokken() { } Sokken::~Sokken() { } Sokken::Sokken(std::string kleur) { this->sokKleur = kleur; } Sokken::Sokken(const Sokken& puffelensSokken) { if (this == &puffelensSokken) return; sokKleur = puffelensSokken.sokKleur; } Sokken& Sokken::operator=(const Sokken& puffenlensSokken) { if (this == &puffenlensSokken) return *this; this->sokKleur = puffenlensSokken.sokKleur; return *this; }
b8b3c698476c294d022a8d695dd738320dc0f896
8ec3dcb1ee6314588e0c3235215ee0e1ffaa7ce0
/Problems PB-Info/calendar.cpp
3087e166eca7befced6a3556c69336ed479c25e4
[]
no_license
dinuionica08/Projects.Cpp
bffe0eeceb6e486ecd3a3a34e4c0e1469ca8b8c2
4b40f011ce0df8ef37b4ed3d262e6ef041d33236
refs/heads/master
2023-02-24T16:36:00.918468
2021-01-16T11:54:43
2021-01-16T11:54:43
254,618,910
0
0
null
null
null
null
UTF-8
C++
false
false
454
cpp
#include <bits/stdc++.h> using namespace std; int main() { int z, l, a; int ok = 1; cin >> z >> l >> a; if ( a > 2015 || a < 1850 ) ok = 0; else if ( l > 12 || l < 0 ) ok = 0; else if ( z > 31 || z < 0 ) ok = 0; else if ( l == 2 && ( a % 4 == 0) && z > 29) ok = 0; else if ( l == 0 || z == 0 || a == 0 ) ok = 0; if ( ok == 1) { cout << "DA"; } else { cout << "NU"; } return 0; }
267eea6afc0e42d9bf5d71c7dd91e098dc944e92
55a18be459b5f6643e2b4e212a44e115e56756ab
/dx-ball.cpp
c0482b97bc15219c247dcb4f0149b71f2fe5f900
[]
no_license
dup05/dx-ball
fa35c38beb68995fdeedb29808ee7c4c6faec023
260de01cd9f5afe64bb87b3b53b4b6a3caf19c18
refs/heads/master
2020-06-25T09:02:03.906190
2019-07-28T09:25:18
2019-07-28T09:25:18
199,266,589
0
0
null
null
null
null
UTF-8
C++
false
false
2,011
cpp
#include<SFML/Graphics.hpp> #include<time.h> #include<stdlib.h> using namespace sf; bool isCollide(Sprite s1,Sprite s2) { return s1.getGlobalBounds().intersects(s2.getGlobalBounds()); } int main() { srand(time(0)); RenderWindow app(VideoMode(520,450),"DX-BALL"); app.setFramerateLimit(60); Texture t1,t2,t3,t4,t5; t1.loadFromFile("images/block01.png"); t2.loadFromFile("images/background.jpg"); t3.loadFromFile("images/ball.png"); t4.loadFromFile("images/paddle.png"); t5.loadFromFile("images/gameover.png"); Sprite sBackground(t2), sBall(t3), sPaddle(t4),gameover(t5); sPaddle.setPosition(300,440); sBall.setPosition(330,430); gameover.setPosition(100,100); Sprite block[1000]; int n=0; for(int i=1;i<=10;i++) for(int j=1;j<=10;j++) { block[n].setTexture(t1); block[n].setPosition(i*43,j*20); n++; } app.clear(); app.draw(sBall); app.draw(sPaddle); for(int i=0;i<n;i++) app.draw(block[i]); app.display(); float dx=3,dy=3,x=300,y=300; int flag=1,start=0; while(app.isOpen()) { Event e; while(app.pollEvent(e)) { if(e.type==Event::Closed) app.close(); } while(!start) { if(Keyboard::isKeyPressed(Keyboard::Right)) start=1; } sBall.move(dx,0); for(int i=0;i<n;i++) if(isCollide(sBall,block[i])) { block[i].setPosition(-100,0); dx=-dx; } sBall.move(0,dy); for(int i=0;i<n;i++) if(isCollide(sBall,block[i])) { block[i].setPosition(-100,0); dy=-dy; } Vector2f b=sBall.getPosition(); if(b.y>450) { flag=0; } if(b.x<0||b.x>520) dx=-dx; if(b.y<0||b.y>450) dy=-dy; if(Keyboard::isKeyPressed(Keyboard::Right)) sPaddle.move(7,0); if(Keyboard::isKeyPressed(Keyboard::Left)) sPaddle.move(-7,0); if(isCollide(sPaddle,sBall)) dy=-(rand()%5+3); app.clear(); app.draw(sBall); app.draw(sPaddle); for(int i=0;i<n;i++) app.draw(block[i]); if(flag==0) { app.clear(); app.draw(gameover); } app.display(); } }
d7225b6757ec3cb03b50532d7eddcdd75f9d037b
afbb7333426cd97e39458e655972f63a940a9ace
/include/File.h
08f37688ec6d0be742dcfdaeff7b8a399bc68892
[]
no_license
alex43dm/workerd
bf49e6d00ccda7ef211e2da14d91ab600e02c211
51d2a9d6c4ea091a94888e2a70369486d6592fbf
refs/heads/master
2021-01-19T05:34:47.039523
2014-07-28T10:06:40
2014-07-28T10:06:40
22,947,941
0
1
null
null
null
null
UTF-8
C++
false
false
216
h
#ifndef FILE_H #define FILE_H class File { public: File(); virtual ~File(); bool read(std::string &cont); protected: private: long fileSize(int fd); }; #endif // FILE_H
249947a5a8fd9021e6f3497f827bc07761f519cd
458a7b198088718928b72e73af995270db0c55de
/examples/Blink/Blink.cpp
9c4dfacd7ab60629f9fa50cae661ff7f9cb3b9d6
[]
no_license
Serasidis/cbp_HALMX_2
2c4fe6dae6c5f45fc08840f9967a2e272d8bb71a
ff5549841c5c293c2053cb7669f16522e7d688bf
refs/heads/master
2021-01-13T09:50:30.923863
2016-10-22T10:39:22
2016-10-22T10:39:22
69,898,973
1
0
null
null
null
null
UTF-8
C++
false
false
930
cpp
#include <Arduino.h> /* Blink Turns on an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the Uno and Leonardo, it is attached to digital pin 13. If you're unsure what pin the on-board LED is connected to on your Arduino model, check the documentation at http://arduino.cc This example code is in the public domain. modified 8 May 2014 by Scott Fitzgerald */ // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin 13 as an output. pinMode(PC13, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for a second digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW delay(500); // wait for a second }
dc41dca6a00925e57f075aecb34086d9bdc4343e
4cd0b9ce7c2e2a57623cc71b936c6dcda79bdd5c
/xfa/fxfa/parser/cxfa_range.cpp
76b3fc2caa7bec27c89279137bdd23e02cfacb4b
[ "BSD-3-Clause" ]
permissive
prepare/pdfium
32b8f9cecc2dd98cd578d2b4e8d882e5c4f0e1ed
92770e8072cd3a38597966116045147c78b5a359
refs/heads/master
2021-01-21T04:43:53.541194
2018-12-23T06:55:27
2018-12-23T06:55:27
27,119,109
7
3
null
2015-08-11T13:40:07
2014-11-25T09:47:59
C++
UTF-8
C++
false
false
893
cpp
// Copyright 2017 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "xfa/fxfa/parser/cxfa_range.h" namespace { const CXFA_Node::AttributeData kRangeAttributeData[] = { {XFA_Attribute::Desc, XFA_AttributeType::CData, nullptr}, {XFA_Attribute::Lock, XFA_AttributeType::Integer, (void*)0}, {XFA_Attribute::Unknown, XFA_AttributeType::Integer, nullptr}}; } // namespace CXFA_Range::CXFA_Range(CXFA_Document* doc, XFA_PacketType packet) : CXFA_Node(doc, packet, XFA_XDPPACKET_Config, XFA_ObjectType::NodeV, XFA_Element::Range, nullptr, kRangeAttributeData) {} CXFA_Range::~CXFA_Range() = default;
a62dfc4ce9729a91bd466a4f66fb3a9e916b90be
eb390e54efa1630175037c017fbe2e2927ca490a
/COPY/cBody.cpp
3f6775e3fe9cb5788f47d2a5ff2e8d9706b5e034
[]
no_license
cheonjeong/reposit
c7d9dee36b72eca6323d274786e7ee2d646eb5bd
23a29d7cb347c8aad7689c4d6a50d3edc543a124
refs/heads/master
2020-08-01T11:38:07.779495
2019-09-26T08:24:13
2019-09-26T08:24:13
210,983,836
0
0
null
null
null
null
UTF-8
C++
false
false
532
cpp
#include "stdafx.h" #include "cBody.h" cBody::cBody() { } cBody::~cBody() { } void cBody::Setup() { cCubeNode::Setup(); cCubeNode::SetVertex(20, 20, 8, 12, 8, 4, 4); D3DXMATRIXA16 matS, matT, mat; D3DXMatrixIdentity(&matS); D3DXMatrixIdentity(&matT); D3DXMatrixIdentity(&mat); D3DXMatrixScaling(&matS, 0.4f, 0.6f, 0.2f); D3DXMatrixTranslation(&matT, 0.0f, 0.0f, 0.0f); mat = matS * matT; for (size_t i = 0; i < m_vecVertex.size(); i++) { D3DXVec3TransformCoord(&m_vecVertex[i].p, &m_vecVertex[i].p, &mat); } }
43478955ba8c7413a70ac3aa97f3e469c13b0079
979e2b52c768d0fd031812c0c9787be24476b693
/Mythology/Common/Task.h
74db34a9dddb307697cff6af71bdfb083b2a4b94
[]
no_license
JPMMaia/mythology-legacy
cf54215a6fb435d13b56985ea836b0d203b19c21
f34ac9e6b2c1c407d48ee942d5aba8204d2604aa
refs/heads/master
2021-03-30T16:12:46.015866
2017-12-29T16:39:10
2017-12-29T16:39:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
756
h
#pragma once #include <thread> #include <future> namespace Common { class Task { public: template<typename FunctionType> explicit Task(FunctionType&& function) : m_ready(false) { std::packaged_task<void()> task(std::forward<FunctionType>(function)); m_future = task.get_future(); m_thread = std::thread(std::move(task)); } void Update() { if(m_ready) { if (m_future.valid() && m_future.wait_for(std::chrono::milliseconds(0)) == std::future_status::ready) { m_ready = true; } } } bool IsReady() const noexcept { return m_ready; } void Join() { if (m_thread.joinable()) m_thread.join(); } private: std::future<void> m_future; std::thread m_thread; bool m_ready; }; }
f4789beb6cca327efebba0d40389a08ac6394fe9
e641bd95bff4a447e25235c265a58df8e7e57c84
/components/viz/service/display/display_resource_provider.h
c85028235a6c44c18bf8288b246acf388a24cef6
[ "BSD-3-Clause" ]
permissive
zaourzag/chromium
e50cb6553b4f30e42f452e666885d511f53604da
2370de33e232b282bd45faa084e5a8660cb396ed
refs/heads/master
2023-01-02T08:48:14.707555
2020-11-13T13:47:30
2020-11-13T13:47:30
312,600,463
0
0
BSD-3-Clause
2022-12-23T17:01:30
2020-11-13T14:39:10
null
UTF-8
C++
false
false
23,606
h
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_DISPLAY_RESOURCE_PROVIDER_H_ #define COMPONENTS_VIZ_SERVICE_DISPLAY_DISPLAY_RESOURCE_PROVIDER_H_ #include <stddef.h> #include <map> #include <memory> #include <unordered_map> #include <utility> #include <vector> #include "base/containers/flat_map.h" #include "base/containers/small_map.h" #include "base/threading/thread_checker.h" #include "base/trace_event/memory_dump_provider.h" #include "build/build_config.h" #include "components/viz/common/resources/resource_id.h" #include "components/viz/common/resources/return_callback.h" #include "components/viz/common/resources/shared_bitmap.h" #include "components/viz/common/resources/transferable_resource.h" #include "components/viz/service/display/external_use_client.h" #include "components/viz/service/display/resource_fence.h" #include "components/viz/service/viz_service_export.h" #include "gpu/command_buffer/common/sync_token.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/geometry/size.h" namespace gfx { class ColorSpace; } // namespace gfx namespace gpu { namespace gles2 { class GLES2Interface; } // namespace gles2 } // namespace gpu namespace viz { class ContextProvider; class ScopedAllowGpuAccessForDisplayResourceProvider; class SharedBitmapManager; // This class provides abstractions for receiving and using resources from other // modules/threads/processes. It abstracts away GL textures vs GpuMemoryBuffers // vs software bitmaps behind a single ResourceId so that code in common can // hold onto ResourceIds, as long as the code using them knows the correct type. // It accepts as input TransferableResources which it holds internally, tracks // state on, and exposes as a ResourceId. // // The resource's underlying type is accessed through locks that help to // scope and safeguard correct usage with DCHECKs. // // This class is not thread-safe and can only be called from the thread it was // created on. class VIZ_SERVICE_EXPORT DisplayResourceProvider : public base::trace_event::MemoryDumpProvider { public: enum Mode { kGpu, kSoftware, }; // TODO(cblume, crbug.com/900973): |enable_shared_images| is a temporary // solution that unblocks us until SharedImages are threadsafe in WebView. DisplayResourceProvider(Mode mode, ContextProvider* compositor_context_provider, SharedBitmapManager* shared_bitmap_manager, bool enable_shared_images = true); ~DisplayResourceProvider() override; DisplayResourceProvider(const DisplayResourceProvider&) = delete; DisplayResourceProvider& operator=(const DisplayResourceProvider&) = delete; bool IsSoftware() const { return mode_ == kSoftware; } void DidLoseContextProvider() { lost_context_provider_ = true; } size_t num_resources() const { return resources_.size(); } // base::trace_event::MemoryDumpProvider implementation. bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, base::trace_event::ProcessMemoryDump* pmd) override; #if defined(OS_ANDROID) // Indicates if this resource is backed by an Android SurfaceTexture, and thus // can't really be promoted to an overlay. bool IsBackedBySurfaceTexture(ResourceId id); // Return the number of resources that request promotion hints. size_t CountPromotionHintRequestsForTesting(); // This should be called after WaitSyncToken in GLRenderer. void InitializePromotionHintRequest(ResourceId id); #endif // Indicates if this resource wants to receive promotion hints. bool DoesResourceWantPromotionHint(ResourceId id) const; // Return true if and only if any resource wants a promotion hint. bool DoAnyResourcesWantPromotionHints() const; bool IsResourceSoftwareBacked(ResourceId id); GLenum GetResourceTextureTarget(ResourceId id); // Return the format of the underlying buffer that can be used for scanout. gfx::BufferFormat GetBufferFormat(ResourceId id); ResourceFormat GetResourceFormat(ResourceId id); const gfx::ColorSpace& GetColorSpace(ResourceId id); // Indicates if this resource may be used for a hardware overlay plane. bool IsOverlayCandidate(ResourceId id); void WaitSyncToken(ResourceId id); // Checks whether a resource is in use. bool InUse(ResourceId id); // The following lock classes are part of the DisplayResourceProvider API and // are needed to read the resource contents. The user must ensure that they // only use GL locks on GL resources, etc, and this is enforced by assertions. class VIZ_SERVICE_EXPORT ScopedReadLockGL { public: ScopedReadLockGL(DisplayResourceProvider* resource_provider, ResourceId resource_id); ~ScopedReadLockGL(); ScopedReadLockGL(const ScopedReadLockGL&) = delete; ScopedReadLockGL& operator=(const ScopedReadLockGL&) = delete; GLuint texture_id() const { return texture_id_; } GLenum target() const { return target_; } const gfx::Size& size() const { return size_; } const gfx::ColorSpace& color_space() const { return color_space_; } private: DisplayResourceProvider* const resource_provider_; const ResourceId resource_id_; GLuint texture_id_ = 0; GLenum target_ = GL_TEXTURE_2D; gfx::Size size_; gfx::ColorSpace color_space_; }; class VIZ_SERVICE_EXPORT ScopedOverlayLockGL { public: ScopedOverlayLockGL(DisplayResourceProvider* resource_provider, ResourceId resource_id); ~ScopedOverlayLockGL(); ScopedOverlayLockGL(const ScopedOverlayLockGL&) = delete; ScopedOverlayLockGL& operator=(const ScopedOverlayLockGL&) = delete; GLuint texture_id() const { return texture_id_; } private: DisplayResourceProvider* const resource_provider_; const ResourceId resource_id_; GLuint texture_id_ = 0; }; class VIZ_SERVICE_EXPORT ScopedSamplerGL { public: ScopedSamplerGL(DisplayResourceProvider* resource_provider, ResourceId resource_id, GLenum filter); ScopedSamplerGL(DisplayResourceProvider* resource_provider, ResourceId resource_id, GLenum unit, GLenum filter); ~ScopedSamplerGL(); ScopedSamplerGL(const ScopedSamplerGL&) = delete; ScopedSamplerGL& operator=(const ScopedSamplerGL&) = delete; GLuint texture_id() const { return resource_lock_.texture_id(); } GLenum target() const { return target_; } const gfx::ColorSpace& color_space() const { return resource_lock_.color_space(); } private: const ScopedReadLockGL resource_lock_; const GLenum unit_; const GLenum target_; }; class VIZ_SERVICE_EXPORT ScopedReadLockSkImage { public: ScopedReadLockSkImage(DisplayResourceProvider* resource_provider, ResourceId resource_id, SkAlphaType alpha_type = kPremul_SkAlphaType, GrSurfaceOrigin origin = kTopLeft_GrSurfaceOrigin); ~ScopedReadLockSkImage(); ScopedReadLockSkImage(const ScopedReadLockSkImage&) = delete; ScopedReadLockSkImage& operator=(const ScopedReadLockSkImage& other) = delete; const SkImage* sk_image() const { return sk_image_.get(); } sk_sp<SkImage> TakeSkImage() { return std::move(sk_image_); } bool valid() const { return !!sk_image_; } private: DisplayResourceProvider* const resource_provider_; const ResourceId resource_id_; sk_sp<SkImage> sk_image_; }; private: // Forward declared for LockSetForExternalUse below. struct ChildResource; public: // Lock the resource to make sure the shared image is alive when accessing // SharedImage Mailbox. class VIZ_SERVICE_EXPORT ScopedReadLockSharedImage { public: ScopedReadLockSharedImage(DisplayResourceProvider* resource_provider, ResourceId resource_id); ~ScopedReadLockSharedImage(); ScopedReadLockSharedImage(ScopedReadLockSharedImage&& other); ScopedReadLockSharedImage& operator=(ScopedReadLockSharedImage&& other); const gpu::Mailbox& mailbox() const { DCHECK(resource_); return resource_->transferable.mailbox_holder.mailbox; } const gpu::SyncToken& sync_token() const { DCHECK(resource_); return resource_->sync_token(); } private: void Reset(); DisplayResourceProvider* resource_provider_ = nullptr; ResourceId resource_id_ = kInvalidResourceId; ChildResource* resource_ = nullptr; }; // Maintains set of resources locked for external use by SkiaRenderer. class VIZ_SERVICE_EXPORT LockSetForExternalUse { public: // There should be at most one instance of this class per // |resource_provider|. Both |resource_provider| and |client| outlive this // class. LockSetForExternalUse(DisplayResourceProvider* resource_provider, ExternalUseClient* client); ~LockSetForExternalUse(); LockSetForExternalUse(const LockSetForExternalUse&) = delete; LockSetForExternalUse& operator=(const LockSetForExternalUse& other) = delete; // Lock a resource for external use. The return value was created by // |client| at some point in the past. The SkImage color space will be set // to |color_space| if valid, otherwise it will be set to the resource's // color space. If |is_video_plane| is true, the image color space will be // set to nullptr (to avoid LOG spam). ExternalUseClient::ImageContext* LockResource( ResourceId resource_id, bool is_video_plane = false, const gfx::ColorSpace& color_space = gfx::ColorSpace()); // Unlock all locked resources with a |sync_token|. The |sync_token| should // be waited on before reusing the resource's backing to ensure that any // external use of it is completed. This |sync_token| should have been // verified. All resources must be unlocked before destroying this class. void UnlockResources(const gpu::SyncToken& sync_token); private: DisplayResourceProvider* const resource_provider_; std::vector<std::pair<ResourceId, ChildResource*>> resources_; }; // All resources that are returned to children while an instance of this // class exists will be stored and returned when the instance is destroyed. class VIZ_SERVICE_EXPORT ScopedBatchReturnResources { public: explicit ScopedBatchReturnResources( DisplayResourceProvider* resource_provider, bool allow_access_to_gpu_thread = false); ~ScopedBatchReturnResources(); private: DisplayResourceProvider* const resource_provider_; const bool was_access_to_gpu_thread_allowed_; }; class VIZ_SERVICE_EXPORT SynchronousFence : public ResourceFence { public: explicit SynchronousFence(gpu::gles2::GLES2Interface* gl); SynchronousFence(const SynchronousFence&) = delete; SynchronousFence& operator=(const SynchronousFence&) = delete; // ResourceFence implementation. void Set() override; bool HasPassed() override; // Returns true if fence has been set but not yet synchornized. bool has_synchronized() const { return has_synchronized_; } private: ~SynchronousFence() override; void Synchronize(); gpu::gles2::GLES2Interface* gl_; bool has_synchronized_; }; // Sets the current read fence. If a resource is locked for read // and has read fences enabled, the resource will not allow writes // until this fence has passed. void SetReadLockFence(ResourceFence* fence) { current_read_lock_fence_ = fence; } // Creates accounting for a child. Returns a child ID. int CreateChild(const ReturnCallback& return_callback); // Destroys accounting for the child, deleting all accounted resources. void DestroyChild(int child); // Gets the child->parent resource ID map. const std::unordered_map<ResourceId, ResourceId>& GetChildToParentMap( int child) const; // Receives resources from a child, moving them from mailboxes. ResourceIds // passed are in the child namespace, and will be translated to the parent // namespace, added to the child->parent map. // This adds the resources to the working set in the ResourceProvider without // declaring which resources are in use. Use DeclareUsedResourcesFromChild // after calling this method to do that. All calls to ReceiveFromChild should // be followed by a DeclareUsedResourcesFromChild. // NOTE: if the sync_token is set on any TransferableResource, this will // wait on it. void ReceiveFromChild( int child, const std::vector<TransferableResource>& transferable_resources); // Once a set of resources have been received, they may or may not be used. // This declares what set of resources are currently in use from the child, // releasing any other resources back to the child. void DeclareUsedResourcesFromChild(int child, const ResourceIdSet& resources_from_child); // Returns the mailbox corresponding to a resource id. gpu::Mailbox GetMailbox(int resource_id); // Sets if the GPU thread is available (it always is for Chrome, but for // WebView it happens only when Android calls us on RenderThread. void SetAllowAccessToGPUThread(bool allow); private: friend class ScopedAllowGpuAccessForDisplayResourceProvider; enum DeleteStyle { NORMAL, FOR_SHUTDOWN, }; enum SynchronizationState { // The LOCALLY_USED state is the state each resource defaults to when // constructed or modified or read. This state indicates that the // resource has not been properly synchronized and it would be an error // to return this resource to a client. LOCALLY_USED, // The NEEDS_WAIT state is the state that indicates a resource has been // modified but it also has an associated sync token assigned to it. // The sync token has not been waited on with the local context. When // a sync token arrives from a client, it is automatically initialized as // NEEDS_WAIT as well since we still need to wait on it before the resource // is synchronized on the current context. It is an error to use the // resource locally for reading or writing if the resource is in this state. NEEDS_WAIT, // The SYNCHRONIZED state indicates that the resource has been properly // synchronized locally. This can either synchronized externally (such // as the case of software rasterized bitmaps), or synchronized // internally using a sync token that has been waited upon. In the // former case where the resource was synchronized externally, a // corresponding sync token will not exist. In the latter case which was // synchronized from the NEEDS_WAIT state, a corresponding sync token will // exist which is associated with the resource. This sync token is still // valid and still associated with the resource and can be passed as an // external resource for others to wait on. SYNCHRONIZED, }; struct Child { Child(); Child(const Child& other); ~Child(); std::unordered_map<ResourceId, ResourceId> child_to_parent_map; ReturnCallback return_callback; bool marked_for_deletion = false; }; // The data structure used to track state of Gpu and Software-based // resources and the service, for resources transferred // between the two. This is an implementation detail of the resource tracking // for client and service libraries and should not be used directly from // external client code. struct ChildResource { ChildResource(int child_id, const TransferableResource& transferable); ChildResource(ChildResource&& other); ~ChildResource(); bool is_gpu_resource_type() const { return !transferable.is_software; } bool needs_sync_token() const { return is_gpu_resource_type() && synchronization_state_ == LOCALLY_USED; } const gpu::SyncToken& sync_token() const { return sync_token_; } SynchronizationState synchronization_state() const { return synchronization_state_; } // If true the gpu resource needs its SyncToken waited on in order to be // synchronized for use. bool ShouldWaitSyncToken() const { return synchronization_state_ == NEEDS_WAIT; } bool InUse() const { return lock_for_read_count > 0 || locked_for_external_use || lock_for_overlay_count > 0; } void SetLocallyUsed(); void SetSynchronized(); void UpdateSyncToken(const gpu::SyncToken& sync_token); // This is the id of the client the resource comes from. const int child_id; // Data received from the client that describes the resource fully. const TransferableResource transferable; // The number of times the resource has been received from a client. It must // have this many number of references returned back to the client in order // for it to know it is no longer in use in the service. This is used to // avoid races where a resource is in flight to the service while also being // returned to the client. It starts with an initial count of 1, for the // first time the resource is received. int imported_count = 1; // The number of active users of a resource in the display compositor. While // a resource is in use, it will not be returned back to the client even if // the ResourceId is deleted. int lock_for_read_count = 0; // When true, the resource is currently being used externally. This is a // parallel counter to |lock_for_read_count| which can only go to 1. bool locked_for_external_use = false; // The number of active users using this resource as overlay content. int lock_for_overlay_count = 0; // When the resource should be deleted until it is actually reaped. bool marked_for_deletion = false; // Texture id for texture-backed resources, when the mailbox is mapped into // a client GL id in this process. GLuint gl_id = 0; // The current min/mag filter for GL texture-backed resources. The original // filter as given from the client is saved in |transferable|. GLenum filter; // A pointer to the shared memory structure for software-backed resources, // when it is mapped into memory in this process. std::unique_ptr<SharedBitmap> shared_bitmap; // A GUID for reporting the |shared_bitmap| to memory tracing. The GUID is // known by other components in the system as well to give the same id for // this shared memory bitmap everywhere. This is empty until the resource is // mapped for use in the display compositor. base::UnguessableToken shared_bitmap_tracing_guid; // A fence used for accessing a gpu resource for reading, that ensures any // writing done to the resource has been completed. This is implemented and // used to implement transferring ownership of the resource from the client // to the service, and in the GL drawing code before reading from the // texture. scoped_refptr<ResourceFence> read_lock_fence; // SkiaRenderer specific details about this resource. Added to ChildResource // to avoid map lookups further down the pipeline. std::unique_ptr<ExternalUseClient::ImageContext> image_context; private: // Tracks if a sync token needs to be waited on before using the resource. SynchronizationState synchronization_state_; // A SyncToken associated with a texture-backed or GpuMemoryBuffer-backed // resource. It is given from a child to the service, and waited on in order // to use the resource, and this is tracked by the |synchronization_state_|. gpu::SyncToken sync_token_; }; using ChildMap = std::unordered_map<int, Child>; using ResourceMap = std::unordered_map<ResourceId, ChildResource>; ChildResource* InsertResource(ResourceId id, ChildResource resource); ChildResource* GetResource(ResourceId id); // TODO(ericrk): TryGetResource is part of a temporary workaround for cases // where resources which should be available are missing. This version may // return nullptr if a resource is not found. https://crbug.com/811858 ChildResource* TryGetResource(ResourceId id); void PopulateSkBitmapWithResource(SkBitmap* sk_bitmap, const ChildResource* resource); void DeleteResourceInternal(ResourceMap::iterator it, DeleteStyle style); void WaitSyncTokenInternal(ChildResource* resource); // Returns null if we do not have a ContextProvider. gpu::gles2::GLES2Interface* ContextGL() const; const ChildResource* LockForRead(ResourceId id, bool overlay_only); void UnlockForRead(ResourceId id, bool overlay_only); void TryReleaseResource(ResourceId id, ChildResource* resource); // Binds the given GL resource to a texture target for sampling using the // specified filter for both minification and magnification. Returns the // texture target used. The resource must be locked for reading. GLenum BindForSampling(ResourceId resource_id, GLenum unit, GLenum filter); bool ReadLockFenceHasPassed(const ChildResource* resource); #if defined(OS_ANDROID) void DeletePromotionHint(ResourceMap::iterator it, DeleteStyle style); #endif void DeleteAndReturnUnusedResourcesToChild( ChildMap::iterator child_it, DeleteStyle style, const std::vector<ResourceId>& unused); void DestroyChildInternal(ChildMap::iterator it, DeleteStyle style); void SetBatchReturnResources(bool aggregate); void TryFlushBatchedResources(); THREAD_CHECKER(thread_checker_); const Mode mode_; ContextProvider* const compositor_context_provider_; SharedBitmapManager* const shared_bitmap_manager_; ResourceMap resources_; ChildMap children_; base::flat_map<ResourceId, sk_sp<SkImage>> resource_sk_images_; // Used to release resources held by an external consumer. ExternalUseClient* external_use_client_ = nullptr; base::flat_map<int, std::vector<ResourceId>> batched_returning_resources_; scoped_refptr<ResourceFence> current_read_lock_fence_; // Keep track of whether deleted resources should be batched up or returned // immediately. int batch_return_resources_lock_count_ = 0; // Set to true when the ContextProvider becomes lost, to inform that resources // modified by this class are now in an indeterminate state. bool lost_context_provider_ = false; // The ResourceIds in DisplayResourceProvider start from 2 to avoid // conflicts with id from ClientResourceProvider. ResourceId next_id_ = 2; // Used as child id when creating a child. int next_child_ = 1; // A process-unique ID used for disambiguating memory dumps from different // resource providers. int tracing_id_; #if defined(OS_ANDROID) // Set of ResourceIds that would like to be notified about promotion hints. ResourceIdSet wants_promotion_hints_set_; #endif bool enable_shared_images_; // Indicates that gpu thread is available and calls like // ReleaseImageContexts() are expected to finish in finite time. It's always // true for Chrome, but on WebView we need to have access to RenderThread. bool can_access_gpu_thread_ = true; }; } // namespace viz #endif // COMPONENTS_VIZ_SERVICE_DISPLAY_DISPLAY_RESOURCE_PROVIDER_H_
f2858ba30b835ee7660d9896b390532d76809e91
d6578911eff20f7e4ec1eedf9c56feeddf12c830
/Darts_501/Darts_501/Game.cpp
7011cb600534153125fd3c7eeaa35d0fc774523c
[]
no_license
Nekrotic02/Darts_501
c89a36872262018044bb54623c0f777b360a5e6c
52748c5b62cd048cf0e1f4173e0fa97e84120d55
refs/heads/main
2023-04-17T20:02:03.606655
2021-04-21T17:22:48
2021-04-21T17:22:48
357,308,856
0
0
null
null
null
null
UTF-8
C++
false
false
2,417
cpp
#include "Game.h" #include "Throw.h" #include "Board.h" #include "Results.h" #include <iostream> Game::Game() { players[0] = NULL; players[1] = NULL; game_type = 501; } Game::~Game() { } void Game::Play_Game(Results* results, char first) { short int current_player = first; Throw new_Throw; for (int i = 0; i < 13; i++) // playing 13 sets per game { players[0]->Reset_Score(); players[1]->Reset_Score(); while (players[0]->Get_Score() != 0 && players[1]->Get_Score() != 0 && players[0]->Get_Wins() != 7 && players[1]->Get_Wins() != 7) { int temp_score = players[current_player]->Get_Score(); for (short int shots{}; shots < 2; shots++) { short int hit = NULL; for (short int throws{}; throws < 3; throws++) { bool score{}; new_Throw.Strategy(players[current_player]); if (players[current_player]->Get_Score() == 50) { hit = new_Throw.Throw_Bull(players[current_player]); } else { switch (players[current_player]->Get_Strat()) { case 0: hit = new_Throw.Throw_Single(players[current_player]); break; case 1: hit = new_Throw.Throw_Double(players[current_player]); break; case 2: hit = new_Throw.Throw_Treble(players[current_player]); break; } } score = players[current_player]->Check_Score(hit); if (score == 0) { temp_score = 0; break; } else if (score == 1) { // players[current_player]->Change_Score(hit); temp_score = temp_score - hit; } } players[current_player]->Change_Score(temp_score); current_player = !current_player; } // std::cout << "Player 1 Score: " << players[0]->Get_Score() << std::endl; // std::cout << "Player 2 Score: " << players[1]->Get_Score() << std::endl; } if (players[0]->Get_Score() == 0) { players[0]->Add_Win(); } else if (players[1]->Get_Score() == 0) { players[1]->Add_Win(); } } bool champ; if (players[0]->Get_Wins() > players[1]->Get_Wins()) { champ = false; } else { champ = true; } results->Add_Results(champ, players[0], players[1]); players[0]->Reset_Wins(); players[1]->Reset_Wins(); } void Game::First_Player(Player* current_player, short int position) { players[position] = current_player; } std::string Game::Get_Winner() { return winner; } void Game::Set_Winner(std::string player_name) { winner = player_name; }
ccddda93ce209b90172c38937cb25ba98eeda8d7
f8392d1271caaeb0337393eb11153fe569acd3bb
/Untitled5.cpp
84fc5dfa41e5588a0857a405afd2820cf340b86b
[]
no_license
Aditi1017/DataStructures
0eff62180da65874819f8c4b2db467f658a41276
77e0d3dc22a0bbe0bece1a7b9066eb990c4cb929
refs/heads/master
2023-08-11T04:11:34.328502
2021-10-15T12:18:15
2021-10-15T12:18:15
252,183,363
3
1
null
null
null
null
UTF-8
C++
false
false
574
cpp
#include<bits/stdc++.h> using namespace std; struct Node // Creation of a single element of tree { int data; struct Node *left; struct Node *right; }root; //preorder traversal of tree non recursively void preOrder(Node *root) { stack<Node*> s; while(1) { while(root!=NULL) { s.push(root); cout<<root->data<<" "; root=root->left; } if(s.empty()) break; root=s.Pop(); root=root->right; } }
377b01b233dcbdf44d3a2052a3146d7ac31a54f3
ac309bd6ba1aa289dd0f1588ad1e0d8b5f64e745
/Shared Classes/Stats.cpp
45310c3ba8f1aa569b5c663e734e95570828b415
[]
no_license
Mertank/ToneArm
b6cabd6613a34064bff331510f46147ffd948fce
40c62b0de89ac506bea6674e43578bf4e2631f93
refs/heads/master
2021-01-10T16:20:32.736271
2015-11-04T04:45:08
2015-11-04T04:45:08
45,514,584
0
0
null
null
null
null
UTF-8
C++
false
false
2,128
cpp
/* ------------------------------------------------------------------------------------------ Copyright (c) 2014 Vinyl Games Studio Author: Mikhail Kutuzov Date: 10/7/2014 5:45:48 PM ------------------------------------------------------------------------------------------ */ #include "Stats.h" #include "Effect.h" using namespace merrymen; // // handles application of the effect // void Stats::ApplyEffect(const Effect& effect, vgs::GameObject* const author) { Effect* appliedEffect = new Effect(effect); // add the effect to the list of applied effects AppliedEffects.insert(std::pair<Effect*, vgs::GameObject*>(appliedEffect, author)); } // // cancels one of the applied effects // void Stats::UnapplyEffect(Effect* const effect, vgs::GameObject* const author) { // remove the effect from the list of applied effects AppliedEffects.erase(effect); delete effect; } // // returns all of the effects applied to the stats which match the passed type // std::vector<Effect*> Stats::GetAppliedEffectsOfType(const SpecificEffectType& type) { std::vector<Effect*> result; for (auto effect : AppliedEffects) { SpecificEffectType effectType = SpecificEffectType(effect.first->Type, effect.first->Reason); if (effectType == type) { result.push_back(effect.first); } } return result; } // // returns all of the effects of the same type as the passed effect, which are applied to the stats // std::vector<Effect*> Stats::GetSimilarAppliedEffects(const Effect& effect) { std::vector<Effect*> result; SpecificEffectType effectType = SpecificEffectType(effect.Type, effect.Reason); for (auto appliedEffect : AppliedEffects) { SpecificEffectType appliedEfectType = SpecificEffectType(appliedEffect.first->Type, appliedEffect.first->Reason); if (effectType == appliedEfectType) { result.push_back(appliedEffect.first); } } return result; } // // cound the number of effects of the same type as the passed effect, which are applied to the stats // int Stats::CountSimilarAppliedEffects(const Effect& effect) { return GetSimilarAppliedEffects(effect).size(); }
606d239093d703fc4d424c01825e9051ed199b24
361f82ad61fc479c97ec941b12b0cde1087b12cc
/c++abc/algo/bignum/multiplydi.cpp
c357a9b0da4a809653e763d8aab58138f6d9a7db
[]
no_license
yu2003w/vault
799045a0691fbc5b408521bb7a6441633ce1d848
a323d8a811d87b0d64dd92201c6597ce5258f242
refs/heads/master
2021-05-24T01:32:15.721820
2019-08-04T11:25:43
2020-08-15T16:31:59
83,046,163
0
0
null
2017-03-20T09:46:55
2017-02-24T13:53:20
M4
UTF-8
C++
false
false
2,253
cpp
/* It's interesting to multiply big integers. big integers could be divided into multiple sections. */ #include <iostream> #include <cstring> using namespace std; const int INTEGER_LEN = 100; const int RESULT_LEN = 200; int multiply(char num1[], char num2[], char result[]) { int len1 = strlen(num1); int len2 = strlen(num2); if (len1 == 0 || len2 == 0) { result[0] = '\0'; return 0; } int len = len1 > len2 ? len1 : len2; int ret = 0; if (len <= 4) { //calculate directly int n1 = atoi(num1); int n2 = atoi(num2); ret = n1*n2; sprintf(result, "%d", ret); return strlen(result); } /* split integer into two sections num1 = a*10^n + b num2 = c*10^n + d num1 * num2 = (a*10^n + b) * (c*10^n + d) = ac*10^2n + (ad + bc)*10^n + bd = ac*10^2n + ((a-b)(d-c) + ac + bd)*10^n + bd */ char a[50], b[50], c[50], d[50]; char ac[100], bd[100], a1b1[100]; memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); memset(c, 0, sizeof(c)); memset(d, 0, sizeof(d)); memset(ac, 0, sizeof(ac)); memset(bd, 0, sizeof(bd)); memset(a1b1, 0, sizeof(a1b1)); int sec = len / 2; int lena = len1 - sec; if (lena > 0) { strncpy(a, num1, lena); cout<<"a->"<<a<<endl; } strcpy(b, num1 + lena); cout<<"b->"<<b<<endl; int lenc = len2 - sec; if (lenc > 0) { strncpy(c, num2, lenc); cout<<"c->"<<c<<endl; } strcpy(d, num2 + lenc); cout<<"d->"<<d<<endl; if (lena > 0 && lenc > 0) { multiply(a, c, ac); multiply(a, d, a1b1); } else { ac[0] = '\0'; } multiply(b, d, bd); //copy result into right sections int lenac = strlen(ac); int lenbd = strlen(bd); int lena1b1 = strlen(a1b1); strcpy(bd, result + RESULT_LEN - 1 - lenbd); return 0; } int main(int argc, char** argv) { char data1[INTEGER_LEN]; char data2[INTEGER_LEN]; char data3[RESULT_LEN]; memset(data3, 0, sizeof(data3)); cout<<"input the first integer:"; cin>>data1; cout<<"input the second integer:"; cin>>data2; int ret = multiply(data1, data2, data3); cout<<"result: "<<data3 - ret + RESULT_LEN - 1; }
0a6d6e5fbcd327b134d3565e85f9cf9ed78dbb70
5d0f3a2c94543578b96120e0d5be1cf906c7e157
/MyGame/MyGame/Engine.cpp
c29ba637034e9af83a820f640303ba509da72ef1
[]
no_license
guivmc/Game_SFML
138484b907805f439c7f9f9d6f65d9778f872707
42fea10e5223e76b84d340e6b9d1b6c782aa454c
refs/heads/master
2020-04-10T13:38:51.992873
2018-12-24T18:27:25
2018-12-24T18:27:25
161,056,169
0
0
null
null
null
null
UTF-8
C++
false
false
1,999
cpp
#include "pch.h" #include "Engine.h" #include "MenuState.h" #include <iostream> Engine::Engine(int screenWidth, int screenHeight, std::string title) { this->screenWidth = screenWidth; this->screenHeight = screenHeight; //Window with title and close buttons this->_data->_window.create(sf::VideoMode(screenWidth, screenHeight), title, sf::Style::Titlebar + sf::Style::Close); } //Methods void Engine::CreateMenu() { this->_data->_stateMachine.AddState(StateRef(new MenuState(this->_data)), false); } void Engine::drawEngine(float dt) { this->_data->_window.clear(sf::Color::Black); this->_data->_stateMachine.getActiveState()->Draw(dt); this->_data->_window.display(); } void Engine::handleInputEngine() { sf::Event event; while (this->_data->_window.pollEvent(event)) { if (sf::Event::Closed == event.type) { this->_data->_window.close(); } this->_data->_stateMachine.getActiveState()->Input(); } } void Engine::Run() { float newTime, frameTime, interpolation, accumulator = 0, currentTime = _clock.getElapsedTime().asSeconds(); CreateMenu(); while (this->_data->_window.isOpen()) { this->_data->_stateMachine.ProcessStateChanges(); newTime = _clock.getElapsedTime().asSeconds(); //Frame diference frameTime = newTime - currentTime; if (frameTime > 0.25f) frameTime = 0.25f; currentTime = newTime; accumulator += frameTime; //update with frame while (accumulator >= dt) { handleInputEngine(); this->_data->_stateMachine.getActiveState()->Update(dt); accumulator -= dt; } interpolation = accumulator / dt; drawEngine(interpolation); //std::cout << accumulator << std::endl; } } //Getters int Engine::getScreenWidth() { return screenWidth; } int Engine::getScreenHeight() { return screenHeight; } //Setters void Engine::setScreenWidth(int screenWidth) { this->screenWidth = screenWidth; } void Engine::setScreenHeight(int screenHeight) { this->screenHeight = screenHeight; }
32c3ac0a1850a3c0e3eb1a06af78a7563ac476bd
5610d502f019f23c7c12acac44b36a1ab068c054
/bicikl (2).cpp
043ab2b6d598807296200baaa3a85888442e3756
[]
no_license
elvircrn/ccppcodes
7f301760a1cbe486f3991d394d5355483fbf27dd
b5d72b875b5082042826c86643d6f5e47ab2d768
refs/heads/master
2021-01-01T05:46:37.476763
2015-10-14T17:47:57
2015-10-14T17:47:57
44,265,359
0
1
null
null
null
null
UTF-8
C++
false
false
651
cpp
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include <cstring> using namespace std; int input, n, maxsum, RealLeft, RealRight, FakeLeft, FakeRight, cnt; int main () { scanf ("%d", &n); for (int i = 0; i < n; i++) { scanf ("%d", &input); cnt += input; if (cnt < 0) { cnt = 0; FakeLeft = i; } if (cnt > maxsum) { RealLeft = FakeLeft; RealRight = i; cnt = maxsum; } if (cnt == maxsum) { if ( } } return 0; }
e469609be2a40cc93b1f98a8c48330d140ccd180
fe6360bf697243c6c318836a3c64a9c1984b610b
/deprecated/jLib/src/graphics/collada/graphics.collada.file.cpp
0e846f6475b8169137d413c3aa08d2ffcad8549a
[]
no_license
davidmueller13/vexx
366cec96f4abac2e814176cd5d2ae75393561c0d
9194877951c78cd3fde3e7fbe6d511e40c24f8eb
refs/heads/master
2021-01-10T11:51:19.124071
2015-09-26T15:30:05
2015-09-26T15:30:05
43,210,604
0
0
null
null
null
null
UTF-8
C++
false
false
1,264
cpp
#include "graphics/collada/graphics.collada.file.h" BEGIN_JLIB_GRAPHICS_COLLADA_NAMESPACE file::file( string in ) { setContent( in ); base::setMyRoot( &root ); } file::file( jLib::file::ioFile in ) { setContent( in.get() ); base::setMyRoot( &root ); } file::~file() { } void file::setContent( string in ) { content = xml::strip( in ); root = xml::xmlString( content ).fromString().findFirst( "COLLADA" ); } unsigned int file::size( type t ) { xml::tag element = getMyRoot()->findFirst( getFindString( t ) ); return element.findAll( getSubFindString( t ) ).size(); } bool file::has( type t ) { return size( t ) > 0; } string file::getFindString( type t ) { switch( t ) { case geometry: return "library_geometries"; break; default: jFail( "Unrecognised element type" ); break; } return ""; } string file::getSubFindString( type t ) { switch( t ) { case geometry: return "geometry"; break; default: jFail( "Unrecognised element type" ); break; } return ""; } END_JLIB_GRAPHICS_COLLADA_NAMESPACE
[ "jorjpimm@e3525c50-fa1a-11de-8c8a-61c5e9addfc9" ]
jorjpimm@e3525c50-fa1a-11de-8c8a-61c5e9addfc9
1207db2284de1431653f0634171756a04fb87b6d
ad273708d98b1f73b3855cc4317bca2e56456d15
/aws-cpp-sdk-dax/include/aws/dax/model/IsModifiable.h
cb3636d2b6f3e050ae64956ed887ad6dd2573b62
[ "MIT", "Apache-2.0", "JSON" ]
permissive
novaquark/aws-sdk-cpp
b390f2e29f86f629f9efcf41c4990169b91f4f47
a0969508545bec9ae2864c9e1e2bb9aff109f90c
refs/heads/master
2022-08-28T18:28:12.742810
2020-05-27T15:46:18
2020-05-27T15:46:18
267,351,721
1
0
Apache-2.0
2020-05-27T15:08:16
2020-05-27T15:08:15
null
UTF-8
C++
false
false
1,075
h
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/dax/DAX_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> namespace Aws { namespace DAX { namespace Model { enum class IsModifiable { NOT_SET, TRUE, FALSE, CONDITIONAL }; namespace IsModifiableMapper { AWS_DAX_API IsModifiable GetIsModifiableForName(const Aws::String& name); AWS_DAX_API Aws::String GetNameForIsModifiable(IsModifiable value); } // namespace IsModifiableMapper } // namespace Model } // namespace DAX } // namespace Aws
6b5e6563c36472753e6aa44ec0f24982e3039289
2ffc4363ba5b246e48a3b20db662154f9be2a4c7
/performance/fiber/overhead_detach.cpp
8543f56ffe8e3714aa3c3f0c22d515d026d65249
[]
no_license
tempbottle/boost-fiber
b0e230469c7de12919c562e12a419967282dd6cf
59a4317bf35dfbccc8e0b4bd7f23a32a3c9bfc4f
refs/heads/master
2021-01-18T09:10:43.737436
2016-02-02T16:07:29
2016-02-02T16:07:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,425
cpp
// Copyright Oliver Kowalke 2009. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <cstdlib> #include <iostream> #include <stdexcept> #include <boost/cstdint.hpp> #include <boost/fiber/all.hpp> #include <boost/preprocessor.hpp> #include "../clock.hpp" #ifndef JOBS #define JOBS BOOST_PP_LIMIT_REPEAT #endif #define DETACH(z, n, _) \ { \ boost::fibers::fiber f( worker); \ time_point_type start( clock_type::now() ); \ f.detach(); \ duration_type total = clock_type::now() - start; \ total -= overhead; \ result += total; \ } void worker() {} duration_type measure( duration_type overhead) { boost::fibers::fiber( worker).join(); duration_type result = duration_type::zero(); BOOST_PP_REPEAT_FROM_TO(1, JOBS, DETACH, _) result /= JOBS; // loops return result; } int main( int argc, char * argv[]) { try { duration_type overhead = overhead_clock(); boost::uint64_t res = measure( overhead).count(); std::cout << "average of " << res << " nano seconds" << std::endl; return EXIT_SUCCESS; } catch ( std::exception const& e) { std::cerr << "exception: " << e.what() << std::endl; } catch (...) { std::cerr << "unhandled exception" << std::endl; } return EXIT_FAILURE; }
8940b2eb0ffb0efdcda710b1f392da6b226bc0de
60924597751b75da2183026e6a590b7b60479830
/0808/PollPollerServer_MakeLibrary/Cond.h
8ce0658138046349c9f8f3004e4f25602cb5e21d
[]
no_license
ShiboBrady/cpp
48f86ff28d81c433cc23d96dcf373f90a7d0d509
db5896cc37b138c57e8421244d97248de2772009
refs/heads/master
2021-01-18T18:16:54.519577
2014-08-10T05:58:43
2014-08-10T05:58:43
21,695,906
1
0
null
null
null
null
UTF-8
C++
false
false
413
h
#ifndef COND_H #define COND_H #include <pthread.h> #include "NonCopyable.h" class Mutex; class Cond : NonCopyable { public: Cond(Mutex &mutex); ~Cond(); void wait(); void signal(); void broadcast(); private: Cond(const Cond &other); void operator = (const Cond &other); pthread_cond_t cond_; Mutex &mutex_; }; #endif /*COND_H*/
[ "xujie@ubuntu.(none)" ]
xujie@ubuntu.(none)
58b0e95f59d570026a82ae9388aac84696a37867
ce7876095646b3da23811753cd1850f7dde2d673
/highland2/p0dNumuCCQEAnalysis/v2r11p1/src/p0dNumuCCQESelection.cxx
76b954ed2a24732e745e38d48d37f5824afaf93a
[]
no_license
Balthazar6969/T2K
63d7bd6dc2ef9eb1d8e33311d220bf8eb8b61828
14709b0dbe1f9b22992efecf30c50d9b8f8bba5c
refs/heads/master
2020-09-09T18:19:24.346765
2019-11-19T07:01:44
2019-11-19T07:01:44
221,523,255
0
0
null
null
null
null
UTF-8
C++
false
false
3,445
cxx
#include "baseSelection.hxx" #include "p0dNumuCCQESelection.hxx" #include "p0dNumuCCSelection.hxx" #include "CutUtils.hxx" #include "EventBoxUtils.hxx" //******************************************************************** p0dNumuCCQESelection::p0dNumuCCQESelection(bool forceBreak): SelectionBase(forceBreak, EventBoxId::kEventBoxTracker) { //******************************************************************** } //******************************************************************** void p0dNumuCCQESelection::DefineSteps(){ //******************************************************************** p0dNumuCCSelection p0dnumucc; CopySteps(p0dnumucc); //Add a split to the trunk with 2 branches. One for single p0d //selection and the other for multiple. This is necessary to get the //weight systs as ApplyWeightSystematic is only called if a branch //passes. AddSplit(2); // QE selection AddStep(0, StepBase::kCut, "single p0d pid", new SingleP0DPIDCut()); // Other selection. Need this additional "cut" or else the selection crashes AddStep(1, StepBase::kCut, "multiple p0d pid", new MultipleP0DPIDCut()); SetBranchAlias(0,"Single-P0D", 0); SetBranchAlias(1,"Multiple-P0D", 1); } //******************************************************************** void p0dNumuCCQESelection::DefineDetectorFV(){ //******************************************************************** SetDetectorFV(SubDetId::kP0D); } //******************************************************************** bool p0dNumuCCQESelection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){ //******************************************************************** if(allCutsPassed[0]){ static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kP0DNuMuCC; } return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kUnassigned); } //************************************************** void p0dNumuCCQESelection::InitializeEvent(AnaEventC& eventC){ //************************************************** AnaEventB& event = *static_cast<AnaEventB*>(&eventC); // Create the appropriate EventBox if it does not exist yet if (!event.EventBoxes[EventBoxId::kEventBoxTracker]) event.EventBoxes[EventBoxId::kEventBoxTracker] = new EventBoxTracker(); boxUtils::FillTracksWithTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV())); boxUtils::FillTracksWithP0D(event); boxUtils::FillTrajsChargedInTPC(event); boxUtils::FillTrajsChargedInP0D(event); } //************************************************** bool SingleP0DPIDCut::Apply(AnaEventC& eventC, ToyBoxB& box) const{ //************************************************** (void)box; AnaEventB& event = *static_cast<AnaEventB*>(&eventC); // Get all tracks using P0D EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker]; int nP0D=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithP0D]; return (nP0D == 1); } //************************************************** bool MultipleP0DPIDCut::Apply(AnaEventC& eventC, ToyBoxB& box) const{ //************************************************** (void)box; AnaEventB& event = *static_cast<AnaEventB*>(&eventC); // Get all tracks using P0D EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker]; int nP0D=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithP0D]; return (nP0D > 1); }
22e19c5d6f33d1eeab2606c8edb927da061c54dc
7d139ecd60979a89236867022d073ee85b92d829
/snde/openscenegraph_compositor.hpp
7d865c870659d477946002cb08ed44401dd9e087
[]
no_license
isuthermography/spatialnde2
59336f6ef313aa1b0e5759959fe647d509bdd09b
5cf6f0bcd9adad46827a6cffffe976709a6d6cd6
refs/heads/master
2023-05-27T20:44:38.615258
2023-05-10T17:20:10
2023-05-10T17:20:10
235,888,543
0
0
null
null
null
null
UTF-8
C++
false
false
19,996
hpp
#ifndef SNDE_OPENSCENEGRAPH_COMPOSITOR_HPP #define SNDE_OPENSCENEGRAPH_COMPOSITOR_HPP #include <osgViewer/GraphicsWindow> #include <osgViewer/Viewer> #include <osg/Texture2D> #include <osgGA/TrackballManipulator> #include <osg/MatrixTransform> #include <osgUtil/SceneView> #include <osgViewer/Renderer> #include "snde/recstore.hpp" #include "snde/openscenegraph_rendercache.hpp" namespace snde { class osg_compositor; class osg_renderer; // openscenegraph_renderer.hpp class osgViewerCompat34; // openscenegraph_renderer.hpp // Threading approach: // Can delegate most rendering (exc. final compositing) to // a separate thread, but be warned. Per QT, not all graphics // drivers are thread-safe, so best to check the QT capability report // // Either way, we use a condition variable to signal a sub-thread // that an update has occurred. This sub-thread then takes the // latest ready globalrev and parameters and does all of the // calculations/updates. If rendering is considered thread-safe, // then this same sub-thread renders each of the layers in // OpenGL Framebuffers and then // triggers a QT redraw in the main GUI thread. // The main thread redraw sees that an update is available, // performs compositing, and flags the sub-thread that it is OK // for it to continue. // // If rendering is not considered thread-safe, then the rendering // (but not the calculations/updates) are moved into the main thread // redraw but otherwise the process proceeds identically) // There is a potential issue if QT wants a paint while the other thread is // (Note that nothing in this module is QT-specific) // general info about opengl off-screen rendering: // https://stackoverflow.com/questions/9742840/what-are-the-steps-necessary-to-render-my-scene-to-a-framebuffer-objectfbo-and // OpenSceneGraph: Use FrameBufferObject, such as in // https://github.com/openscenegraph/OpenSceneGraph/blob/master/examples/osgfpdepth/osgfpdepth.cpp // or RTT: http://beefdev.blogspot.com/2012/01/render-to-texture-in-openscenegraph.html // *** order-independent-transparency depth peeling example https://github.com/openscenegraph/OpenSceneGraph/blob/34a1d8bc9bba5c415c4ff590b3ea5229fa876ba8/examples/osgoit/DepthPeeling.cpp // https://github.com/openscenegraph/OpenSceneGraph/blob/master/examples/osgmultiplerendertargets/osgmultiplerendertargets.cpp // OSG fbo creation: https://github.com/openscenegraph/OpenSceneGraph/blob/3141cea7c102cf7431a9fa1b55414aa4ff2f6495/examples/osgfpdepth/osgfpdepth.cpp except this creates a depth texture // Basically, you generate a framebuffer handle, (glGenFramebuffers, in osg FrameBufferObject::apply() // a texture handle, glGenTextures (presumably osg::Texture2D?) // and a render buffer (depth) handle. glGenRenderbuffers (RenderBuffer::getObjectID) // The framebuffer must be bound to the current context (camera operation?) // Likewise the texure and depth buffers must be bound. // Texture resolution defined by glTexImage2D. (osg::Texture2D) // Consider setting texture min_filter and mag_filter parameters. // Use glFramebufferTexture2D to attach the framebuffer // to the texture. // Use glRenderBufferStorage to define the depth buffer resolution // Use glFramebufferRenderBuffer to attach the renderbuffer to the framebuffer // Use glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) to verify supported mode // set up glViewport according to geometry // // in OSG the various attachments are done with FrameBufferAttachment::attach in FrameBufferObject.cpp which is triggered by FrameBufferObject.setAttachment() // rttCamera->setRenderTargetImplementation(Camera::FRAME_BUFFER_OBJECT) // camera->attach(Camera::COLOR_BUFFER, colorTexture.get(), 0, 0, false, // config.coverageSamples, config.depthSamples); // camera->attach(Camera::DEPTH_BUFFER, depthTexture.get() // See also FboTest in osgmemorytest.cpp // Also: https://stackoverflow.com/questions/31640707/sequential-off-screen-rendering-screen-capture-without-windowing-system-using // Viewer: Must setThredingModel(SingleThreaded); !!! // Compositor specifics // -------------------- // Consider two threads (these are the same thread // for the GLUT compositor example, but are // different threads in the QT GUI // A: Main GUI Thread + Compositor thread // B: Layer Rendering thread // // The threads interact using condition variables // with the main gui thread being the leader and // the layer rendering thread being the follower. // The layer rendering thread is only allowed to // execute when delegated to by the main GUI thread. // When the main GUI thread has delegated to the // layer rendering thread, the main GUI thread // is not itself allowed to do any rendering. // // Compositor initialized in main GUI thread // Rendercache initialized in layer rendering thread // // Layer rendering thread maintains a set of // osg::Viewers, with osg_layerwindows or the // osg_qtoffscreenlayer subclass as their // "osg::GraphicsWindow", one per currently defined // channel (These release their rootnode if they // are not activated for rendering). These are // all created in the layer rendering thread and // thus may (only) execute in that thread. NOTE: // the QOffscreenSurface must be created or destroyed // only in the main GUI thread so that functionality // will have to be delegated (!) -- Delegate with QtConcurrent // to a thread pool containing just the main GUI thread // and wait on the QFuture. // // The Layer rendering thread also provides the // graticule layer. // // When an update is triggered, the layer rendering // thread triggers the relevant recstore_display_transforms // and waits for completion. Then it goes through // all activated channels, finds their corresponding // osg::Viewer and calls Viewer.frame() to render // each to their corresponding framebuffer object. // The layer rendering thread then notifies the // main GUI thread that it is done. // // The main GUI thread can then assemble the layers // from the corresponding framebuffer object textures // and render into the QOpenGLWidget. // // In the class the notification methods just call // the other thread code directly; a subclass implements the // thread dispatching. // NOTES: // Aternate option: Need to set RenderStage FrameBufferObject and perhaps remove DisableFboAfterRender // Renderstage accessed through osgViewer::Renderer::getSceneView(0 or 1)->GetRenderStage() -- which was set in SceneView->setDefaults()... // Renderer probably accessible through camera::getRenderer // (Renderer is a GraphicsOperation), created in View constructor // want doCopyTexture = false... requries "callingContext=useContext" (?) but that tries to enable pBuffer ... No... instead don't assign texture, just // bind it at last minute? ... but bound texture required for _rtt? // maybe no read_fbo? // // Apply texture binding to _fbo in predrawcallback? // overriding the provided RenderBuffer? // Then do readback in postdraw... class osg_compositor_eventhandler: public osgGA::GUIEventHandler { public: osg_compositor *comp; // use the compositor_dead flag (only set in main GUI loop thread) instead of a weak_ptr so that osg_compositor is compatible with both shared_ptr and QT ownership models. compositor_dead will be set in the destructor of the osg_compositor bool compositor_dead; // used as a validity flag for comp std::shared_ptr<display_info> display; osg_compositor_eventhandler(osg_compositor *comp,std::shared_ptr<display_info> display); osg_compositor_eventhandler(const osg_compositor_eventhandler &) = delete; osg_compositor_eventhandler & operator=(const osg_compositor_eventhandler &) = delete; virtual ~osg_compositor_eventhandler() = default; virtual bool handle(const osgGA::GUIEventAdapter &eventadapt, osgGA::GUIActionAdapter &actionadapt); }; // ****!!!!! Need resize method.. should call display->set_pixelsperdiv() !!!**** // note that qt_osg_compositor derives from this and specializes it. class osg_compositor { // Used as a base class for QTRecRender, which also inherits from QOpenGLWidget public: std::weak_ptr<recdatabase> recdb; // immutable once initialized // These pointers (not necessarily content) are immutable once initialized // and represent the composited view. In the QT environment they need // to be initialized from the main GUI thread (SNDE_OSGRCS_COMPOSITING // context). They generally are only to be worked with from the main thread // (compositing step) osg::ref_ptr<osgViewer::Viewer> Viewer; osg::ref_ptr<osg::Group> RootGroup; osg::ref_ptr<osgViewer::GraphicsWindow> GraphicsWindow; osg::ref_ptr<osg::Camera> Camera; osg::ref_ptr<osg_compositor_eventhandler> eventhandler; std::map<std::string,osg::Matrixd> FutureChannelCamPose; // locked by admin mutex std::map<std::string,snde_coord> FutureChannelRotationCenterDist; // locked by admin mutex std::shared_ptr<display_info> display; std::string selected_channel; // locked by admin lock.... maybe selected channel should instead be handled like compositor_width, compositor_height, etc. below. or stored in display_info copy we will eventually have? bool threaded; bool enable_threaded_opengl; bool enable_shaders; GLuint LayerDefaultFramebufferObject; // default FBO # for layer renderers // PickerCrossHairs and GraticuleTransform for 2D image and 1D waveform rendering // They are initialized in the compositor's constructor and immutable thereafter osg::ref_ptr<osg::MatrixTransform> PickerCrossHairs; osg::ref_ptr<osg::MatrixTransform> GraticuleTransform; // entire graticule hangs off of this! // these are initialized in the ONDEMANDCALCS step and referenced in subsequent steps // (perhaps from different threads, but there will have been mutex/condition variable // synchronization since) std::vector<std::shared_ptr<display_channel>> channels_to_display; std::map<std::string,std::shared_ptr<display_requirement>> display_reqs; std::shared_ptr<recstore_display_transforms> display_transforms; // Render cache is maintained by the rendering step which runs in the rendering thread std::shared_ptr<osg_rendercache> RenderCache; // Should be freed (set to nullptr) ONLY by layer rendering thread with the proper OpenGL context loaded // Renderers maintained by the rendering step which runs in the rendering thread std::shared_ptr<std::map<std::string,std::shared_ptr<osg_renderer>>> renderers; // Should be freed (set to nullptr) ONLY by layer rendering thread with the proper OpenGL context loaded. This is locked by the admin lock because it may be accessed by event handling threads to pass events on to the viewer // Renderers created by rendering step which runs in the rendering thread, but // the integer texture ID numbers are used in the compositing step std::shared_ptr<std::map<std::string,std::pair<osg::ref_ptr<osg::Texture2D>,GLuint>>> layer_rendering_rendered_textures; // should be freed ONLY by layer rendering thread. Indexed by channel name; texture pointer valid in layer rendering thread and opengl texture ID number. //std::shared_ptr<std::map<std::string,std::pair<osg::ref_ptr<osg::Texture2D>,GLuint>>> compositing_textures; // should be freed ONLY by compositing thread. Indexed by channel name. Texture pointer valid in compositing thread // CompositingShaderProgram is owned by the compositing step. osg::ref_ptr<osg::Program> CompositingShaderProgram; // Rendering consists of four phases, which may be in different threads, // but must proceed sequentially with one thread handing off to the next // 1. Waiting for trigger; the trigger indicates that an update // is necessary, such as the need_rerender or need_recomposite // flags below. It can come from QT, from the presence of a new // ready globalrevision, etc. Any thread can do the trigger, // by locking the admin mutex, setting the flag, and calling the // state_update notify method. // 2. Identification of channels to render and waiting for on-demand // calculations (e.g. colormapping) to become ready // 3. Rendering of enabled channels onto textures. // (Note: Easy optimization opportunity: Don't re-render if scene // hasn't changed -- i.e. same cached elements) // 4. Compositing of enabled textures onto final output. // In the QT integration this final step must be done in the // main GUI event loop. The others do not have to, unless the // platform doesn't support threaded OpenGL, in which case // step #3 also has to be in the main GUI event loop. //std::mutex execution_lock; // Whoever is executing an above step must own th execution_lock. It is early in the locking order, prior to recdb locks (see lockmanager.hpp) std::mutex admin; // the admin lock primarily locks next_state, execution_notify, need_rerender, need_recomposite std::condition_variable execution_notify; //paired with the admin lock, above int next_state; // When you are ready to start doing one of the above // operations, acquire the admin lock and check next_state. If next_state // is your responsibility (i.e. if // responsibility_mapping.at(std::this_thread::get_id) contains next_state, // then you take over execution. Clear need_rerender or need_recomposite // as appropriate and then drop the admin lock and start executing. // If next_state is not your responsibility, // you need to either drop the admin lock and do other stuff, or // keep the admin lock but wait on the execution_notify condition // variable. Once you finish, re-acquire the admin lock and // (checking first to see if next_state has been modified to exceed // SNDE_SGRCS_CLEANUP, in which case you should return to the main loop and // initate cleanup procedures if possible) // set next_state to one of the SNDE_OSGRCS_xxxxs // below representing the next step. Finally drop the admin lock and // call the state_update notify method, which triggers the execution_notify // condition variable with notify_all() (and subclasses might do other // notification mechanisms as well such as QT slots). // reponsibility_mapping needs to be pre-configured with // which threads take which responsibilities (SNDE_OSGRCS... below) // So any given thread needs to check if it can take responsibility // for a given next_state. Only a single thread should every be allowed // to have responsibility for any given state. std::map<std::thread::id,std::set<int>> responsibility_mapping; // this is immutable once created bool threads_started; // whether we have performed the thread/responsibility_mapping initialization (regardless of if we are using a threaded model) // These all locked with admin lock bool need_rerender; bool need_recomposite; bool need_resize; // pull new size from resize_width and resize_height, below int resize_width; // set with need_resize int resize_height; #define SNDE_OSGRCS_WAITING 1 // Entry #1, above. This one is special // in that the responsible thread should be waiting on the // condition variable and checking the need_rerender and // need_recomposite bools, and marking the next state as // SNDE_OSGRCS_ONDEMANDCALCS or SNDE_OSGRCS_COMPOSITING as // appropriate if one of those is set. #define SNDE_OSGRCS_ONDEMANDCALCS 2 // Entry #2, above #define SNDE_OSGRCS_RENDERING 3 // Entry #3, above #define SNDE_OSGRCS_COMPOSITING 4 // Entry #4, above //#define SNDE_OSGRCS_CLEANUP 5 #define SNDE_OSGRCS_COMPOSITING_CLEANUP 6 // command to worker thread(s) to cleanup #define SNDE_OSGRCS_RENDERING_CLEANUP 7 // command to worker thread(s) to cleanup #define SNDE_OSGRCS_EXIT 8 // command to worker thread(s) to exit std::shared_ptr<std::thread> worker_thread; // NOTE: Not used by QT subclass std::shared_ptr<std::thread::id> worker_thread_id; // C++ id of worker thread (set even by QT subclass); Immutable once published (after start()) size_t compositor_width; // updated in peform_ondemand_calcs; Should only be modified there, and read by whoever is running a step size_t compositor_height; double borderwidthpixels; std::map<std::string,size_t> ColorIdx_by_channelpath; // updated in perform_ondemand_calc; std::atomic_bool request_continuous_update; // updated in perform_layer_rendering(); true if any renderer is requesting continuous updates // ***!!! NOTE: don't set platform_supports_threaded_opengl unless you have arranged some means for the worker thread to operate in a different OpenGL context that shares textures with the main context !!!*** // NOTE 2: This will be (is?) subclassed by a QT version that does just that. // ***!!!! Should provide some means to set the default framebuffer for the various GraphicsWindows ***!!! osg_compositor(std::shared_ptr<recdatabase> recdb, std::shared_ptr<display_info> display, osg::ref_ptr<osgViewer::Viewer> Viewer,osg::ref_ptr<osgViewer::GraphicsWindow> GraphicsWindow, bool threaded,bool enable_threaded_opengl, bool enable_shaders, GLuint LayerDefaultFramebufferObject=0); osg_compositor(const osg_compositor &) = delete; osg_compositor & operator=(const osg_compositor &) = delete; virtual ~osg_compositor(); virtual void trigger_rerender(); virtual void wait_render(); virtual void set_selected_channel(const std::string &selected_name); virtual std::string get_selected_channel(); virtual void perform_ondemand_calcs(std::unique_lock<std::mutex> *adminlock); virtual void perform_layer_rendering(std::unique_lock<std::mutex> *adminlock); virtual void perform_compositing(std::unique_lock<std::mutex> *adminlock); virtual bool this_thread_ok_for_locked(int action); virtual bool this_thread_ok_for(int action); virtual void wake_up_ondemand_locked(std::unique_lock<std::mutex> *adminlock); virtual void wake_up_renderer_locked(std::unique_lock<std::mutex> *adminlock); virtual void wake_up_compositor_locked(std::unique_lock<std::mutex> *adminlock); virtual void clean_up_renderer_locked(std::unique_lock<std::mutex> *adminlock); virtual void dispatch(bool return_if_idle,bool wait, bool loop_forever); virtual void worker_code(); virtual void _start_worker_thread(std::unique_lock<std::mutex> *adminlock); virtual void _join_worker_thread(); virtual void resize_compositor(int width, int height); virtual snde_orientation3 get_camera_pose(std::string channel_path); // get the camera pose (or a null orientation) for the given channel virtual void set_camera_pose(std::string channel_path,const snde_orientation3 &newpose); virtual snde_coord get_rotation_center_dist(std::string channel_path); // get the viewer rotation center virtual void set_rotation_center_dist(std::string channel_path,snde_coord newcenterdist); virtual void start(); virtual void stop(); virtual void SetPickerCrossHairs(); //void SetPickerCrossHairs(); //void SetRootNode(osg::ref_ptr<osg::Node> RootNode); //virtual void ClearPickedOrientation() //{ // // notification from picker to clear any marked orientation // // probably needs to be reimplemented by derived classes //} //std::tuple<double,double> GetPadding(size_t drawareawidth,size_t drawareaheight); //std::tuple<double,double> GetScalefactors(std::string recname); //osg::Matrixd GetChannelTransform(std::string recname,std::shared_ptr<display_channel> displaychan,size_t drawareawidth,size_t drawareaheight,size_t layer_index); }; }; #endif // SNDE_OPENSCENEGRAPH_COMPOSITOR_HPP
dc77eea050a9b3f4063bead4eeadc3ec1b29e1f3
9d0cfa52dc15cb529baf3ddfd83ead07c698ad55
/Graphics/Sprite.cpp
b27b3428eb061df61d6acf64aa122272adaec26d
[]
no_license
cha0s/avocado-cpp-core
4917fcbe0308f9af48607ef59197a63da1e66aa1
a206fdb2c78936dade9dc147ea394f4de4b6dd11
refs/heads/master
2016-08-11T18:06:07.536014
2014-06-12T23:48:50
2014-06-12T23:48:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
423
cpp
#include "../avocado-global.h" #include "Sprite.h" namespace avo { FactoryManager<Sprite> Sprite::factoryManager; Sprite::Sprite() : _canvas(NULL) , _image(NULL) { } Sprite::~Sprite() { } void Sprite::setSource(Canvas *canvas) { _canvas = canvas; } void Sprite::setSource(Image *image) { _image = image; } Canvas *Sprite::canvas() const { return _canvas; } Image *Sprite::image() const { return _image; } }