file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/148699.c
/* unused */ /* crypto/bn/expspeed.c */ /* Copyright (C) 1995-1998 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson ([email protected]). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young ([email protected])" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson ([email protected])" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ /* most of this code has been pilfered from my libdes speed.c program */ #define BASENUM 5000 #define NUM_START 0 /* * determine timings for modexp, modmul, modsqr, gcd, Kronecker symbol, * modular inverse, or modular square roots */ #define TEST_EXP #undef TEST_MUL #undef TEST_SQR #undef TEST_GCD #undef TEST_KRON #undef TEST_INV #undef TEST_SQRT #define P_MOD_64 9 /* least significant 6 bits for prime to be * used for BN_sqrt timings */ #if defined(TEST_EXP) + defined(TEST_MUL) + defined(TEST_SQR) + defined(TEST_GCD) + defined(TEST_KRON) + defined(TEST_INV) +defined(TEST_SQRT) != 1 # error "choose one test" #endif #if defined(TEST_INV) || defined(TEST_SQRT) # define C_PRIME static void genprime_cb(int p, int n, void *arg); #endif #undef PROG #define PROG bnspeed_main #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <string.h> #include <openssl/crypto.h> #include <openssl/err.h> #include <openssl/rand.h> #if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX) # define TIMES #endif #ifndef _IRIX # include <time.h> #endif #ifdef TIMES # include <sys/types.h> # include <sys/times.h> #endif /* * Depending on the VMS version, the tms structure is perhaps defined. The * __TMS macro will show if it was. If it wasn't defined, we should undefine * TIMES, since that tells the rest of the program how things should be * handled. -- Richard Levitte */ #if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS) # undef TIMES #endif #ifndef TIMES # include <sys/timeb.h> #endif #if defined(sun) || defined(__ultrix) # define _POSIX_SOURCE # include <limits.h> # include <sys/param.h> #endif #include <openssl/bn.h> #include <openssl/x509.h> /* The following if from times(3) man page. It may need to be changed */ #ifndef HZ # ifndef CLK_TCK # ifndef _BSD_CLK_TCK_ /* FreeBSD hack */ # define HZ 100.0 # else /* _BSD_CLK_TCK_ */ # define HZ ((double)_BSD_CLK_TCK_) # endif # else /* CLK_TCK */ # define HZ ((double)CLK_TCK) # endif #endif #undef BUFSIZE #define BUFSIZE ((long)1024*8) int run = 0; static double Time_F(int s); #define START 0 #define STOP 1 static double Time_F(int s) { double ret; #ifdef TIMES static struct tms tstart, tend; if (s == START) { times(&tstart); return (0); } else { times(&tend); ret = ((double)(tend.tms_utime - tstart.tms_utime)) / HZ; return ((ret < 1e-3) ? 1e-3 : ret); } #else /* !times() */ static struct timeb tstart, tend; long i; if (s == START) { ftime(&tstart); return (0); } else { ftime(&tend); i = (long)tend.millitm - (long)tstart.millitm; ret = ((double)(tend.time - tstart.time)) + ((double)i) / 1000.0; return ((ret < 0.001) ? 0.001 : ret); } #endif } #define NUM_SIZES 7 #if NUM_START > NUM_SIZES # error "NUM_START > NUM_SIZES" #endif static int sizes[NUM_SIZES] = { 128, 256, 512, 1024, 2048, 4096, 8192 }; static int mul_c[NUM_SIZES] = { 8 * 8 * 8 * 8 * 8 * 8, 8 * 8 * 8 * 8 * 8, 8 * 8 * 8 * 8, 8 * 8 * 8, 8 * 8, 8, 1 }; /* * static int sizes[NUM_SIZES]={59,179,299,419,539}; */ #define RAND_SEED(string) { const char str[] = string; RAND_seed(string, sizeof(str)); } void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx); int main(int argc, char **argv) { BN_CTX *ctx; BIGNUM *a, *b, *c, *r; #if 1 if (!CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0)) abort(); #endif ctx = BN_CTX_new(); a = BN_new(); b = BN_new(); c = BN_new(); r = BN_new(); while (!RAND_status()) /* not enough bits */ RAND_SEED("I demand a manual recount!"); do_mul_exp(r, a, b, c, ctx); return 0; } void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx) { int i, k; double tm; long num; num = BASENUM; for (i = NUM_START; i < NUM_SIZES; i++) { #ifdef C_PRIME # ifdef TEST_SQRT if (!BN_set_word(a, 64)) goto err; if (!BN_set_word(b, P_MOD_64)) goto err; # define ADD a # define REM b # else # define ADD NULL # define REM NULL # endif if (!BN_generate_prime(c, sizes[i], 0, ADD, REM, genprime_cb, NULL)) goto err; putc('\n', stderr); fflush(stderr); #endif for (k = 0; k < num; k++) { if (k % 50 == 0) { /* Average over num/50 different choices of * random numbers. */ if (!BN_pseudo_rand(a, sizes[i], 1, 0)) goto err; if (!BN_pseudo_rand(b, sizes[i], 1, 0)) goto err; #ifndef C_PRIME if (!BN_pseudo_rand(c, sizes[i], 1, 1)) goto err; #endif #ifdef TEST_SQRT if (!BN_mod_sqr(a, a, c, ctx)) goto err; if (!BN_mod_sqr(b, b, c, ctx)) goto err; #else if (!BN_nnmod(a, a, c, ctx)) goto err; if (!BN_nnmod(b, b, c, ctx)) goto err; #endif if (k == 0) Time_F(START); } #if defined(TEST_EXP) if (!BN_mod_exp(r, a, b, c, ctx)) goto err; #elif defined(TEST_MUL) { int i = 0; for (i = 0; i < 50; i++) if (!BN_mod_mul(r, a, b, c, ctx)) goto err; } #elif defined(TEST_SQR) { int i = 0; for (i = 0; i < 50; i++) { if (!BN_mod_sqr(r, a, c, ctx)) goto err; if (!BN_mod_sqr(r, b, c, ctx)) goto err; } } #elif defined(TEST_GCD) if (!BN_gcd(r, a, b, ctx)) goto err; if (!BN_gcd(r, b, c, ctx)) goto err; if (!BN_gcd(r, c, a, ctx)) goto err; #elif defined(TEST_KRON) if (-2 == BN_kronecker(a, b, ctx)) goto err; if (-2 == BN_kronecker(b, c, ctx)) goto err; if (-2 == BN_kronecker(c, a, ctx)) goto err; #elif defined(TEST_INV) if (!BN_mod_inverse(r, a, c, ctx)) goto err; if (!BN_mod_inverse(r, b, c, ctx)) goto err; #else /* TEST_SQRT */ if (!BN_mod_sqrt(r, a, c, ctx)) goto err; if (!BN_mod_sqrt(r, b, c, ctx)) goto err; #endif } tm = Time_F(STOP); printf( #if defined(TEST_EXP) "modexp %4d ^ %4d %% %4d" #elif defined(TEST_MUL) "50*modmul %4d %4d %4d" #elif defined(TEST_SQR) "100*modsqr %4d %4d %4d" #elif defined(TEST_GCD) "3*gcd %4d %4d %4d" #elif defined(TEST_KRON) "3*kronecker %4d %4d %4d" #elif defined(TEST_INV) "2*inv %4d %4d mod %4d" #else /* TEST_SQRT */ "2*sqrt [prime == %d (mod 64)] %4d %4d mod %4d" #endif " -> %8.6fms %5.1f (%ld)\n", #ifdef TEST_SQRT P_MOD_64, #endif sizes[i], sizes[i], sizes[i], tm * 1000.0 / num, tm * mul_c[i] / num, num); num /= 7; if (num <= 0) num = 1; } return; err: ERR_print_errors_fp(stderr); } #ifdef C_PRIME static void genprime_cb(int p, int n, void *arg) { char c = '*'; if (p == 0) c = '.'; if (p == 1) c = '+'; if (p == 2) c = '*'; if (p == 3) c = '\n'; putc(c, stderr); fflush(stderr); (void)n; (void)arg; } #endif
the_stack_data/40328.c
int max(int a,int b){ return a > b ? a : b; }
the_stack_data/954630.c
/* * Date: 06/07/2015 * Created by: Ton Chanh Le ([email protected]) * Adapted from Gothenburg_true-termination.c */ typedef enum {false, true} bool; extern int __VERIFIER_nondet_int(void); int main() { int x, y, a, b; a = __VERIFIER_nondet_int(); b = __VERIFIER_nondet_int(); x = __VERIFIER_nondet_int(); y = __VERIFIER_nondet_int(); if (a == b + 1 && x < 0) { while (x >= 0 || y >= 0) { x = x + a - b - 1; y = y + b - a - 1; } } return 0; }
the_stack_data/165765543.c
#include <stdio.h> int main() { int a; int b; scanf("%d", &a); scanf("%d", &b); int x; x = a + b; printf("X = %d\n", x); return 0; }
the_stack_data/98064.c
// RUN: c-index-test -test-print-linkage-source %s | FileCheck %s enum Baz { Qux = 0 }; int x; void foo(); static int w; void bar(int y) { static int z; int k; } extern int n; static int wibble(int); void ena(int (*dio)(int tria)); static int test2; void f16(void) { extern int test2; } // CHECK: EnumDecl=Baz:3:6 (Definition)linkage=External // CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=NoLinkage // CHECK: VarDecl=x:4:5linkage=External // CHECK: FunctionDecl=foo:5:6linkage=External // CHECK: VarDecl=w:6:12linkage=Internal // CHECK: FunctionDecl=bar:7:6 (Definition)linkage=External // CHECK: ParmDecl=y:7:14 (Definition)linkage=NoLinkage // CHECK: VarDecl=z:8:14 (Definition)linkage=NoLinkage // CHECK: VarDecl=k:9:7 (Definition)linkage=NoLinkage // CHECK: VarDecl=n:11:12linkage=External // CHECK: FunctionDecl=wibble:12:12linkage=Internal // CHECK: ParmDecl=:12:22 (Definition)linkage=NoLinkage // CHECK: FunctionDecl=ena:14:6linkage=External // CHECK: ParmDecl=dio:14:16 (Definition)linkage=NoLinkage // CHECK: ParmDecl=tria:14:25 (Definition)linkage=NoLinkage // CHECK: VarDecl=test2{{.*}}linkage=Internal // CHECK: VarDecl=test2{{.*}}linkage=Internal
the_stack_data/37826.c
/* $OpenBSD: s_cargl.c,v 1.1 2011/07/08 19:25:31 martynas Exp $ */ /* * Copyright (c) 2011 Martynas Venckus <[email protected]> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <complex.h> #include <math.h> long double cargl(long double complex z) { return atan2l(__imag__ z, __real__ z); }
the_stack_data/7363.c
//////////////////////////////////////////////////////////////////////////// // // Function Name : Even() // Description : Accept Number From User & Display Elements Which Are Divisible By 5 // Input : Integer // Output : Integer // Author : Prasad Dangare // Date : 19 Mar 2021 // //////////////////////////////////////////////////////////////////////////// #include <stdio.h> #include <stdlib.h> void Even(int Arr[], int iSize) { int i = 0; if((Arr == NULL) || (iSize <= 0)) { return; } printf("Elements Divisible By 5 Are : \n"); for(i = 0; i < iSize; i++) { if(Arr[i] % 5 == 0) { printf("%d\n", Arr[i]); } } } int main() { int *arr = NULL; // pointer int iLength = 0, i = 0; printf("Enter Number Of Elements : "); scanf("%d", &iLength); arr = (int*)malloc(iLength * sizeof(int)); if(arr == NULL) { printf("Unable To Allocate The Memory "); return -1; } printf("Enter Elements : \n"); for(i = 0; i < iLength; i++) { scanf("%d", &arr[i]); } Even(arr, iLength); free(arr); return 0; }
the_stack_data/3263673.c
/* * The Computer Lannguage Shootout * http://shootout.alioth.debian.org/ * Contributed by Heiner Marxen * * "fannkuch" for C gcc * * $Id: fannkuch-gcc.code,v 1.51 2008-03-06 02:23:27 igouy-guest Exp $ */ #include <stdio.h> #include <stdlib.h> #define Int int #define Aint int static long fannkuch( int n ) { Aint* perm; Aint* perm1; Aint* count; long flips; long flipsMax; Int r; Int i; Int k; Int didpr; const Int n1 = n - 1; if( n < 1 ) return 0; perm = calloc(n, sizeof(*perm )); perm1 = calloc(n, sizeof(*perm1)); count = calloc(n, sizeof(*count)); for( i=0 ; i<n ; ++i ) perm1[i] = i; /* initial (trivial) permu */ r = n; didpr = 0; flipsMax = 0; for(;;) { if( didpr < 30 ) { for( i=0 ; i<n ; ++i ) printf("%d", (int)(1+perm1[i])); printf("\n"); ++didpr; } for( ; r!=1 ; --r ) { count[r-1] = r; } #define XCH(x,y) { Aint t_mp; t_mp=(x); (x)=(y); (y)=t_mp; } if( ! (perm1[0]==0 || perm1[n1]==n1) ) { flips = 0; for( i=1 ; i<n ; ++i ) { /* perm = perm1 */ perm[i] = perm1[i]; } k = perm1[0]; /* cache perm[0] in k */ do { /* k!=0 ==> k>0 */ Int j; for( i=1, j=k-1 ; i<j ; ++i, --j ) { XCH(perm[i], perm[j]) } ++flips; /* * Now exchange k (caching perm[0]) and perm[k]... with care! * XCH(k, perm[k]) does NOT work! */ j=perm[k]; perm[k]=k ; k=j; }while( k ); if( flipsMax < flips ) { flipsMax = flips; } } for(;;) { if( r == n ) { return flipsMax; } /* rotate down perm[0..r] by one */ { Int perm0 = perm1[0]; i = 0; while( i < r ) { k = i+1; perm1[i] = perm1[k]; i = k; } perm1[r] = perm0; } if( (count[r] -= 1) > 0 ) { break; } ++r; } } } int main( int argc, char* argv[] ) { int n = 11; printf("Pfannkuchen(%d) = %ld\n", n, fannkuch(n)); return 0; }
the_stack_data/119959.c
/****************************************************/ /* File: tm.c */ /* The TM ("Tiny Machine") computer */ /* Compiler Construction: Principles and Practice */ /* Kenneth C. Louden */ /****************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif /******* const *******/ #define IADDR_SIZE 1024 /* increase for large programs */ #define DADDR_SIZE 1024 /* increase for large programs */ #define NO_REGS 8 #define PC_REG 7 #define LINESIZE 121 #define WORDSIZE 20 /******* type *******/ typedef enum { opclRR, /* reg operands r,s,t */ opclRM, /* reg r, mem d+s */ opclRA /* reg r, int d+s */ } OPCLASS; typedef enum { /* RR instructions */ opHALT, /* RR halt, operands are ignored */ opIN, /* RR read into reg(r); s and t are ignored */ opOUT, /* RR write from reg(r), s and t are ignored */ opADD, /* RR reg(r) = reg(s)+reg(t) */ opSUB, /* RR reg(r) = reg(s)-reg(t) */ opMUL, /* RR reg(r) = reg(s)*reg(t) */ opDIV, /* RR reg(r) = reg(s)/reg(t) */ opRRLim, /* limit of RR opcodes */ /* RM instructions */ opLD, /* RM reg(r) = mem(d+reg(s)) */ opST, /* RM mem(d+reg(s)) = reg(r) */ opRMLim, /* Limit of RM opcodes */ /* RA instructions */ opLDA, /* RA reg(r) = d+reg(s) */ opLDC, /* RA reg(r) = d ; reg(s) is ignored */ opJLT, /* RA if reg(r)<0 then reg(7) = d+reg(s) */ opJLE, /* RA if reg(r)<=0 then reg(7) = d+reg(s) */ opJGT, /* RA if reg(r)>0 then reg(7) = d+reg(s) */ opJGE, /* RA if reg(r)>=0 then reg(7) = d+reg(s) */ opJEQ, /* RA if reg(r)==0 then reg(7) = d+reg(s) */ opJNE, /* RA if reg(r)!=0 then reg(7) = d+reg(s) */ opRALim /* Limit of RA opcodes */ } OPCODE; typedef enum { srOKAY, srHALT, srIMEM_ERR, srDMEM_ERR, srZERODIVIDE } STEPRESULT; typedef struct { int iop ; int iarg1 ; int iarg2 ; int iarg3 ; } INSTRUCTION; /******** vars ********/ int iloc = 0 ; int dloc = 0 ; int traceflag = FALSE; int icountflag = FALSE; INSTRUCTION iMem [IADDR_SIZE]; int dMem [DADDR_SIZE]; int reg [NO_REGS]; char * opCodeTab[] = {"HALT","IN","OUT","ADD","SUB","MUL","DIV","????", /* RR opcodes */ "LD","ST","????", /* RM opcodes */ "LDA","LDC","JLT","JLE","JGT","JGE","JEQ","JNE","????" /* RA opcodes */ }; char * stepResultTab[] = {"OK","Halted","Instruction Memory Fault", "Data Memory Fault","Division by 0" }; char pgmName[20]; FILE *pgm ; char in_Line[LINESIZE] ; int lineLen ; int inCol ; int num ; char word[WORDSIZE] ; char ch ; int done ; /********************************************/ int opClass( int c ) { if ( c <= opRRLim) return ( opclRR ); else if ( c <= opRMLim) return ( opclRM ); else return ( opclRA ); } /* opClass */ /********************************************/ void writeInstruction ( int loc ) { printf( "%5d: ", loc) ; if ( (loc >= 0) && (loc < IADDR_SIZE) ) { printf("%6s%3d,", opCodeTab[iMem[loc].iop], iMem[loc].iarg1); switch ( opClass(iMem[loc].iop) ) { case opclRR: printf("%1d,%1d", iMem[loc].iarg2, iMem[loc].iarg3); break; case opclRM: case opclRA: printf("%3d(%1d)", iMem[loc].iarg2, iMem[loc].iarg3); break; } printf ("\n") ; } } /* writeInstruction */ /********************************************/ void getCh (void) { if (++inCol < lineLen) ch = in_Line[inCol] ; else ch = ' ' ; } /* getCh */ /********************************************/ int nonBlank (void) { while ((inCol < lineLen) && (in_Line[inCol] == ' ') ) inCol++ ; if (inCol < lineLen) { ch = in_Line[inCol] ; return TRUE ; } else { ch = ' ' ; return FALSE ; } } /* nonBlank */ /********************************************/ int getNum (void) { int sign; int term; int temp = FALSE; num = 0 ; do { sign = 1; while ( nonBlank() && ((ch == '+') || (ch == '-')) ) { temp = FALSE ; if (ch == '-') sign = - sign ; getCh(); } term = 0 ; nonBlank(); while (isdigit(ch)) { temp = TRUE ; term = term * 10 + ( ch - '0' ) ; getCh(); } num = num + (term * sign) ; } while ( (nonBlank()) && ((ch == '+') || (ch == '-')) ) ; return temp; } /* getNum */ /********************************************/ int getWord (void) { int temp = FALSE; int length = 0; if (nonBlank ()) { while (isalnum(ch)) { if (length < WORDSIZE-1) word [length++] = ch ; getCh() ; } word[length] = '\0'; temp = (length != 0); } return temp; } /* getWord */ /********************************************/ int skipCh ( char c ) { int temp = FALSE; if ( nonBlank() && (ch == c) ) { getCh(); temp = TRUE; } return temp; } /* skipCh */ /********************************************/ int atEOL(void) { return ( ! nonBlank ()); } /* atEOL */ /********************************************/ int error( char * msg, int lineNo, int instNo) { printf("Line %d",lineNo); if (instNo >= 0) printf(" (Instruction %d)",instNo); printf(" %s\n",msg); return FALSE; } /* error */ /********************************************/ int readInstructions (void) { OPCODE op; int arg1, arg2, arg3; int loc, regNo, lineNo; for (regNo = 0 ; regNo < NO_REGS ; regNo++) reg[regNo] = 0 ; dMem[0] = DADDR_SIZE - 1 ; for (loc = 1 ; loc < DADDR_SIZE ; loc++) dMem[loc] = 0 ; for (loc = 0 ; loc < IADDR_SIZE ; loc++) { iMem[loc].iop = opHALT ; iMem[loc].iarg1 = 0 ; iMem[loc].iarg2 = 0 ; iMem[loc].iarg3 = 0 ; } lineNo = 0 ; while (! feof(pgm)) { fgets( in_Line, LINESIZE-2, pgm ) ; inCol = 0 ; lineNo++; lineLen = strlen(in_Line)-1 ; if (in_Line[lineLen]=='\n') in_Line[lineLen] = '\0' ; else in_Line[++lineLen] = '\0'; if ( (nonBlank()) && (in_Line[inCol] != '*') ) { if (! getNum()) return error("Bad location", lineNo,-1); loc = num; if (loc > IADDR_SIZE) return error("Location too large",lineNo,loc); if (! skipCh(':')) return error("Missing colon", lineNo,loc); if (! getWord ()) return error("Missing opcode", lineNo,loc); op = opHALT ; while ((op < opRALim) && (strncmp(opCodeTab[op], word, 4) != 0) ) op++ ; if (strncmp(opCodeTab[op], word, 4) != 0) return error("Illegal opcode", lineNo,loc); switch ( opClass(op) ) { case opclRR : /***********************************/ if ( (! getNum ()) || (num < 0) || (num >= NO_REGS) ) return error("Bad first register", lineNo,loc); arg1 = num; if ( ! skipCh(',')) return error("Missing comma", lineNo, loc); if ( (! getNum ()) || (num < 0) || (num >= NO_REGS) ) return error("Bad second register", lineNo, loc); arg2 = num; if ( ! skipCh(',')) return error("Missing comma", lineNo,loc); if ( (! getNum ()) || (num < 0) || (num >= NO_REGS) ) return error("Bad third register", lineNo,loc); arg3 = num; break; case opclRM : case opclRA : /***********************************/ if ( (! getNum ()) || (num < 0) || (num >= NO_REGS) ) return error("Bad first register", lineNo,loc); arg1 = num; if ( ! skipCh(',')) return error("Missing comma", lineNo,loc); if (! getNum ()) return error("Bad displacement", lineNo,loc); arg2 = num; if ( ! skipCh('(') && ! skipCh(',') ) return error("Missing LParen", lineNo,loc); if ( (! getNum ()) || (num < 0) || (num >= NO_REGS)) return error("Bad second register", lineNo,loc); arg3 = num; break; } iMem[loc].iop = op; iMem[loc].iarg1 = arg1; iMem[loc].iarg2 = arg2; iMem[loc].iarg3 = arg3; } } return TRUE; } /* readInstructions */ /********************************************/ STEPRESULT stepTM (void) { INSTRUCTION currentinstruction ; int pc ; int r,s,t,m ; int ok ; pc = reg[PC_REG] ; if ( (pc < 0) || (pc > IADDR_SIZE) ) return srIMEM_ERR ; reg[PC_REG] = pc + 1 ; currentinstruction = iMem[ pc ] ; switch (opClass(currentinstruction.iop) ) { case opclRR : /***********************************/ r = currentinstruction.iarg1 ; s = currentinstruction.iarg2 ; t = currentinstruction.iarg3 ; break; case opclRM : /***********************************/ r = currentinstruction.iarg1 ; s = currentinstruction.iarg3 ; m = currentinstruction.iarg2 + reg[s] ; if ( (m < 0) || (m > DADDR_SIZE)) return srDMEM_ERR ; break; case opclRA : /***********************************/ r = currentinstruction.iarg1 ; s = currentinstruction.iarg3 ; m = currentinstruction.iarg2 + reg[s] ; break; } /* case */ switch ( currentinstruction.iop) { /* RR instructions */ case opHALT : /***********************************/ printf("HALT: %1d,%1d,%1d\n",r,s,t); return srHALT ; /* break; */ case opIN : /***********************************/ do { printf("Enter value for IN instruction: ") ; fflush (stdin); fflush (stdout); gets(in_Line); lineLen = strlen(in_Line) ; inCol = 0; ok = getNum(); if ( ! ok ) printf ("Illegal value\n"); else reg[r] = num; } while (! ok); break; case opOUT : printf ("OUT instruction prints: %d\n", reg[r] ) ; break; case opADD : reg[r] = reg[s] + reg[t] ; break; case opSUB : reg[r] = reg[s] - reg[t] ; break; case opMUL : reg[r] = reg[s] * reg[t] ; break; case opDIV : /***********************************/ if ( reg[t] != 0 ) reg[r] = reg[s] / reg[t]; else return srZERODIVIDE ; break; /*************** RM instructions ********************/ case opLD : reg[r] = dMem[m] ; break; case opST : dMem[m] = reg[r] ; break; /*************** RA instructions ********************/ case opLDA : reg[r] = m ; break; case opLDC : reg[r] = currentinstruction.iarg2 ; break; case opJLT : if ( reg[r] < 0 ) reg[PC_REG] = m ; break; case opJLE : if ( reg[r] <= 0 ) reg[PC_REG] = m ; break; case opJGT : if ( reg[r] > 0 ) reg[PC_REG] = m ; break; case opJGE : if ( reg[r] >= 0 ) reg[PC_REG] = m ; break; case opJEQ : if ( reg[r] == 0 ) reg[PC_REG] = m ; break; case opJNE : if ( reg[r] != 0 ) reg[PC_REG] = m ; break; /* end of legal instructions */ } /* case */ return srOKAY ; } /* stepTM */ /********************************************/ int doCommand (void) { char cmd; int stepcnt=0, i; int printcnt; int stepResult; int regNo, loc; do { printf ("Enter command: "); fflush (stdin); fflush (stdout); gets(in_Line); lineLen = strlen(in_Line); inCol = 0; } while (! getWord ()); cmd = word[0] ; switch ( cmd ) { case 't' : /***********************************/ traceflag = ! traceflag ; printf("Tracing now "); if ( traceflag ) printf("on.\n"); else printf("off.\n"); break; case 'h' : /***********************************/ printf("Commands are:\n"); printf(" s(tep <n> "\ "Execute n (default 1) TM instructions\n"); printf(" g(o "\ "Execute TM instructions until HALT\n"); printf(" r(egs "\ "Print the contents of the registers\n"); printf(" i(Mem <b <n>> "\ "Print n iMem locations starting at b\n"); printf(" d(Mem <b <n>> "\ "Print n dMem locations starting at b\n"); printf(" t(race "\ "Toggle instruction trace\n"); printf(" p(rint "\ "Toggle print of total instructions executed"\ " ('go' only)\n"); printf(" c(lear "\ "Reset simulator for new execution of program\n"); printf(" h(elp "\ "Cause this list of commands to be printed\n"); printf(" q(uit "\ "Terminate the simulation\n"); break; case 'p' : /***********************************/ icountflag = ! icountflag ; printf("Printing instruction count now "); if ( icountflag ) printf("on.\n"); else printf("off.\n"); break; case 's' : /***********************************/ if ( atEOL ()) stepcnt = 1; else if ( getNum ()) stepcnt = abs(num); else printf("Step count?\n"); break; case 'g' : stepcnt = 1 ; break; case 'r' : /***********************************/ for (i = 0; i < NO_REGS; i++) { printf("%1d: %4d ", i,reg[i]); if ( (i % 4) == 3 ) printf ("\n"); } break; case 'i' : /***********************************/ printcnt = 1 ; if ( getNum ()) { iloc = num ; if ( getNum ()) printcnt = num ; } if ( ! atEOL ()) printf ("Instruction locations?\n"); else { while ((iloc >= 0) && (iloc < IADDR_SIZE) && (printcnt > 0) ) { writeInstruction(iloc); iloc++ ; printcnt-- ; } } break; case 'd' : /***********************************/ printcnt = 1 ; if ( getNum ()) { dloc = num ; if ( getNum ()) printcnt = num ; } if ( ! atEOL ()) printf("Data locations?\n"); else { while ((dloc >= 0) && (dloc < DADDR_SIZE) && (printcnt > 0)) { printf("%5d: %5d\n",dloc,dMem[dloc]); dloc++; printcnt--; } } break; case 'c' : /***********************************/ iloc = 0; dloc = 0; stepcnt = 0; for (regNo = 0; regNo < NO_REGS ; regNo++) reg[regNo] = 0 ; dMem[0] = DADDR_SIZE - 1 ; for (loc = 1 ; loc < DADDR_SIZE ; loc++) dMem[loc] = 0 ; break; case 'q' : return FALSE; /* break; */ default : printf("Command %c unknown.\n", cmd); break; } /* case */ stepResult = srOKAY; if ( stepcnt > 0 ) { if ( cmd == 'g' ) { stepcnt = 0; while (stepResult == srOKAY) { iloc = reg[PC_REG] ; if ( traceflag ) writeInstruction( iloc ) ; stepResult = stepTM (); stepcnt++; } if ( icountflag ) printf("Number of instructions executed = %d\n",stepcnt); } else { while ((stepcnt > 0) && (stepResult == srOKAY)) { iloc = reg[PC_REG] ; if ( traceflag ) writeInstruction( iloc ) ; stepResult = stepTM (); stepcnt-- ; } } printf( "%s\n",stepResultTab[stepResult] ); } return TRUE; } /* doCommand */ /********************************************/ /* E X E C U T I O N B E G I N S H E R E */ /********************************************/ int main( int argc, char * argv[] ) { if (argc != 2) { printf("usage: %s <filename>\n",argv[0]); exit(1); } strcpy(pgmName,argv[1]) ; if (strchr (pgmName, '.') == NULL) strcat(pgmName,".tm"); pgm = fopen(pgmName,"r"); if (pgm == NULL) { printf("file '%s' not found\n",pgmName); exit(1); } /* read the program */ if ( ! readInstructions ()) exit(1) ; /* switch input file to terminal */ /* reset( input ); */ /* read-eval-print */ printf("TM simulation (enter h for help)...\n"); do done = ! doCommand (); while (! done ); printf("Simulation done.\n"); return 0; }
the_stack_data/78522.c
#include<stdio.h> #include <stdlib.h> unsigned long long rdtsc() { unsigned long long a, d; asm volatile ("mfence"); asm volatile ("rdtsc": "=a" (a), "=d" (d)); a = (d << 32) | a; asm volatile ("mfence"); return a; } void flush(void* p){ asm volatile ("clflush 0(%0)\n" : : "c" (p) : "rax"); } int main(){ FILE *fp1 = NULL; FILE *fp2 = NULL; FILE *fp3 = NULL; FILE *fp4 = NULL; fp1 = fopen("out/misses.txt", "w"); fp2 = fopen("out/hits.txt", "w"); fp3 = fopen("out/r.txt", "w"); fp4 = fopen("out/w.txt", "w"); int n = 100000; int k = 1000; int a[n]; int temp = 0, ind = 0; unsigned long long t1, t2, t3, t4, t5; // bring a to cache for(int i=0; i<n; i++){ flush(&a[i]); t3 = rdtsc(); temp = a[i]; t4 = rdtsc(); temp = a[i]; t5 = rdtsc(); printf("Miss: %lld\n", t4-t3); printf("Hit: %lld\n", t5-t4); fprintf(fp1, "%d %lld\n", i, t4-t3); fprintf(fp2, "%d %lld\n", i, t5-t4); } // flush for(int i=0; i<k; i++){ ind = rand() % n; t1 = rdtsc(); flush(&a[ind]); t2 = rdtsc(); printf("clf: %lld\n", t2-t1); fprintf(fp3, "%d %lld\n", i, t2-t1); } // bring a to cache for(int i=0; i<n; i++){ temp = a[i]; } // make dirty for(int i=0; i<n; i++){ a[i] = 0; } // // check if a is in cache // for(int i=0; i<n; i++){ // t4 = rdtsc(); // temp = a[i]; // t5 = rdtsc(); // printf("Hit: %lld\n", t5-t4); // fprintf(fp2, "%d %lld\n", i, t5-t4); // } // flush for(int i=0; i<k; i++){ ind = rand() % n; t1 = rdtsc(); flush(&a[ind]); t2 = rdtsc(); printf("clf: %lld\n", t2-t1); fprintf(fp4, "%d %lld\n", i, t2-t1); } }
the_stack_data/243893750.c
/* PR bootstrap/6315 */ /* { dg-do compile } */ /* { dg-options "-O2 -mhard-quad-float" } */ void bar (const char *, ...); void foo (const char *x, long double y, int z) { if (z >= 0) bar (x, z, y); else bar (x, y); }
the_stack_data/884681.c
/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to [email protected] before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with the GNU C Library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. Ditto for AIX 3.2 and <stdlib.h>. */ #ifndef _NO_PROTO #define _NO_PROTO #endif #ifdef HAVE_CONFIG_H #include <config.h> #endif #if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif #include <stdio.h> /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling and linking in this code is a waste when using the GNU C library (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 #if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 #include <gnu-versions.h> #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE #endif #endif #ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include <stdlib.h> #include <unistd.h> #endif /* GNU C library. */ #ifdef VMS #include <unixlib.h> #if HAVE_STRING_H - 0 #include <string.h> #endif #endif #if defined (WIN32) && !defined (__CYGWIN32__) /* It's not Unix, really. See? Capital letters. */ #include <windows.h> #define getpid() GetCurrentProcessId() #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ #ifdef HAVE_LIBINTL_H # include <libintl.h> # define _(msgid) gettext (msgid) #else # define _(msgid) (msgid) #endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = NULL; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ /* 1003.2 says this must be 1 before any call. */ int optind = 1; /* Formerly, initialization of getopt depended on optind==0, which causes problems with re-calling getopt as programs generally don't know that. */ int __getopt_initialized = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Set to an option character which was unrecognized. This must be initialized on some systems to avoid linking in the system's own getopt implementation. */ int optopt = '?'; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ #include <string.h> #define my_index strchr #else /* Avoid depending on library functions or files whose names are inconsistent. */ char *getenv (); static char * my_index (str, chr) const char *str; int chr; { while (*str) { if (*str == chr) return (char *) str; str++; } return 0; } /* If using GCC, we can safely declare strlen this way. If not using GCC, it is ok not to declare it. */ #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ #if !defined (__STDC__) || !__STDC__ /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); #endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; #ifdef _LIBC /* Bash 2.0 gives us an environment variable containing flags indicating ARGV elements that should not be considered arguments. */ static const char *nonoption_flags; static int nonoption_flags_len; static int original_argc; static char *const *original_argv; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ static void store_args (int argc, char *const *argv) __attribute__ ((unused)); static void store_args (int argc, char *const *argv) { /* XXX This is no good solution. We should rather copy the args so that we can compare them later. But we must not use malloc(3). */ original_argc = argc; original_argv = argv; } text_set_element (__libc_subinit, store_args); #endif /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ #if defined (__STDC__) && __STDC__ static void exchange (char **); #endif static void exchange (argv) char **argv; { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; char *tem; /* Exchange the shorter segment with the far end of the longer segment. That puts the shorter segment into the right place. It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { /* Bottom segment is the short one. */ int len = middle - bottom; register int i; /* Swap it with the top part of the top segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; } /* Exclude the moved bottom segment from further swapping. */ top -= len; } else { /* Top segment is the short one. */ int len = top - middle; register int i; /* Swap it with the bottom part of the bottom segment. */ for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; } /* Exclude the moved top segment from further swapping. */ bottom += len; } } /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined (__STDC__) && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * _getopt_initialize (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ first_nonopt = last_nonopt = optind = 1; nextchar = NULL; posixly_correct = getenv ("POSIXLY_CORRECT"); /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; #ifdef _LIBC if (posixly_correct == NULL && argc == original_argc && argv == original_argv) { /* Bash 2.0 puts a special variable in the environment for each command it runs, specifying which ARGV elements are the results of file name wildcard expansion and therefore should not be considered as options. */ char var[100]; sprintf (var, "_%d_GNU_nonoption_argv_flags_", getpid ()); nonoption_flags = getenv (var); if (nonoption_flags == NULL) nonoption_flags_len = 0; else nonoption_flags_len = strlen (nonoption_flags); } else nonoption_flags_len = 0; #endif return optstring; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { optarg = NULL; if (!__getopt_initialized || optind == 0) { optstring = _getopt_initialize (argc, argv, optstring); optind = 1; /* Don't scan ARGV[0], the program name. */ __getopt_initialized = 1; } /* Test whether ARGV[optind] points to a non-option argument. Either it does not have option syntax, or there is an environment flag from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ || (optind < nonoption_flags_len \ && nonoption_flags[optind] == '1')) #else #define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been moved back by the user (who may also have changed the arguments). */ if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } /* The special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) return -1; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Skip the initial punctuation. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } /* Decode the current option-ARGV-element. */ /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if (longopts != NULL && (argv[optind][1] == '-' || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; optopt = 0; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); nextchar += strlen (nextchar); optopt = pfound->val; return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' || my_index (optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; optopt = 0; return '?'; } } /* Look at and handle the next short option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { if (posixly_correct) /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c); else fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c); } optopt = c; return '?'; } /* Convenience. Treat POSIX -W foo same as long option --foo */ if (temp[0] == 'W' && temp[1] == ';') { char *nameend; const struct option *p; const struct option *pfound = NULL; int exact = 0; int ambig = 0; int indfound = 0; int option_index; /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; return c; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; /* optarg is now the argument, see if it's in the table of longopts. */ for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) /* Do nothing. */ ; /* Test all long options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { if ((unsigned int) (nameend - nextchar) == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second or later nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; if (*nameend) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = nameend + 1; else { if (opterr) fprintf (stderr, _("\ %s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name); nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, _("%s: option `%s' requires an argument\n"), argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return optstring[0] == ':' ? ':' : '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } nextchar = NULL; return 'W'; /* Let the application handle it. */ } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = NULL; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) { /* 1003.2 specifies the format of this message. */ fprintf (stderr, _("%s: option requires an argument -- %c\n"), argv[0], c); } optopt = c; if (optstring[0] == ':') c = ':'; else c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #endif /* Not ELIDE_CODE. */ #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == -1) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */
the_stack_data/140766777.c
/* * Problem: UVa 112 Tree Summing * Lang: ANSI C * Time: 0.035s * Author: minix */ #include <stdio.h> #include <ctype.h> #define N 10000 int s[N]; int main() { int t, l, p, sum, y, r, f; char c, pc; while (scanf("%d",&t) != EOF) { sum = 0; y = 0; r = 0; while ((c=getchar()) != '('); l = 1; p = 0; pc = '('; f = 1; while (l!=0) { if (c=='(' || c==')') pc = c; c = getchar(); if (c==' '||c=='\n') continue; if (c=='-') { f *= -1; continue; } if (c=='(') { if (pc=='(') { /* get a new number */ r = 0; p = f * p; sum = sum + p; s[l] = p; f = 1; p=0; } l++; } if (c==')') { if (pc=='(') r++; if (pc==')') { sum -= s[l]; s[l] = 0;} /* back to upper layer */ l--; if (r==2 && pc=='(') { /* encounter a leaf */ if (sum == t) { y = 1; break; } } } if (isdigit(c)) { p = 10*p+c-'0'; } } while (l!=0) { c = getchar(); if (c=='(') l++; if (c==')') l--; } c = getchar(); if (y) puts("yes"); else puts("no"); } return 0; }
the_stack_data/68887833.c
#include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <unistd.h> int main() { pid_t pid; /* fork a child process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed\n"); return 1; } if (pid == 0) { /* this is a child: dies immediately and becomes zombie */ exit(0); } else { /* parent process: just asks for the user input */ printf("Press enter after looking at the zombie process..."); (void)getchar(); } return 0; }
the_stack_data/35575.c
/* Premake's Lua scripts, as static data buffers for release mode builds */ /* DO NOT EDIT - this file is autogenerated - see BUILD.txt */ /* To regenerate this file, run: premake4 embed */ const char* builtin_scripts[] = { /* base/os.lua */ "function os.executef(cmd, ...)\nlocal arg={...}\ncmd = string.format(cmd, table.unpack(arg))\nreturn os.execute(cmd)\nend\nlocal function parse_ld_so_conf(conf_file)\nlocal first, last\nlocal dirs = { }\nlocal file = io.open(conf_file)\nif file == nil then\nreturn dirs\nend\nfor line in file:lines() do\nfirst = line:find(\"#\", 1, true)\nif first ~= nil then\nline = line:sub(1, first - 1)\nend\nif line ~= \"\" then\nfirst, last = line:find(\"include%s+\")\nif first ~= nil then\nlocal include_glob = line:sub(last + 1)\nlocal includes = os.matchfiles(include_glob)\nfor _, v in ipairs(includes) do\ndirs = table.join(dirs, parse_ld_so_conf(v))\nend\nelse\ntable.insert(dirs, line)\nend\nend\nend\nreturn dirs\nend\nfunction os.findlib(libname)\nlocal path, formats\nif os.is(\"windows\") then\nformats = { \"%s.dll\", \"%s\" }\npath = os.getenv(\"PATH\")\nelse\nif os.is(\"macosx\") then\nformats = { \"lib%s.dylib\", \"%s.dylib\" }\npath = os.getenv(\"DYLD_LIBRARY_PATH\")\nelse\nformats = { \"lib%s.so\", \"%s.so\" }\np" "ath = os.getenv(\"LD_LIBRARY_PATH\") or \"\"\nfor _, v in ipairs(parse_ld_so_conf(\"/etc/ld.so.conf\")) do\npath = path .. \":\" .. v\nend\nend\ntable.insert(formats, \"%s\")\npath = path or \"\"\nif os.is64bit() then\npath = path .. \":/lib64:/usr/lib64/:usr/local/lib64\"\nend\npath = path .. \":/lib:/usr/lib:/usr/local/lib\"\nend\nfor _, fmt in ipairs(formats) do\nlocal name = string.format(fmt, libname)\nlocal result = os.pathsearch(name, path)\nif result then return result end\nend\nend\nfunction os.get()\nreturn _OPTIONS.os or _OS\nend\nfunction os.is(id)\nreturn (os.get():lower() == id:lower())\nend\nlocal _64BitHostTypes = {\n\"x86_64\",\n\"ia64\",\n\"amd64\",\n\"ppc64\",\n\"powerpc64\",\n\"sparc64\",\n\"arm64\"\n}\nfunction os.is64bit()\nif (os._is64bit()) then\nreturn true\nend\nlocal arch = \"\"\nif _OS == \"windows\" then\narch = os.getenv(\"PROCESSOR_ARCHITECTURE\")\nelseif _OS == \"macosx\" then\narch = os.outputof(\"echo $HOSTTYPE\")\nelse\narch = os.outputof(\"uname -m\")\nend\nif nil ~= arch th" "en\narch = arch:lower()\nfor _, hosttype in ipairs(_64BitHostTypes) do\nif arch:find(hosttype) then\nreturn true\nend\nend\nend\nreturn false\nend\nlocal function domatch(result, mask, wantfiles)\nif mask:startswith(\"./\") then\nmask = mask:sub(3)\nend\nlocal basedir = mask\nlocal starpos = mask:find(\"%*\")\nif starpos then\nbasedir = basedir:sub(1, starpos - 1)\nend\nbasedir = path.getdirectory(basedir)\nif (basedir == \".\") then basedir = \"\" end\nlocal recurse = mask:find(\"**\", nil, true)\nmask = path.wildcards(mask)\nlocal function matchwalker(basedir)\nlocal wildcard = path.join(basedir, \"*\")\nlocal m = os.matchstart(wildcard)\nwhile (os.matchnext(m)) do\nlocal isfile = os.matchisfile(m)\nif ((wantfiles and isfile) or (not wantfiles and not isfile)) then\nlocal fname = path.join(basedir, os.matchname(m))\nif fname:match(mask) == fname then\ntable.insert(result, fname)\nend\nend\nend\nos.matchdone(m)\nif recurse then\nm = os.matchstart(wildcard)\nwhile (os.matchnext(m)) do\nif not os.matchisfile(m)" " then\nlocal dirname = os.matchname(m)\nmatchwalker(path.join(basedir, dirname))\nend\nend\nos.matchdone(m)\nend\nend\nmatchwalker(basedir)\nend\nfunction os.matchdirs(...)\nlocal arg={...}\nlocal result = { }\nfor _, mask in ipairs(arg) do\ndomatch(result, mask, false)\nend\nreturn result\nend\nfunction os.matchfiles(...)\nlocal arg={...}\nlocal result = { }\nfor _, mask in ipairs(arg) do\ndomatch(result, mask, true)\nend\nreturn result\nend\nlocal builtin_mkdir = os.mkdir\nfunction os.mkdir(p)\nlocal dir = iif(p:startswith(\"/\"), \"/\", \"\")\nfor part in p:gmatch(\"[^/]+\") do\ndir = dir .. part\nif (part ~= \"\" and not path.isabsolute(part) and not os.isdir(dir)) then\nlocal ok, err = builtin_mkdir(dir)\nif (not ok) then\nreturn nil, err\nend\nend\ndir = dir .. \"/\"\nend\nreturn true\nend\nfunction os.outputof(cmd)\nlocal pipe = io.popen(cmd)\nlocal result = pipe:read('*a')\npipe:close()\nreturn result\nend\nlocal builtin_rmdir = os.rmdir\nfunction os.rmdir(p)\nlocal dirs = os.matchdirs(p .. \"/*\")\nfo" "r _, dname in ipairs(dirs) do\nos.rmdir(dname)\nend\nlocal files = os.matchfiles(p .. \"/*\")\nfor _, fname in ipairs(files) do\nos.remove(fname)\nend\nbuiltin_rmdir(p)\nend\n", /* base/path.lua */ "function path.getbasename(p)\nlocal name = path.getname(p)\nlocal i = name:findlast(\".\", true)\nif (i) then\nreturn name:sub(1, i - 1)\nelse\nreturn name\nend\nend\nfunction path.removeext(name)\nlocal i = name:findlast(\".\", true)\nif (i) then\nreturn name:sub(1, i - 1)\nelse\nreturn name\nend\nend\nfunction path.getdirectory(p)\nlocal i = p:findlast(\"/\", true)\nif (i) then\nif i > 1 then i = i - 1 end\nreturn p:sub(1, i)\nelse\nreturn \".\"\nend\nend\nfunction path.getdrive(p)\nlocal ch1 = p:sub(1,1)\nlocal ch2 = p:sub(2,2)\nif ch2 == \":\" then\nreturn ch1\nend\nend\nfunction path.getextension(p)\nlocal i = p:findlast(\".\", true)\nif (i) then\nreturn p:sub(i)\nelse\nreturn \"\"\nend\nend\nfunction path.getname(p)\nlocal i = p:findlast(\"[/\\\\]\")\nif (i) then\nreturn p:sub(i + 1)\nelse\nreturn p\nend\nend\nfunction path.getcommonbasedir(a, b)\na = path.getdirectory(a)..'/'\nb = path.getdirectory(b)..'/'\nlocal idx = 0\nwhile (true) do\nlocal tst = a:find('/', idx + 1, true)\nif tst then\nif a:sub(1,t" "st) == b:sub(1,tst) then\nidx = tst\nelse\nbreak\nend\nelse\nbreak\nend\nend\nlocal result = ''\nif idx > 1 then\nresult = a:sub(1, idx - 1)-- Remove the trailing slash to be consistent with other functions.\nend\nreturn result\nend\nfunction path.hasextension(fname, extensions)\nlocal fext = path.getextension(fname):lower()\nif type(extensions) == \"table\" then\nfor _, extension in pairs(extensions) do\nif fext == extension then\nreturn true\nend\nend\nreturn false\nelse\nreturn (fext == extensions)\nend\nend\nfunction path.iscfile(fname)\nreturn path.hasextension(fname, { \".c\", \".m\" })\nend\nfunction path.iscppfile(fname)\nreturn path.hasextension(fname, { \".cc\", \".cpp\", \".cxx\", \".c++\", \".c\", \".m\", \".mm\" })\nend\nfunction path.iscxfile(fname)\nreturn path.hasextension(fname, \".cx\")\nend\nfunction path.isobjcfile(fname)\nreturn path.hasextension(fname, { \".m\", \".mm\" })\nend\nfunction path.iscppheader(fname)\nreturn path.hasextension(fname, { \".h\", \".hh\", \".hpp\", \".hxx\" })\nend" "\nfunction path.isappxmanifest(fname)\nreturn path.hasextension(fname, \".appxmanifest\")\nend\nfunction path.isandroidbuildfile(fname)\nreturn path.getname(fname) == \"AndroidManifest.xml\"\nend\nfunction path.isnatvis(fname)\nreturn path.hasextension(fname, \".natvis\")\nend\nfunction path.isasmfile(fname)\nreturn path.hasextension(fname, { \".asm\", \".s\", \".S\" })\nend\nfunction path.isvalafile(fname)\nreturn path.hasextension(fname, \".vala\")\nend\nfunction path.isgresource(fname)\nlocal ending = \".gresource.xml\"\nreturn ending == \"\" or fname:sub(-#ending) == ending\nend\nfunction path.isswiftfile(fname)\nreturn path.hasextension(fname, \".swift\")\nend\nfunction path.issourcefile(fname)\nreturn path.iscfile(fname)\nor path.iscppfile(fname)\nor path.iscxfile(fname)\nor path.isasmfile(fname)\nor path.isvalafile(fname)\nor path.isswiftfile(fname)\nend\nfunction path.issourcefilevs(fname)\nreturn path.hasextension(fname, { \".cc\", \".cpp\", \".cxx\", \".c++\", \".c\" })\nor path.iscxfile(fname)\nend" "\nfunction path.isobjectfile(fname)\nreturn path.hasextension(fname, { \".o\", \".obj\" })\nend\nfunction path.isresourcefile(fname)\nreturn path.hasextension(fname, \".rc\")\nend\nfunction path.isimagefile(fname)\nlocal extensions = { \".png\" }\nlocal ext = path.getextension(fname):lower()\nreturn table.contains(extensions, ext)\nend\nfunction path.join(...)\nlocal arg={...}\nlocal numargs = select(\"#\", ...)\nif numargs == 0 then\nreturn \"\";\nend\nlocal allparts = {}\nfor i = numargs, 1, -1 do\nlocal part = select(i, ...)\nif part and #part > 0 and part ~= \".\" then\nwhile part:endswith(\"/\") do\npart = part:sub(1, -2)\nend\ntable.insert(allparts, 1, part)\nif path.isabsolute(part) then\nbreak\nend\nend\nend\nreturn table.concat(allparts, \"/\")\nend\nfunction path.rebase(p, oldbase, newbase)\np = path.getabsolute(path.join(oldbase, p))\np = path.getrelative(newbase, p)\nreturn p\nend\nfunction path.translate(p, sep)\nif (type(p) == \"table\") then\nlocal result = { }\nfor _, value in ipairs(p) do\ntab" "le.insert(result, path.translate(value))\nend\nreturn result\nelse\nif (not sep) then\nif (os.is(\"windows\")) then\nsep = \"\\\\\"\nelse\nsep = \"/\"\nend\nend\nlocal result = p:gsub(\"[/\\\\]\", sep)\nreturn result\nend\nend\nfunction path.wildcards(pattern)\npattern = pattern:gsub(\"([%+%.%-%^%$%(%)%%])\", \"%%%1\")\npattern = pattern:gsub(\"%*%*\", \"\\001\")\npattern = pattern:gsub(\"%*\", \"\\002\")\npattern = pattern:gsub(\"\\001\", \".*\")\npattern = pattern:gsub(\"\\002\", \"[^/]*\")\nreturn pattern\nend\nfunction path.trimdots(p)\nlocal changed\nrepeat\nchanged = true\nif p:startswith(\"./\") then\np = p:sub(3)\nelseif p:startswith(\"../\") then\np = p:sub(4)\nelse\nchanged = false\nend\nuntil not changed\nreturn p\nend\nfunction path.rebase(p, oldbase, newbase)\np = path.getabsolute(path.join(oldbase, p))\np = path.getrelative(newbase, p)\nreturn p\nend\nfunction path.replaceextension(p, newext)\nlocal ext = path.getextension(p)\nif not ext then\nreturn p\nend\nif #newext > 0 and not newext:findlast" "(\".\", true) then\nnewext = \".\"..newext\nend\nreturn p:match(\"^(.*)\"..ext..\"$\")..newext\nend\n", /* base/string.lua */ "function string.explode(s, pattern, plain)\nif (pattern == '') then return false end\nlocal pos = 0\nlocal arr = { }\nfor st,sp in function() return s:find(pattern, pos, plain) end do\ntable.insert(arr, s:sub(pos, st-1))\npos = sp + 1\nend\ntable.insert(arr, s:sub(pos))\nreturn arr\nend\nfunction string.findlast(s, pattern, plain)\nlocal curr = 0\nlocal term = nil\nrepeat\nlocal next, nextterm = s:find(pattern, curr + 1, plain)\nif (next) then\ncurr = next\nterm = nextterm\nend\nuntil (not next)\nif (curr > 0) then\nreturn curr, term\nend\nend\nfunction string.startswith(haystack, needle)\nreturn (haystack:find(needle, 1, true) == 1)\nend\nfunction string.trim(s)\nreturn (s:gsub(\"^%s*(.-)%s*$\", \"%1\"))\nend\n", /* base/table.lua */ "function table.contains(t, value)\nfor _, v in pairs(t) do\nif v == value then return true end\nend\nreturn false\nend\nfunction table.icontains(t, value)\nfor _, v in ipairs(t) do\nif v == value then return true end\nend\nreturn false\nend\nfunction table.deepcopy(object)\nlocal seen = {}\nlocal function copy(object)\nif type(object) ~= \"table\" then\nreturn object\nelseif seen[object] then\nreturn seen[object]\nend\nlocal clone = {}\nseen[object] = clone\nfor key, value in pairs(object) do\nclone[key] = copy(value)\nend\nsetmetatable(clone, getmetatable(object))\nreturn clone\nend\nreturn copy(object)\nend\nfunction table.extract(arr, fname)\nlocal result = { }\nfor _,v in ipairs(arr) do\ntable.insert(result, v[fname])\nend\nreturn result\nend\nfunction table.flatten(arr)\nlocal result = { }\nlocal function flatten(arr)\nfor _, v in ipairs(arr) do\nif type(v) == \"table\" then\nflatten(v)\nelse\ntable.insert(result, v)\nend\nend\nend\nflatten(arr)\nreturn result\nend\nfunction table.implode(arr, before, aft" "er, between)\nlocal result = \"\"\nfor _,v in ipairs(arr) do\nif (result ~= \"\" and between) then\nresult = result .. between\nend\nresult = result .. before .. v .. after\nend\nreturn result\nend\nfunction table.insertflat(tbl, values)\nif type(values) == \"table\" then\nfor _, value in ipairs(values) do\ntable.insertflat(tbl, value)\nend\nelse\ntable.insert(tbl, values)\nend\nend\nfunction table.isempty(t)\nreturn next(t) == nil\nend\nfunction table.join(...)\nlocal arg={...}\nlocal result = { }\nfor _,t in ipairs(arg) do\nif type(t) == \"table\" then\nfor _,v in ipairs(t) do\ntable.insert(result, v)\nend\nelse\ntable.insert(result, t)\nend\nend\nreturn result\nend\nfunction table.keys(tbl)\nlocal keys = {}\nfor k, _ in pairs(tbl) do\ntable.insert(keys, k)\nend\nreturn keys\nend\nfunction table.sortedpairs(t)\nlocal keys = table.keys(t)\nlocal i = 0\ntable.sort(keys)\nreturn function()\ni = i + 1\nif keys[i] == nil then\nreturn nil\nend\nreturn keys[i], t[keys[i]]\nend\nend\nfunction table.merge(...)\nlocal" " arg={...}\nlocal result = { }\nfor _,t in ipairs(arg) do\nif type(t) == \"table\" then\nfor k,v in pairs(t) do\nresult[k] = v\nend\nelse\nerror(\"invalid value\")\nend\nend\nreturn result\nend\nfunction table.translate(arr, translation)\nlocal result = { }\nfor _, value in ipairs(arr) do\nlocal tvalue\nif type(translation) == \"function\" then\ntvalue = translation(value)\nelse\ntvalue = translation[value]\nend\nif (tvalue) then\ntable.insert(result, tvalue)\nend\nend\nreturn result\nend\nfunction table.reverse(arr)\nfor i=1, math.floor(#arr / 2) do\narr[i], arr[#arr - i + 1] = arr[#arr - i + 1], arr[i]\nend\nreturn arr\nend\nfunction table.arglist(arg, value)\nif #value > 0 then\nlocal args = {}\nfor _, val in ipairs(value) do\ntable.insert(args, string.format(\"%s %s\", arg, val))\nend\nreturn table.concat(args, \" \")\nelse\nreturn \"\"\nend\nend\n", /* base/io.lua */ "io.eol = \"\\n\"\nio.indent = \"\\t\"\nio.indentLevel = 0\nlocal function _escaper(v) return v end\n_esc = _escaper\nfunction io.capture()\nlocal prev = io.captured\nio.captured = ''\nreturn prev\nend\nfunction io.endcapture(restore)\nlocal captured = io.captured\nio.captured = restore\nreturn captured\nend\nlocal builtin_open = io.open\nfunction io.open(fname, mode)\nif (mode) then\nif (mode:find(\"w\")) then\nlocal dir = path.getdirectory(fname)\nok, err = os.mkdir(dir)\nif (not ok) then\nerror(err, 0)\nend\nend\nend\nreturn builtin_open(fname, mode)\nend\nfunction io.printf(msg, ...)\nlocal arg={...}\nif not io.eol then\nio.eol = \"\\n\"\nend\nif not io.indent then\nio.indent = \"\\t\"\nend\nif type(msg) == \"number\" then\ns = string.rep(io.indent, msg) .. string.format(table.unpack(arg))\nelse\ns = string.format(msg, table.unpack(arg))\nend\nif io.captured then\nio.captured = io.captured .. s .. io.eol\nelse\nio.write(s)\nio.write(io.eol)\nend\nend\nfunction io.xprintf(msg, ...)\nlocal arg = " "{...}\nfor i = 1, #arg do\narg[i] = io.esc(arg[i])\nend\nio.printf(msg, unpack(arg))\nend\nfunction io.esc(value)\nif type(value) == \"table\" then\nlocal result = {}\nlocal n = #value\nfor i = 1, n do\ntable.insert(result, io.esc(value[i]))\nend\nreturn result\nend\nreturn _esc(value or \"\")\nend\nfunction io.escaper(func)\n_esc = func or _escaper\nend\n_p = io.printf\n_x = io.xprintf\n", /* base/globals.lua */ "premake = { }\npremake.platforms =\n{\nNative =\n{\ncfgsuffix = \"\",\n},\nx32 =\n{\ncfgsuffix = \"32\",\n},\nx64 =\n{\ncfgsuffix = \"64\",\n},\nUniversal =\n{\ncfgsuffix = \"univ\",\n},\nUniversal32 =\n{\ncfgsuffix = \"univ32\",\n},\nUniversal64 =\n{\ncfgsuffix = \"univ64\",\n},\nPS3 =\n{\ncfgsuffix = \"ps3\",\niscrosscompiler = true,\nnosharedlibs = true,\nnamestyle = \"PS3\",\n},\nWiiDev =\n{\ncfgsuffix = \"wii\",\niscrosscompiler = true,\nnamestyle = \"PS3\",\n},\nXbox360 =\n{\ncfgsuffix = \"xbox360\",\niscrosscompiler = true,\nnamestyle = \"windows\",\n},\nPowerPC =\n{\ncfgsuffix = \"ppc\",\niscrosscompiler = true,\n},\nARM =\n{\ncfgsuffix = \"ARM\",\niscrosscompiler = true,\n},\nARM64 =\n{\ncfgsuffix = \"ARM64\",\niscrosscompiler = true,\n},\nOrbis =\n{\ncfgsuffix = \"orbis\",\niscrosscompiler = true,\nnamestyle = \"Orbis\",\n},\nDurango =\n{\ncfgsuffix = \"durango\",\niscrosscompiler = true,\nn" "osharedlibs = true,\nnamestyle = \"windows\",\n},\nTegraAndroid =\n{\ncfgsuffix = \"tegraandroid\",\niscrosscompiler = true,\nnamestyle = \"TegraAndroid\",\n},\nNX32 =\n{\ncfgsuffix = \"nx32\",\niscrosscompiler = true,\nnamestyle = \"NX\",\n},\nNX64 =\n{\ncfgsuffix = \"nx64\",\niscrosscompiler = true,\nnamestyle = \"NX\",\n},\nEmscripten =\n{\ncfgsuffix = \"emscripten\",\niscrosscompiler = true,\nnosharedlibs = true,\nnamestyle = \"Emscripten\",\n},\n}\nlocal builtin_dofile = dofile\nfunction dofile(fname)\nlocal oldcwd = os.getcwd()\nlocal oldfile = _SCRIPT\nif (not os.isfile(fname)) then\nlocal path = os.pathsearch(fname, _OPTIONS[\"scripts\"], os.getenv(\"PREMAKE_PATH\"))\nif (path) then\nfname = path..\"/\"..fname\nend\nend\n_SCRIPT = path.getabsolute(fname)\nlocal newcwd = path.getdirectory(_SCRIPT)\nos.chdir(newcwd)\nlocal a, b, c, d, e, f = builtin_dofile(_SCRIPT)\n_SCRIPT = oldfile\nos.chdir(oldcwd)\nreturn a, b, c, d, e, f\nend\nfunction iif(" "expr, trueval, falseval)\nif (expr) then\nreturn trueval\nelse\nreturn falseval\nend\nend\nfunction include(fname)\nlocal dir, name = premake.findDefaultScript(fname, false)\nif dir ~= nil then\nreturn dofile(dir .. \"/\" .. name)\nend\nreturn nil\nend\nfunction printf(msg, ...)\nlocal arg={...}\nprint(string.format(msg, table.unpack(arg)))\nend\nfunction typex(t)\nlocal mt = getmetatable(t)\nif (mt) then\nif (mt.__type) then\nreturn mt.__type\nend\nend\nreturn type(t)\nend\n", /* base/action.lua */ "premake.action = { }\npremake.action.list = { }\nfunction premake.action.add(a)\nlocal missing\nfor _, field in ipairs({\"description\", \"trigger\"}) do\nif (not a[field]) then\nmissing = field\nend\nend\nif (missing) then\nerror(\"action needs a \" .. missing, 3)\nend\npremake.action.list[a.trigger] = a\nend\nfunction premake.action.call(name)\nlocal a = premake.action.list[name]\nfor sln in premake.solution.each() do\nif a.onsolution then\na.onsolution(sln)\nend\nif sln.postsolutioncallbacks then\nfor _,cb in ipairs(sln.postsolutioncallbacks) do\ncb(sln)\nend\nend\nfor prj in premake.solution.eachproject(sln) do\nif a.onproject then\na.onproject(prj)\nend\nif prj.postprojectcallbacks then\nfor _,cb in ipairs(prj.postprojectcallbacks) do\ncb(prj)\nend\nend\nend\nend\nif a.execute then\na.execute()\nend\nend\nfunction premake.action.current()\nreturn premake.action.get(_ACTION)\nend\nfunction premake.action.get(name)\nreturn premake.action.list[name]\nend\nfunction premake.action.each()\nlocal keys = { }\nfor" " _, action in pairs(premake.action.list) do\ntable.insert(keys, action.trigger)\nend\ntable.sort(keys)\nlocal i = 0\nreturn function()\ni = i + 1\nreturn premake.action.list[keys[i]]\nend\nend\nfunction premake.action.set(name)\n_ACTION = name\nlocal action = premake.action.get(name)\nif action then\n_OS = action.os or _OS\nend\nend\nfunction premake.action.supports(action, feature)\nif not action then\nreturn false\nend\nif action.valid_languages then\nif table.contains(action.valid_languages, feature) then\nreturn true\nend\nend\nif action.valid_kinds then\nif table.contains(action.valid_kinds, feature) then\nreturn true\nend\nend\nreturn false\nend\n", /* base/option.lua */ "premake.option = { }\npremake.option.list = { }\nfunction premake.option.add(opt)\nlocal missing\nfor _, field in ipairs({ \"description\", \"trigger\" }) do\nif (not opt[field]) then\nmissing = field\nend\nend\nif (missing) then\nerror(\"option needs a \" .. missing, 3)\nend\npremake.option.list[opt.trigger] = opt\nend\nfunction premake.option.get(name)\nreturn premake.option.list[name]\nend\nfunction premake.option.each()\nlocal keys = { }\nfor _, option in pairs(premake.option.list) do\ntable.insert(keys, option.trigger)\nend\ntable.sort(keys)\nlocal i = 0\nreturn function()\ni = i + 1\nreturn premake.option.list[keys[i]]\nend\nend\nfunction premake.option.validate(values)\nfor key, value in pairs(values) do\nlocal opt = premake.option.get(key)\nif (not opt) then\nreturn false, \"invalid option '\" .. key .. \"'\"\nend\nif (opt.value and value == \"\") then\nreturn false, \"no value specified for option '\" .. key .. \"'\"\nend\nif opt.allowed then\nlocal found = false\nfor _, match in ipairs(opt.allowed) d" "o\nif match[1] == value then\nfound = true\nbreak\nend\nend\nif not found then\nreturn false, string.format(\"invalid value '%s' for option '%s'\", value, key)\nend\nend\nend\nreturn true\nend\n", /* base/tree.lua */ "premake.tree = { }\nlocal tree = premake.tree\nfunction premake.tree.new(n)\nlocal t = {\nname = n,\nchildren = { }\n}\nreturn t\nend\nfunction premake.tree.add(tr, p, onaddfunc)\nif p == \".\" then\nreturn tr\nend\nif p == \"/\" then\nreturn tr\nend\nlocal parentnode = tree.add(tr, path.getdirectory(p), onaddfunc)\nlocal childname = path.getname(p)\nif childname == \"..\" then\nreturn parentnode\nend\nlocal childnode = parentnode.children[childname]\nif not childnode or childnode.path ~= p then\nchildnode = tree.insert(parentnode, tree.new(childname))\nchildnode.path = p\nif onaddfunc then\nonaddfunc(childnode)\nend\nend\nreturn childnode\nend\nfunction premake.tree.insert(parent, child)\ntable.insert(parent.children, child)\nif child.name then\nparent.children[child.name] = child\nend\nchild.parent = parent\nreturn child\nend\nfunction premake.tree.getlocalpath(node)\nif node.parent.path then\nreturn node.name\nelseif node.cfg then\nreturn node.cfg.name\nelse\nreturn node.path\nend\nend\nfunction premake.tre" "e.remove(node)\nlocal children = node.parent.children\nfor i = 1, #children do\nif children[i] == node then\ntable.remove(children, i)\nend\nend\nnode.children = {}\nend\nfunction premake.tree.sort(tr)\ntree.traverse(tr, {\nonnode = function(node)\ntable.sort(node.children, function(a,b)\nreturn a.name < b.name\nend)\nend\n}, true)\nend\nfunction premake.tree.traverse(t, fn, includeroot, initialdepth)\nlocal donode, dochildren\ndonode = function(node, fn, depth)\nif node.isremoved then\nreturn\nend\nif fn.onnode then\nfn.onnode(node, depth)\nend\nif #node.children > 0 then\nif fn.onbranchenter then\nfn.onbranchenter(node, depth)\nend\nif fn.onbranch then\nfn.onbranch(node, depth)\nend\ndochildren(node, fn, depth + 1)\nif fn.onbranchexit then\nfn.onbranchexit(node, depth)\nend\nelse\nif fn.onleaf then\nfn.onleaf(node, depth)\nend\nend\nend\ndochildren = function(parent, fn, depth)\nlocal i = 1\nwhile i <= #parent.children do\nlocal node = parent.children[i]\ndonode(node, fn, depth)\nif node == parent.children[i" "] then\ni = i + 1\nend\nend\nend\nif not initialdepth then\ninitialdepth = 0\nend\nif includeroot then\ndonode(t, fn, initialdepth)\nelse\ndochildren(t, fn, initialdepth)\nend\nend\n", /* base/solution.lua */ "premake.solution = { }\npremake.solution.list = { }\nfunction premake.solution.new(name)\nlocal sln = { }\ntable.insert(premake.solution.list, sln)\npremake.solution.list[name] = sln\nsetmetatable(sln, { __type=\"solution\" })\nsln.name = name\nsln.basedir = os.getcwd()\nsln.projects = { }\nsln.blocks = { }\nsln.configurations = { }\nsln.groups = { }\nsln.importedprojects = { }\nreturn sln\nend\nfunction premake.solution.each()\nlocal i = 0\nreturn function ()\ni = i + 1\nif i <= #premake.solution.list then\nreturn premake.solution.list[i]\nend\nend\nend\nfunction premake.solution.eachproject(sln)\nlocal i = 0\nreturn function ()\ni = i + 1\nif (i <= #sln.projects) then\nreturn premake.solution.getproject(sln, i)\nend\nend\nend\nfunction premake.solution.eachgroup(sln)\nlocal i = 0\nreturn function()\ni = i + 1\nif(i <= #sln.groups) then\nreturn premake.solution.getgroup(sln, i)\nend\nend\nend\nfunction premake.solution.get(key)\nreturn premake.solution.list[key]\nend\nfu" "nction premake.solution.getproject(sln, idx)\nlocal prj = sln.projects[idx]\nlocal cfg = premake.getconfig(prj)\ncfg.name = prj.name\nreturn cfg\nend\nfunction premake.solution.getgroup(sln, idx)\nlocal grp = sln.groups[idx]\nreturn grp\nend", /* base/project.lua */ "premake.project = { }\nfunction premake.project.buildsourcetree(prj, allfiles)\nlocal tr = premake.tree.new(prj.name)\ntr.project = prj\nlocal isvpath\nlocal function onadd(node)\nnode.isvpath = isvpath\nend\nfor fcfg in premake.project.eachfile(prj, allfiles) do\nisvpath = (fcfg.name ~= fcfg.vpath)\nlocal node = premake.tree.add(tr, fcfg.vpath, onadd)\nnode.cfg = fcfg\nend\npremake.tree.sort(tr)\nreturn tr\nend\nfunction premake.eachconfig(prj, platform)\nif prj.project then prj = prj.project end\nlocal cfgs = prj.solution.configurations\nlocal i = 0\nreturn function ()\ni = i + 1\nif i <= #cfgs then\nreturn premake.getconfig(prj, cfgs[i], platform)\nend\nend\nend\nfunction premake.project.eachfile(prj, allfiles)\nif not prj.project then prj = premake.getconfig(prj) end\nlocal i = 0\nlocal t = iif(allfiles, prj.allfiles, prj.files)\nlocal c = iif(allfiles, prj.__allfileconfigs, prj.__fileconfigs)\nreturn function ()\ni = i + 1\nif (i <= #t) then\nlocal fcfg = c[t[i]]\nfcfg.vpath = premake.project.getvpath(prj" ", fcfg.name)\nreturn fcfg\nend\nend\nend\nfunction premake.esc(value)\nif (type(value) == \"table\") then\nlocal result = { }\nfor _,v in ipairs(value) do\ntable.insert(result, premake.esc(v))\nend\nreturn result\nelse\nvalue = value:gsub('&', \"&amp;\")\nvalue = value:gsub('\"', \"&quot;\")\nvalue = value:gsub(\"'\", \"&apos;\")\nvalue = value:gsub('<', \"&lt;\")\nvalue = value:gsub('>', \"&gt;\")\nvalue = value:gsub('\\r', \"&#x0D;\")\nvalue = value:gsub('\\n', \"&#x0A;\")\nreturn value\nend\nend\nfunction premake.filterplatforms(sln, map, default)\nlocal result = { }\nlocal keys = { }\nif sln.platforms then\nfor _, p in ipairs(sln.platforms) do\nif map[p] and not table.contains(keys, map[p]) then\ntable.insert(result, p)\ntable.insert(keys, map[p])\nend\nend\nend\nif #result == 0 and default then\ntable.insert(result, default)\nend\nreturn result\nend\nfunction premake.findproject(name)\nfor sln in premake.solution.each() do\nfor prj in premake.solution.eachproject(sln) do\nif (prj.name == name) then\n" "return prj\nend\nend\nend\nend\nfunction premake.findfile(prj, extension)\nfor _, fname in ipairs(prj.files) do\nif fname:endswith(extension) then return fname end\nend\nend\nfunction premake.getconfig(prj, cfgname, pltname)\nprj = prj.project or prj\nif pltname == \"Native\" or not table.contains(prj.solution.platforms or {}, pltname) then\npltname = nil\nend\nlocal key = (cfgname or \"\")\nif pltname then key = key .. pltname end\nreturn prj.__configs[key]\nend\nfunction premake.getconfigname(cfgname, platform, useshortname)\nif cfgname then\nlocal name = cfgname\nif platform and platform ~= \"Native\" then\nif useshortname then\nname = name .. premake.platforms[platform].cfgsuffix\nelse\nname = name .. \"|\" .. platform\nend\nend\nreturn iif(useshortname, name:lower(), name)\nend\nend\nfunction premake.getdependencies(prj)\nprj = prj.project or prj\nlocal results = { }\nfor _, cfg in pairs(prj.__configs) do\nfor _, link in ipairs(cfg.links) do\nlocal dep = premake.findproject(link)\nif dep and not table.co" "ntains(results, dep) then\ntable.insert(results, dep)\nend\nend\nend\nreturn results\nend\nfunction premake.project.getbasename(prjname, pattern)\nreturn pattern:gsub(\"%%%%\", prjname)\nend\nfunction premake.project.getfilename(prj, pattern)\nlocal fname = premake.project.getbasename(prj.name, pattern)\nfname = path.join(prj.location, fname)\nreturn path.getrelative(os.getcwd(), fname)\nend\n function premake.getlinks(cfg, kind, part)\nlocal result = iif (part == \"directory\" and kind == \"all\", cfg.libdirs, {})\nlocal cfgname = iif(cfg.name == cfg.project.name, \"\", cfg.name)\nlocal pathstyle = premake.getpathstyle(cfg)\nlocal namestyle = premake.getnamestyle(cfg)\nlocal function canlink(source, target)\nif (target.kind ~= \"SharedLib\" and target.kind ~= \"StaticLib\") then\nreturn false\nend\nif premake.iscppproject(source) then\nreturn premake.iscppproject(target)\nelseif premake.isdotnetproject(source) then\nreturn premake.isdotnetproject(target)\nelseif premake.isswiftproject(source) then\nreturn pre" "make.isswiftproject(source) or premake.iscppproject(source)\nend\nend\nfor _, link in ipairs(cfg.links) do\nlocal item\nlocal prj = premake.findproject(link)\nif prj and kind ~= \"system\" then\nlocal prjcfg = premake.getconfig(prj, cfgname, cfg.platform)\nif kind == \"dependencies\" or canlink(cfg, prjcfg) then\nif (part == \"directory\") then\nitem = path.rebase(prjcfg.linktarget.directory, prjcfg.location, cfg.location)\nelseif (part == \"basename\") then\nitem = prjcfg.linktarget.basename\nelseif (part == \"fullpath\") then\nitem = path.rebase(prjcfg.linktarget.fullpath, prjcfg.location, cfg.location)\nelseif (part == \"object\") then\nitem = prjcfg\nend\nend\nelseif not prj and (kind == \"system\" or kind == \"all\") then\nif (part == \"directory\") then\nitem = path.getdirectory(link)\nelseif (part == \"fullpath\") then\nitem = link\nif namestyle == \"windows\" then\nif premake.iscppproject(cfg) then\nitem = item .. \".lib\"\nelseif premake.isdotnetproject(cfg) then\nitem = item .. \".dll\"\nend\nend\nel" "seif part == \"name\" then\nitem = path.getname(link)\nelseif part == \"basename\" then\nitem = path.getbasename(link)\nelse\nitem = link\nend\nif item:find(\"/\", nil, true) then\nitem = path.getrelative(cfg.project.location, item)\nend\nend\nif item then\nif pathstyle == \"windows\" and part ~= \"object\" then\nitem = path.translate(item, \"\\\\\")\nend\nif not table.contains(result, item) then\ntable.insert(result, item)\nend\nend\nend\nreturn result\nend\nfunction premake.getnamestyle(cfg)\nreturn premake.platforms[cfg.platform].namestyle or premake.gettool(cfg).namestyle or \"posix\"\nend\nfunction premake.getpathstyle(cfg)\nif premake.action.current().os == \"windows\" then\nreturn \"windows\"\nelse\nreturn \"posix\"\nend\nend\nfunction premake.gettarget(cfg, direction, pathstyle, namestyle, system)\nif system == \"bsd\" then\nsystem = \"linux\"\nend\nlocal kind = cfg.kind\nif premake.iscppproject(cfg) or premake.isvalaproject(cfg) then\nif (namestyle == \"windows\" or system == \"windows\")\nand kind ==" " \"SharedLib\" and direction == \"link\"\nand not cfg.flags.NoImportLib\nthen\nkind = \"StaticLib\"\nend\nif namestyle == \"posix\" and system == \"windows\" and kind ~= \"StaticLib\" then\nnamestyle = \"windows\"\nend\nend\nlocal field = \"build\"\nif direction == \"link\" and cfg.kind == \"SharedLib\" then\nfield = \"implib\"\nend\nlocal name = cfg[field..\"name\"] or cfg.targetname or cfg.project.name\nlocal dir = cfg[field..\"dir\"] or cfg.targetdir or path.getrelative(cfg.location, cfg.basedir)\nlocal subdir = cfg[field..\"subdir\"] or cfg.targetsubdir or \".\"\nlocal prefix = \"\"\nlocal suffix = \"\"\nlocal ext = \"\"\nlocal bundlepath, bundlename\ndir = path.join(dir, subdir)\nif namestyle == \"windows\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".exe\"\nelseif kind == \"SharedLib\" then\next = \".dll\"\nelseif kind == \"StaticLib\" then\next = \".lib\"\nend\nelseif namestyle == \"posix\" then\nif kind == \"WindowedApp\" and system == \"macosx\" and not cfg" ".options.SkipBundling then\nbundlename = name .. \".app\"\nbundlepath = path.join(dir, bundlename)\ndir = path.join(bundlepath, \"Contents/MacOS\")\nelseif (kind == \"ConsoleApp\" or kind == \"WindowedApp\") and system == \"os2\" then\next = \".exe\"\nelseif kind == \"SharedLib\" then\nprefix = \"lib\"\next = iif(system == \"macosx\", \".dylib\", \".so\")\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\next = \".a\"\nend\nelseif namestyle == \"PS3\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".elf\"\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\next = \".a\"\nend\nelseif namestyle == \"Orbis\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".elf\"\nelseif kind == \"StaticLib\" then\nprefix = \"lib\"\next = \".a\"\nelseif kind == \"SharedLib\" then\next = \".prx\"\nend\nelseif namestyle == \"TegraAndroid\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" or kind == \"SharedLib\" then\nprefix = \"lib\"\next = \".so\"\nelseif kind == \"St" "aticLib\" then\nprefix = \"lib\"\next = \".a\"\nend\nelseif namestyle == \"NX\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".nspd_root\"\nelseif kind == \"StaticLib\" then\next = \".a\"\nelseif kind == \"SharedLib\" then\next = \".nro\"\nend\nelseif namestyle == \"Emscripten\" then\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\next = \".html\"\nelseif kind == \"StaticLib\" then\next = \".bc\"\nelseif kind == \"SharedLib\" then\next = \".js\"\nend\nend\nprefix = cfg[field..\"prefix\"] or cfg.targetprefix or prefix\nsuffix = cfg[field..\"suffix\"] or cfg.targetsuffix or suffix\next = cfg[field..\"extension\"] or cfg.targetextension or ext\nlocal result = { }\nresult.basename = name .. suffix\nresult.name = prefix .. name .. suffix .. ext\nresult.directory = dir\nresult.subdirectory = subdir\nresult.prefix = prefix\nresult.suffix = suffix\nresult.fullpath = path.join(result.directory, result.name)\nresult.bundlepath = bundlepath or resu" "lt.fullpath\nif pathstyle == \"windows\" then\nresult.directory = path.translate(result.directory, \"\\\\\")\nresult.subdirectory = path.translate(result.subdirectory, \"\\\\\")\nresult.fullpath = path.translate(result.fullpath, \"\\\\\")\nend\nreturn result\nend\nfunction premake.gettool(prj)\nif premake.iscppproject(prj) then\nif _OPTIONS.cc then\nreturn premake[_OPTIONS.cc]\nend\nlocal action = premake.action.current()\nif action.valid_tools then\nreturn premake[action.valid_tools.cc[1]]\nend\nreturn premake.gcc\nelseif premake.isdotnetproject(prj) then\nreturn premake.dotnet\nelseif premake.isswiftproject(prj) then\nreturn premake.swift\nelse\nreturn premake.valac\nend\nend\nfunction premake.project.getvpath(prj, abspath)\nlocal vpath = abspath\nlocal fname = path.getname(abspath)\nlocal max = abspath:len() - fname:len()\n -- First check for an exact match from the inverse vpaths\n if prj.inversevpaths and prj.inversevpaths[abspath] then\n return path.join(prj.inversevpaths" "[abspath], fname)\n end\n local matches = {}\nfor replacement, patterns in pairs(prj.vpaths or {}) do\nfor _, pattern in ipairs(patterns) do\nlocal i = abspath:find(path.wildcards(pattern))\nif i == 1 then\ni = pattern:find(\"*\", 1, true) or (pattern:len() + 1)\nlocal leaf\nif i < max then\nleaf = abspath:sub(i)\nelse\nleaf = fname\nend\nif leaf:startswith(\"/\") then\nleaf = leaf:sub(2)\nend\nlocal stem = \"\"\nif replacement:len() > 0 then\nstem, stars = replacement:gsub(\"%*\", \"\")\nif stars == 0 then\nleaf = path.getname(leaf)\nend\nelse\nleaf = path.getname(leaf)\nend\ntable.insert(matches, path.join(stem, leaf))\nend\nend\nend\n if #matches > 0 then\n -- for the sake of determinism, return the first alphabetically\n table.sort(matches)\n vpath = matches[1]\n end\nreturn path.trimdots(vpath)\nend\nfunction premake.hascppproject(sln)\nfor prj in premake.solution.eachproject(sln) do\nif premake.iscppproject(prj) then\nreturn true\nend\nend\nend" "\nfunction premake.hasdotnetproject(sln)\nfor prj in premake.solution.eachproject(sln) do\nif premake.isdotnetproject(prj) then\nreturn true\nend\nend\nend\nfunction premake.project.iscproject(prj)\nlocal language = prj.language or prj.solution.language\nreturn language == \"C\"\nend\nfunction premake.iscppproject(prj)\nlocal language = prj.language or prj.solution.language\nreturn (language == \"C\" or language == \"C++\")\nend\nfunction premake.isdotnetproject(prj)\nlocal language = prj.language or prj.solution.language\nreturn (language == \"C#\")\nend\nfunction premake.isvalaproject(prj)\nlocal language = prj.language or prj.solution.language\nreturn (language == \"Vala\")\nend\nfunction premake.isswiftproject(prj)\nlocal language = prj.language or prj.solution.language\nreturn (language == \"Swift\")\nend\n", /* base/config.lua */ "premake.config = { }\nlocal config = premake.config\nfunction premake.config.isdebugbuild(cfg)\nif cfg.flags.DebugRuntime then\nreturn true\nend\nif cfg.flags.ReleaseRuntime then\nreturn false\nend\nif cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed then\nreturn false\nend\nif not cfg.flags.Symbols then\nreturn false\nend\nreturn true\nend\nfunction premake.config.eachfile(cfg)\nlocal i = 0\nlocal t = cfg.files\nreturn function ()\ni = i + 1\nif (i <= #t) then\nlocal fcfg = cfg.__fileconfigs[t[i]]\nfcfg.vpath = premake.project.getvpath(cfg.project, fcfg.name)\nreturn fcfg\nend\nend\nend\nfunction premake.config.isincrementallink(cfg)\nif cfg.kind == \"StaticLib\" then\nreturn false\nend\nreturn not config.islinkeroptimizedbuild(cfg.flags) and not cfg.flags.NoIncrementalLink\nend\nfunction premake.config.isoptimizedbuild(flags)\nreturn flags.Optimize or flags.OptimizeSize or flags.OptimizeSpeed\nend\nfunction premake.config.islinkeroptimizedbuild(flags)\nreturn config.isoptimizedbuild(fl" "ags) and not flags.NoOptimizeLink\nend\nfunction premake.config.iseditandcontinue(cfg)\nif cfg.flags.NoEditAndContinue\nor cfg.flags.Managed\nor (cfg.kind ~= \"StaticLib\" and not config.isincrementallink(cfg))\nor config.islinkeroptimizedbuild(cfg.flags) then\nreturn false\nend\nreturn true\nend\n", /* base/bake.lua */ "premake.bake = { }\nlocal bake = premake.bake\nlocal nocopy =\n{\nblocks = true,\nkeywords = true,\nprojects = true,\n__configs = true,\n}\nlocal nocascade =\n{\nmakesettings = true,\n}\nlocal keeprelative =\n{\nbasedir = true,\nlocation = true,\n}\nfunction premake.getactiveterms(obj)\nlocal terms = { _action = _ACTION:lower(), os = os.get() }\nfor key, value in pairs(_OPTIONS) do\nif value ~= \"\" then\ntable.insert(terms, value:lower())\nelse\ntable.insert(terms, key:lower())\nend\nend\nreturn terms\nend\nfunction premake.iskeywordmatch(keyword, terms)\nif keyword:startswith(\"not \") then\nreturn not premake.iskeywordmatch(keyword:sub(5), terms)\nend\nfor _, pattern in ipairs(keyword:explode(\" or \")) do\nfor termkey, term in pairs(terms) do\nif term:match(pattern) == term then\nreturn termkey\nend\nend\nend\nend\nfunction premake.iskeywordsmatch(keywords, terms)\nlocal hasrequired = false\nfor _, keyword in ipairs(keywords) do\nlocal matched = premake.iskeywordmatch(keyword, terms)\nif not matched " "then\nreturn false\nend\nif matched == \"required\" then\nhasrequired = true\nend\nend\nif terms.required and not hasrequired then\nreturn false\nelse\nreturn true\nend\nend\nlocal function adjustpaths(location, obj)\nfunction adjustpathlist(list)\nfor i, p in ipairs(list) do\nlist[i] = path.getrelative(location, p)\nend\nend\nif obj.allfiles ~= nil then\nadjustpathlist(obj.allfiles)\nend\nfor name, value in pairs(obj) do\nlocal field = premake.fields[name]\nif field and value and not keeprelative[name] then\nif field.kind == \"path\" then\nobj[name] = path.getrelative(location, value)\nelseif field.kind == \"dirlist\" or field.kind == \"filelist\" then\nadjustpathlist(value)\nelseif field.kind == \"keypath\" then\nfor k,v in pairs(value) do\nadjustpathlist(v)\nend\nend\nend\nend\nend\nlocal function removevalue(tbl, remove)\nfor index, item in ipairs(tbl) do\nif item == remove then\ntable.remove(tbl, index)\nbreak\nend\nend\nend\nlocal function removevalues(tbl, removes)\nfor k, v in pairs(tbl) do\nfor _, pat" "tern in ipairs(removes) do\nif pattern == tbl[k] then\nif type(k) == \"number\" then\ntable.remove(tbl, k)\nelse\ntbl[k] = nil\nend\nbreak\nend\nend\nend\nend\nlocal function mergefield(kind, dest, src, mergecopiestotail)\nlocal tbl = dest or { }\nif kind == \"keyvalue\" or kind == \"keypath\" then\nfor key, value in pairs(src) do\ntbl[key] = mergefield(\"list\", tbl[key], value, mergecopiestotail)\nend\nelse\nfor _, item in ipairs(src) do\nif tbl[item] then\nif mergecopiestotail then\nremovevalue(tbl, item)\ntable.insert(tbl, item)\ntbl[item] = item\nend\nelse\ntable.insert(tbl, item)\ntbl[item] = item\nend\nend\nend\nreturn tbl\nend\nlocal function mergeobject(dest, src)\nif not src then\nreturn\nend\nfor fieldname, value in pairs(src) do\nif not nocopy[fieldname] then\nlocal field = premake.fields[fieldname]\nif field then\nif type(value) == \"table\" then\ndest[fieldname] = mergefield(field.kind, dest[fieldname], value, field.mergecopiestotail)\nif src.removes then\nremoves = src.removes[fieldname]\nif rem" "oves then\nremovevalues(dest[fieldname], removes)\nend\nend\nelse\ndest[fieldname] = value\nend\nelse\ndest[fieldname] = value\nend\nend\nend\nend\nlocal function merge(dest, obj, basis, terms, cfgname, pltname)\nlocal key = cfgname or \"\"\npltname = pltname or \"Native\"\nif pltname ~= \"Native\" then\nkey = key .. pltname\nend\nterms.config = (cfgname or \"\"):lower()\nterms.platform = pltname:lower()\nlocal cfg = {}\nmergeobject(cfg, basis[key])\nadjustpaths(obj.location, cfg)\nmergeobject(cfg, obj)\nif (cfg.kind) then\nterms['kind']=cfg.kind:lower()\nend\nfor _, blk in ipairs(obj.blocks) do\nif (premake.iskeywordsmatch(blk.keywords, terms))then\nmergeobject(cfg, blk)\nif (cfg.kind and not cfg.terms.kind) then\ncfg.terms['kind'] = cfg.kind:lower()\nterms['kind'] = cfg.kind:lower()\nend\nend\nend\ncfg.name = cfgname\ncfg.platform = pltname\nfor k,v in pairs(terms) do\ncfg.terms[k] =v\nend\ndest[key] = cfg\nend\nlocal function collapse(obj, basis)\nlocal result = {}\nbasis = basis or {}\nlocal sln = ob" "j.solution or obj\nlocal terms = premake.getactiveterms(obj)\nmerge(result, obj, basis, terms)--this adjusts terms\nfor _, cfgname in ipairs(sln.configurations) do\nlocal terms_local = {}\nfor k,v in pairs(terms)do terms_local[k]=v end\nmerge(result, obj, basis, terms_local, cfgname, \"Native\")--terms cam also be adjusted here\nfor _, pltname in ipairs(sln.platforms or {}) do\nif pltname ~= \"Native\" then\nmerge(result, obj, basis,terms_local, cfgname, pltname)--terms also here\nend\nend\nend\nreturn result\nend\nlocal function builduniquedirs()\nlocal num_variations = 4\nlocal cfg_dirs = {}\nlocal hit_counts = {}\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nlocal dirs = { }\ndirs[1] = path.getabsolute(path.join(cfg.location, cfg.objdir or cfg.project.objdir or \"obj\"))\ndirs[2] = path.join(dirs[1], iif(cfg.platform == \"Native\", \"\", cfg.platform))\ndirs[3] = path.join(dirs[2], cfg.name)\ndirs[4] = path.join(dirs[3], cfg.project.nam" "e)\ncfg_dirs[cfg] = dirs\nlocal start = iif(cfg.name, 2, 1)\nfor v = start, num_variations do\nlocal d = dirs[v]\nhit_counts[d] = (hit_counts[d] or 0) + 1\nend\nend\nend\nend\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nlocal dir\nlocal start = iif(cfg.name, 2, 1)\nfor v = start, iif(cfg.flags.SingleOutputDir==true,num_variations-1,num_variations) do\ndir = cfg_dirs[cfg][v]\nif hit_counts[dir] == 1 then break end\nend\ncfg.objectsdir = path.getrelative(cfg.location, dir)\nend\nend\nend\nend\nlocal function buildtargets()\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nfor _, cfg in pairs(prj.__configs) do\nlocal pathstyle = premake.getpathstyle(cfg)\nlocal namestyle = premake.getnamestyle(cfg)\ncfg.buildtarget = premake.gettarget(cfg, \"build\", pathstyle, namestyle, cfg.system)\ncfg.linktarget = premake.gettarget(cfg, \"link\", pathstyle, namestyle, cfg.system)\nif pathstyle == \"windows\" then\ncfg.objec" "tsdir = path.translate(cfg.objectsdir, \"\\\\\")\nend\nend\nend\nend\nend\n local function getCfgKind(cfg)\n if(cfg.kind) then\n return cfg.kind;\n end\n if(cfg.project.__configs[\"\"] and cfg.project.__configs[\"\"].kind) then\n return cfg.project.__configs[\"\"].kind;\n end\n return nil\n end\n local function getprojrec(dstArray, foundList, cfg, cfgname, searchField, bLinkage)\n if(not cfg) then return end\n local foundUsePrjs = {};\n for _, useName in ipairs(cfg[searchField]) do\n local testName = useName:lower();\n if((not foundList[testName])) then\n local theProj = nil;\n local theUseProj = nil;\n for _, prj in ipairs(cfg.project.solution.projects) do\n if (prj.name:lower() == testName) then\n if(prj.usage) then\n theUseProj = prj;\n else\n theProj = prj;\n end\n end\n end\n --Must connect to a usage project.\n if(theUseProj) then\n foundList[testName] = true;\n local prjEntry = {\n name = testName,\n proj = theProj,\n usageProj = theUseProj,\n bLinkageOnly = bLinkage,\n" " };\n dstArray[testName] = prjEntry;\n table.insert(foundUsePrjs, theUseProj);\n end\n end\n end\n for _, usePrj in ipairs(foundUsePrjs) do\n --Links can only recurse through static libraries.\n if((searchField ~= \"links\") or\n (getCfgKind(usePrj.__configs[cfgname]) == \"StaticLib\")) then\n getprojrec(dstArray, foundList, usePrj.__configs[cfgname],\n cfgname, searchField, bLinkage);\n end\n end\n end\n --\n -- This function will recursively get all projects that the given configuration has in its \"uses\"\n -- field. The return values are a list of tables. Each table in that list contains the following:\n --name = The lowercase name of the project.\n --proj = The project. Can be nil if it is usage-only.\n --usageProj = The usage project. Can't be nil, as using a project that has no\n -- usage project is not put into the list.\n --bLinkageOnly = If this is true, then only the linkage information should be copied.\n -- The recursion will only look at the \"uses\" field on *usage* proje" "cts.\n -- This function will also add projects to the list that are mentioned in the \"links\"\n -- field of usage projects. These will only copy linker information, but they will recurse.\n -- through other \"links\" fields.\n --\n local function getprojectsconnections(cfg, cfgname)\n local dstArray = {};\n local foundList = {};\n foundList[cfg.project.name:lower()] = true;\n --First, follow the uses recursively.\n getprojrec(dstArray, foundList, cfg, cfgname, \"uses\", false);\n --Next, go through all of the usage projects and recursively get their links.\n --But only if they're not already there. Get the links as linkage-only.\n local linkArray = {};\n for prjName, prjEntry in pairs(dstArray) do\n getprojrec(linkArray, foundList, prjEntry.usageProj.__configs[cfgname], cfgname,\n \"links\", true);\n end\n --Copy from linkArray into dstArray.\n for prjName, prjEntry in pairs(linkArray) do\n dstArray[prjName] = prjEntry;\n end\n return dstArray;\n end\n local function isnameofproj(cfg, " "strName)\n local sln = cfg.project.solution;\n local strTest = strName:lower();\n for prjIx, prj in ipairs(sln.projects) do\n if (prj.name:lower() == strTest) then\n return true;\n end\n end\n return false;\n end\n --\n -- Copies the field from dstCfg to srcCfg.\n --\n local function copydependentfield(srcCfg, dstCfg, strSrcField)\n local srcField = premake.fields[strSrcField];\n local strDstField = strSrcField;\n if type(srcCfg[strSrcField]) == \"table\" then\n --handle paths.\n if (srcField.kind == \"dirlist\" or srcField.kind == \"filelist\") and\n (not keeprelative[strSrcField]) then\n for i,p in ipairs(srcCfg[strSrcField]) do\n table.insert(dstCfg[strDstField],\n path.rebase(p, srcCfg.project.location, dstCfg.project.location))\n end\n else\n if(strSrcField == \"links\") then\n for i,p in ipairs(srcCfg[strSrcField]) do\n if(not isnameofproj(dstCfg, p)) then\n table.insert(dstCfg[strDstField], p)\n else\n printf(\"Failed to copy '%s' from proj '%s'.\",\n p, srcCfg.project.nam" "e);\n end\n end\n else\n for i,p in ipairs(srcCfg[strSrcField]) do\n table.insert(dstCfg[strDstField], p)\n end\n end\n end\n else\n if(srcField.kind == \"path\" and (not keeprelative[strSrcField])) then\n dstCfg[strDstField] = path.rebase(srcCfg[strSrcField],\n prj.location, dstCfg.project.location);\n else\n dstCfg[strDstField] = srcCfg[strSrcField];\n end\n end\n end\n --\n -- This function will take the list of project entries and apply their usage project data\n -- to the given configuration. It will copy compiling information for the projects that are\n -- not listed as linkage-only. It will copy the linking information for projects only if\n -- the source project is not a static library. It won't copy linking information\n -- if the project is in this solution; instead it will add that project to the configuration's\n -- links field, expecting that Premake will handle the rest.\n --\n local function copyusagedata(cfg, cfgname, linkToProjs)\n local myPrj = cfg.project;\n local" " bIsStaticLib = (getCfgKind(cfg) == \"StaticLib\");\n for prjName, prjEntry in pairs(linkToProjs) do\n local srcPrj = prjEntry.usageProj;\n local srcCfg = srcPrj.__configs[cfgname];\n for name, field in pairs(premake.fields) do\n if(srcCfg[name]) then\n if(field.usagecopy) then\n if(not prjEntry.bLinkageOnly) then\n copydependentfield(srcCfg, cfg, name)\n end\n elseif(field.linkagecopy) then\n --Copy the linkage data if we're building a non-static thing\n --and this is a pure usage project. If it's not pure-usage, then\n --we will simply put the project's name in the links field later.\n if((not bIsStaticLib) and (not prjEntry.proj)) then\n copydependentfield(srcCfg, cfg, name)\n end\n end\n end\n end\n if((not bIsStaticLib) and prjEntry.proj) then\n table.insert(cfg.links, prjEntry.proj.name);\n end\n end\n end\n local function inverseliteralvpaths()\n for sln in premake.solution.each() do\n for _,prj in ipairs(sln.projects) do\n prj.inversevpaths = " "{}\n for replacement, patterns in pairs(prj.vpaths or {}) do\n for _, pattern in ipairs(patterns) do\n if string.find(pattern, \"*\") == nil then\n prj.inversevpaths[pattern] = replacement\n end\n end\n end\n end\n end\n end\nfunction premake.bake.buildconfigs()\nfor sln in premake.solution.each() do\nfor _, prj in ipairs(sln.projects) do\nprj.location = prj.location or sln.location or prj.basedir\nadjustpaths(prj.location, prj)\nfor _, blk in ipairs(prj.blocks) do\nadjustpaths(prj.location, blk)\nend\nend\nsln.location = sln.location or sln.basedir\nend\n -- convert paths for imported projects to be relative to solution location\nfor sln in premake.solution.each() do\nfor _, iprj in ipairs(sln.importedprojects) do\niprj.location = path.getabsolute(iprj.location)\nend\nend\n inverseliteralvpaths()\nfor sln in premake.solution.each() do\n" "local basis = collapse(sln)\nfor _, prj in ipairs(sln.projects) do\nprj.__configs = collapse(prj, basis)\nfor _, cfg in pairs(prj.__configs) do\nbake.postprocess(prj, cfg)\nend\nend\nend\nfor sln in premake.solution.each() do\nfor prjIx, prj in ipairs(sln.projects) do\nif(not prj.usage) then\nfor cfgname, cfg in pairs(prj.__configs) do\nlocal usesPrjs = getprojectsconnections(cfg, cfgname);\ncopyusagedata(cfg, cfgname, usesPrjs)\nend\nend\nend\nend\nfor sln in premake.solution.each() do\nfor prjIx, prj in ipairs(sln.projects) do\nfor cfgName, cfg in pairs(prj.__configs) do\ncfg.build = true\nlocal removes = nil\nif cfg.removes ~= nil then\nremoves = cfg.removes[\"platforms\"];\nend\nif removes ~= nil then\nfor _,p in ipairs(removes) do\nif p == cfg.platform then\ncfg.build = false\nend\nend\nend\nend\nend\nend\nfor sln in premake.solution.each() do\nlocal removeList = {};\nfor index, prj in ipairs(sln.projects) do\nif(prj.usage) then\ntable.insert(removeList, 1, index); --Add in reverse order.\nend\nend\nfor " "_, index in ipairs(removeList) do\ntable.remove(sln.projects, index);\nend\nend\nbuilduniquedirs()\nbuildtargets(cfg)\nend\nfunction premake.bake.postprocess(prj, cfg)\ncfg.project = prj\ncfg.shortname = premake.getconfigname(cfg.name, cfg.platform, true)\ncfg.longname = premake.getconfigname(cfg.name, cfg.platform)\ncfg.location = cfg.location or cfg.basedir\nlocal platform = premake.platforms[cfg.platform]\nif platform.iscrosscompiler then\ncfg.system = cfg.platform\nelse\ncfg.system = os.get()\nend\nif cfg.kind == \"Bundle\"\nand _ACTION ~= \"gmake\"\nand (_ACTION ~= \"ninja\" and (not prj.options or not prj.options.SkipBundling))\nand not _ACTION:match(\"xcode[0-9]\") then\ncfg.kind = \"SharedLib\"\nend\nif cfg.kind == \"SharedLib\" and platform.nosharedlibs then\ncfg.kind = \"StaticLib\"\nend\nlocal removefiles = cfg.removefiles\nif _ACTION == 'gmake' or _ACTION == 'ninja' then\nremovefiles = table.join(removefiles, cfg.excludes)\nend\nlocal removefilesDict = {}\nfor _, fname in ipairs(removefiles) do" "\nremovefilesDict[fname] = true\nend\nlocal files = {}\nfor _, fname in ipairs(cfg.files) do\nif removefilesDict[fname] == nil then\ntable.insert(files, fname)\nend\nend\ncfg.files = files\nlocal allfiles = {}\nlocal allfilesDict = {}\nif cfg.allfiles ~= nil then\nfor _, fname in ipairs(cfg.allfiles) do\nif allfilesDict[fname] == nil then\nif removefilesDict[fname] == nil then\nallfilesDict[fname] = true\ntable.insert(allfiles, fname)\nend\nend\nend\nend\ncfg.allfiles = allfiles\nfor name, field in pairs(premake.fields) do\nif field.isflags then\nlocal values = cfg[name]\nfor _, flag in ipairs(values) do values[flag] = true end\nend\nend\nlocal cfgfields = {\n{\"__fileconfigs\", cfg.files},\n{\"__allfileconfigs\", cfg.allfiles},\n}\nfor _, cfgfield in ipairs(cfgfields) do\nlocal fieldname = cfgfield[1]\nlocal field = cfgfield[2]\ncfg[fieldname] = { }\nfor _, fname in ipairs(field) do\nlocal fcfg = {}\nif premake._filelevelconfig then\ncfg.terms.required = fname:lower()\nfor _, blk in ipairs(cfg.project." "blocks) do\nif (premake.iskeywordsmatch(blk.keywords, cfg.terms)) then\nmergeobject(fcfg, blk)\nend\nend\nend\nfcfg.name = fname\ncfg[fieldname][fname] = fcfg\ntable.insert(cfg[fieldname], fcfg)\nend\nend\nend\n", /* base/api.lua */ "premake.fields = {}\npremake.check_paths = false\nfunction premake.checkvalue(value, allowed)\nif (allowed) then\nif (type(allowed) == \"function\") then\nreturn allowed(value)\nelse\nfor _,v in ipairs(allowed) do\nif (value:lower() == v:lower()) then\nreturn v\nend\nend\nreturn nil, \"invalid value '\" .. value .. \"'\"\nend\nelse\nreturn value\nend\nend\nfunction premake.getobject(t)\nlocal container\nif (t == \"container\" or t == \"solution\") then\ncontainer = premake.CurrentContainer\nelse\ncontainer = premake.CurrentConfiguration\nend\nif t == \"solution\" then\nif typex(container) == \"project\" then\ncontainer = container.solution\nend\nif typex(container) ~= \"solution\" then\ncontainer = nil\nend\nend\nlocal msg\nif (not container) then\nif (t == \"container\") then\nmsg = \"no active solution or project\"\nelseif (t == \"solution\") then\nmsg = \"no active solution\"\nelse\nmsg = \"no active solution, project, or configuration\"\nend\nend\nreturn container, msg\nend\nfunction premake.setarray(obj, " "fieldname, value, allowed)\nobj[fieldname] = obj[fieldname] or {}\nlocal function add(value, depth)\nif type(value) == \"table\" then\nfor _,v in ipairs(value) do\nadd(v, depth + 1)\nend\nelse\nvalue, err = premake.checkvalue(value, allowed)\nif not value then\nerror(err, depth)\nend\ntable.insert(obj[fieldname], value)\nend\nend\nif value then\nadd(value, 5)\nend\nreturn obj[fieldname]\nend\nfunction premake.settable(obj, fieldname, value, allowed)\nobj[fieldname] = obj[fieldname] or {}\ntable.insert(obj[fieldname], value)\nreturn obj[fieldname]\nend\nlocal function domatchedarray(fields, value, matchfunc)\nlocal result = { }\nfunction makeabsolute(value, depth)\nif (type(value) == \"table\") then\nfor _, item in ipairs(value) do\nmakeabsolute(item, depth + 1)\nend\nelseif type(value) == \"string\" then\nif value:find(\"*\") then\nlocal arr = matchfunc(value);\nif (premake.check_paths) and (#arr == 0) then\nerror(\"Can't find matching files for pattern :\" .. value)\nend\nmakeabsolute(arr, depth + 1)\nelse\nt" "able.insert(result, path.getabsolute(value))\nend\nelse\nerror(\"Invalid value in list: expected string, got \" .. type(value), depth)\nend\nend\nmakeabsolute(value, 3)\nlocal retval = {}\nfor index, field in ipairs(fields) do\nlocal ctype = field[1]\nlocal fieldname = field[2]\nlocal array = premake.setarray(ctype, fieldname, result)\nif index == 1 then\nretval = array\nend\nend\nreturn retval\nend\nfunction premake.setdirarray(fields, value)\nreturn domatchedarray(fields, value, os.matchdirs)\nend\nfunction premake.setfilearray(fields, value)\nreturn domatchedarray(fields, value, os.matchfiles)\nend\nfunction premake.setkeyvalue(ctype, fieldname, values)\nlocal container, err = premake.getobject(ctype)\nif not container then\nerror(err, 4)\nend\nif not container[fieldname] then\ncontainer[fieldname] = {}\nend\nif type(values) ~= \"table\" then\nerror(\"invalid value; table expected\", 4)\nend\nlocal field = container[fieldname]\nfor key,value in pairs(values) do\nif not field[key] then\nfield[key] = {}\nend" "\ntable.insertflat(field[key], value)\nend\nreturn field\nend\nfunction premake.setstring(ctype, fieldname, value, allowed)\nlocal container, err = premake.getobject(ctype)\nif (not container) then\nerror(err, 4)\nend\nif (value) then\nvalue, err = premake.checkvalue(value, allowed)\nif (not value) then\nerror(err, 4)\nend\ncontainer[fieldname] = value\nend\nreturn container[fieldname]\nend\nfunction premake.remove(fieldname, value)\nlocal cfg = premake.CurrentConfiguration\ncfg.removes = cfg.removes or {}\ncfg.removes[fieldname] = premake.setarray(cfg.removes, fieldname, value)\nend\nlocal function accessor(name, value)\nlocal kind = premake.fields[name].kind\nlocal scope = premake.fields[name].scope\nlocal allowed = premake.fields[name].allowed\nif (kind == \"string\" or kind == \"path\") and value then\nif type(value) ~= \"string\" then\nerror(\"string value expected\", 3)\nend\nend\nlocal container, err = premake.getobject(scope)\nif (not container) then\nerror(err, 3)\nend\nif kind == \"string\" then" "\nreturn premake.setstring(scope, name, value, allowed)\nelseif kind == \"path\" then\nif value then value = path.getabsolute(value) end\nreturn premake.setstring(scope, name, value)\nelseif kind == \"list\" then\nreturn premake.setarray(container, name, value, allowed)\nelseif kind == \"table\" then\nreturn premake.settable(container, name, value, allowed)\nelseif kind == \"dirlist\" then\nreturn premake.setdirarray({{container, name}}, value)\nelseif kind == \"filelist\" or kind == \"absolutefilelist\" then\nlocal fields = {{container, name}}\nif name == \"files\" then\nlocal prj, err = premake.getobject(\"container\")\nif (not prj) then\nerror(err, 2)\nend\ntable.insert(fields, {prj.blocks[1], \"allfiles\"})\nend\nreturn premake.setfilearray(fields, value)\nelseif kind == \"keyvalue\" or kind == \"keypath\" then\nreturn premake.setkeyvalue(scope, name, value)\nend\nend\nfunction configuration(terms)\nif not terms then\nreturn premake.CurrentConfiguration\nend\nlocal container, err = premake.getobject(\"cont" "ainer\")\nif (not container) then\nerror(err, 2)\nend\nlocal cfg = { }\ncfg.terms = table.flatten({terms})\ntable.insert(container.blocks, cfg)\npremake.CurrentConfiguration = cfg\ncfg.keywords = { }\nfor _, word in ipairs(cfg.terms) do\ntable.insert(cfg.keywords, path.wildcards(word):lower())\nend\nfor name, field in pairs(premake.fields) do\nif (field.kind ~= \"string\" and field.kind ~= \"path\") then\ncfg[name] = { }\nend\nend\nreturn cfg\nend\nlocal function creategroup(name, sln, curpath, parent, inpath)\nlocal group = {}\nsetmetatable(group, {\n__type = \"group\"\n})\ntable.insert(sln.groups, group)\nsln.groups[inpath] = group\nif parent ~= nil then\ntable.insert(parent.groups, group)\nend\ngroup.solution = sln\ngroup.name = name\ngroup.uuid = os.uuid(curpath)\ngroup.parent = parent\ngroup.projects = { }\ngroup.groups = { }\nreturn group\nend\nlocal function creategroupsfrompath(inpath, sln)\nif inpath == nil then return nil end\ninpath = path.translate(inpath, \"/\")\nlocal groups = string.explode(inpa" "th, \"/\")\nlocal curpath = \"\"\nlocal lastgroup = nil\nfor i, v in ipairs(groups) do\ncurpath = curpath .. \"/\" .. v:lower()\nlocal group = sln.groups[curpath]\nif group == nil then\ngroup = creategroup(v, sln, curpath, lastgroup, curpath)\nend\nlastgroup = group\nend\nreturn lastgroup\nend\nlocal function createproject(name, sln, isUsage)\nlocal prj = {}\nsetmetatable(prj, {\n__type = \"project\",\n})\ntable.insert(sln.projects, prj)\nif(isUsage) then\nif(sln.projects[name]) then\nsln.projects[name].usageProj = prj;\nelse\nsln.projects[name] = prj\nend\nelse\nif(sln.projects[name]) then\nprj.usageProj = sln.projects[name];\nend\nsln.projects[name] = prj\nend\nlocal group = creategroupsfrompath(premake.CurrentGroup, sln)\nif group ~= nil then\ntable.insert(group.projects, prj)\nend\nprj.solution = sln\nprj.name = name\nprj.basedir = os.getcwd()\nprj.uuid = os.uuid(prj.name)\nprj.blocks = { }\nprj.usage = isUsage\nprj.group = group\nreturn prj;\nend" "\nfunction usage(name)\nif (not name) then\nif(typex(premake.CurrentContainer) ~= \"project\") then return nil end\nif(not premake.CurrentContainer.usage) then return nil end\nreturn premake.CurrentContainer\nend\nlocal sln\nif (typex(premake.CurrentContainer) == \"project\") then\nsln = premake.CurrentContainer.solution\nelse\nsln = premake.CurrentContainer\nend\nif (typex(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\nif((not sln.projects[name]) or\n((not sln.projects[name].usage) and (not sln.projects[name].usageProj))) then\npremake.CurrentContainer = createproject(name, sln, true)\nelse\npremake.CurrentContainer = iff(sln.projects[name].usage,\nsln.projects[name], sln.projects[name].usageProj)\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction project(name)\nif (not name) then\nif(typex(premake.CurrentContainer) ~= \"project\") then return nil end\nif(premake.CurrentContainer.usage) then return nil end\nreturn premake.CurrentContainer\nend\nlocal sln\nif (typex(pre" "make.CurrentContainer) == \"project\") then\nsln = premake.CurrentContainer.solution\nelse\nsln = premake.CurrentContainer\nend\nif (typex(sln) ~= \"solution\") then\nerror(\"no active solution\", 2)\nend\nif((not sln.projects[name]) or sln.projects[name].usage) then\npremake.CurrentContainer = createproject(name, sln)\nelse\npremake.CurrentContainer = sln.projects[name];\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction solution(name)\nif not name then\nif typex(premake.CurrentContainer) == \"project\" then\nreturn premake.CurrentContainer.solution\nelse\nreturn premake.CurrentContainer\nend\nend\npremake.CurrentContainer = premake.solution.get(name)\nif (not premake.CurrentContainer) then\npremake.CurrentContainer = premake.solution.new(name)\nend\nconfiguration { }\nreturn premake.CurrentContainer\nend\nfunction group(name)\nif not name then\nreturn premake.CurrentGroup\nend\npremake.CurrentGroup = name\nreturn premake.CurrentGroup\nend\nfunction importvsproject(location)\nif string.fi" "nd(_ACTION, \"vs\") ~= 1 then\nerror(\"Only available for visual studio actions\")\nend\nsln, err = premake.getobject(\"solution\")\nif not sln then\nerror(err)\nend\nlocal group = creategroupsfrompath(premake.CurrentGroup, sln)\nlocal project = {}\nproject.location = location\nproject.group = group\nproject.flags = {}\ntable.insert(sln.importedprojects, project)\n end\nfunction newaction(a)\npremake.action.add(a)\nend\nfunction newoption(opt)\npremake.option.add(opt)\nend\nfunction enablefilelevelconfig()\npremake._filelevelconfig = true\nend\nfunction newapifield(field)\npremake.fields[field.name] = field\n_G[field.name] = function(value)\nreturn accessor(field.name, value)\nend\nif field.kind == \"list\"\nor field.kind == \"dirlist\"\nor field.kind == \"filelist\"\nor field.kind == \"absolutefilelist\"\nthen\nif field.name ~= \"removefiles\"\nand field.name ~= \"files\" then\n_G[\"remove\"..field.name] = function(value)\npremake.remove(field.name, value)\nend\nend\nend\nend\nnewapifield {\nname = \"arc" "hivesplit_size\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"basedir\",\nkind = \"path\",\nscope = \"container\",\n}\nnewapifield {\nname = \"buildaction\",\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"Compile\",\n\"Copy\",\n\"Embed\",\n\"None\"\n}\n}\nnewapifield {\nname = \"buildoptions\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"buildoptions_asm\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"buildoptions_c\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"buildoptions_cpp\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"buildoptions_objc\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"buildoptions_objcpp\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"buildoptions_vala\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"clrreferences\",\nkind = \"list\",\nscope = \"container\",\n}\nnewapifield {\nname" " = \"configurations\",\nkind = \"list\",\nscope = \"solution\",\n}\nnewapifield {\nname = \"custombuildtask\",\nkind = \"table\",\nscope = \"config\",\n}\nnewapifield {\nname = \"debugcmd\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"debugargs\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"debugdir\",\nkind = \"path\",\nscope = \"config\",\n}\nnewapifield {\nname = \"debugenvs\" ,\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"defines\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"deploymentoptions\",\nkind = \"list\",\nscope = \"config\",\nusagecopy = true,\n}\nnewapifield {\nname = \"dependency\",\nkind = \"table\",\nscope = \"config\",\n}\nnewapifield {\nname = \"deploymode\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"excludes\",\nkind = \"filelist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"forcenative\",\nkind = \"filelist\",\nscope = \"config\",\n}\nnewapifield " "{\nname = \"nopch\",\nkind = \"filelist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"files\",\nkind = \"filelist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"removefiles\",\nkind = \"filelist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"flags\",\nkind = \"list\",\nscope = \"config\",\nisflags = true,\nusagecopy = true,\nallowed = function(value)\nlocal allowed_flags = {\nAntBuildDebuggable = 1,\nC7DebugInfo = 1,\nCpp11 = 1,\nCpp14 = 1,\nCpp17 = 1,\nCppLatest = 1,\nDebugEnvsDontMerge = 1,\nDebugEnvsInherit = 1,\nDeploymentContent = 1,\nEnableMinimalRebuild = 1,\nEnableSSE = 1,\nEnableSSE2 = 1,\nEnableAVX = 1,\nEnableAVX2 = 1,\nPedanticWarnings = 1,\nExtraWarnings = 1,\nFatalWarnings = 1,\nFloatFast = 1,\nFloatStrict = 1,\nFullSymbols = 1,\nGenerateMapFiles = 1,\nHotpatchable = 1,\nLinkSupportCircularDependencies = 1,\nManaged = 1,\nMinimumWarnings = 1,\nNativeWChar = 1,\nNo64BitChecks = 1,\nNoBufferSecurityCheck = 1,\nNoEditAndContinue = 1,\nNoExceptions = 1,\nNoFramePointer = 1,\nN" "oImportLib = 1,\nNoIncrementalLink = 1,\nNoJMC = 1,\nNoManifest = 1,\nNoMultiProcessorCompilation = 1,\nNoNativeWChar = 1,\nNoOptimizeLink = 1,\nNoPCH = 1,\nNoRTTI = 1,\nNoRuntimeChecks = 1,\nNoWinMD = 1, -- explicitly disables Windows Metadata\nNoWinRT = 1, -- explicitly disables Windows Runtime Extension\nFastCall = 1,\nStdCall = 1,\nSingleOutputDir = 1,\nObjcARC = 1,\nOptimize = 1,\nOptimizeSize = 1,\nOptimizeSpeed = 1,\nDebugRuntime = 1,\nReleaseRuntime = 1,\nSEH = 1,\nStaticRuntime = 1,\nSymbols = 1,\nUnicode = 1,\nUnitySupport = 1,\nUnsafe = 1,\nUnsignedChar = 1,\nUseFullPaths = 1,\nUseLDResponseFile = 1,\nUseObjectResponseFile = 1,\nWinMain = 1\n}\nlocal englishToAmericanSpelling =\n{\nnooptimiselink = 'nooptimizelink',\noptimise = 'optimize',\noptimisesize = 'optimizesize',\noptimisespeed = 'optimizespeed',\n}\nlocal lowervalue = value:lower()\nlowervalue = englishToAmericanSpelling[lowervalue] or lowervalue\nfor v, _ in pairs(allowed_flags) do\nif v:lower() == lowervalue then\nreturn v\nend\nend" "\nreturn nil, \"invalid flag\"\nend,\n}\nnewapifield {\nname = \"framework\",\nkind = \"string\",\nscope = \"container\",\nallowed = {\n\"1.0\",\n\"1.1\",\n\"2.0\",\n\"3.0\",\n\"3.5\",\n\"4.0\",\n\"4.5\",\n\"4.5.1\",\n\"4.5.2\",\n\"4.6\",\n\"4.6.1\",\n\"4.6.2\",\n}\n}\nnewapifield {\nname = \"iostargetplatformversion\",\nkind = \"string\",\nscope = \"project\",\n}\nnewapifield {\nname = \"macostargetplatformversion\",\nkind = \"string\",\nscope = \"project\",\n}\nnewapifield {\nname = \"tvostargetplatformversion\",\nkind = \"string\",\nscope = \"project\",\n}\nnewapifield {\nname = \"windowstargetplatformversion\",\nkind = \"string\",\nscope = \"project\",\n}\nnewapifield {\nname = \"windowstargetplatformminversion\",\nkind = \"string\",\nscope = \"project\",\n}\nnewapifield {\nname = \"forcedincludes\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"imagepath\",\nkind = \"path\",\nscope = \"config\",\n}\nnewapifield {\nname = \"imageoptions\",\nkind = \"list\",\nscope = \"co" "nfig\",\n}\nnewapifield {\nname = \"implibdir\",\nkind = \"path\",\nscope = \"config\",\n}\nnewapifield {\nname = \"implibextension\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"implibname\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"implibprefix\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"implibsuffix\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"includedirs\",\nkind = \"dirlist\",\nscope = \"config\",\nusagecopy = true,\n}\nnewapifield {\nname = \"systemincludedirs\",\nkind = \"dirlist\",\nscope = \"config\",\nusagecopy = true,\n}\nnewapifield {\nname = \"userincludedirs\",\nkind = \"dirlist\",\nscope = \"config\",\nusagecopy = true,\n}\nnewapifield {\nname = \"usingdirs\",\nkind = \"dirlist\",\nscope = \"config\",\nusagecopy = true,\n}\nnewapifield {\nname = \"kind\",\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"ConsoleApp\",\n\"WindowedApp\",\n\"StaticLib\",\n\"SharedLi" "b\",\n\"Bundle\",\n}\n}\nnewapifield {\nname = \"language\",\nkind = \"string\",\nscope = \"container\",\nallowed = {\n\"C\",\n\"C++\",\n\"C#\",\n\"Vala\",\n\"Swift\",\n}\n}\nnewapifield {\nname = \"libdirs\",\nkind = \"dirlist\",\nscope = \"config\",\nlinkagecopy = true,\n}\nnewapifield {\nname = \"linkoptions\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"links\",\nkind = \"list\",\nscope = \"config\",\nallowed = function(value)\nif value:find('/', nil, true) then\nvalue = path.getabsolute(value)\nend\nreturn value\nend,\nlinkagecopy = true,\nmergecopiestotail = true,\n}\nnewapifield {\nname = \"location\",\nkind = \"path\",\nscope = \"container\",\n}\nnewapifield {\nname = \"makesettings\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"messageskip\",\nkind = \"list\",\nscope = \"solution\",\nisflags = true,\nusagecopy = true,\nallowed = function(value)\nlocal allowed_messages = {\nSkipCreatingMessage = 1,\nSkipBuildingMessage = 1,\nSkipCleaningMessage" " = 1,\n}\nlocal lowervalue = value:lower()\nfor v, _ in pairs(allowed_messages) do\nif v:lower() == lowervalue then\nreturn v\nend\nend\nreturn nil, \"invalid message to skip\"\nend,\n}\nnewapifield {\nname = \"msgarchiving\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"msgcompile\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"msgprecompile\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"msgcompile_objc\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"msgresource\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"msglinking\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"objdir\",\nkind = \"path\",\nscope = \"config\",\n}\nnewapifield {\nname = \"options\",\nkind = \"list\",\nscope = \"container\",\nisflags = true,\nusagecopy = true,\nallowed = function(value)\nlocal allowed_options = {\nForceCPP = 1,\nArchiveSplit = 1,\nSkipBundling = 1,\nXcodeLibrarySch" "emes = 1,\nXcodeSchemeNoConfigs = 1,\n}\nlocal lowervalue = value:lower()\nfor v, _ in pairs(allowed_options) do\nif v:lower() == lowervalue then\nreturn v\nend\nend\nreturn nil, \"invalid option\"\nend,\n}\nnewapifield {\nname = \"pchheader\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"pchsource\",\nkind = \"path\",\nscope = \"config\",\n}\nnewapifield {\nname = \"platforms\",\nkind = \"list\",\nscope = \"solution\",\nallowed = table.keys(premake.platforms),\n}\nnewapifield {\nname = \"postbuildcommands\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"prebuildcommands\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"postcompiletasks\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"prelinkcommands\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"propertysheets\",\nkind = \"dirlist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"pullmappingfile\",\nkind = \"path\",\nscope = \"confi" "g\",\n}\nnewapifield {\nname = \"applicationdatadir\",\nkind = \"path\",\nscope = \"config\",\n}\nnewapifield {\nname = \"finalizemetasource\",\nkind = \"path\",\nscope = \"config\",\n}\nnewapifield {\nname = \"resdefines\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"resincludedirs\",\nkind = \"dirlist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"resoptions\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"sdkreferences\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"startproject\",\nkind = \"string\",\nscope = \"solution\",\n}\nnewapifield {\nname = \"targetdir\",\nkind = \"path\",\nscope = \"config\",\n}\nnewapifield {\nname = \"targetsubdir\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"targetextension\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"targetname\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"targetprefix\",\nkind = \"string" "\",\nscope = \"config\",\n}\nnewapifield {\nname = \"targetsuffix\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"trimpaths\",\nkind = \"dirlist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"uuid\",\nkind = \"string\",\nscope = \"container\",\nallowed = function(value)\nlocal ok = true\nif (#value ~= 36) then ok = false end\nfor i=1,36 do\nlocal ch = value:sub(i,i)\nif (not ch:find(\"[ABCDEFabcdef0123456789-]\")) then ok = false end\nend\nif (value:sub(9,9) ~= \"-\") then ok = false end\nif (value:sub(14,14) ~= \"-\") then ok = false end\nif (value:sub(19,19) ~= \"-\") then ok = false end\nif (value:sub(24,24) ~= \"-\") then ok = false end\nif (not ok) then\nreturn nil, \"invalid UUID\"\nend\nreturn value:upper()\nend\n}\nnewapifield {\nname = \"uses\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"vapidirs\",\nkind = \"dirlist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"vpaths\",\nkind = \"keypath\",\nscope = \"container\",\n}\nnewapifield" " {\nname = \"vsimportreferences\",\nkind = \"filelist\",\nscope = \"container\",\n}\nnewapifield {\nname = \"dpiawareness\",\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"None\",\n\"High\",\n\"HighPerMonitor\",\n}\n}\nnewapifield {\nname = \"xcodeprojectopts\",\nkind = \"table\",\nscope = \"config\",\n}\nnewapifield {\nname = \"xcodetargetopts\",\nkind = \"table\",\nscope = \"config\",\n}\nnewapifield {\nname = \"xcodescriptphases\",\nkind = \"table\",\nscope = \"config\",\n}\nnewapifield {\nname = \"xcodecopyresources\",\nkind = \"table\",\nscope = \"project\",\n}\nnewapifield {\nname = \"xcodecopyframeworks\",\nkind = \"filelist\",\nscope = \"project\",\n}\nnewapifield {\nname = \"wholearchive\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"swiftmodulemaps\",\nkind = \"filelist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"buildoptions_swift\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"linkoptions_swift\",\nkind = \"list\",\nsc" "ope = \"config\",\n}\nnewapifield {\nname = \"androidtargetapi\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"androidminapi\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"androidarch\",\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"armv7-a\",\n\"armv7-a-hard\",\n\"arm64-v8a\",\n\"x86\",\n\"x86_64\",\n}\n}\nnewapifield {\nname = \"androidndktoolchainversion\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"androidstltype\",\nkind = \"string\",\nscope = \"config\",\n}\nnewapifield {\nname = \"androidcppstandard\",\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"c++98\",\n\"c++11\",\n\"c++1y\",\n\"gnu++98\",\n\"gnu++11\",\n\"gnu++1y\",\n}\n}\nnewapifield {\nname = \"androidlinker\",\nkind = \"string\",\nscope = \"config\",\nallowed = {\n\"bfd\",\n\"gold\",\n}\n}\nnewapifield {\nname = \"androiddebugintentparams\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"antbuildjavasourcedirs\",\nkind = " "\"dirlist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"antbuildjardirs\",\nkind = \"dirlist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"antbuildjardependencies\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"antbuildnativelibdirs\",\nkind = \"dirlist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"antbuildnativelibdependencies\",\nkind = \"list\",\nscope = \"config\",\n}\nnewapifield {\nname = \"antbuildassetsdirs\",\nkind = \"dirlist\",\nscope = \"config\",\n}\nnewapifield {\nname = \"postsolutioncallbacks\",\nkind = \"list\",\nscope = \"solution\",\n}\nnewapifield {\nname = \"postprojectcallbacks\",\nkind = \"list\",\nscope = \"project\",\n}\n", /* base/cmdline.lua */ "newoption\n{\ntrigger = \"cc\",\nvalue = \"VALUE\",\ndescription = \"Choose a C/C++ compiler set\",\nallowed = {\n{ \"gcc\", \"GNU GCC (gcc/g++)\" },\n{ \"ow\", \"OpenWatcom\" },\n{ \"ghs\", \"Green Hills Software\" },\n}\n}\nnewoption\n{\ntrigger = \"dotnet\",\nvalue = \"VALUE\",\ndescription = \"Choose a .NET compiler set\",\nallowed = {\n{ \"msnet\", \"Microsoft .NET (csc)\" },\n{ \"mono\", \"Novell Mono (mcs)\" },\n{ \"pnet\", \"Portable.NET (cscc)\" },\n}\n}\nnewoption\n{\ntrigger = \"file\",\nvalue = \"FILE\",\ndescription = \"Read FILE as a Premake script; default is 'premake4.lua'\"\n}\nnewoption\n{\ntrigger = \"help\",\ndescription = \"Display this information\"\n}\nnewoption\n{\ntrigger = \"os\",\nvalue = \"VALUE\",\ndescription = \"Generate files for a different operating system\",\nallowed = {\n{ \"bsd\", \"OpenBSD, NetBSD, or FreeBSD\" },\n{ \"linux\", \"Linux\" },\n{ \"macosx\", \"Apple Mac OS X\" },\n{ \"solaris\", \"Sola" "ris\" },\n{ \"windows\", \"Microsoft Windows\" },\n}\n}\nnewoption\n{\ntrigger = \"platform\",\nvalue = \"VALUE\",\ndescription = \"Add target architecture (if supported by action)\",\nallowed = {\n{ \"x32\", \"32-bit\" },\n{ \"x64\", \"64-bit\" },\n{ \"universal\", \"Mac OS X Universal, 32- and 64-bit\" },\n{ \"universal32\", \"Mac OS X Universal, 32-bit only\" },\n{ \"universal64\", \"Mac OS X Universal, 64-bit only\" },\n{ \"ps3\", \"Playstation 3\" },\n{ \"orbis\", \"Playstation 4\" },\n{ \"xbox360\", \"Xbox 360\" },\n{ \"durango\", \"Xbox One\" },\n{ \"ARM\", \"ARM\" },\n{ \"ARM64\", \"ARM64\" },\n{ \"PowerPC\", \"PowerPC\" },\n{ \"nx32\", \"Nintendo Switch, 32-bit only\" },\n{ \"nx64\", \"Nintendo Switch, 64-bit only\" },\n}\n}\nnewoption\n{\ntrigger = \"scripts\",\nvalue = \"path\",\ndescription = \"Search for additional scripts on the given path\"\n}\nnewoption\n{\ntrigger = \"debug-profiler\",\ndescripti" "on = \"GENie script generation profiler.\"\n}\nnewoption\n{\ntrigger = \"version\",\ndescription = \"Display version information\"\n}\n", /* base/inspect.lua */ "-- Copyright (c) 2013 Enrique García Cota\nlocal function smartQuote(str)\n if str:match('\"') and not str:match(\"'\") then\n return \"'\" .. str .. \"'\"\n end\n return '\"' .. str:gsub('\"', '\\\\\"') .. '\"'\nend\nlocal controlCharsTranslation = {\n [\"\\a\"] = \"\\\\a\", [\"\\b\"] = \"\\\\b\", [\"\\f\"] = \"\\\\f\", [\"\\n\"] = \"\\\\n\",\n [\"\\r\"] = \"\\\\r\", [\"\\t\"] = \"\\\\t\", [\"\\v\"] = \"\\\\v\"\n}\nlocal function escapeChar(c) return controlCharsTranslation[c] end\nlocal function escape(str)\n local result = str:gsub(\"\\\\\", \"\\\\\\\\\"):gsub(\"(%c)\", escapeChar)\n return result\nend\nlocal function isIdentifier(str)\n return type(str) == 'string' and str:match( \"^[_%a][_%a%d]*$\" )\nend\nlocal function isArrayKey(k, length)\n return type(k) == 'number' and 1 <= k and k <= length\nend\nlocal function isDictionaryKey(k, length)\n return not isArrayKey(k, length)\nend\nlocal defaultTypeOrders = {\n ['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4,\n ['fu" "nction'] = 5, ['userdata'] = 6, ['thread'] = 7\n}\nlocal function sortKeys(a, b)\n local ta, tb = type(a), type(b)\n -- strings and numbers are sorted numerically/alphabetically\n if ta == tb and (ta == 'string' or ta == 'number') then return a < b end\n local dta, dtb = defaultTypeOrders[ta], defaultTypeOrders[tb]\n -- Two default types are compared according to the defaultTypeOrders table\n if dta and dtb then return defaultTypeOrders[ta] < defaultTypeOrders[tb]\n elseif dta then return true -- default types before custom ones\n elseif dtb then return false -- custom types after default ones\n end\n -- custom types are sorted out alphabetically\n return ta < tb\nend\nlocal function getDictionaryKeys(t)\n local keys, length = {}, #t\n for k,_ in pairs(t) do\n if isDictionaryKey(k, length) then table.insert(keys, k) end\n end\n table.sort(keys, sortKeys)\n return keys\nend\nlocal function getToStringResultSafely(t, mt)\n local __tostring = type(mt) == 'table' and rawget(mt, '__tost" "ring')\n local str, ok\n if type(__tostring) == 'function' then\n ok, str = pcall(__tostring, t)\n str = ok and str or 'error: ' .. tostring(str)\n end\n if type(str) == 'string' and #str > 0 then return str end\nend\nlocal maxIdsMetaTable = {\n __index = function(self, typeName)\n rawset(self, typeName, 0)\n return 0\n end\n}\nlocal idsMetaTable = {\n __index = function (self, typeName)\n local col = setmetatable({}, {__mode = \"kv\"})\n rawset(self, typeName, col)\n return col\n end\n}\nlocal function countTableAppearances(t, tableAppearances)\n tableAppearances = tableAppearances or setmetatable({}, {__mode = \"k\"})\n if type(t) == 'table' then\n if not tableAppearances[t] then\n tableAppearances[t] = 1\n for k,v in pairs(t) do\n countTableAppearances(k, tableAppearances)\n countTableAppearances(v, tableAppearances)\n end\n countTableAppearances(getmetatable(t), tableAppearances)\n else\n tableAppearances[t] = tableAppearances[t] +" " 1\n end\n end\n return tableAppearances\nend\nlocal function parse_filter(filter)\n if type(filter) == 'function' then return filter end\n -- not a function, so it must be a table or table-like\n filter = type(filter) == 'table' and filter or {filter}\n local dictionary = {}\n for _,v in pairs(filter) do dictionary[v] = true end\n return function(x) return dictionary[x] end\nend\nlocal function makePath(path, key)\n local newPath, len = {}, #path\n for i=1, len do newPath[i] = path[i] end\n newPath[len+1] = key\n return newPath\nend\nfunction inspect(rootObject, options)\n options = options or {}\n local depth = options.depth or math.huge\n local filter = parse_filter(options.filter or {})\n local tableAppearances = countTableAppearances(rootObject)\n local buffer = {}\n local maxIds = setmetatable({}, maxIdsMetaTable)\n local ids = setmetatable({}, idsMetaTable)\n local level = 0\n local blen = 0 -- buffer length\n local function puts(...)\n local args = {...}\n " "for i=1, #args do\n blen = blen + 1\n buffer[blen] = tostring(args[i])\n end\n end\n local function down(f)\n level = level + 1\n f()\n level = level - 1\n end\n local function tabify()\n puts(\"\\n\", string.rep(\" \", level))\n end\n local function commaControl(needsComma)\n if needsComma then puts(',') end\n return true\n end\n local function alreadyVisited(v)\n return ids[type(v)][v] ~= nil\n end\n local function getId(v)\n local tv = type(v)\n local id = ids[tv][v]\n if not id then\n id = maxIds[tv] + 1\n maxIds[tv] = id\n ids[tv][v] = id\n end\n return id\n end\n local putValue -- forward declaration that needs to go before putTable & putKey\n local function putKey(k)\n if isIdentifier(k) then return puts(k) end\n puts( \"[\" )\n putValue(k, {})\n puts(\"]\")\n end\n local function putTable(t, path)\n if alreadyVisited(t) then\n puts('<table ', getId(t), '>')\n elseif level >= depth then\n " "puts('{...}')\n else\n if tableAppearances[t] > 1 then puts('<', getId(t), '>') end\n local dictKeys = getDictionaryKeys(t)\n local length = #t\n local mt = getmetatable(t)\n local to_string_result = getToStringResultSafely(t, mt)\n puts('{')\n down(function()\n if to_string_result then\n puts(' -- ', escape(to_string_result))\n if length >= 1 then tabify() end -- tabify the array values\n end\n local needsComma = false\n for i=1, length do\n needsComma = commaControl(needsComma)\n puts(' ')\n putValue(t[i], makePath(path, i))\n end\n for _,k in ipairs(dictKeys) do\n needsComma = commaControl(needsComma)\n tabify()\n putKey(k)\n puts(' = ')\n putValue(t[k], makePath(path, k))\n end\n if mt then\n needsComma = commaControl(needsComma)\n tabify()\n puts('<metatable> = '" ")\n putValue(mt, makePath(path, '<metatable>'))\n end\n end)\n if #dictKeys > 0 or mt then -- dictionary table. Justify closing }\n tabify()\n elseif length > 0 then -- array tables have one extra space before closing }\n puts(' ')\n end\n puts('}')\n end\n end\n -- putvalue is forward-declared before putTable & putKey\n putValue = function(v, path)\n if filter(v, path) then\n puts('<filtered>')\n else\n local tv = type(v)\n if tv == 'string' then\n puts(smartQuote(escape(v)))\n elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then\n puts(tostring(v))\n elseif tv == 'table' then\n putTable(v, path)\n else\n puts('<',tv,' ',getId(v),'>')\n end\n end\n end\n putValue(rootObject, {})\n return table.concat(buffer)\nend\nfunction printtable(name, table)\nprint(\"table: \", name, inspect(table), \"\\n\")\nend\nfunction printstack()\nprint(debug.traceback(), \"\\n\")\nend\n", /* base/profiler.lua */ "_profiler = {}\nfunction newProfiler(variant, sampledelay)\nif _profiler.running then\nprint(\"Profiler already running.\")\nreturn\nend\nvariant = variant or \"time\"\nif variant ~= \"time\" and variant ~= \"call\" then\nprint(\"Profiler method must be 'time' or 'call'.\")\nreturn\nend\nlocal newprof = {}\nfor k,v in pairs(_profiler) do\nnewprof[k] = v\nend\nnewprof.variant = variant\nnewprof.sampledelay = sampledelay or 100000\nreturn newprof\nend\nfunction _profiler.start(self)\nif _profiler.running then\nreturn\nend\n_profiler.running = self\nself.rawstats = {}\nself.callstack = {}\nif self.variant == \"time\" then\nself.lastclock = os.clock()\ndebug.sethook( _profiler_hook_wrapper_by_time, \"\", self.sampledelay )\nelseif self.variant == \"call\" then\ndebug.sethook( _profiler_hook_wrapper_by_call, \"cr\" )\nelse\nprint(\"Profiler method must be 'time' or 'call'.\")\nsys.exit(1)\nend\nend\nfunction _profiler.stop(self)\nif _profiler.running ~= self then\nreturn\nend\ndebug.sethook( nil )\n_profiler.runnin" "g = nil\nend\nfunction _profiler_hook_wrapper_by_call(action)\nif _profiler.running == nil then\ndebug.sethook( nil )\nend\n_profiler.running:_internal_profile_by_call(action)\nend\nfunction _profiler_hook_wrapper_by_time(action)\nif _profiler.running == nil then\ndebug.sethook( nil )\nend\n_profiler.running:_internal_profile_by_time(action)\nend\nfunction _profiler._internal_profile_by_call(self,action)\nlocal caller_info = debug.getinfo( 3 )\nif caller_info == nil then\nprint \"No caller_info\"\nreturn\nend\nlocal latest_ar = nil\nif table.getn(self.callstack) > 0 then\nlatest_ar = self.callstack[table.getn(self.callstack)]\nend\nlocal should_not_profile = 0\nfor k,v in pairs(self.prevented_functions) do\nif k == caller_info.func then\nshould_not_profile = v\nend\nend\nif latest_ar then\nif latest_ar.should_not_profile == 2 then\nshould_not_profile = 2\nend\nend\nif action == \"call\" then\nlocal this_ar = {}\nthis_ar.should_not_profile = should_not_profile\nthis_ar.parent_ar = latest_ar\nthis_ar.anon_child " "= 0\nthis_ar.name_child = 0\nthis_ar.children = {}\nthis_ar.children_time = {}\nthis_ar.clock_start = os.clock()\ntable.insert( self.callstack, this_ar )\nelse\nlocal this_ar = latest_ar\nif this_ar == nil then\nreturn -- No point in doing anything if no upper activation record\nend\nthis_ar.clock_end = os.clock()\nthis_ar.this_time = this_ar.clock_end - this_ar.clock_start\nif this_ar.parent_ar then\nthis_ar.parent_ar.children[caller_info.func] =\n(this_ar.parent_ar.children[caller_info.func] or 0) + 1\nthis_ar.parent_ar.children_time[caller_info.func] =\n(this_ar.parent_ar.children_time[caller_info.func] or 0 ) +\nthis_ar.this_time\nif caller_info.name == nil then\nthis_ar.parent_ar.anon_child =\nthis_ar.parent_ar.anon_child + this_ar.this_time\nelse\nthis_ar.parent_ar.name_child =\nthis_ar.parent_ar.name_child + this_ar.this_time\nend\nend\nif this_ar.should_not_profile == 0 then\nlocal inforec = self:_get_func_rec(caller_info.func,1)\ninforec.count = inforec.count + 1\ninforec.time = inforec.time + this_ar" ".this_time\ninforec.anon_child_time = inforec.anon_child_time + this_ar.anon_child\ninforec.name_child_time = inforec.name_child_time + this_ar.name_child\ninforec.func_info = caller_info\nfor k,v in pairs(this_ar.children) do\ninforec.children[k] = (inforec.children[k] or 0) + v\ninforec.children_time[k] =\n(inforec.children_time[k] or 0) + this_ar.children_time[k]\nend\nend\ntable.remove( self.callstack, table.getn( self.callstack ) )\nend\nend\nfunction _profiler._internal_profile_by_time(self,action)\nlocal timetaken = os.clock() - self.lastclock\nlocal depth = 3\nlocal at_top = true\nlocal last_caller\nlocal caller = debug.getinfo(depth)\nwhile caller do\nif not caller.func then caller.func = \"(tail call)\" end\nif self.prevented_functions[caller.func] == nil then\nlocal info = self:_get_func_rec(caller.func, 1, caller)\ninfo.count = info.count + 1\ninfo.time = info.time + timetaken\nif last_caller then\nif last_caller.name then\ninfo.name_child_time = info.name_child_time + timetaken\nelse\ninfo.anon_ch" "ild_time = info.anon_child_time + timetaken\nend\ninfo.children[last_caller.func] =\n(info.children[last_caller.func] or 0) + 1\ninfo.children_time[last_caller.func] =\n(info.children_time[last_caller.func] or 0) + timetaken\nend\nend\ndepth = depth + 1\nlast_caller = caller\ncaller = debug.getinfo(depth)\nend\nself.lastclock = os.clock()\nend\nfunction _profiler._get_func_rec(self,func,force,info)\nlocal ret = self.rawstats[func]\nif ret == nil and force ~= 1 then\nreturn nil\nend\nif ret == nil then\nret = {}\nret.func = func\nret.count = 0\nret.time = 0\nret.anon_child_time = 0\nret.name_child_time = 0\nret.children = {}\nret.children_time = {}\nret.func_info = info\nself.rawstats[func] = ret\nend\nreturn ret\nend\nfunction _profiler.report( self, outfile, sort_by_total_time )\noutfile:write\n[[Lua Profile output created by profiler.lua. Copyright Pepperfish 2002+\n]]\nlocal terms = {}\nif self.variant == \"time\" then\nterms.capitalized = \"Sample\"\nterms.single = \"sample\"\nterms.pastverb = \"sampled\"" "\nelseif self.variant == \"call\" then\nterms.capitalized = \"Call\"\nterms.single = \"call\"\nterms.pastverb = \"called\"\nelse\nassert(false)\nend\nlocal total_time = 0\nlocal ordering = {}\nfor func,record in pairs(self.rawstats) do\ntable.insert(ordering, func)\nend\nif sort_by_total_time then\ntable.sort( ordering,\nfunction(a,b) return self.rawstats[a].time > self.rawstats[b].time end\n)\nelse\ntable.sort( ordering,\nfunction(a,b)\nlocal arec = self.rawstats[a]\nlocal brec = self.rawstats[b]\nlocal atime = arec.time - (arec.anon_child_time + arec.name_child_time)\nlocal btime = brec.time - (brec.anon_child_time + brec.name_child_time)\nreturn atime > btime\nend\n)\nend\nfor i=1,#ordering do\nlocal func = ordering[i]\nlocal record = self.rawstats[func]\nlocal thisfuncname = \" \" .. self:_pretty_name(func) .. \" \"\nif string.len( thisfuncname ) < 42 then\nthisfuncname = string.rep( \"-\", math.floor((42 - string.len(thisfuncname))/2) ) .. thisfuncname\nthisfuncname = thisfuncname .. string.rep( \"-\", 42" " - string.len(thisfuncname) )\nend\ntotal_time = total_time + ( record.time - ( record.anon_child_time +\nrecord.name_child_time ) )\noutfile:write( string.rep( \"-\", 19 ) .. thisfuncname ..\nstring.rep( \"-\", 19 ) .. \"\\n\" )\noutfile:write( terms.capitalized..\" count: \" ..\nstring.format( \"%4d\", record.count ) .. \"\\n\" )\noutfile:write( \"Time spend total: \" ..\nstring.format( \"%4.3f\", record.time ) .. \"s\\n\" )\noutfile:write( \"Time spent in children: \" ..\nstring.format(\"%4.3f\",record.anon_child_time+record.name_child_time) ..\n\"s\\n\" )\nlocal timeinself =\nrecord.time - (record.anon_child_time + record.name_child_time)\noutfile:write( \"Time spent in self: \" ..\nstring.format(\"%4.3f\", timeinself) .. \"s\\n\" )\noutfile:write( \"Time spent per \" .. terms.single .. \": \" ..\nstring.format(\"%4.5f\", record.time/record.count) ..\n\"s/\" .. terms.single .. \"\\n\" )\noutfile:write( \"Time spent in self per \"..terms.single..\": \" ..\nstring.format( \"%4.5f\", timein" "self/record.count ) .. \"s/\" ..\nterms.single..\"\\n\" )\nlocal added_blank = 0\nfor k,v in pairs(record.children) do\nif self.prevented_functions[k] == nil or\nself.prevented_functions[k] == 0\nthen\nif added_blank == 0 then\noutfile:write( \"\\n\" ) -- extra separation line\nadded_blank = 1\nend\noutfile:write( \"Child \" .. self:_pretty_name(k) ..\nstring.rep( \" \", 41-string.len(self:_pretty_name(k)) ) .. \" \" ..\nterms.pastverb..\" \" .. string.format(\"%6d\", v) )\noutfile:write( \" times. Took \" ..\nstring.format(\"%4.2f\", record.children_time[k] ) .. \"s\\n\" )\nend\nend\noutfile:write( \"\\n\" ) -- extra separation line\noutfile:flush()\nend\noutfile:write( \"\\n\\n\" )\noutfile:write( \"Total time spent in profiled functions: \" ..\nstring.format(\"%5.3g\",total_time) .. \"s\\n\" )\noutfile:write( [[\nEND\n]] )\noutfile:flush()\nend\nfunction _profiler.lua_report(self,outfile)\nlocal ordering = {}\nlocal functonum = {}\nfor func,record in pairs(self.rawstats) do\ntable.insert(ordering, func)\nfu" "nctonum[func] = table.getn(ordering)\nend\noutfile:write(\n\"-- Profile generated by profiler.lua Copyright Pepperfish 2002+\\n\\n\" )\noutfile:write( \"-- Function names\\nfuncnames = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\noutfile:write( \"funcnames[\" .. i .. \"] = \" ..\nstring.format(\"%q\", self:_pretty_name(thisfunc)) .. \"\\n\" )\nend\noutfile:write( \"\\n\" )\noutfile:write( \"-- Function times\\nfunctimes = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\nlocal record = self.rawstats[thisfunc]\noutfile:write( \"functimes[\" .. i .. \"] = { \" )\noutfile:write( \"tot=\" .. record.time .. \", \" )\noutfile:write( \"achild=\" .. record.anon_child_time .. \", \" )\noutfile:write( \"nchild=\" .. record.name_child_time .. \", \" )\noutfile:write( \"count=\" .. record.count .. \" }\\n\" )\nend\noutfile:write( \"\\n\" )\noutfile:write( \"-- Child links\\nchildren = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\nlocal record" " = self.rawstats[thisfunc]\noutfile:write( \"children[\" .. i .. \"] = { \" )\nfor k,v in pairs(record.children) do\nif functonum[k] then -- non-recorded functions will be ignored now\noutfile:write( functonum[k] .. \", \" )\nend\nend\noutfile:write( \"}\\n\" )\nend\noutfile:write( \"\\n\" )\noutfile:write( \"-- Child call counts\\nchildcounts = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\nlocal record = self.rawstats[thisfunc]\noutfile:write( \"children[\" .. i .. \"] = { \" )\nfor k,v in record.children do\nif functonum[k] then -- non-recorded functions will be ignored now\noutfile:write( v .. \", \" )\nend\nend\noutfile:write( \"}\\n\" )\nend\noutfile:write( \"\\n\" )\noutfile:write( \"-- Child call time\\nchildtimes = {}\\n\" )\nfor i=1,table.getn(ordering) do\nlocal thisfunc = ordering[i]\nlocal record = self.rawstats[thisfunc];\noutfile:write( \"children[\" .. i .. \"] = { \" )\nfor k,v in pairs(record.children) do\nif functonum[k] then -- non-recorded functions will be ignor" "ed now\noutfile:write( record.children_time[k] .. \", \" )\nend\nend\noutfile:write( \"}\\n\" )\nend\noutfile:write( \"\\n\\n-- That is all.\\n\\n\" )\noutfile:flush()\nend\nfunction _profiler._pretty_name(self,func)\nlocal info = self.rawstats[ func ].func_info\nlocal name = \"\"\nif info.what == \"Lua\" then\nname = \"L:\"\nend\nif info.what == \"C\" then\nname = \"C:\"\nend\nif info.what == \"main\" then\nname = \" :\"\nend\nif info.name == nil then\nname = name .. \"<\"..tostring(func) .. \">\"\nelse\nname = name .. info.name\nend\nif info.source then\nname = name\nelse\nif info.what == \"C\" then\nname = name .. \"@?\"\nelse\nname = name .. \"@<string>\"\nend\nend\nname = name .. \":\"\nif info.what == \"C\" then\nname = name .. \"?\"\nelse\nname = name .. info.linedefined\nend\nreturn name\nend\nfunction _profiler.prevent(self, func, level)\nself.prevented_functions[func] = (level or 1)\nend\n_profiler.prevented_functions = {\n[_profiler.start] = 2,\n[_profiler.stop] = 2,\n[_profiler._internal_profile_by" "_time] = 2,\n[_profiler._internal_profile_by_call] = 2,\n[_profiler_hook_wrapper_by_time] = 2,\n[_profiler_hook_wrapper_by_call] = 2,\n[_profiler.prevent] = 2,\n[_profiler._get_func_rec] = 2,\n[_profiler.report] = 2,\n[_profiler.lua_report] = 2,\n[_profiler._pretty_name] = 2\n}\n", /* tools/dotnet.lua */ "premake.dotnet = { }\npremake.dotnet.namestyle = \"windows\"\nlocal flags =\n{\nFatalWarning = \"/warnaserror\",\nOptimize = \"/optimize\",\nOptimizeSize = \"/optimize\",\nOptimizeSpeed = \"/optimize\",\nSymbols = \"/debug\",\nUnsafe = \"/unsafe\"\n}\nfunction premake.dotnet.getbuildaction(fcfg)\nlocal ext = path.getextension(fcfg.name):lower()\nif fcfg.buildaction == \"Compile\" or ext == \".cs\" then\nreturn \"Compile\"\nelseif fcfg.buildaction == \"Embed\" or ext == \".resx\" then\nreturn \"EmbeddedResource\"\nelseif fcfg.buildaction == \"Copy\" or ext == \".asax\" or ext == \".aspx\" then\nreturn \"Content\"\nelse\nreturn \"None\"\nend\nend\nfunction premake.dotnet.getcompilervar(cfg)\nif (_OPTIONS.dotnet == \"msnet\") then\nreturn \"csc\"\nelseif (_OPTIONS.dotnet == \"mono\") then\nreturn \"mcs\"\nelse\nreturn \"cscc\"\nend\nend\nfunction premake.dotnet.getflags(cfg)\nlocal result = table.translate(cfg.flags, flags)\nreturn result\nend\nfunction premake.dotnet.getkind(cfg)\nif (c" "fg.kind == \"ConsoleApp\") then\nreturn \"Exe\"\nelseif (cfg.kind == \"WindowedApp\") then\nreturn \"WinExe\"\nelseif (cfg.kind == \"SharedLib\") then\nreturn \"Library\"\nend\nend\n", /* tools/gcc.lua */ "premake.gcc = { }\npremake.gcc.cc = \"gcc\"\npremake.gcc.cxx = \"g++\"\npremake.gcc.ar = \"ar\"\npremake.gcc.rc = \"windres\"\npremake.gcc.llvm = false\nlocal cflags =\n{\nEnableSSE = \"-msse\",\nEnableSSE2 = \"-msse2\",\nEnableAVX = \"-mavx\",\nEnableAVX2 = \"-mavx2\",\nPedanticWarnings = \"-Wall -Wextra -pedantic\",\nExtraWarnings = \"-Wall -Wextra\",\nFatalWarnings = \"-Werror\",\nFloatFast = \"-ffast-math\",\nFloatStrict = \"-ffloat-store\",\nNoFramePointer = \"-fomit-frame-pointer\",\nOptimize = \"-O2\",\nOptimizeSize = \"-Os\",\nOptimizeSpeed = \"-O3\",\nSymbols = \"-g\",\n}\nlocal cxxflags =\n{\nCpp11 = \"-std=c++11\",\nCpp14 = \"-std=c++14\",\nCpp17 = \"-std=c++17\",\nCppLatest = \"-std=c++2a\",\nNoExceptions = \"-fno-exceptions\",\nNoRTTI = \"-fno-rtti\",\nUnsignedChar = \"-funsigned-char\",\n}\nlocal objcflags =\n{\nObjcARC = \"-fobjc-arc\",\n}\npremake.gcc.platforms =\n{\nNative = {\n" "cppflags = \"-MMD -MP\",\n},\nx32 = {\ncppflags = \"-MMD -MP\",\nflags = \"-m32\",\n},\nx64 = {\ncppflags = \"-MMD -MP\",\nflags = \"-m64\",\n},\nUniversal = {\nar = \"libtool\",\ncppflags = \"-MMD -MP\",\nflags = \"-arch i386 -arch x86_64 -arch ppc -arch ppc64\",\n},\nUniversal32 = {\nar = \"libtool\",\ncppflags = \"-MMD -MP\",\nflags = \"-arch i386 -arch ppc\",\n},\nUniversal64 = {\nar = \"libtool\",\ncppflags = \"-MMD -MP\",\nflags = \"-arch x86_64 -arch ppc64\",\n},\nPS3 = {\ncc = \"ppu-lv2-g++\",\ncxx = \"ppu-lv2-g++\",\nar = \"ppu-lv2-ar\",\ncppflags = \"-MMD -MP\",\n},\nWiiDev = {\ncppflags = \"-MMD -MP -I$(LIBOGC_INC) $(MACHDEP)\",\nldflags= \"-L$(LIBOGC_LIB) $(MACHDEP)\",\ncfgsettings = [[\n ifeq ($(strip $(DEVKITPPC)),)\n $(error \"DEVKITPPC environment variable is not set\")'\n endif\n include $(DEVKITPPC)/wii_rules']],\n},\nOrbis = {\ncc = \"orbis-clang\",\ncxx = \"orbis-clang++\",\nar = \"orbis-ar\",\ncppflag" "s = \"-MMD -MP\",\n},\nEmscripten = {\ncc = \"$(EMSCRIPTEN)/emcc\",\ncxx = \"$(EMSCRIPTEN)/em++\",\nar = \"$(EMSCRIPTEN)/emar\",\ncppflags = \"-MMD -MP\",\n},\nNX32 = {\ncc = \"clang\",\ncxx = \"clang++\",\nar = \"armv7l-nintendo-nx-eabihf-ar\",\ncppflags = \"-MMD -MP\",\nflags = \"-march=armv7l\",\n},\nNX64 = {\ncc = \"clang\",\ncxx = \"clang++\",\nar = \"aarch64-nintendo-nx-elf-ar\",\ncppflags = \"-MMD -MP\",\nflags = \"-march=aarch64\",\n},\n}\nlocal platforms = premake.gcc.platforms\nfunction premake.gcc.getcppflags(cfg)\nlocal flags = { }\ntable.insert(flags, platforms[cfg.platform].cppflags)\nif flags[1]:startswith(\"-MMD\") then\ntable.insert(flags, \"-MP\")\nend\nreturn flags\nend\nfunction premake.gcc.getcflags(cfg)\nlocal result = table.translate(cfg.flags, cflags)\ntable.insert(result, platforms[cfg.platform].flags)\nif cfg.system ~= \"windows\" and cfg.kind == \"SharedLib\" then\ntable.insert(result, \"-fPIC\")\n" "end\nreturn result\nend\nfunction premake.gcc.getcxxflags(cfg)\nlocal result = table.translate(cfg.flags, cxxflags)\nreturn result\nend\nfunction premake.gcc.getobjcflags(cfg)\nreturn table.translate(cfg.flags, objcflags)\nend\nfunction premake.gcc.getldflags(cfg)\nlocal result = { }\nif not cfg.flags.Symbols then\nif cfg.system == \"macosx\" then\nelse\ntable.insert(result, \"-s\")\nend\nend\nif cfg.kind == \"Bundle\" then\ntable.insert(result, \"-bundle\")\nend\nif cfg.kind == \"SharedLib\" then\nif cfg.system == \"macosx\" then\ntable.insert(result, \"-dynamiclib\")\nelse\ntable.insert(result, \"-shared\")\nend\nif cfg.system == \"windows\" and not cfg.flags.NoImportLib then\ntable.insert(result, '-Wl,--out-implib=\"' .. cfg.linktarget.fullpath .. '\"')\nend\nend\nif cfg.kind == \"WindowedApp\" and cfg.system == \"windows\" then\ntable.insert(result, \"-mwindows\")\nend\nlocal platform = platforms[cfg.platform]\ntable.insert(result, platform.flags)\ntable.insert(result, platform.ldflags)\nreturn result\nend" "\nfunction premake.gcc.getlibdirflags(cfg)\nlocal result = { }\nfor _, value in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\ntable.insert(result, '-L\\\"' .. value .. '\\\"')\nend\nreturn result\nend\nfunction premake.gcc.islibfile(p)\nif path.getextension(p) == \".a\" then\nreturn true\nend\nreturn false\nend\nfunction premake.gcc.getlibfiles(cfg)\nlocal result = {}\nfor _, value in ipairs(premake.getlinks(cfg, \"system\", \"fullpath\")) do\nif premake.gcc.islibfile(value) then\ntable.insert(result, _MAKE.esc(value))\nend\nend\nreturn result\nend\nfunction premake.gcc.getlinkflags(cfg)\nlocal result = {}\nfor _, value in ipairs(premake.getlinks(cfg, \"system\", \"fullpath\")) do\nif premake.gcc.islibfile(value) then\nvalue = path.rebase(value, cfg.project.location, cfg.location)\ntable.insert(result, _MAKE.esc(value))\nelseif path.getextension(value) == \".framework\" then\ntable.insert(result, '-framework ' .. _MAKE.esc(path.getbasename(value)))\nelse\ntable.insert(result, '-l' .. _MAKE.esc(path" ".getname(value)))\nend\nend\nreturn result\nend\nfunction premake.gcc.wholearchive(lib)\nif premake.gcc.llvm then\nreturn {\"-force_load\", lib}\nelseif os.get() == \"macosx\" then\nreturn {\"-Wl,-force_load\", lib}\nelse\nreturn {\"-Wl,--whole-archive\", lib, \"-Wl,--no-whole-archive\"}\nend\nend\nfunction premake.gcc.getarchiveflags(prj, cfg, ndx)\nlocal result = {}\nif cfg.platform:startswith(\"Universal\") then\nif prj.options.ArchiveSplit then\nerror(\"gcc tool 'Universal*' platforms do not support split archives\")\nend\ntable.insert(result, '-o')\nelse\nif (not prj.options.ArchiveSplit) then\nif premake.gcc.llvm then\ntable.insert(result, 'rcs')\nelse\ntable.insert(result, '-rcs')\nend\nelse\nif premake.gcc.llvm then\nif (not ndx) then\ntable.insert(result, 'qc')\nelse\ntable.insert(result, 'cs')\nend\nelse\nif (not ndx) then\ntable.insert(result, '-qc')\nelse\ntable.insert(result, '-cs')\nend\nend\nend\nend\nreturn result\nend\nfunction premake.gcc.getdefines(defines)\nlocal result = { }\nfor _,def in " "ipairs(defines) do\ntable.insert(result, \"-D\" .. def)\nend\nreturn result\nend\nfunction premake.gcc.getincludedirs(includedirs)\nlocal result = { }\nfor _,dir in ipairs(includedirs) do\ntable.insert(result, \"-I\\\"\" .. dir .. \"\\\"\")\nend\nreturn result\nend\nfunction premake.gcc.getquoteincludedirs(includedirs)\nlocal result = { }\nfor _,dir in ipairs(includedirs) do\ntable.insert(result, \"-iquote \\\"\" .. dir .. \"\\\"\")\nend\nreturn result\nend\nfunction premake.gcc.getsystemincludedirs(includedirs)\nlocal result = { }\nfor _,dir in ipairs(includedirs) do\ntable.insert(result, \"-isystem \\\"\" .. dir .. \"\\\"\")\nend\nreturn result\nend\nfunction premake.gcc.getcfgsettings(cfg)\nreturn platforms[cfg.platform].cfgsettings\nend\n", /* tools/ghs.lua */ "premake.ghs = { }\npremake.ghs.namestyle = \"PS3\"\npremake.ghs.cc = \"ccppc\"\npremake.ghs.cxx = \"cxppc\"\npremake.ghs.ar = \"cxppc\"\nlocal cflags =\n{\nFatalWarnings = \"--quit_after_warnings\",\nOptimize = \"-Ogeneral\",\nOptimizeSize = \"-Osize\",\nOptimizeSpeed = \"-Ospeed\",\nSymbols = \"-g\",\n}\nlocal cxxflags =\n{\nNoExceptions = \"--no_exceptions\",\nNoRTTI = \"--no_rtti\",\nUnsignedChar = \"--unsigned_chars\",\n}\npremake.ghs.platforms =\n{\nNative = {\ncppflags = \"-MMD\",\n},\nPowerPC = {\ncc = \"ccppc\",\ncxx = \"cxppc\",\nar = \"cxppc\",\ncppflags = \"-MMD\",\narflags = \"-archive -o\",\n},\nARM = {\ncc = \"ccarm\",\ncxx = \"cxarm\",\nar = \"cxarm\",\ncppflags = \"-MMD\",\narflags = \"-archive -o\",\n}\n}\nlocal platforms = premake.ghs.platforms\nfunction premake.ghs.getcppflags(cfg)\nlocal flags = { }\ntable.insert(flags, platforms[cfg.platform].cppflags)\nreturn flags\nend\nfunction premake.ghs.getcf" "lags(cfg)\nlocal result = table.translate(cfg.flags, cflags)\ntable.insert(result, platforms[cfg.platform].flags)\nreturn result\nend\nfunction premake.ghs.getcxxflags(cfg)\nlocal result = table.translate(cfg.flags, cxxflags)\nreturn result\nend\nfunction premake.ghs.getldflags(cfg)\nlocal result = { }\nlocal platform = platforms[cfg.platform]\ntable.insert(result, platform.flags)\ntable.insert(result, platform.ldflags)\nreturn result\nend\nfunction premake.ghs.getlibdirflags(cfg)\nlocal result = { }\nfor _, value in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\ntable.insert(result, '-L' .. _MAKE.esc(value))\nend\nreturn result\nend\nfunction premake.ghs.getlibfiles(cfg)\nlocal result = {}\nreturn result\nend\nfunction premake.ghs.getlinkflags(cfg)\nlocal result = {}\nfor _, value in ipairs(premake.getlinks(cfg, \"system\", \"name\")) do\ntable.insert(result, '-lnk=' .. _MAKE.esc(value))\nend\nreturn result\nend\nfunction premake.ghs.getarchiveflags(prj, cfg, ndx)\nif prj.options.ArchiveSplit then" "\nerror(\"ghs tool does not support split archives\")\nend\nlocal result = {}\nlocal platform = platforms[cfg.platform]\ntable.insert(result, platform.arflags)\nreturn result\nend\nfunction premake.ghs.getdefines(defines)\nlocal result = { }\nfor _,def in ipairs(defines) do\ntable.insert(result, '-D' .. def)\nend\nreturn result\nend\nfunction premake.ghs.getincludedirs(includedirs)\nlocal result = { }\nfor _,dir in ipairs(includedirs) do\ntable.insert(result, \"-I\" .. _MAKE.esc(dir))\nend\nreturn result\nend\nfunction premake.ghs.getcfgsettings(cfg)\nreturn platforms[cfg.platform].cfgsettings\nend\n", /* tools/msc.lua */ "premake.msc = { }\npremake.msc.namestyle = \"windows\"\n", /* tools/ow.lua */ "premake.ow = { }\npremake.ow.namestyle = \"windows\"\npremake.ow.cc = \"WCL386\"\npremake.ow.cxx = \"WCL386\"\npremake.ow.ar = \"ar\"\nlocal cflags =\n{\nPedanticWarnings = \"-wx\",\nExtraWarnings = \"-wx\",\nFatalWarning = \"-we\",\nFloatFast = \"-omn\",\nFloatStrict = \"-op\",\nOptimize = \"-ox\",\nOptimizeSize = \"-os\",\nOptimizeSpeed = \"-ot\",\nSymbols = \"-d2\",\n}\nlocal cxxflags =\n{\nNoExceptions = \"-xd\",\nNoRTTI = \"-xr\",\n}\npremake.ow.platforms =\n{\nNative = {\nflags = \"\"\n},\n}\nfunction premake.ow.getcppflags(cfg)\nreturn {}\nend\nfunction premake.ow.getcflags(cfg)\nlocal result = table.translate(cfg.flags, cflags)\nif (cfg.flags.Symbols) then\ntable.insert(result, \"-hw\") -- Watcom debug format for Watcom debugger\nend\nreturn result\nend\nfunction premake.ow.getcxxflags(cfg)\nlocal result = table.translate(cfg.flags, cxxflags)\nreturn result\nend\nfunction premake.ow.getldflags(cfg)\nlocal result = { }\nif (cfg.flags.Symb" "ols) then\ntable.insert(result, \"op symf\")\nend\nreturn result\nend\nfunction premake.ow.getlibfiles(cfg)\nlocal result = {}\nreturn result\nend\nfunction premake.ow.getlinkflags(cfg)\nlocal result = { }\nreturn result\nend\nfunction premake.ow.getdefines(defines)\nlocal result = { }\nfor _,def in ipairs(defines) do\ntable.insert(result, '-D' .. def)\nend\nreturn result\nend\nfunction premake.ow.getincludedirs(includedirs)\nlocal result = { }\nfor _,dir in ipairs(includedirs) do\ntable.insert(result, '-I \"' .. dir .. '\"')\nend\nreturn result\nend\n", /* tools/snc.lua */ "premake.snc = { }\npremake.snc.cc = \"snc\"\npremake.snc.cxx = \"g++\"\npremake.snc.ar = \"ar\"\nlocal cflags =\n{\nPedanticWarnings = \"-Xdiag=2\",\nExtraWarnings = \"-Xdiag=2\",\nFatalWarnings = \"-Xquit=2\",\n}\nlocal cxxflags =\n{\nNoExceptions = \"\", -- No exceptions is the default in the SNC compiler.\nNoRTTI = \"-Xc-=rtti\",\n}\npremake.snc.platforms =\n{\nPS3 = {\ncc = \"ppu-lv2-g++\",\ncxx = \"ppu-lv2-g++\",\nar = \"ppu-lv2-ar\",\ncppflags = \"-MMD -MP\",\n}\n}\nlocal platforms = premake.snc.platforms\nfunction premake.snc.getcppflags(cfg)\nlocal result = { }\ntable.insert(result, platforms[cfg.platform].cppflags)\nreturn result\nend\nfunction premake.snc.getcflags(cfg)\nlocal result = table.translate(cfg.flags, cflags)\ntable.insert(result, platforms[cfg.platform].flags)\nif cfg.kind == \"SharedLib\" then\ntable.insert(result, \"-fPIC\")\nend\nreturn result\nend\nfunction premake.snc.getcxxflags(cfg)\nlocal result = table.translate(cfg.flags, cxxfl" "ags)\nreturn result\nend\nfunction premake.snc.getldflags(cfg)\nlocal result = { }\nif not cfg.flags.Symbols then\ntable.insert(result, \"-s\")\nend\nif cfg.kind == \"SharedLib\" then\ntable.insert(result, \"-shared\")\nif not cfg.flags.NoImportLib then\ntable.insert(result, '-Wl,--out-implib=\"' .. cfg.linktarget.fullpath .. '\"')\nend\nend\nlocal platform = platforms[cfg.platform]\ntable.insert(result, platform.flags)\ntable.insert(result, platform.ldflags)\nreturn result\nend\nfunction premake.snc.getlibdirflags(cfg)\nlocal result = { }\nfor _, value in ipairs(premake.getlinks(cfg, \"all\", \"directory\")) do\ntable.insert(result, '-L' .. _MAKE.esc(value))\nend\nreturn result\nend\nfunction premake.snc.getlibfiles(cfg)\nlocal result = {}\nreturn result\nend\nfunction premake.snc.getlinkflags(cfg)\nlocal result = {}\nfor _, value in ipairs(premake.getlinks(cfg, \"system\", \"name\")) do\ntable.insert(result, '-l' .. _MAKE.esc(value))\nend\nreturn result\nend\nfunction premake.snc.getdefines(defines)\nlocal r" "esult = { }\nfor _,def in ipairs(defines) do\ntable.insert(result, '-D' .. def)\nend\nreturn result\nend\nfunction premake.snc.getincludedirs(includedirs)\nlocal result = { }\nfor _,dir in ipairs(includedirs) do\ntable.insert(result, \"-I\" .. _MAKE.esc(dir))\nend\nreturn result\nend\n", /* tools/valac.lua */ "premake.valac = { }\npremake.valac.valac = \"valac\"\npremake.valac.cc = premake.gcc.cc\npremake.valac.glibrc = \"glib-compile-resources\"\nlocal valaflags =\n{\nDisableAssert = \"--disable-assert\", -- Disable assertions\nDisableSinceCheck = \"--disable-since-check\", -- Do not check whether used symbols exist in local packages\nDisableWarnings = \"--disable-warnings\", -- Disable warnings\nEnableChecking = \"--enable-checking\", -- Enable additional run-time checks\nEnableDeprecated = \"--enable-deprecated\", -- Enable deprecated features\nEnableExperimental = \"--enable-experimental\", -- Enable experimental features\nEnableExperimentalNonNull = \"--enable-experimental-non-null\", -- Enable experimental enhancements for non-null types\nEnableGObjectTracing = \"--enable-gobject-tracing\", -- Enable GObject creation tracing\nEnableMemProfiler = \"--enable-mem-pro" "filer\", -- Enable GLib memory profiler\nFatalWarnings = \"--fatal-warnings\", -- Treat warnings as fatal\nHideInternal = \"--hide-internal\", -- Hide symbols marked as internal\nNoStdPkg = \"--nostdpkg\", -- Do not include standard packages\nSymbols = \"-g\", -- Produce debug information\n}\nlocal valaccflags =\n{\nOptimize = \"-O2\",\nOptimizeSize = \"-Os\",\nOptimizeSpeed = \"-O3\",\nSymbols = \"-g\", -- Produce debug information\n}\npremake.valac.platforms =\n{\nNative = {\n},\nx64 = {\nflags = \"-m64\"\n},\n}\nfunction premake.valac.getvalaflags(cfg)\nreturn table.translate(cfg.flags, valaflags)\nend\nfunction premake.valac.getvalaccflags(cfg)\nreturn table.translate(cfg.flags, valaccflags)\nend\nfunction premake.valac.getlinks(links)\nlocal result = { }\nfor _, pkg in ipairs" "(links) do\ntable.insert(result, '--pkg ' .. pkg)\nend\nreturn result\nend\nfunction premake.valac.getdefines(defines)\nlocal result = { }\nfor _, def in ipairs(defines) do\ntable.insert(result, '-D ' .. def)\nend\nreturn result\nend\nfunction premake.valac.getvapidirs(vapidirs)\nlocal result = { }\nfor _, def in ipairs(vapidirs) do\ntable.insert(result, '--vapidir=' .. def)\nend\nreturn result\nend\n", /* tools/swift.lua */ "premake.swift = { }\npremake.swift.swiftc = \"swiftc\"\npremake.swift.swift = \"swift\"\npremake.swift.cc = \"gcc\"\npremake.swift.ar = \"ar\"\npremake.swift.ld = \"ld\"\npremake.swift.dsymutil = \"dsymutil\"\nlocal swiftcflags =\n{\nSymbols = \"-g\", -- Produce debug information\nDisableWarnings = \"--suppress-warnings\", -- Disable warnings\nFatalWarnings = \"--warnings-as-errors\", -- Treat warnings as fatal\nOptimize = \"-O -whole-module-optimization\",\nOptimizeSize = \"-O -whole-module-optimization\",\nOptimizeSpeed = \"-Ounchecked -whole-module-optimization\",\nMinimumWarnings = \"-minimum-warnings\",\n}\nlocal swiftlinkflags = {\nStaticRuntime = \"-static-stdlib\",\n}\npremake.swift.platforms = {\nNative = {\nswiftcflags = \"\",\nswiftlinkflags = \"\",\n},\nx64 = {\nswiftcflags = \"\",\nswiftlinkflags = \"\",\n}\n}\nlocal p" "latforms = premake.swift.platforms\nfunction premake.swift.get_sdk_path(cfg)\nreturn string.trim(os.outputof(\"xcrun --show-sdk-path\"))\nend\nfunction premake.swift.get_sdk_platform_path(cfg)\nreturn string.trim(os.outputof(\"xcrun --show-sdk-platform-path\"))\nend\nfunction premake.swift.get_toolchain_path(cfg)\nreturn string.trim(os.outputof(\"xcode-select -p\")) .. \"/Toolchains/XcodeDefault.xctoolchain\"\nend\nfunction premake.swift.gettarget(cfg)\nreturn \"-target x86_64-apple-macosx10.11\"\nend\nfunction premake.swift.getswiftcflags(cfg)\nlocal result = table.translate(cfg.flags, swiftcflags)\ntable.insert(result, platforms[cfg.platform].swiftcflags)\nresult = table.join(result, cfg.buildoptions_swift)\nif cfg.kind == \"SharedLib\" or cfg.kind == \"StaticLib\" then\ntable.insert(result, \"-parse-as-library\")\nend\ntable.insert(result, premake.swift.gettarget(cfg))\nreturn result\nend\nfunction premake.swift.getswiftlinkflags(cfg)\nlocal result = table.translate(cfg.flags, swiftlinkflags)\ntable.insert(" "result, platforms[cfg.platform].swiftlinkflags)\nresult = table.join(result, cfg.linkoptions_swift)\nif cfg.kind == \"SharedLib\" or cfg.kind == \"StaticLib\" then\ntable.insert(result, \"-emit-library\")\nelse\ntable.insert(result, \"-emit-executable\")\nend\ntable.insert(result, premake.swift.gettarget(cfg))\nreturn result\nend\nfunction premake.swift.getmodulemaps(cfg)\nlocal maps = {}\nif next(cfg.swiftmodulemaps) then\nfor _, mod in ipairs(cfg.swiftmodulemaps) do\ntable.insert(maps, string.format(\"-Xcc -fmodule-map-file=%s\", mod))\nend\nend\nreturn maps\nend\nfunction premake.swift.getlibdirflags(cfg)\nreturn premake.gcc.getlibdirflags(cfg)\nend\nfunction premake.swift.getldflags(cfg)\nlocal result = { platforms[cfg.platform].ldflags }\nlocal links = premake.getlinks(cfg, \"siblings\", \"basename\")\nfor _,v in ipairs(links) do\nif path.getextension(v) == \".framework\" then\ntable.insert(result, \"-framework \"..v)\nelse\ntable.insert(result, \"-l\"..v)\nend\nend\nreturn result\nend\nfunction premake.s" "wift.getlinkflags(cfg)\nreturn premake.gcc.getlinkflags(cfg)\nend\nfunction premake.swift.getarchiveflags(cfg)\nreturn \"\"\nend\n", /* base/validate.lua */ "function premake.checkprojects()\nlocal action = premake.action.current()\nfor sln in premake.solution.each() do\nif (#sln.projects == 0) then\nreturn nil, \"solution '\" .. sln.name .. \"' needs at least one project\"\nend\nif (#sln.configurations == 0) then\nreturn nil, \"solution '\" .. sln.name .. \"' needs configurations\"\nend\nfor prj in premake.solution.eachproject(sln) do\nif (not prj.language) then\nreturn nil, \"project '\" ..prj.name .. \"' needs a language\"\nend\nif (action.valid_languages) then\nif (not table.contains(action.valid_languages, prj.language)) then\nreturn nil, \"the \" .. action.shortname .. \" action does not support \" .. prj.language .. \" projects\"\nend\nend\nfor cfg in premake.eachconfig(prj) do\nif (not cfg.kind) then\nreturn nil, \"project '\" ..prj.name .. \"' needs a kind in configuration '\" .. cfg.name .. \"'\"\nend\nif (action.valid_kinds) then\nif (not table.contains(action.valid_kinds, cfg.kind)) then\nreturn nil, \"the \" .. action.shortname .. \" action does not su" "pport \" .. cfg.kind .. \" projects\"\nend\nend\nend\nif action.oncheckproject then\naction.oncheckproject(prj)\nend\nend\nend\nreturn true\nend\nfunction premake.checktools()\nlocal action = premake.action.current()\nif (not action.valid_tools) then \nreturn true \nend\nfor tool, values in pairs(action.valid_tools) do\nif (_OPTIONS[tool]) then\nif (not table.contains(values, _OPTIONS[tool])) then\nreturn nil, \"the \" .. action.shortname .. \" action does not support /\" .. tool .. \"=\" .. _OPTIONS[tool] .. \" (yet)\"\nend\nelse\n_OPTIONS[tool] = values[1]\nend\nend\nreturn true\nend\n", /* base/help.lua */ "function premake.showhelp()\nprintf(\"\")\nprintf(\"Usage: genie [options] action [arguments]\")\nprintf(\"\")\nprintf(\"OPTIONS\")\nprintf(\"\")\nfor option in premake.option.each() do\nlocal trigger = option.trigger\nlocal description = option.description\nif (option.value) then trigger = trigger .. \"=\" .. option.value end\nif (option.allowed) then description = description .. \"; one of:\" end\nprintf(\" --%-15s %s\", trigger, description)\nif (option.allowed) then\nfor _, value in ipairs(option.allowed) do\nprintf(\" %-14s %s\", value[1], value[2])\nend\nend\nprintf(\"\")\nend\nprintf(\"ACTIONS\")\nprintf(\"\")\nfor action in premake.action.each() do\nprintf(\" %-17s %s\", action.trigger, action.description)\nend\nprintf(\"\")\nprintf(\"For additional information, see https://github.com/bkaradzic/genie\")\nend\n", /* base/premake.lua */ "premake._filelevelconfig = false\npremake._checkgenerate = true\nfunction premake.generate(obj, filename, callback)\nlocal prev = io.capture()\nlocal abort = (callback(obj) == false)\nlocal new = io.endcapture(prev)\nif abort then\npremake.stats.num_skipped = premake.stats.num_skipped + 1\nreturn\nend\nfilename = premake.project.getfilename(obj, filename)\nif (premake._checkgenerate) then\nlocal delta = false\nlocal f, err = io.open(filename, \"rb\")\nif (not f) then\nif string.find(err, \"No such file or directory\") then\ndelta = true\nelse\nerror(err, 0)\nend\nelse\nlocal existing = f:read(\"*all\")\nif existing ~= new then\ndelta = true\nend\nf:close()\nend\nif delta then\nprintf(\"Generating %q\", filename)\nlocal f, err = io.open(filename, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nf:write(new)\nf:close()\npremake.stats.num_generated = premake.stats.num_generated + 1\nelse\npremake.stats.num_skipped = premake.stats.num_skipped + 1\nend\nelse\nprintf(\"Generating %q\", filename)\nlocal f, err = io.o" "pen(filename, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nf:write(new)\nf:close()\npremake.stats.num_generated = premake.stats.num_generated + 1\nend\nend\nfunction premake.findDefaultScript(dir, search_upwards)\nsearch_upwards = search_upwards or true\nlocal last = \"\"\nwhile dir ~= last do\nfor _, name in ipairs({ \"genie.lua\", \"solution.lua\", \"premake4.lua\" }) do\nlocal script0 = dir .. \"/\" .. name\nif (os.isfile(script0)) then\nreturn dir, name\nend\nlocal script1 = dir .. \"/scripts/\" .. name\nif (os.isfile(script1)) then\nreturn dir .. \"/scripts/\", name\nend\nend\nlast = dir\ndir = path.getabsolute(dir .. \"/..\")\nif dir == \".\" or not search_upwards then break end\nend\nreturn nil, nil\nend\n", /* base/iter.lua */ "iter = {}\nfunction iter.sortByKeys(arr, f)\nlocal a = table.keys(arr)\ntable.sort(a, f)\nlocal i = 0\nreturn function()\ni = i + 1\nif a[i] ~= nil then \nreturn a[i], arr[a[i]]\nend\nend\nend\n", /* base/set.lua */ "Set_mt = {}\nfunction Set(t)\nlocal set = {}\nfor k, l in ipairs(t) do \nset[l] = true \nend\nsetmetatable(set, Set_mt)\nreturn set\nend\nfunction Set_mt.union(a, b)\nlocal res = Set{}\nfor k in pairs(a) do res[k] = true end\nfor k in pairs(b) do res[k] = true end\nreturn res\nend\nfunction Set_mt.intersection(a, b)\nlocal res = Set{}\nfor k in pairs(a) do\nres[k] = b[k]\nend\nreturn res\nend\nlocal function get_cache(a)\nif not rawget(a, \"__cache\") then\nrawset(a, \"__cache\", Set_mt.totable(a))\nend\nreturn rawget(a, \"__cache\")\nend\nfunction Set_mt.len(a)\nreturn #get_cache(a)\nend\nfunction Set_mt.implode(a, sep)\nreturn table.concat(get_cache(a), sep)\nend\nfunction Set_mt.totable(a)\nlocal res = {}\nfor k in pairs(a) do\ntable.insert(res, k)\nend\nreturn res\nend\nfunction Set_mt.difference(a, b)\nif getmetatable(b) ~= Set_mt then\nif type(b) ~= \"table\" then\nerror(type(b)..\" is not a Set or table\")\nend\nb=Set(b)\nend\nlocal res = Set{}\nfor k in pairs(a) do\nres[k] = not b[k] or nil\nend\nrawse" "t(res, \"__cache\", nil)\nreturn res\nend\nfunction Set_mt.__index(a, i)\nif type(i) == \"number\" then\nreturn get_cache(a)[i]\nend\nreturn Set_mt[i] or rawget(a, i)\nend\nSet_mt.__add = Set_mt.union\nSet_mt.__mul = Set_mt.intersection\nSet_mt.__sub = Set_mt.difference\nSet_mt.__len = Set_mt.len\nSet_mt.__concat = Set_mt.implode", /* actions/cmake/_cmake.lua */ "premake.cmake = { }\nnewaction {\ntrigger = \"cmake\",\nshortname = \"CMake\",\ndescription = \"Generate CMake project files\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\" },\nvalid_tools = {\ncc = { \"gcc\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"CMakeLists.txt\", premake.cmake.workspace)\nend,\nonproject = function(prj)\npremake.generate(prj, \"%%/CMakeLists.txt\", premake.cmake.project)\nend,\noncleansolution = function(sln)\npremake.clean.file(sln, \"CMakeLists.txt\")\nend,\noncleanproject = function(prj)\npremake.clean.file(prj, \"%%/CMakeLists.txt\")\nend\n}", /* actions/cmake/cmake_workspace.lua */ "function premake.cmake.workspace(sln)\nif (sln.location ~= _WORKING_DIR) then\nlocal name = string.format(\"%s/CMakeLists.txt\", _WORKING_DIR)\nlocal f, err = io.open(name, \"wb\")\nif (not f) then\nerror(err, 0)\nend\nf:write([[\n# CMakeLists autogenerated by GENie\nproject(GENie)\ncmake_minimum_required(VERSION 3.15)\n#########################################################################\n# Set a default build type if none was specified\n# Source: https://blog.kitware.com/cmake-and-the-default-build-type/\nset(default_build_type \"Release\")\nif(EXISTS \"${CMAKE_SOURCE_DIR}/.git\")\n set(default_build_type \"Debug\")\nendif()\nif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)\n message(STATUS \"Setting build type to '${default_build_type}' as none was specified.\")\n set(CMAKE_BUILD_TYPE \"${default_build_type}\" CACHE STRING \"Choose the type of build.\" FORCE)\n # Set the possible values of build type for cmake-gui\n set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS \"Debug\" \"Release" "\" \"MinSizeRel\" \"RelWithDebInfo\")\nendif()\n#########################################################################\n]])\nif os.is(\"windows\") then\nf:write('cmake_policy(SET CMP0091 NEW)\\n')\nend\nf:write('add_subdirectory('.. path.getrelative(_WORKING_DIR, sln.location) ..')\\n')\nf:close()\nend\n_p([[\n# CMakeLists autogenerated by GENie\ncmake_minimum_required(VERSION 3.15)\n]])\nif os.is(\"windows\") then\n_p('cmake_policy(SET CMP0091 NEW)')\nend\nfor i,prj in ipairs(sln.projects) do\nlocal name = premake.esc(prj.name)\n_p('add_subdirectory(%s)', name)\nend\nend\n", /* actions/cmake/cmake_project.lua */ "local cmake = premake.cmake\nlocal tree = premake.tree\nlocal includestr = 'include_directories(../%s)'\nlocal definestr = 'add_definitions(-D%s)'\nlocal function is_excluded(prj, cfg, file)\n if table.icontains(prj.excludes, file) then\n return true\n end\n if table.icontains(cfg.excludes, file) then\n return true\n end\n return false\nend\nfunction cmake.excludedFiles(prj, cfg, src)\n for _, v in ipairs(src) do\n if (is_excluded(prj, cfg, v)) then\n _p(1, 'list(REMOVE_ITEM source_list ../%s)', v)\n end\n end\nend\nfunction cmake.list(value)\n if #value > 0 then\n return \" \" .. table.concat(value, \" \")\n else\n return \"\"\n end\nend\nfunction cmake.listWrapped(value, prefix, postfix)\n if #value > 0 then\n return prefix .. table.concat(value, postfix .. prefix) .. postfix\n else\n return \"\"\n end\nend\nfunction cmake.files(prj)\n local ret = {}\n local tr = premake.project.buildsourcetree(prj" ")\n tree.traverse(tr, {\n onbranchenter = function(node, depth)\n end,\n onbranchexit = function(node, depth)\n end,\n onleaf = function(node, depth)\n assert(node, \"unexpected empty node\")\n if node.cfg then\n table.insert(ret, node.cfg.name)\n _p(1, '../%s', node.cfg.name)\n end\n end,\n }, true, 1)\n return ret\nend\nfunction cmake.header(prj)\n _p('# %s project autogenerated by GENie', premake.action.current().shortname)\n _p('cmake_minimum_required(VERSION 3.15)')\n if os.is(\"windows\") then\n -- Add support for CMP0091, see https://cmake.org/cmake/help/latest/policy/CMP0091.html\n _p('cmake_policy(SET CMP0091 NEW)')\n end\n _p('')\n _p('project(%s)', premake.esc(prj.name))\n _p('')\n _p('include(GNUInstallDirs)')\nend\nfunction cmake.customtasks(prj)\n local dirs = {}\n local tasks = {}\n for _, custombuildtask in ipairs(prj.custombuildtask or" " {}) do\n for _, buildtask in ipairs(custombuildtask or {}) do\n table.insert(tasks, buildtask)\n local d = string.format(\"${CMAKE_CURRENT_SOURCE_DIR}/../%s\", path.getdirectory(path.getrelative(prj.location, buildtask[2])))\n if not table.contains(dirs, d) then\n table.insert(dirs, d)\n _p('file(MAKE_DIRECTORY \\\"%s\\\")', d)\n end\n end\n end\n _p('')\n for _, buildtask in ipairs(tasks) do\n local deps = string.format(\"${CMAKE_CURRENT_SOURCE_DIR}/../%s \", path.getrelative(prj.location, buildtask[1]))\n local outputs = string.format(\"${CMAKE_CURRENT_SOURCE_DIR}/../%s \", path.getrelative(prj.location, buildtask[2]))\n local msg = \"\"\n for _, depdata in ipairs(buildtask[3] or {}) do\n deps = deps .. string.format(\"${CMAKE_CURRENT_SOURCE_DIR}/../%s \", path.getrelative(prj.location, depdata))\n end\n _p('add_custom_command(')\n _p(1, 'OUTPUT %s', ou" "tputs)\n _p(1, 'DEPENDS %s', deps)\n for _, cmdline in ipairs(buildtask[4] or {}) do\n if (cmdline:sub(1, 1) ~= \"@\") then\n local cmd = cmdline\n local num = 1\n for _, depdata in ipairs(buildtask[3] or {}) do\n cmd = string.gsub(cmd, \"%$%(\" .. num .. \"%)\", string.format(\"${CMAKE_CURRENT_SOURCE_DIR}/../%s \", path.getrelative(prj.location, depdata)))\n num = num + 1\n end\n cmd = string.gsub(cmd, \"%$%(<%)\", string.format(\"${CMAKE_CURRENT_SOURCE_DIR}/../%s \", path.getrelative(prj.location, buildtask[1])))\n cmd = string.gsub(cmd, \"%$%(@%)\", outputs)\n _p(1, 'COMMAND %s', cmd)\n else\n msg = cmdline\n end\n end\n _p(1, 'COMMENT \\\"%s\\\"', msg)\n _p(')')\n _p('')\n end\nend\nfunction cmake.depRules(prj)\n local maintable = {}\n for _, dependency in ipairs(prj.d" "ependency) do\n for _, dep in ipairs(dependency) do\n if path.issourcefile(dep[1]) then\n local dep1 = premake.esc(path.getrelative(prj.location, dep[1]))\n local dep2 = premake.esc(path.getrelative(prj.location, dep[2]))\n if not maintable[dep1] then maintable[dep1] = {} end\n table.insert(maintable[dep1], dep2)\n end\n end\n end\n for key, _ in pairs(maintable) do\n local deplist = {}\n local depsname = string.format('%s_deps', path.getname(key))\n for _, d2 in pairs(maintable[key]) do\n table.insert(deplist, d2)\n end\n _p('set(')\n _p(1, depsname)\n for _, v in pairs(deplist) do\n _p(1, '${CMAKE_CURRENT_SOURCE_DIR}/../%s', v)\n end\n _p(')')\n _p('')\n _p('set_source_files_properties(')\n _p(1, '\\\"${CMAKE_CURRENT_SOURCE_DIR}/../%s\\\"', key)\n _p(1, 'PROPERTIES OBJECT_DEPENDS \\\"${%s}\\\"', d" "epsname)\n _p(')')\n _p('')\n end\nend\nfunction cmake.commonRules(conf, str)\n local Dupes = {}\n local t2 = {}\n for _, cfg in ipairs(conf) do\n local cfgd = iif(str == includestr, cfg.includedirs, cfg.defines)\n for _, v in ipairs(cfgd) do\n if(t2[v] == #conf - 1) then\n _p(str, v)\n table.insert(Dupes, v)\n end\n if not t2[v] then\n t2[v] = 1\n else\n t2[v] = t2[v] + 1\n end\n end\n end\n return Dupes\nend\nfunction cmake.cfgRules(cfg, dupes, str)\n for _, v in ipairs(cfg) do\n if (not table.icontains(dupes, v)) then\n _p(1, str, v)\n end\n end\nend\nfunction cmake.removeCrosscompiler(platforms)\n for i = #platforms, 1, -1 do\n if premake.platforms[platforms[i]].iscrosscompiler then\n table.remove(platforms, i)\n end\n end\nend\nfunction cmake.project(prj)\n io.indent = \" \"" "\n cmake.header(prj)\n _p('set(')\n _p('source_list')\n local source_files = cmake.files(prj)\n _p(')')\n _p('')\n local nativeplatform = iif(os.is64bit(), \"x64\", \"x32\")\n local cc = premake.gettool(prj)\n local platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\n cmake.removeCrosscompiler(platforms)\n local configurations = {}\n for _, platform in ipairs(platforms) do\n for cfg in premake.eachconfig(prj, platform) do\n -- TODO: Extend support for 32-bit targets on 64-bit hosts\n if cfg.platform == nativeplatform then\n table.insert(configurations, cfg)\n end\n end\n end\n local commonIncludes = cmake.commonRules(configurations, includestr)\n local commonDefines = cmake.commonRules(configurations, definestr)\n _p('')\n for _, cfg in ipairs(configurations) do\n _p('if(CMAKE_BUILD_TYPE MATCHES \\\"%s\\\")', cfg.name)\n -- list excluded files\n cmake.ex" "cludedFiles(prj, cfg, source_files)\n -- add includes directories\n cmake.cfgRules(cfg.includedirs, commonIncludes, includestr)\n -- add build defines\n cmake.cfgRules(cfg.defines, commonDefines, definestr)\n -- set CXX flags\n _p(1, 'set(CMAKE_CXX_FLAGS \\\"${CMAKE_CXX_FLAGS} %s\\\")', cmake.list(table.join(cc.getcppflags(cfg), cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_cpp)))\n -- set C flags\n _p(1, 'set(CMAKE_C_FLAGS \\\"${CMAKE_C_FLAGS} %s\\\")', cmake.list(table.join(cc.getcppflags(cfg), cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_c)))\n _p('endif()')\n _p('')\n end\n -- force CPP if needed\n if (prj.options.ForceCPP) then\n _p('set_source_files_properties(${source_list} PROPERTIES LANGUAGE CXX)')\n end\n -- add custom tasks\n cmake.customtasks(prj)\n -- per-dependency build rules\n cmake.depRules(prj)\n for _, cfg in ipairs(configurations) do\n _p('if(C" "MAKE_BUILD_TYPE MATCHES \\\"%s\\\")', cfg.name)\n if (prj.kind == 'StaticLib') then\n _p(1, 'add_library(%s STATIC ${source_list})', premake.esc(cfg.buildtarget.basename))\n -- Install\n _p(1, 'install(TARGETS %s RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR})', premake.esc(cfg.buildtarget.basename))\n end\n if (prj.kind == 'SharedLib') then\n _p(1, 'add_library(%s SHARED ${source_list})', premake.esc(cfg.buildtarget.basename))\n -- Install\n _p(1, 'install(TARGETS %s RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR})', premake.esc(cfg.buildtarget.basename))\n end\n if (prj.kind == 'ConsoleApp' or prj.kind == 'WindowedApp') then\n _p(1, 'add_executable(%s ${source_list})', premake.esc(cfg.buildtarget.basename))\n local libdirs = cmake.listWrapped(premake.esc(premake.getlinks(cfg, \"all\", \"directory\")), \" -L\\\"../\", \"\\\"\")\n _p(1, 'target_link_libraries(%s%s%s%s%s%s)', premake.es" "c(cfg.buildtarget.basename), libdirs, cmake.list(cfg.linkoptions), cmake.list(cc.getldflags(cfg)), cmake.list(premake.esc(premake.getlinks(cfg, \"siblings\", \"basename\"))), cmake.list(cc.getlinkflags(cfg)))\n -- Install\n _p(1, 'install(TARGETS %s RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})', premake.esc(cfg.buildtarget.basename))\n end\n _p('endif()')\n _p('')\n end\nend", /* actions/make/_make.lua */ "_MAKE = { }\npremake.make = { }\nlocal make = premake.make\nfunction _MAKE.esc(value)\nlocal result\nif (type(value) == \"table\") then\nresult = { }\nfor _,v in ipairs(value) do\ntable.insert(result, _MAKE.esc(v))\nend\nreturn result\nelse\nresult = value:gsub(\"\\\\\", \"\\\\\\\\\")\nresult = result:gsub(\" \", \"\\\\ \")\nresult = result:gsub(\"%%(\", \"\\\\%(\")\nresult = result:gsub(\"%%)\", \"\\\\%)\")\nresult = result:gsub(\"$\\\\%((.-)\\\\%)\", \"$%(%1%)\")\nreturn result\nend\nend\nfunction _MAKE.escquote(value)\nlocal result\nif (type(value) == \"table\") then\nresult = { }\nfor _,v in ipairs(value) do\ntable.insert(result, _MAKE.escquote(v))\nend\nreturn result\nelse\nresult = value:gsub(\" \", \"\\\\ \")\nresult = result:gsub(\"\\\"\", \"\\\\\\\"\")\nreturn result\nend\nend\nfunction premake.make_copyrule(source, target)\n_p('%s: %s', target, source)\n_p('\\t@echo Copying $(notdir %s)', target)\n_p('\\t-$(call COPY,%s,%s)', source, target)\nend\nfunction premake.make_mkdirrule(var)\n_p('\\t@echo Cr" "eating %s', var)\n_p('\\t-$(call MKDIR,%s)', var)\n_p('')\nend\nfunction make.list(value)\nif #value > 0 then\nreturn \" \" .. table.concat(value, \" \")\nelse\nreturn \"\"\nend\nend\nfunction _MAKE.getmakefilename(this, searchprjs)\nlocal count = 0\nfor sln in premake.solution.each() do\nif (sln.location == this.location) then count = count + 1 end\nif (searchprjs) then\nfor _,prj in ipairs(sln.projects) do\nif (prj.location == this.location) then count = count + 1 end\nend\nend\nend\nif (count == 1) then\nreturn \"Makefile\"\nelse\nreturn this.name .. \".make\"\nend\nend\nfunction _MAKE.getnames(tbl)\nlocal result = table.extract(tbl, \"name\")\nfor k,v in pairs(result) do\nresult[k] = _MAKE.esc(v)\nend\nreturn result\nend\nfunction make.settings(cfg, cc)\nif #cfg.makesettings > 0 then\nfor _, value in ipairs(cfg.makesettings) do\n_p(value)\nend\nend\nlocal toolsettings = cc.platforms[cfg.platform].cfgsettings\nif toolsettings then\n_p(toolsettings)\nend\nend\nnewaction {\ntrigger = \"gmake\",\nshort" "name = \"GNU Make\",\ndescription = \"Generate GNU makefiles for POSIX, MinGW, and Cygwin\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\", \"C#\", \"Vala\", \"Swift\" },\nvalid_tools = {\ncc = { \"gcc\", \"ghs\" },\ndotnet = { \"mono\", \"msnet\", \"pnet\" },\nvalac = { \"valac\" },\nswift = { \"swift\" },\n},\nonsolution = function(sln)\npremake.generate(sln, _MAKE.getmakefilename(sln, false), premake.make_solution)\nend,\nonproject = function(prj)\nlocal makefile = _MAKE.getmakefilename(prj, true)\nif premake.isdotnetproject(prj) then\npremake.generate(prj, makefile, premake.make_csharp)\nelseif premake.iscppproject(prj) then\npremake.generate(prj, makefile, premake.make_cpp)\nelseif premake.isswiftproject(prj) then\npremake.generate(prj, makefile, premake.make_swift)\nelse\npremake.generate(prj, makefile, premake.make_vala)\nend\nend,\noncleansolution = function(sln)\npremake.clean.file(sln, _MAKE.ge" "tmakefilename(sln, false))\nend,\noncleanproject = function(prj)\npremake.clean.file(prj, _MAKE.getmakefilename(prj, true))\nend,\ngmake = {}\n}\n", /* actions/make/make_solution.lua */ "function premake.make_solution(sln)\nlocal cc = premake[_OPTIONS.cc]\nlocal platforms = premake.filterplatforms(sln, cc.platforms, \"Native\")\n_p('# %s solution makefile autogenerated by GENie', premake.action.current().shortname)\n_p('# Type \"make help\" for usage help')\n_p('')\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(sln.configurations[1], platforms[1], true)))\n_p('endif')\n_p('export config')\n_p('')\nlocal projects = table.extract(sln.projects, \"name\")\ntable.sort(projects)\n_p('PROJECTS := %s', table.concat(_MAKE.esc(projects), \" \"))\n_p('')\n_p('.PHONY: all clean help $(PROJECTS)')\n_p('')\n_p('all: $(PROJECTS)')\n_p('')\nfor _, prj in ipairs(sln.projects) do\n_p('%s: %s', _MAKE.esc(prj.name), table.concat(_MAKE.esc(table.extract(premake.getdependencies(prj), \"name\")), \" \"))\nif (not sln.messageskip) or (not table.contains(sln.messageskip, \"SkipBuildingMessage\")) then\n_p('\\t@echo \"==== Building %s ($(config)) ====\"', prj.name)\nend\n_p('\\t@${MAKE} --no-pr" "int-directory -C %s -f %s', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))\n_p('')\nend\n_p('clean:')\nfor _ ,prj in ipairs(sln.projects) do\n_p('\\t@${MAKE} --no-print-directory -C %s -f %s clean', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))\nend\n_p('')\n_p('help:')\n_p(1,'@echo \"Usage: make [config=name] [target]\"')\n_p(1,'@echo \"\"')\n_p(1,'@echo \"CONFIGURATIONS:\"')\nlocal cfgpairs = { }\nfor _, platform in ipairs(platforms) do\nfor _, cfgname in ipairs(sln.configurations) do\n_p(1,'@echo \" %s\"', premake.getconfigname(cfgname, platform, true))\nend\nend\n_p(1,'@echo \"\"')\n_p(1,'@echo \"TARGETS:\"')\n_p(1,'@echo \" all (default)\"')\n_p(1,'@echo \" clean\"')\nfor _, prj in ipairs(sln.projects) do\n_p(1,'@echo \" %s\"', prj.name)\nend\n_p(1,'@echo \"\"')\n_p(1,'@echo \"For more information, see https://github.com/bkaradzic/genie\"')\nend\n", /* actions/make/make_cpp.lua */ "-- --\npremake.make.cpp = { }\npremake.make.override = { }\npremake.make.makefile_ignore = false\nlocal cpp = premake.make.cpp\nlocal make = premake.make\nfunction premake.make_cpp(prj)\nlocal cc = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\nlocal action = premake.action.current()\npremake.gmake_cpp_header(prj, cc, platforms)\npremake.gmake_cpp_configs(prj, cc, platforms)\ntable.sort(prj.allfiles)\nlocal objdirs = {}\nlocal additionalobjdirs = {}\nfor _, file in ipairs(prj.allfiles) do\nif path.issourcefile(file) then\nobjdirs[_MAKE.esc(path.getdirectory(path.trimdots(file)))] = 1\nend\nend\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask in ipairs(custombuildtask or {}) do\nadditionalobjdirs[_MAKE.esc(path.getdirectory(path.getrelative(prj.location,buildtask[2])))] = 1\nend\nend\n_p('OBJDIRS := \\\\')\n_p('\\t$(OBJDIR) \\\\')\nfor dir, _ in iter.sortByKeys(objdirs) do\n_p('\\t$(OBJDIR)/%s \\\\', dir)\nend\nfor dir, _" " in iter.sortByKeys(additionalobjdirs) do\n_p('\\t%s \\\\', dir)\nend\n_p('')\n_p('RESOURCES := \\\\')\nfor _, file in ipairs(prj.allfiles) do\nif path.isresourcefile(file) then\n_p('\\t$(OBJDIR)/%s.res \\\\', _MAKE.esc(path.getbasename(file)))\nend\nend\n_p('')\n_p('.PHONY: clean prebuild prelink')\n_p('')\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" and not prj.options.SkipBundling then\n_p('all: $(OBJDIRS) $(TARGETDIR) prebuild prelink $(TARGET) $(dir $(TARGETDIR))PkgInfo $(dir $(TARGETDIR))Info.plist')\nelse\n_p('all: $(OBJDIRS) $(TARGETDIR) prebuild prelink $(TARGET)')\nend\n_p('\\t@:')\n_p('')\nif (prj.kind == \"StaticLib\" and prj.options.ArchiveSplit) then\n_p('define max_args')\n_p('\\t$(eval _args:=)')\n_p('\\t$(foreach obj,$3,$(eval _args+=$(obj))$(if $(word $2,$(_args)),$1 $(_args)$(EOL)$(eval _args:=)))')\n_p('\\t$(if $(_args),$1 $(_args))')\n_p('endef')\n_p('')\n_p('define EOL')\n_p('')\n_p('')\n_p('endef')\n_p('')\nend\n_p('$(TARGET): $(GCH) $(OBJECTS) $(LIBDEPS) $(EXTERNAL_LIBS) $(RESO" "URCES) $(OBJRESP) $(LDRESP) | $(TARGETDIR) $(OBJDIRS)')\nif prj.kind == \"StaticLib\" then\nif prj.msgarchiving then\n_p('\\t@echo ' .. prj.msgarchiving)\nelse\n_p('\\t@echo Archiving %s', prj.name)\nend\nif (not prj.archivesplit_size) then\nprj.archivesplit_size=200\nend\nif (not prj.options.ArchiveSplit) then\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGET)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGET)) del $(subst /,\\\\\\\\,$(TARGET))')\n_p('endif')\n_p('\\t$(SILENT) $(LINKCMD) $(LINKOBJS)' .. (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\"))\nelse\n_p('\\t$(call RM,$(TARGET))')\n_p('\\t@$(call max_args,$(LINKCMD),'.. prj.archivesplit_size ..',$(LINKOBJS))' .. (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\"))\n_p('\\t$(SILENT) $(LINKCMD_NDX)')\nend\nelse\nif prj.msglinking then\n_p('\\t@echo ' .. prj.msglinking)\nelse\n_p('\\t@echo Linking %s', prj.name)\nend\n_p('\\t$(SILENT) $(LINKCM" "D)')\nend\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n_p('$(TARGETDIR):')\npremake.make_mkdirrule(\"$(TARGETDIR)\")\n_p('$(OBJDIRS):')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCreatingMessage\")) then\n_p('\\t@echo Creating $(@)')\nend\n_p('\\t-$(call MKDIR,$@)')\n_p('')\nif os.is(\"MacOSX\") and prj.kind == \"WindowedApp\" and not prj.options.SkipBundling then\n_p('$(dir $(TARGETDIR))PkgInfo:')\n_p('$(dir $(TARGETDIR))Info.plist:')\n_p('')\nend\n_p('clean:')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCleaningMessage\")) then\n_p('\\t@echo Cleaning %s', prj.name)\nend\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGET)')\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGET)) del $(subst /,\\\\\\\\,$(TARGET))')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('endif')\n_p('')\n_p('prebuild:')\n_p('\\t$(P" "REBUILDCMDS)')\n_p('')\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\ncpp.pchrules(prj)\ncpp.fileRules(prj, cc)\ncpp.dependencyRules(prj)\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask in ipairs(custombuildtask or {}) do\nlocal deps = string.format(\"%s \",path.getrelative(prj.location,buildtask[1]))\nfor _, depdata in ipairs(buildtask[3] or {}) do\ndeps = deps .. string.format(\"%s \",path.getrelative(prj.location,depdata))\nend\n_p('%s: %s | $(TARGETDIR) $(OBJDIRS)'\n,path.getrelative(prj.location,buildtask[2])\n, deps\n)\nfor _, cmdline in ipairs(buildtask[4] or {}) do\nlocal cmd = cmdline\nlocal num = 1\nfor _, depdata in ipairs(buildtask[3] or {}) do\ncmd = string.gsub(cmd,\"%$%(\" .. num ..\"%)\", string.format(\"%s \",path.getrelative(prj.location,depdata)))\nnum = num + 1\nend\ncmd = string.gsub(cmd, \"%$%(<%)\", \"$<\")\ncmd = string.gsub(cmd, \"%$%(@%)\", \"$@\")\n_p('\\t$(SILENT) %s',cmd)\nend\n_p('')\nend\nend\n_p('-include $(OBJECTS:%%.o=%%.d)')\n_p('ifneq (," "$(PCH))')\n_p(' -include $(OBJDIR)/$(notdir $(PCH)).d')\n_p(' -include $(OBJDIR)/$(notdir $(PCH))_objc.d')\n_p('endif')\nend\nfunction premake.gmake_cpp_header(prj, cc, platforms)\n_p('# %s project makefile autogenerated by GENie', premake.action.current().shortname)\n_p('')\n_p('.SUFFIXES:') -- Delete the default suffix rules.\n_p('')\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))\n_p('endif')\n_p('')\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(MAKESHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' MKDIR = $(SILENT) mkdir -p \"$(1)\"')\n_p(' COPY = $(SILENT) cp -fR \"$(1)\" \"$(2)\"')\n_p(' RM = $(SILENT) rm -f \"$(1)\"')\n_p('else')" "\n_p(' MKDIR = $(SILENT) mkdir \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p(' COPY = $(SILENT) copy /Y \"$(subst /,\\\\\\\\,$(1))\" \"$(subst /,\\\\\\\\,$(2))\"')\n_p(' RM = $(SILENT) del /F \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p('endif')\n_p('')\n_p('CC = %s', cc.cc)\n_p('CXX = %s', cc.cxx)\n_p('AR = %s', cc.ar)\n_p('')\n_p('ifndef RESCOMP')\n_p(' ifdef WINDRES')\n_p(' RESCOMP = $(WINDRES)')\n_p(' else')\n_p(' RESCOMP = %s', cc.rc or 'windres')\n_p(' endif')\n_p('endif')\n_p('')\nif (not premake.make.makefile_ignore) then\n_p('MAKEFILE = %s', _MAKE.getmakefilename(prj, true))\n_p('')\nend\nend\nlocal function is_excluded(prj, cfg, file)\nif table.icontains(prj.excludes, file) then\nreturn true\nend\nif table.icontains(cfg.excludes, file) then\nreturn true\nend\nreturn false\nend\nfunction premake.gmake_cpp_configs(prj, cc, platforms)\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\npremake.gmake_cpp_config(prj, cfg, cc)\nend\nend" "\nend\nfunction premake.gmake_cpp_config(prj, cfg, cc)\n_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))\ncpp.platformtools(cfg, cc)\nlocal targetDir = _MAKE.esc(cfg.buildtarget.directory)\n_p(' ' .. (table.contains(premake.make.override,\"OBJDIR\") and \"override \" or \"\") .. 'OBJDIR = %s', _MAKE.esc(cfg.objectsdir))\n_p(' ' .. (table.contains(premake.make.override,\"TARGETDIR\") and \"override \" or \"\") .. 'TARGETDIR = %s', iif(targetDir == \"\", \".\", targetDir))\n_p(' ' .. (table.contains(premake.make.override,\"TARGET\") and \"override \" or \"\") .. 'TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))\n_p(' DEFINES +=%s', make.list(_MAKE.escquote(cc.getdefines(cfg.defines))))\nlocal id = make.list(cc.getincludedirs(cfg.includedirs));\nlocal uid = make.list(cc.getquoteincludedirs(cfg.userincludedirs))\nlocal sid = make.list(cc.getsystemincludedirs(cfg.systemincludedirs))\nif id ~= \"\" then\n_p(' INCLUDES +=%s', id)\nend" "\nif uid ~= \"\" then\n_p(' INCLUDES +=%s', uid)\nend\nif sid ~= \"\" then\n_p(' INCLUDES +=%s', sid)\nend\ncpp.pchconfig(cfg)\ncpp.flags(cfg, cc)\ncpp.linker(prj, cfg, cc)\ntable.sort(cfg.files)\nif cfg.flags.UseObjectResponseFile then\n_p(' OBJRESP = $(OBJDIR)/%s_objects', prj.name)\nelse\n_p(' OBJRESP =')\nend\n_p(' OBJECTS := \\\\')\nfor _, file in ipairs(cfg.files) do\nif path.issourcefile(file) then\nif not is_excluded(prj, cfg, file) then\n_p('\\t$(OBJDIR)/%s.o \\\\'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n)\nend\nend\nend\n_p('')\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define PRELINKCMDS')\nif #cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_p('\\t%s', table.implode(cfg.prelinkcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define POSTBUILD" "CMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\nmake.settings(cfg, cc)\n_p('endif')\n_p('')\nend\nfunction cpp.platformtools(cfg, cc)\nlocal platform = cc.platforms[cfg.platform]\nif platform.cc then\n_p(' CC = %s', platform.cc)\nend\nif platform.cxx then\n_p(' CXX = %s', platform.cxx)\nend\nif platform.ar then\n_p(' AR = %s', platform.ar)\nend\nend\nfunction cpp.flags(cfg, cc)\nif cfg.pchheader and not cfg.flags.NoPCH then\n_p(' FORCE_INCLUDE += -include $(OBJDIR)/$(notdir $(PCH))')\n_p(' FORCE_INCLUDE_OBJC += -include $(OBJDIR)/$(notdir $(PCH))_objc')\nend\nif #cfg.forcedincludes > 0 then\n_p(' FORCE_INCLUDE += -include %s'\n,_MAKE.esc(table.concat(cfg.forcedincludes, \";\")))\nend\n_p(' ALL_CPPFLAGS += $(CPPFLAGS) %s $(DEFINES) $(INCLUDES)', table.concat(cc.getcppflags(cfg), \" \"))\n_p(' ALL_ASMFLAGS += $(ASMFLAGS) $(CFLA" "GS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_asm)))\n_p(' ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_c)))\n_p(' ALL_CXXFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_cpp)))\n_p(' ALL_OBJCFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getobjcflags(cfg), cfg.buildoptions, cfg.buildoptions_objc)))\n_p(' ALL_OBJCPPFLAGS += $(CXXFLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)%s', make.list(table.join(cc.getcflags(cfg), cc.getcxxflags(cfg), cc.getobjcflags(cfg), cfg.buildoptions, cfg.buildoptions_objcpp)))\n_p(' ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)%s',\n make.list(table.join(cc.getdefines(cfg.resdefines),\n cc.getincludedirs(cfg.resincludedirs), cf" "g.resoptions)))\nend\nfunction cpp.linker(prj, cfg, cc)\nlocal libdeps\nlocal lddeps\nif #cfg.wholearchive > 0 then\nlibdeps = {}\nlddeps = {}\nfor _, linkcfg in ipairs(premake.getlinks(cfg, \"siblings\", \"object\")) do\nlocal linkpath = path.rebase(linkcfg.linktarget.fullpath, linkcfg.location, cfg.location)\nif table.icontains(cfg.wholearchive, linkcfg.project.name) then\nlddeps = table.join(lddeps, cc.wholearchive(linkpath))\nelse\ntable.insert(lddeps, linkpath)\nend\ntable.insert(libdeps, linkpath)\nend\nlibdeps = make.list(_MAKE.esc(libdeps))\nlddeps = make.list(_MAKE.esc(lddeps))\nelse\nlibdeps = make.list(_MAKE.esc(premake.getlinks(cfg, \"siblings\", \"fullpath\")))\nlddeps = libdeps\nend\n_p(' ALL_LDFLAGS += $(LDFLAGS)%s', make.list(table.join(cc.getlibdirflags(cfg), cc.getldflags(cfg), cfg.linkoptions)))\n_p(' LIBDEPS +=%s', libdeps)\n_p(' LDDEPS +=%s', lddeps)\nif cfg.flags.UseLDResponseFile then\n_p(' LDRESP = $(OBJDIR)/%s_libs', prj.name)\n_p(' LI" "BS += @$(LDRESP)%s', make.list(cc.getlinkflags(cfg)))\nelse\n_p(' LDRESP =')\n_p(' LIBS += $(LDDEPS)%s', make.list(cc.getlinkflags(cfg)))\nend\n_p(' EXTERNAL_LIBS +=%s', make.list(cc.getlibfiles(cfg)))\n_p(' LINKOBJS = %s', (cfg.flags.UseObjectResponseFile and \"@$(OBJRESP)\" or \"$(OBJECTS)\"))\nif cfg.kind == \"StaticLib\" then\nif (not prj.options.ArchiveSplit) then\n_p(' LINKCMD = $(AR) %s $(TARGET)', make.list(cc.getarchiveflags(prj, cfg, false)))\nelse\n_p(' LINKCMD = $(AR) %s $(TARGET)', make.list(cc.getarchiveflags(prj, cfg, false)))\n_p(' LINKCMD_NDX = $(AR) %s $(TARGET)', make.list(cc.getarchiveflags(prj, cfg, true)))\nend\nelse\nlocal tool = iif(cfg.language == \"C\", \"CC\", \"CXX\")\nlocal startgroup = ''\nlocal endgroup = ''\nif (cfg.flags.LinkSupportCircularDependencies) then\nstartgroup = '-Wl,--start-group '\nendgroup = ' -Wl,--end-group'\nend\n_p(' LINKCMD = $(%s) -o $(TARGET) $(LINK" "OBJS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) %s$(LIBS)%s', tool, startgroup, endgroup)\nend\nend\nfunction cpp.pchconfig(cfg)\nif not cfg.pchheader or cfg.flags.NoPCH then\nreturn\nend\nlocal pch = cfg.pchheader\nfor _, incdir in ipairs(cfg.includedirs) do\nlocal abspath = path.getabsolute(path.join(cfg.project.location, incdir))\nlocal testname = path.join(abspath, pch)\nif os.isfile(testname) then\npch = path.getrelative(cfg.location, testname)\nbreak\nend\nend\n_p(' PCH = %s', _MAKE.esc(pch))\n_p(' GCH = $(OBJDIR)/$(notdir $(PCH)).gch')\n_p(' GCH_OBJC = $(OBJDIR)/$(notdir $(PCH))_objc.gch')\nend\nfunction cpp.pchrules(prj)\n_p('ifneq (,$(PCH))')\n_p('$(GCH): $(PCH) $(MAKEFILE) | $(OBJDIR)')\nif prj.msgprecompile then\n_p('\\t@echo ' .. prj.msgprecompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nlocal cmd = iif(prj.language == \"C\", \"$(CC) $(ALL_CFLAGS) -x c-header\", \"$(CXX) $(ALL_CXXFLAGS) -x c++-header\")\n_p('\\t$(SILENT) %s $(DEFINES) $(INCLUDES) -o \"$@\" -" "c \"$<\"', cmd)\n_p('')\n_p('$(GCH_OBJC): $(PCH) $(MAKEFILE) | $(OBJDIR)')\nif prj.msgprecompile then\n_p('\\t@echo ' .. prj.msgprecompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nlocal cmd = iif(prj.language == \"C\", \"$(CC) $(ALL_OBJCFLAGS) -x objective-c-header\", \"$(CXX) $(ALL_OBJCPPFLAGS) -x objective-c++-header\")\n_p('\\t$(SILENT) %s $(DEFINES) $(INCLUDES) -o \"$@\" -c \"$<\"', cmd)\n_p('endif')\n_p('')\nend\nfunction cpp.fileRules(prj, cc)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\n_p('ifneq (,$(OBJRESP))')\n_p('$(OBJRESP): $(OBJECTS) | $(TARGETDIR) $(OBJDIRS)')\n_p('\\t$(SILENT) echo $^')\n_p('\\t$(SILENT) echo $^ > $@')\n_p('endif')\n_p('')\n_p('ifneq (,$(LDRESP))')\n_p('$(LDRESP): $(LDDEPS) | $(TARGETDIR) $(OBJDIRS)')\n_p('\\t$(SILENT) echo $^')\n_p('\\t$(SILENT) echo $^ > $@')\n_p('endif')\n_p('')\ntable.sort(prj.allfiles)\nfor _, file in ipairs(prj.allfiles or {}) do\nif path.issourcefile(file) then\nif (path.isobjcfile(file)) then\n_p('$(OBJDIR)/%s.o: %" "s $(GCH_OBJC) $(MAKEFILE) | $(OBJDIR)/%s'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(file)\n, _MAKE.esc(path.getdirectory(path.trimdots(file)))\n)\nelse\n_p('$(OBJDIR)/%s.o: %s $(GCH) $(MAKEFILE) | $(OBJDIR)/%s'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(file)\n, _MAKE.esc(path.getdirectory(path.trimdots(file)))\n)\nend\nif (path.isobjcfile(file) and prj.msgcompile_objc) then\n_p('\\t@echo ' .. prj.msgcompile_objc)\nelseif prj.msgcompile then\n_p('\\t@echo ' .. prj.msgcompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\nif (path.isobjcfile(file)) then\nif (path.iscfile(file)) then\n_p('\\t$(SILENT) $(CXX) $(ALL_OBJCFLAGS) $(FORCE_INCLUDE_OBJC) -o \"$@\" -c \"$<\"')\nelse\n_p('\\t$(SILENT) $(CXX) $(ALL_OBJCPPFLAGS) $(FORCE_INCLUDE_OBJC) -o \"$@\" -c \"$<\"')\nend\nelseif (path.isasmfile(file)) then\n_p('\\t$(SILENT) $(CC) $(ALL_ASMFLAGS) -o \"$@\" -c \"$<\"')\nelse\ncpp.buildcommand(path.iscfile(file) and not prj.options.ForceCPP, \"o\")\nend\nfor _, task in ipairs(prj.postc" "ompiletasks or {}) do\n_p('\\t$(SILENT) %s', task)\n_p('')\nend\n_p('')\nelseif (path.getextension(file) == \".rc\") then\n_p('$(OBJDIR)/%s.res: %s', _MAKE.esc(path.getbasename(file)), _MAKE.esc(file))\nif prj.msgresource then\n_p('\\t@echo ' .. prj.msgresource)\nelse\n_p('\\t@echo $(notdir $<)')\nend\n_p('\\t$(SILENT) $(RESCOMP) $< -O coff -o \"$@\" $(ALL_RESFLAGS)')\n_p('')\nend\nend\nend\nfunction cpp.dependencyRules(prj)\nfor _, dependency in ipairs(prj.dependency or {}) do\nfor _, dep in ipairs(dependency or {}) do\nif (dep[3]==nil or dep[3]==false) then\n_p('$(OBJDIR)/%s.o: %s'\n, _MAKE.esc(path.trimdots(path.removeext(path.getrelative(prj.location, dep[1]))))\n, _MAKE.esc(path.getrelative(prj.location, dep[2]))\n)\nelse\n_p('%s: %s'\n, _MAKE.esc(dep[1])\n, _MAKE.esc(path.getrelative(prj.location, dep[2]))\n)\nend\n_p('')\nend\nend\nend\nfunction cpp.buildcommand(iscfile, objext)\nlocal flags = iif(iscfile, '$(CC) $(ALL_CFLAGS)', '$(CXX) $(ALL_CXXFLAGS)')\n_p('\\t$(SILENT) %s $(FORCE_INCLUDE) -o \"$@\" -" "c \"$<\"', flags, objext)\nend\n", /* actions/make/make_csharp.lua */ "local function getresourcefilename(cfg, fname)\nif path.getextension(fname) == \".resx\" then\nlocal name = cfg.buildtarget.basename .. \".\"\nlocal dir = path.getdirectory(fname)\nif dir ~= \".\" then\nname = name .. path.translate(dir, \".\") .. \".\"\nend\nreturn \"$(OBJDIR)/\" .. _MAKE.esc(name .. path.getbasename(fname)) .. \".resources\"\nelse\nreturn fname\nend\nend\nfunction premake.make_csharp(prj)\nlocal csc = premake.dotnet\nlocal cfglibs = { }\nlocal cfgpairs = { }\nlocal anycfg\nfor cfg in premake.eachconfig(prj) do\nanycfg = cfg\ncfglibs[cfg] = premake.getlinks(cfg, \"siblings\", \"fullpath\")\ncfgpairs[cfg] = { }\nfor _, fname in ipairs(cfglibs[cfg]) do\nif path.getdirectory(fname) ~= cfg.buildtarget.directory then\ncfgpairs[cfg][\"$(TARGETDIR)/\" .. _MAKE.esc(path.getname(fname))] = _MAKE.esc(fname)\nend\nend\nend\nlocal sources = {}\nlocal embedded = { }\nlocal copypairs = { }\nfor fcfg in premake.project.eachfile(prj) do\nlocal action = csc.getbuildaction(fcfg)\nif action == \"Compile\" then" "\ntable.insert(sources, fcfg.name)\nelseif action == \"EmbeddedResource\" then\ntable.insert(embedded, fcfg.name)\nelseif action == \"Content\" then\ncopypairs[\"$(TARGETDIR)/\" .. _MAKE.esc(path.getname(fcfg.name))] = _MAKE.esc(fcfg.name)\nelseif path.getname(fcfg.name):lower() == \"app.config\" then\ncopypairs[\"$(TARGET).config\"] = _MAKE.esc(fcfg.name)\nend\nend\nlocal paths = table.translate(prj.libdirs, function(v) return path.join(prj.basedir, v) end)\npaths = table.join({prj.basedir}, paths)\nfor _, libname in ipairs(premake.getlinks(prj, \"system\", \"fullpath\")) do\nlocal libdir = os.pathsearch(libname..\".dll\", unpack(paths))\nif (libdir) then\nlocal target = \"$(TARGETDIR)/\" .. _MAKE.esc(path.getname(libname))\nlocal source = path.getrelative(prj.basedir, path.join(libdir, libname))..\".dll\"\ncopypairs[target] = _MAKE.esc(source)\nend\nend\n_p('# %s project makefile autogenerated by GENie', premake.action.current().shortname)\n_p('')\n_p('.SUFFIXES:') -- Delete the default suffix rules.\n_p('')" "\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(prj.configurations[1]:lower()))\n_p('endif')\n_p('')\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(MAKESHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' MKDIR = $(SILENT) mkdir -p \"$(1)\"')\n_p(' COPY = $(SILENT) cp -fR \"$(1)\" \"$(2)\"')\n_p('else')\n_p(' MKDIR = $(SILENT) mkdir \"$(subst /,\\\\\\\\,$(1))\" 2> nul')\n_p(' COPY = $(SILENT) copy /Y \"$(subst /,\\\\\\\\,$(1))\" \"$(subst /,\\\\\\\\,$(2))\"')\n_p('endif')\n_p('')\n_p('ifndef CSC')\n_p(' CSC=%s', csc.getcompilervar(prj))\n_p('endif')\n_p('')\n_p('ifndef RESGEN')\n_p(' RESGEN=resgen')\n_p('endif')\n_p('')\nlocal platforms = premake.filterplatforms(prj.solution, premake[_OPTIONS.cc].platforms)\ntable.i" "nsert(platforms, 1, \"\")\nfor cfg in premake.eachconfig(prj) do\npremake.gmake_cs_config(cfg, csc, cfglibs)\nend\n_p('# To maintain compatibility with VS.NET, these values must be set at the project level')\n_p('TARGET := $(TARGETDIR)/%s', _MAKE.esc(prj.buildtarget.name))\n_p('FLAGS += /t:%s %s', csc.getkind(prj):lower(), table.implode(_MAKE.esc(prj.libdirs), \"/lib:\", \"\", \" \"))\n_p('REFERENCES += %s', table.implode(_MAKE.esc(premake.getlinks(prj, \"system\", \"basename\")), \"/r:\", \".dll\", \" \"))\n_p('')\n_p('SOURCES := \\\\')\nfor _, fname in ipairs(sources) do\n_p('\\t%s \\\\', _MAKE.esc(path.translate(fname)))\nend\n_p('')\n_p('EMBEDFILES := \\\\')\nfor _, fname in ipairs(embedded) do\n_p('\\t%s \\\\', getresourcefilename(prj, fname))\nend\n_p('')\n_p('COPYFILES += \\\\')\nfor target, source in pairs(cfgpairs[anycfg]) do\n_p('\\t%s \\\\', target)\nend\nfor target, source in pairs(copypairs) do\n_p('\\t%s \\\\', target)\nend\n_p('')\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPE" "C))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(MAKESHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('')\n_p('.PHONY: clean prebuild prelink')\n_p('')\n_p('all: $(TARGETDIR) $(OBJDIR) prebuild $(EMBEDFILES) $(COPYFILES) prelink $(TARGET)')\n_p('')\n_p('$(TARGET): $(SOURCES) $(EMBEDFILES) $(DEPENDS)')\n_p('\\t$(SILENT) $(CSC) /nologo /out:$@ $(FLAGS) $(REFERENCES) $(SOURCES) $(patsubst %%,/resource:%%,$(EMBEDFILES))')\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n_p('$(TARGETDIR):')\npremake.make_mkdirrule(\"$(TARGETDIR)\")\n_p('$(OBJDIR):')\npremake.make_mkdirrule(\"$(OBJDIR)\")\n_p('clean:')\n_p('\\t@echo Cleaning %s', prj.name)\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGET) $(COPYFILES)')\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGETDIR)/%s.*) del $(subst /,\\\\\\\\,$(TARGETDIR)/%s.*)', prj.buildtarget.basename, p" "rj.buildtarget.basename)\nfor target, source in pairs(cfgpairs[anycfg]) do\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,%s) del $(subst /,\\\\\\\\,%s)', target, target)\nend\nfor target, source in pairs(copypairs) do\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,%s) del $(subst /,\\\\\\\\,%s)', target, target)\nend\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('endif')\n_p('')\n_p('prebuild:')\n_p('\\t$(PREBUILDCMDS)')\n_p('')\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\n_p('# Per-configuration copied file rules')\nfor cfg in premake.eachconfig(prj) do\n_p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower()))\nfor target, source in pairs(cfgpairs[cfg]) do\npremake.make_copyrule(source, target)\nend\n_p('endif')\n_p('')\nend\n_p('# Copied file rules')\nfor target, source in pairs(copypairs) do\npremake.make_copyrule(source, target)\nend\n_p('# Embedded file rules')\nfor _, fname in ipairs(embedded) do\nif path.getextension(fname) == " "\".resx\" then\n_p('%s: %s', getresourcefilename(prj, fname), _MAKE.esc(fname))\n_p('\\t$(SILENT) $(RESGEN) $^ $@')\nend\n_p('')\nend\nend\nfunction premake.gmake_cs_config(cfg, csc, cfglibs)\nlocal targetDir = _MAKE.esc(cfg.buildtarget.directory)\n_p('ifneq (,$(findstring %s,$(config)))', _MAKE.esc(cfg.name:lower()))\n_p(' TARGETDIR := %s', iif(targetDir == \"\", \".\", targetDir))\n_p(' OBJDIR := %s', _MAKE.esc(cfg.objectsdir))\n_p(' DEPENDS := %s', table.concat(_MAKE.esc(premake.getlinks(cfg, \"dependencies\", \"fullpath\")), \" \"))\n_p(' REFERENCES := %s', table.implode(_MAKE.esc(cfglibs[cfg]), \"/r:\", \"\", \" \"))\n_p(' FLAGS += %s %s', table.implode(cfg.defines, \"/d:\", \"\", \" \"), table.concat(table.join(csc.getflags(cfg), cfg.buildoptions), \" \"))\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define PRELINKCMDS')\nif #" "cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_p('\\t%s', table.implode(cfg.prelinkcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define POSTBUILDCMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p('endif')\n_p('')\nend\n", /* actions/make/make_vala.lua */ "premake.make.vala = { }\nlocal vala = premake.make.vala\nlocal make = premake.make\nfunction premake.make_vala(prj)\nlocal valac = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, valac.platforms, \"Native\")\npremake.gmake_vala_header(prj, valac, platforms)\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\npremake.gmake_valac_config(prj, cfg, valac)\nend\nend\nlocal objdirs = {}\nlocal additionalobjdirs = {}\nfor _, file in ipairs(prj.allfiles) do\nif path.issourcefile(file) or path.isgresource(file) then\nobjdirs[_MAKE.esc(path.getdirectory(path.trimdots(file)))] = 1\nend\nend\n_p('OBJDIRS := \\\\')\n_p('\\t$(OBJDIR) \\\\')\nfor dir, _ in iter.sortByKeys(objdirs) do\n_p('\\t$(OBJDIR)/%s \\\\', dir)\nend\nfor dir, _ in iter.sortByKeys(additionalobjdirs) do\n_p('\\t%s \\\\', dir)\nend\n_p('')\n_p('.PHONY: clean prebuild prelink')\n_p('')\n_p('all: $(OBJDIRS) $(TARGETDIR) prebuild prelink $(TARGET)')\n_p('\\t@:')\n_p('')\n_p('$(TARGET): $(OBJ" "ECTS) | $(TARGETDIR)')\n_p('\\t@echo Linking %s', prj.name)\n_p('\\t$(SILENT) $(LINKCMD)')\n_p('\\t$(POSTBUILDCMDS)')\n_p('')\n_p('$(TARGETDIR):')\npremake.make_mkdirrule(\"$(TARGETDIR)\")\n_p('$(OBJDIRS):')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCreatingMessage\")) then\n_p('\\t@echo Creating $(@)')\nend\n_p('\\t-$(call MKDIR,$@)')\n_p('')\n_p('clean:')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCleaningMessage\")) then\n_p('\\t@echo Cleaning %s', prj.name)\nend\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGET)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGET)) del $(subst /,\\\\\\\\,$(TARGET))')\n_p('endif')\n_p('')\n_p('prebuild:')\n_p('\\t$(PREBUILDCMDS)')\n_p('')\n_p('prelink:')\n_p('\\t$(PRELINKCMDS)')\n_p('')\nvala.fileRules(prj, valac)\nend\nfunction premake.gmake_vala_header(prj, valac, platforms)\n_p('# %s project makefile autogenerated by GENie', premake.action.curr" "ent().shortname)\n_p('')\n_p('.SUFFIXES:') -- Delete the default suffix rules.\n_p('')\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))\n_p('endif')\n_p('')\n_p('ifndef verbose')\n_p(' SILENT = @')\n_p('endif')\n_p('')\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(MAKESHELL)))')\n_p(' SHELLTYPE := posix')\n_p('endif')\n_p('')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(' MKDIR = $(SILENT) mkdir -p \"$(1)\"')\n_p(' COPY = $(SILENT) cp -fR \"$(1)\" \"$(2)\"')\n_p(' RM = $(SILENT) rm -f \"$(1)\"')\n_p('else')\n_p(' MKDIR = $(SILENT) mkdir \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p(' COPY = $(SILENT) copy /Y \"$(subst /,\\\\\\\\,$(1))\" \"$(subst /,\\\\\\\\,$(2))\"')\n_p(' RM = $(SILENT) del /F \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n" "_p('endif')\n_p('')\n_p('VALAC = %s', valac.valac)\n_p('CC = %s', valac.cc)\n_p('GLIBRC = %s', valac.glibrc)\n_p('')\nend\nlocal function is_excluded(prj, cfg, file)\nif table.icontains(prj.excludes, file) then\nreturn true\nend\nif table.icontains(cfg.excludes, file) then\nreturn true\nend\nreturn false\nend\nfunction premake.gmake_valac_config(prj, cfg, valac)\n_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))\n_p(' BASEDIR = %s', _MAKE.esc(path.getrelative(cfg.location, _WORKING_DIR)))\n_p(' OBJDIR = %s', _MAKE.esc(cfg.objectsdir))\n_p(' TARGETDIR = %s', _MAKE.esc(cfg.buildtarget.directory))\n_p(' TARGET = $(TARGETDIR)/%s', _MAKE.esc(cfg.buildtarget.name))\n_p(' DEFINES +=%s', make.list(valac.getdefines(cfg.defines)))\n_p(' VAPIDIRS +=%s', make.list(valac.getvapidirs(cfg.vapidirs)))\n_p(' PKGS +=%s', make.list(valac.getlinks(cfg.links)))\n_p(' FLAGS += $(DEFINES) $(VAPIDIRS) $(PKGS)%s', make.list(table.join(valac.getvalaflags(cfg), cfg.buildoptions_vala)))\n_p(' A" "LL_LDFLAGS+= $(LDFLAGS)%s', make.list(table.join(cfg.linkoptions)))\n_p(' LINKOBJS = %s', \"$(OBJECTS)\")\n_p(' ALL_CFLAGS += $(CFLAGS) $(ARCH)%s', make.list(table.join(cfg.buildoptions, cfg.buildoptions_c, valac.getvalaccflags(cfg))))\n_p(' LINKCMD = $(CC) -o $(TARGET) $(LINKOBJS) $(ARCH) $(ALL_LDFLAGS)');\ntable.sort(cfg.files)\n_p(' OBJECTS := \\\\')\nfor _, file in ipairs(cfg.files) do\nif path.issourcefile(file) or path.isgresource(file) then\nif not is_excluded(prj, cfg, file) then\n_p('\\t$(OBJDIR)/%s.o \\\\'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n)\nend\nend\nend\n_p('')\n_p(' SOURCES := \\\\')\nfor _, file in ipairs(cfg.files) do\nif path.issourcefile(file) and path.isvalafile(file) then\nif not is_excluded(prj, cfg, file) then\n_p('\\t%s \\\\', _MAKE.esc(file))\nend\nend\nend\n_p('')\n_p(' GRESOURCES := \\\\')\nfor _, file in ipairs(cfg.files) do\nif path.isgresource(file) then\nif not is_excluded(prj, cfg, file) then\n_p('\\t%s \\\\', _MAKE.esc(file))\nend\nend\nend\n_p('')" "\n_p(' define PREBUILDCMDS')\nif #cfg.prebuildcommands > 0 then\n_p('\\t@echo Running pre-build commands')\n_p('\\t%s', table.implode(cfg.prebuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define PRELINKCMDS')\nif #cfg.prelinkcommands > 0 then\n_p('\\t@echo Running pre-link commands')\n_p('\\t%s', table.implode(cfg.prelinkcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p(' define POSTBUILDCMDS')\nif #cfg.postbuildcommands > 0 then\n_p('\\t@echo Running post-build commands')\n_p('\\t%s', table.implode(cfg.postbuildcommands, \"\", \"\", \"\\n\\t\"))\nend\n_p(' endef')\n_p('endif')\n_p('')\nend\nfunction vala.fileRules(prj, cc)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\n_p('ifneq (,$(OBJRESP))')\n_p('$(OBJRESP): $(OBJECTS) | $(TARGETDIR) $(OBJDIRS)')\n_p('\\t$(SILENT) echo $^')\n_p('\\t$(SILENT) echo $^ > $@')\n_p('endif')\n_p('')\n_p('ifneq (,$(LDRESP))')\n_p('$(LDRESP): $(LDDEPS) | $(TARGETDIR) $(OBJDIRS)')\n_p('\\t$(SILENT) echo $^')\n_p('" "\\t$(SILENT) echo $^ > $@')\n_p('endif')\n_p('')\nlocal pattern_targets = \"\"\ntable.sort(prj.allfiles)\nfor _, file in ipairs(prj.allfiles or {}) do\nif path.issourcefile(file) or path.isgresource(file) then\nif path.isvalafile(file) or path.iscfile(file) or path.isgresource(file) then\nif path.isvalafile(file) or path.isgresource(file) then\n_p('$(OBJDIR)/%s.o: $(OBJDIR)/%s.c $(GCH) $(MAKEFILE) | $(OBJDIR)/%s'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(path.getdirectory(path.trimdots(file)))\n)\nif not path.isgresource(file) then\npattern_targets = pattern_targets\n.. \"$(OBJDIR)/\"\n.. _MAKE.esc(path.trimdots(path.removeext(file)))\n.. \".% \\\\\\n\" -- Pattern rule: https://stackoverflow.com/a/3077254\nend\nelse\n_p('$(OBJDIR)/%s.o: %s $(GCH) $(MAKEFILE) | $(OBJDIR)/%s'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, file\n, _MAKE.esc(path.getdirectory(path.trimdots(file)))\n)\nend\nif prj.msgcompile then\n_p('\\t@echo ' .. prj.msg" "compile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\n_p('\\t$(SILENT) %s $(FORCE_INCLUDE) -o \"$@\" -c \"$<\"'\n, \"$(CC) $(ALL_CFLAGS)\"\n, _MAKE.esc(path.getbasename(file))\n)\nfor _, task in ipairs(prj.postcompiletasks or {}) do\n_p('\\t$(SILENT) %s', task)\n_p('')\nend\n_p('')\nif path.isgresource(file) then\n_p('$(OBJDIR)/%s.c: %s $(GCH) $(MAKEFILE) | $(OBJDIR)/%s'\n, _MAKE.esc(path.trimdots(path.removeext(file)))\n, _MAKE.esc(file)\n, _MAKE.esc(path.getdirectory(path.trimdots(file)))\n)\nif prj.msgcompile then\n_p('\\t@echo ' .. prj.msgcompile)\nelse\n_p('\\t@echo $(notdir $<)')\nend\n_p('\\t$(SILENT) %s \"$<\" --target=\"$@\" --sourcedir=\"%s\" --generate'\n, \"$(GLIBRC)\"\n, _MAKE.esc(path.getdirectory(file))\n)\nfor _, task in ipairs(prj.postcompiletasks or {}) do\n_p('\\t$(SILENT) %s', task)\n_p('')\nend\nend\n_p('')\nend\nend\nend\nif pattern_targets ~= \"\" then\n_p('%s: $(SOURCES) $(GRESOURCES) $(GCH) $(MAKEFILE)', pattern_targets)\nif prj.msgcompile then\n_p('\\t@echo ' .. prj.msgcompile)\nelse\n_p(" "'\\t@echo [GEN] valac')\nend\n_p('\\t$(SILENT) %s $(SOURCES) --directory $(OBJDIR) --basedir $(BASEDIR) --gresources=$(GRESOURCES) -C > /dev/null'\n, \"$(VALAC) $(FLAGS)\"\n)\nfor _, task in ipairs(prj.postcompiletasks or {}) do\n_p('\\t$(SILENT) %s', task)\n_p('')\nend\nend\nend\n", /* actions/make/make_swift.lua */ "local make = premake.make\nlocal swift = { }\nfunction premake.make_swift(prj)\nlocal tool = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, tool.platforms, \"Native\")\n_p('# %s project makefile autogenerated by GENie', premake.action.current().shortname)\n_p('')\n_p('.SUFFIXES:') -- Delete the default suffix rules.\n_p('')\n_p('ifndef config')\n_p(1, 'config=%s', _MAKE.esc(premake.getconfigname(prj.solution.configurations[1], platforms[1], true)))\n_p('endif')\n_p('')\n_p('ifndef verbose')\n_p(1, 'SILENT = @')\n_p('endif')\n_p('')\n_p('SHELLTYPE := msdos')\n_p('ifeq (,$(ComSpec)$(COMSPEC))')\n_p(1, 'SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(SHELL)))')\n_p(1, 'SHELLTYPE := posix')\n_p('endif')\n_p('ifeq (/bin,$(findstring /bin,$(MAKESHELL)))')\n_p(1, 'SHELLTYPE := posix')\n_p('endif')\n_p('')\n_p('ifeq (posix,$(SHELLTYPE))')\n_p(1, 'MKDIR = $(SILENT) mkdir -p \"$(1)\"')\n_p(1, 'COPY = $(SILENT) cp -fR \"$(1)\" \"$(2)\"')\n_p(1, 'RM = $(SILENT) rm -" "f \"$(1)\"')\n_p('else')\n_p(1, 'MKDIR = $(SILENT) mkdir \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p(1, 'COPY = $(SILENT) copy /Y \"$(subst /,\\\\\\\\,$(1))\" \"$(subst /,\\\\\\\\,$(2))\"')\n_p(1, 'RM = $(SILENT) del /F \"$(subst /,\\\\\\\\,$(1))\" 2> nul || exit 0')\n_p('endif')\n_p('')\n_p('SWIFTC = %s', tool.swift)\n_p('SWIFTLINK = %s', tool.swiftc)\n_p('DSYMUTIL = %s', tool.dsymutil)\n_p('AR = %s', tool.ar)\n_p('')\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\nswift.generate_config(prj, cfg, tool)\nend\nend\n_p('.PHONY: ')\n_p('')\n_p('all: $(WORK_DIRS) $(TARGET)')\n_p('')\n_p('$(WORK_DIRS):')\n_p(1, '$(SILENT) $(call MKDIR,$@)')\n_p('')\n_p('SOURCES := \\\\')\nfor _, file in ipairs(prj.files) do\nif path.isswiftfile(file) then\n_p(1, '%s \\\\', _MAKE.esc(file))\nend\nend\n_p('')\nlocal objfiles = {}\n_p('OBJECTS_WITNESS := $(OBJDIR)/build.stamp')\n_p('OBJECTS := \\\\')\nfor _, file in ipairs(prj.files) do\nif path.isswiftfile(file) then\nlocal objna" "me = _MAKE.esc(swift.objectname(file))\ntable.insert(objfiles, objname)\n_p(1, '%s \\\\', objname)\nend\nend\n_p('')\nswift.file_rules(prj, objfiles)\nswift.linker(prj, tool)\nswift.generate_clean(prj)\nend\nfunction swift.objectname(file)\nreturn path.join(\"$(OBJDIR)\", path.getname(file)..\".o\")\nend\nfunction swift.file_rules(prj, objfiles)\n_p('$(OBJECTS_WITNESS): $(SOURCES)')\n_p(1, \"@rm -f $(OBJDIR)/data.tmp\")\n_p(1, \"@touch $(OBJDIR)/data.tmp\")\n_p(1, \"$(SILENT) $(SWIFTC) -frontend -c $(SOURCES) -enable-objc-interop $(SDK) -I $(OUT_DIR) $(SWIFTC_FLAGS) -module-cache-path $(MODULECACHE_DIR) -D SWIFT_PACKAGE $(MODULE_MAPS) -emit-module-doc-path $(OUT_DIR)/$(MODULE_NAME).swiftdoc -module-name $(MODULE_NAME) -emit-module-path $(OUT_DIR)/$(MODULE_NAME).swiftmodule -num-threads 8 %s\", table.arglist(\"-o\", objfiles))\n_p(1, \"@mv -f $(OBJDIR)/data.tmp $(OBJECTS_WITNESS)\")\n_p('')\n_p('$(OBJECTS): $(OBJECTS_WITNESS)')\n_p(1, '@if test -f $@; then :; else \\\\')\n_p(2, 'rm -f $(OBJECTS_WITNESS); \\\\')" "\n_p(2, '$(MAKE) $(AM_MAKEFLAGS) $(OBJECTS_WITNESS); \\\\')\n_p(1, 'fi')\n_p('')\nend\nfunction swift.linker(prj, tool)\nlocal lddeps = make.list(premake.getlinks(prj, \"siblings\", \"fullpath\"))\nif prj.kind == \"StaticLib\" then\n_p(\"$(TARGET): $(OBJECTS) %s \", lddeps)\n_p(1, \"$(SILENT) $(AR) cr $(AR_FLAGS) $@ $(OBJECTS) %s\", (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\"))\nelse\n_p(\"$(TARGET): $(OBJECTS) $(LDDEPS)\", lddeps)\n_p(1, \"$(SILENT) $(SWIFTLINK) $(SDK) -L $(OUT_DIR) -o $@ $(SWIFTLINK_FLAGS) $(LD_FLAGS) $(OBJECTS)\")\n_p(\"ifdef SYMBOLS\")\n_p(1, \"$(SILENT) $(DSYMUTIL) $(TARGET) -o $(SYMBOLS)\")\n_p(\"endif\")\nend\n_p('')\nend\nfunction swift.generate_clean(prj)\n_p('clean:')\nif (not prj.solution.messageskip) or (not table.contains(prj.solution.messageskip, \"SkipCleaningMessage\")) then\n_p('\\t@echo Cleaning %s', prj.name)\nend\n_p('ifeq (posix,$(SHELLTYPE))')\n_p('\\t$(SILENT) rm -f $(TARGET)')\n_p('\\t$(SILENT) rm -rf $(OBJDIR)')\n_p('\\t$(SI" "LENT) rm -rf $(SYMBOLS)')\n_p('\\t$(SILENT) rm -rf $(MODULECACHE_DIR)')\n_p('else')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(TARGET)) del $(subst /,\\\\\\\\,$(TARGET))')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(OBJDIR)) rmdir /s /q $(subst /,\\\\\\\\,$(OBJDIR))')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(SYMBOLS)) rmdir /s /q $(subst /,\\\\\\\\,$(SYMBOLS))')\n_p('\\t$(SILENT) if exist $(subst /,\\\\\\\\,$(MODULECACHE_DIR)) rmdir /s /q $(subst /,\\\\\\\\,$(MODULECACHE_DIR))')\n_p('endif')\n_p('')\nend\nfunction swift.generate_config(prj, cfg, tool)\n_p('ifeq ($(config),%s)', _MAKE.esc(cfg.shortname))\n_p(1, \"OUT_DIR = %s\", cfg.buildtarget.directory)\n _p(1, \"MODULECACHE_DIR = $(OUT_DIR)/ModuleCache\")\n_p(1, \"TARGET = $(OUT_DIR)/%s\", _MAKE.esc(cfg.buildtarget.name))\nlocal objdir = path.join(cfg.objectsdir, prj.name .. \".build\")\n_p(1, \"OBJDIR = %s\", objdir)\n_p(1, \"MODULE_NAME = %s\", prj.name)\n_p(1, \"MODULE_MAPS = %s\", make.list(tool.getmodulemaps(cfg)))\n_p(1, \"SWIFTC_FLAGS" " = %s\", make.list(tool.getswiftcflags(cfg)))\n_p(1, \"SWIFTLINK_FLAGS = %s\", make.list(tool.getswiftlinkflags(cfg)))\n_p(1, \"AR_FLAGS = %s\", make.list(tool.getarchiveflags(cfg, cfg, false)))\n_p(1, \"LD_FLAGS = %s\", make.list(tool.getldflags(cfg)))\n_p(1, \"LDDEPS = %s\", make.list(premake.getlinks(cfg, \"siblings\", \"fullpath\")))\nif cfg.flags.Symbols then\n_p(1, \"SYMBOLS = $(TARGET).dSYM\")\nend\nlocal sdk = tool.get_sdk_path(cfg)\nif sdk then\n_p(1, \"TOOLCHAIN_PATH = %s\", tool.get_toolchain_path(cfg))\n_p(1, \"SDK_PATH = %s\", sdk)\n_p(1, \"PLATFORM_PATH = %s\", tool.get_sdk_platform_path(cfg))\n_p(1, \"SDK = -sdk $(SDK_PATH)\")\nelse\n_p(1, \"SDK_PATH =\")\n_p(1, \"SDK =\")\nend\n_p(1,'WORK_DIRS = $(OUT_DIR) $(OBJDIR)')\n_p('endif')\n_p('')\nend\n", /* actions/vstudio/_vstudio.lua */ "premake.vstudio = { }\nlocal toolsets = {\nvs2010 = \"v100\",\nvs2012 = \"v110\",\nvs2013 = \"v120\",\nvs2015 = \"v140\",\nvs2017 = \"v141\",\nvs2019 = \"v142\",\n}\npremake.vstudio.toolset = toolsets[_ACTION] or \"unknown?\"\npremake.vstudio.splashpath = ''\npremake.vstudio.xpwarning = true\nlocal vstudio = premake.vstudio\nvstudio.platforms = {\nany = \"Any CPU\",\nmixed = \"Mixed Platforms\",\nNative = \"Win32\",\nx86 = \"x86\",\nx32 = \"Win32\",\nx64 = \"x64\",\nPS3 = \"PS3\",\nXbox360 = \"Xbox 360\",\nARM = \"ARM\",\nARM64 = \"ARM64\",\nOrbis = \"ORBIS\",\nDurango = \"Durango\",\nTegraAndroid = \"Tegra-Android\",\nNX32 = \"NX32\",\nNX64 = \"NX64\",\nEmscripten = \"Emscripten\",\n}\nfunction vstudio.arch(prj)\nif (prj.language == \"C#\") then\nreturn \"Any CPU\"\nelse\nreturn \"Win32\"\nend\nend\nfunction vstudio.iswinrt()\nreturn vstudio.storeapp ~= nil and vstudio.storeapp ~= ''\nend\nfunction vstudio.buildconfigs(sln)\nlocal cfgs = { }\nlocal platforms = premake.fi" "lterplatforms(sln, vstudio.platforms, \"Native\")\nlocal hascpp = premake.hascppproject(sln)\nlocal hasdotnet = premake.hasdotnetproject(sln)\nif hasdotnet and (_ACTION > \"vs2008\" or hascpp) then\ntable.insert(platforms, 1, \"mixed\")\nend\nif hasdotnet and (_ACTION < \"vs2010\" or not hascpp) then\ntable.insert(platforms, 1, \"any\")\nend\nif _ACTION > \"vs2008\" then\nlocal platforms2010 = { }\nfor _, platform in ipairs(platforms) do\nif vstudio.platforms[platform] == \"Win32\" then\nif hascpp then\ntable.insert(platforms2010, platform)\nend\nif hasdotnet then\ntable.insert(platforms2010, \"x86\")\nend\nelse\ntable.insert(platforms2010, platform)\nend\nend\nplatforms = platforms2010\nend\nfor _, buildcfg in ipairs(sln.configurations) do\nfor _, platform in ipairs(platforms) do\nlocal entry = { }\nentry.src_buildcfg = buildcfg\nentry.src_platform = platform\nif platform ~= \"PS3\" or _ACTION > \"vs2008\" then\nentry.buildcfg = buildcfg\nentry.platform = vstudio.platforms[platform]\nelse\nentry.buildcfg =" " platform .. \" \" .. buildcfg\nentry.platform = \"Win32\"\nend\nentry.name = entry.buildcfg .. \"|\" .. entry.platform\nentry.isreal = (platform ~= \"any\" and platform ~= \"mixed\")\ntable.insert(cfgs, entry)\nend\nend\nreturn cfgs\nend\nfunction premake.vstudio.bakeimports(sln)\nfor _,iprj in ipairs(sln.importedprojects) do\nif string.find(iprj.location, \".csproj\") ~= nil then\niprj.language = \"C#\"\nelse\niprj.language = \"C++\"\nend\nlocal f, err = io.open(iprj.location, \"r\")\nif (not f) then\nerror(err, 1)\nend\nlocal projcontents = f:read(\"*all\")\nf:close()\nlocal found, _, uuid = string.find(projcontents, \"<ProjectGuid>{([%w%-]+)}</ProjectGuid>\")\nif not found then\nerror(\"Could not find ProjectGuid element in project \" .. iprj.location, 1)\nend\niprj.uuid = uuid\nif iprj.language == \"C++\" and string.find(projcontents, \"<CLRSupport>true</CLRSupport>\") then\niprj.flags.Managed = true\nend\niprj.relpath = path.getrelative(sln.location, iprj.location)\nend\nend\nfunction premake.vstudio.get" "importprj(prjpath, sln)\nfor _,iprj in ipairs(sln.importedprojects) do\nif prjpath == iprj.relpath then\nreturn iprj\nend\nend\nerror(\"Could not find reference import project \" .. prjpath, 1)\nend\nfunction vstudio.cleansolution(sln)\npremake.clean.file(sln, \"%%.sln\")\npremake.clean.file(sln, \"%%.suo\")\npremake.clean.file(sln, \"%%.ncb\")\npremake.clean.file(sln, \"%%.userprefs\")\npremake.clean.file(sln, \"%%.usertasks\")\nend\nfunction vstudio.cleanproject(prj)\nlocal fname = premake.project.getfilename(prj, \"%%\")\nos.remove(fname .. \".vcproj\")\nos.remove(fname .. \".vcproj.user\")\nos.remove(fname .. \".vcxproj\")\nos.remove(fname .. \".vcxproj.user\")\nos.remove(fname .. \".vcxproj.filters\")\nos.remove(fname .. \".csproj\")\nos.remove(fname .. \".csproj.user\")\nos.remove(fname .. \".pidb\")\nos.remove(fname .. \".sdf\")\nend\nfunction vstudio.cleantarget(name)\nos.remove(name .. \".pdb\")\nos.remove(name .. \".idb\")\nos.remove(name .. \".ilk\")\nos.remove(name .. \".vshost.exe\")\nos.remove(na" "me .. \".exe.manifest\")\nend\nfunction vstudio.projectfile(prj)\nlocal pattern\nif prj.language == \"C#\" then\npattern = \"%%.csproj\"\nelse\npattern = iif(_ACTION > \"vs2008\", \"%%.vcxproj\", \"%%.vcproj\")\nend\nlocal fname = premake.project.getbasename(prj.name, pattern)\nfname = path.join(prj.location, fname)\nreturn fname\nend\nfunction vstudio.tool(prj)\nif (prj.language == \"C#\") then\nreturn \"FAE04EC0-301F-11D3-BF4B-00C04F79EFBC\"\nelse\nreturn \"8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942\"\nend\nend\n", /* actions/vstudio/vstudio_solution.lua */ "premake.vstudio.sln2005 = { }\nlocal vstudio = premake.vstudio\nlocal sln2005 = premake.vstudio.sln2005\nfunction sln2005.generate(sln)\nio.eol = '\\r\\n'\nsln.vstudio_configs = premake.vstudio.buildconfigs(sln)\npremake.vstudio.bakeimports(sln)\n_p('\\239\\187\\191')\nsln2005.reorderProjects(sln)\nsln2005.header(sln)\nfor grp in premake.solution.eachgroup(sln) do\nsln2005.group(grp)\nend\nfor prj in premake.solution.eachproject(sln) do\nsln2005.project(prj)\nend\n \nfor _,iprj in ipairs(sln.importedprojects) do\nsln2005.importproject(iprj)\nend\n_p('Global')\nsln2005.platforms(sln)\nsln2005.project_platforms(sln)\nsln2005.properties(sln)\nsln2005.project_groups(sln)\n_p('EndGlobal')\nend\nfunction sln2005.reorderProjects(sln)\nif sln.startproject then\nfor i, prj in ipairs(sln.projects) do\nif sln.startproject == prj.name then\nlocal cur = prj.group\nwhile cur ~= nil do\nfor j, group in ipairs(sln.groups) do\nif group == cur then\ntable.remove(sln.groups, j)\nbreak\nend\nend\ntable.insert(sln.groups, 1" ", cur)\ncur = cur.parent\nend\ntable.remove(sln.projects, i)\ntable.insert(sln.projects, 1, prj)\nbreak\nend\nend\nend\nend\nfunction sln2005.header(sln)\nlocal action = premake.action.current()\n_p('Microsoft Visual Studio Solution File, Format Version %d.00', action.vstudio.solutionVersion)\nif(_ACTION:sub(3) == \"2015\" or _ACTION:sub(3) == \"2017\") then\n_p('# Visual Studio %s', action.vstudio.toolsVersion:sub(1,2))\nelseif(_ACTION:sub(3) == \"2019\") then\n_p('# Visual Studio Version %s', action.vstudio.toolsVersion:sub(1,2))\nelse\n_p('# Visual Studio %s', _ACTION:sub(3))\nend\nend\nfunction sln2005.project(prj)\nlocal projpath = path.translate(path.getrelative(prj.solution.location, vstudio.projectfile(prj)), \"\\\\\")\n_p('Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"', vstudio.tool(prj), prj.name, projpath, prj.uuid)\nsln2005.projectdependencies(prj)\n_p('EndProject')\nend\nfunction sln2005.group(grp)\n_p('Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"%s\", \"%s\", \"{%s}\"', grp.name, grp." "name, grp.uuid)\n_p('EndProject')\nend\n \nfunction sln2005.importproject(iprj)\n_p('Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"', vstudio.tool(iprj), path.getbasename(iprj.location), iprj.relpath, iprj.uuid)\n_p('EndProject')\nend\nfunction sln2005.projectdependencies(prj)\nlocal deps = premake.getdependencies(prj)\nif #deps > 0 then\nlocal function compareuuid(a, b) return a.uuid < b.uuid end\ntable.sort(deps, compareuuid)\n_p('\\tProjectSection(ProjectDependencies) = postProject')\nfor _, dep in ipairs(deps) do\n_p('\\t\\t{%s} = {%s}', dep.uuid, dep.uuid)\nend\n_p('\\tEndProjectSection')\nend\nend\nfunction sln2005.platforms(sln)\n_p('\\tGlobalSection(SolutionConfigurationPlatforms) = preSolution')\nfor _, cfg in ipairs(sln.vstudio_configs) do\n_p('\\t\\t%s = %s', cfg.name, cfg.name)\nend\n_p('\\tEndGlobalSection')\nend\nfunction sln2005.project_platform(prj, sln)\nfor _, cfg in ipairs(sln.vstudio_configs) do\nlocal mapped\nlocal buildfor\nif premake.isdotnetproject(prj) then\nbuildfor = \"x64\"\nmapped" " = \"Any CPU\"\nelseif prj.flags and prj.flags.Managed then\nmapped = \"x64\"\nelse\nif cfg.platform == \"Any CPU\" or cfg.platform == \"Mixed Platforms\" then\nmapped = sln.vstudio_configs[3].platform\nelse\nmapped = cfg.platform\nend\nend\nlocal build_project = true\nif prj.solution ~= nil then\n build_project = premake.getconfig(prj, cfg.src_buildcfg, cfg.src_platform).build\nend\n_p('\\t\\t{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfg.name, cfg.buildcfg, mapped)\nif build_project then\n if mapped == cfg.platform or cfg.platform == \"Mixed Platforms\" or buildfor == cfg.platform then\n _p('\\t\\t{%s}.%s.Build.0 = %s|%s', prj.uuid, cfg.name, cfg.buildcfg, mapped)\n end\n if premake.vstudio.iswinrt() and prj.kind == \"WindowedApp\" then\n _p('\\t\\t{%s}.%s.Deploy.0 = %s|%s', prj.uuid, cfg.name, cfg.buildcfg, mapped)\n end\nend\nend\nend\nfunction sln2005.project_platforms(sln)\n_p('\\tGlobalSection(ProjectConfigurationPlatforms) = postSolution')\nfor prj in premake.solution.eachproject(s" "ln) do\nsln2005.project_platform(prj, sln)\nend\nfor _,iprj in ipairs(sln.importedprojects) do\nsln2005.project_platform(iprj, sln)\nend\n_p('\\tEndGlobalSection')\nend\nfunction sln2005.properties(sln)\n_p('\\tGlobalSection(SolutionProperties) = preSolution')\n_p('\\t\\tHideSolutionNode = FALSE')\n_p('\\tEndGlobalSection')\nend\nfunction sln2005.project_groups(sln)\n_p('\\tGlobalSection(NestedProjects) = preSolution')\nfor grp in premake.solution.eachgroup(sln) do\nif grp.parent ~= nil then\n_p('\\t\\t{%s} = {%s}', grp.uuid, grp.parent.uuid)\nend\nend\nfor prj in premake.solution.eachproject(sln) do\nif prj.group ~= nil then\n_p('\\t\\t{%s} = {%s}', prj.uuid, prj.group.uuid)\nend\nend\nfor _,iprj in ipairs(sln.importedprojects) do\nif iprj.group ~= nil then\n_p('\\t\\t{%s} = {%s}', iprj.uuid, iprj.group.uuid)\nend\nend\n \n_p('\\tEndGlobalSection')\nend", /* actions/vstudio/vstudio_vcxproj.lua */ "premake.vstudio.vc2010 = { }\nlocal vc2010 = premake.vstudio.vc2010\nlocal vstudio = premake.vstudio\nlocal function vs2010_config(prj)\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nif cfginfo.src_platform == \"TegraAndroid\" then\n_p(1,'<PropertyGroup Label=\"NsightTegraProject\">')\n_p(2,'<NsightTegraProjectRevisionNumber>11</NsightTegraProjectRevisionNumber>')\n_p(1,'</PropertyGroup>')\nbreak\nend\nend\n_p(1,'<ItemGroup Label=\"ProjectConfigurations\">')\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\n_p(2,'<ProjectConfiguration Include=\"%s\">', premake.esc(cfginfo.name))\n_p(3,'<Configuration>%s</Configuration>',cfginfo.buildcfg)\n_p(3,'<Platform>%s</Platform>',cfginfo.platform)\n_p(2,'</ProjectConfiguration>')\nend\n_p(1,'</ItemGroup>')\nend\nlocal function vs2010_globals(prj)\nlocal action = premake.action.current()\n_p(1,'<PropertyGroup Label=\"Globals\">')\n_p(2, '<ProjectGuid>{%s}</ProjectGuid>',prj.uuid)\n_p(2, '<RootNamespace>%s</RootNamespace>',prj.name)\nif vstudio.store" "app ~= \"durango\" then\nlocal windowsTargetPlatformVersion = prj.windowstargetplatformversion or action.vstudio.windowsTargetPlatformVersion\nif windowsTargetPlatformVersion ~= nil then\n_p(2,'<WindowsTargetPlatformVersion>%s</WindowsTargetPlatformVersion>',windowsTargetPlatformVersion)\nif windowsTargetPlatformVersion and string.startswith(windowsTargetPlatformVersion, \"10.\") then\n_p(2,'<WindowsTargetPlatformMinVersion>%s</WindowsTargetPlatformMinVersion>', prj.windowstargetplatformminversion or \"10.0.10240.0\")\nend\nend\nend\nif prj.flags and prj.flags.Managed then\nlocal frameworkVersion = prj.framework or \"4.0\"\n_p(2, '<TargetFrameworkVersion>v%s</TargetFrameworkVersion>', frameworkVersion)\n_p(2, '<Keyword>ManagedCProj</Keyword>')\nelseif vstudio.iswinrt() then\n_p(2, '<DefaultLanguage>en-US</DefaultLanguage>')\nif vstudio.storeapp == \"durango\" then\n_p(2, '<Keyword>Win32Proj</Keyword>')\n_p(2, '<ApplicationEnvironment>title</ApplicationEnvironment>')\n_p(2, '<MinimumVisualStudioVersion>14.0</Mi" "nimumVisualStudioVersion>')\n_p(2, '<TargetRuntime>Native</TargetRuntime>')\nelse\n_p(2, '<AppContainerApplication>true</AppContainerApplication>')\n_p(2, '<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>')\n_p(2, '<ApplicationType>Windows Store</ApplicationType>')\n_p(2, '<ApplicationTypeRevision>%s</ApplicationTypeRevision>', vstudio.storeapp)\nend\nelse\n_p(2, '<Keyword>Win32Proj</Keyword>')\nend\nif not vstudio.xpwarning then\n_p(2, '<XPDeprecationWarning>false</XPDeprecationWarning>')\nend\n_p(1,'</PropertyGroup>')\nend\nfunction vc2010.config_type(config)\nlocal t =\n{\nSharedLib = \"DynamicLibrary\",\nStaticLib = \"StaticLibrary\",\nConsoleApp = \"Application\",\nWindowedApp = \"Application\"\n}\nreturn t[config.kind]\nend\nlocal function if_config_and_platform()\nreturn 'Condition=\"\\'$(Configuration)|$(Platform)\\'==\\'%s\\'\"'\nend\nlocal function optimisation(cfg)\nlocal result = \"Disabled\"\nfor _, value in ipairs(cfg.flags) do\nif (value == \"Optimize\") then\nresult = \"Full\"\nels" "eif (value == \"OptimizeSize\") then\nresult = \"MinSpace\"\nelseif (value == \"OptimizeSpeed\") then\nresult = \"MaxSpeed\"\nend\nend\nreturn result\nend\nfunction vc2010.configurationPropertyGroup(cfg, cfginfo)\n_p(1, '<PropertyGroup '..if_config_and_platform() ..' Label=\"Configuration\">'\n, premake.esc(cfginfo.name))\nlocal is2019 = premake.action.current() == premake.action.get(\"vs2019\")\nif is2019 then\n _p(2, '<VCProjectVersion>%s</VCProjectVersion>', action.vstudio.toolsVersion)\nif cfg.flags.UnitySupport then\n _p(2, '<EnableUnitySupport>true</EnableUnitySupport>')\nend\nend\n_p(2, '<ConfigurationType>%s</ConfigurationType>', vc2010.config_type(cfg))\n_p(2, '<UseDebugLibraries>%s</UseDebugLibraries>', iif(optimisation(cfg) == \"Disabled\",\"true\",\"false\"))\n_p(2, '<PlatformToolset>%s</PlatformToolset>', premake.vstudio.toolset)\nif os.is64bit() then\n_p(2, '<PreferredToolArchitecture>x64</PreferredToolArchitecture>')\nend\nif cfg.flags.Unicode then\n_p(2,'<CharacterSet>Unicode</Charact" "erSet>')\nend\nif cfg.flags.Managed then\n_p(2,'<CLRSupport>true</CLRSupport>')\nend\nif cfg.platform == \"TegraAndroid\" then\nif cfg.androidtargetapi then\n_p(2,'<AndroidTargetAPI>android-%s</AndroidTargetAPI>', cfg.androidtargetapi)\nend\nif cfg.androidminapi then\n_p(2,'<AndroidMinAPI>android-%s</AndroidMinAPI>', cfg.androidminapi)\nend\nif cfg.androidarch then\n_p(2,'<AndroidArch>%s</AndroidArch>', cfg.androidarch)\nend\nif cfg.androidndktoolchainversion then\n_p(2,'<NdkToolchainVersion>%s</NdkToolchainVersion>', cfg.androidndktoolchainversion)\nend\nif cfg.androidstltype then\n_p(2,'<AndroidStlType>%s</AndroidStlType>', cfg.androidstltype)\nend\nend\nif cfg.platform == \"NX32\" or cfg.platform == \"NX64\" then\n_p(2,'<NintendoSdkRoot>$(NINTENDO_SDK_ROOT)\\\\</NintendoSdkRoot>')\n_p(2,'<NintendoSdkSpec>NX</NintendoSdkSpec>')\nif premake.config.isdebugbuild(cfg) then\n_p(2,'<NintendoSdkBuildType>Debug</NintendoSdkBuildType>')\nelse\n_p(2,'<NintendoSdkBuildType>Release</NintendoSdkBuildType>')\nend\nend\nif" " cfg.flags.Symbols and (premake.action.current() == premake.action.get(\"vs2017\") or is2019) then\n_p(2, '<DebugSymbols>true</DebugSymbols>')\nend\n_p(1,'</PropertyGroup>')\nend\nlocal function import_props(prj)\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\n_p(1,'<ImportGroup '..if_config_and_platform() ..' Label=\"PropertySheets\">'\n,premake.esc(cfginfo.name))\n_p(2,'<Import Project=\"$(UserRootDir)\\\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists(\\'$(UserRootDir)\\\\Microsoft.Cpp.$(Platform).user.props\\')\" Label=\"LocalAppDataPlatform\" />')\nif #cfg.propertysheets > 0 then\nlocal dirs = cfg.propertysheets\nfor _, dir in ipairs(dirs) do\nlocal translated = path.translate(dir)\n_p(2,'<Import Project=\"%s\" Condition=\"exists(\\'%s\\')\" />', translated, translated)\nend\nend\n_p(1,'</ImportGroup>')\nend\nend\nlocal function add_trailing_backslash(dir)\nif dir:len() > 0 and dir:sub(-1) ~= \"\\\\\" the" "n\nreturn dir..\"\\\\\"\nend\nreturn dir\nend\nfunction vc2010.outputProperties(prj)\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\nlocal target = cfg.buildtarget\nlocal outdir = add_trailing_backslash(target.directory)\nlocal intdir = add_trailing_backslash(iif(action.vstudio.intDirAbsolute\n, path.translate(\n path.join(prj.solution.location, cfg.objectsdir)\n, '\\\\')\n, cfg.objectsdir\n))\n_p(1,'<PropertyGroup '..if_config_and_platform() ..'>', premake.esc(cfginfo.name))\n_p(2,'<OutDir>%s</OutDir>', iif(outdir:len() > 0, premake.esc(outdir), \".\\\\\"))\nif cfg.platform == \"Xbox360\" then\n_p(2,'<OutputFile>$(OutDir)%s</OutputFile>', premake.esc(target.name))\nend\n_p(2,'<IntDir>%s</IntDir>', premake.esc(intdir))\n_p(2,'<TargetName>%s</TargetName>', premake.esc(path.getbasename(target.name)))\n_p(2,'<TargetExt>%s</TargetExt>', premake.esc(path.getextension(target.name)))\nif cfg.kind == \"SharedLib\" then\nlocal " "ignore = (cfg.flags.NoImportLib ~= nil)\n_p(2,'<IgnoreImportLibrary>%s</IgnoreImportLibrary>', tostring(ignore))\nend\nif cfg.platform == \"NX32\" or cfg.platform == \"NX64\" then\nif cfg.flags.Cpp17 then\n_p(2,'<CppLanguageStandard>Gnu++17</CppLanguageStandard>')\nend\nend\nif cfg.platform == \"Durango\" then\n_p(2, '<ReferencePath>$(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath)</ReferencePath>')\n_p(2, '<LibraryPath>$(Console_SdkLibPath)</LibraryPath>')\n_p(2, '<LibraryWPath>$(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath)</LibraryWPath>')\n_p(2, '<IncludePath>$(Console_SdkIncludeRoot)</IncludePath>')\n_p(2, '<ExecutablePath>$(Console_SdkRoot)bin;$(VCInstallDir)bin\\\\x86_amd64;$(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\\\\Tools\\\\bin;$(VSInstallDir)Common7\\\\tools;$(VSInstallDir)Common7\\\\ide;$(ProgramFiles)\\\\HTML Help Workshop;$(MSBuildToolsPath32);$(FxCopDir);$(PATH);</ExecutablePath>')\nif cfg.imagepath then\n_p(2, '<LayoutDir>%s</LayoutDir>', cfg.image" "path)\nelse\n_p(2, '<LayoutDir>%s</LayoutDir>', prj.name)\nend\nif cfg.pullmappingfile ~= nil then\n_p(2,'<PullMappingFile>%s</PullMappingFile>', premake.esc(cfg.pullmappingfile))\nend\n_p(2, '<LayoutExtensionFilter>*.pdb;*.ilk;*.exp;*.lib;*.winmd;*.appxrecipe;*.pri;*.idb</LayoutExtensionFilter>')\n_p(2, '<IsolateConfigurationsOnDeploy>true</IsolateConfigurationsOnDeploy>')\nend\nif cfg.kind ~= \"StaticLib\" then\n_p(2,'<LinkIncremental>%s</LinkIncremental>', tostring(premake.config.isincrementallink(cfg)))\nend\nif cfg.applicationdatadir ~= nil then\n_p(2,'<ApplicationDataDir>%s</ApplicationDataDir>', premake.esc(cfg.applicationdatadir))\nend\nif cfg.flags.NoManifest then\n_p(2,'<GenerateManifest>false</GenerateManifest>')\nend\n_p(1,'</PropertyGroup>')\nend\nend\nlocal function runtime(cfg)\nlocal runtime\nlocal flags = cfg.flags\nif premake.config.isdebugbuild(cfg) then\nruntime = iif(flags.StaticRuntime and not flags.Managed, \"MultiThreadedDebug\", \"MultiThreadedDebugDLL\")\nelse\nruntime = iif(flags.Sta" "ticRuntime and not flags.Managed, \"MultiThreaded\", \"MultiThreadedDLL\")\nend\nreturn runtime\nend\nlocal function precompiled_header(cfg)\n if not cfg.flags.NoPCH and cfg.pchheader then\n_p(3,'<PrecompiledHeader>Use</PrecompiledHeader>')\n_p(3,'<PrecompiledHeaderFile>%s</PrecompiledHeaderFile>', cfg.pchheader)\nelse\n_p(3,'<PrecompiledHeader></PrecompiledHeader>')\nend\nend\nlocal function preprocessor(indent,cfg,escape)\nif #cfg.defines > 0 then\nlocal defines = table.concat(cfg.defines, \";\")\nif escape then\ndefines = defines:gsub('\"', '\\\\\"')\nend\nlocal isPreprocessorDefinitionPresent = string.find(defines, \"%%%(PreprocessorDefinitions%)\")\nif isPreprocessorDefinitionPresent then\n_p(indent,'<PreprocessorDefinitions>%s</PreprocessorDefinitions>'\n,premake.esc(defines))\nelse\n_p(indent,'<PreprocessorDefinitions>%s;%%(PreprocessorDefinitions)</PreprocessorDefinitions>'\n,premake.esc(defines))\nend\nelse\n_p(indent,'<PreprocessorDefinitions></PreprocessorDefinitions>')\nend\nend\nlocal functio" "n include_dirs(indent,cfg)\nlocal includedirs = table.join(cfg.userincludedirs, cfg.includedirs, cfg.systemincludedirs)\nif #includedirs> 0 then\n_p(indent,'<AdditionalIncludeDirectories>%s;%%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>'\n,premake.esc(path.translate(table.concat(includedirs, \";\"), '\\\\')))\nend\nend\nlocal function using_dirs(indent,cfg)\nif #cfg.usingdirs > 0 then\n_p(indent,'<AdditionalUsingDirectories>%s;%%(AdditionalUsingDirectories)</AdditionalUsingDirectories>'\n,premake.esc(path.translate(table.concat(cfg.usingdirs, \";\"), '\\\\')))\nend\nend\nlocal function resource_compile(cfg)\n_p(2,'<ResourceCompile>')\npreprocessor(3,cfg,true)\ninclude_dirs(3,cfg)\n_p(2,'</ResourceCompile>')\nend\nlocal function cppstandard_vs2017_or_2019(cfg)\nif cfg.flags.CppLatest then\n_p(3, '<LanguageStandard>stdcpplatest</LanguageStandard>')\n_p(3, '<EnableModules>true</EnableModules>')\nelseif cfg.flags.Cpp17 then\n_p(3, '<LanguageStandard>stdcpp17</LanguageStandard>')\nelseif cfg.flags." "Cpp14 then\n_p(3, '<LanguageStandard>stdcpp14</LanguageStandard>')\nend\nend\nlocal function exceptions(cfg)\nif cfg.platform == \"Orbis\" then\nif cfg.flags.NoExceptions then\n_p(3, '<CppExceptions>false</CppExceptions>')\nend\nelseif cfg.platform == \"TegraAndroid\" then\nif cfg.flags.NoExceptions then\n_p(3, '<GccExceptionHandling>false</GccExceptionHandling>')\nend\nelseif cfg.platform == \"NX32\" or cfg.platform == \"NX64\" then\nif cfg.flags.NoExceptions then\n_p(3, '<CppExceptions>false</CppExceptions>')\nelse\n_p(3, '<CppExceptions>true</CppExceptions>')\nend\nelse\nif cfg.flags.NoExceptions then\n_p(3, '<ExceptionHandling>false</ExceptionHandling>')\nelseif cfg.flags.SEH then\n_p(3, '<ExceptionHandling>Async</ExceptionHandling>')\nend\nend\nend\nlocal function rtti(cfg)\nif cfg.flags.NoRTTI and not cfg.flags.Managed then\n_p(3,'<RuntimeTypeInfo>false</RuntimeTypeInfo>')\nend\nend\nlocal function calling_convention(cfg)\nif cfg.flags.FastCall then\n_p(3,'<CallingConvention>FastCall</CallingConvention>'" ")\nelseif cfg.flags.StdCall then\n_p(3,'<CallingConvention>StdCall</CallingConvention>')\nend\nend\nlocal function wchar_t_builtin(cfg)\nif cfg.flags.NativeWChar then\n_p(3,'<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>')\nelseif cfg.flags.NoNativeWChar then\n_p(3,'<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>')\nend\nend\nlocal function sse(cfg)\nif cfg.flags.EnableSSE then\n_p(3, '<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>')\nelseif cfg.flags.EnableSSE2 then\n_p(3, '<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>')\nelseif cfg.flags.EnableAVX then\n_p(3, '<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>')\nelseif cfg.flags.EnableAVX2 then\n_p(3, '<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>')\nend\nend\nlocal function floating_point(cfg)\nif cfg.platform == \"Orbis\" then\nif cfg.flags.FloatFast then\n_p(3,'<FastMath>true</" "FastMath>')\nend\nelseif cfg.platform == \"TegraAndroid\" then\nelseif cfg.platform == \"NX32\" or cfg.platform == \"NX64\" then\nif cfg.flags.FloatFast then\n_p(3, '<FastMath>true</FastMath>')\nend\nelse\nif cfg.flags.FloatFast then\n_p(3,'<FloatingPointModel>Fast</FloatingPointModel>')\nelseif cfg.flags.FloatStrict and not cfg.flags.Managed then\n_p(3,'<FloatingPointModel>Strict</FloatingPointModel>')\nend\nend\nend\nlocal function debug_info(cfg)\nlocal debug_info = ''\nif cfg.flags.Symbols then\nif cfg.flags.C7DebugInfo then\ndebug_info = \"OldStyle\"\nelseif (action.vstudio.supports64bitEditContinue == false and cfg.platform == \"x64\")\nor not premake.config.iseditandcontinue(cfg)\nthen\ndebug_info = \"ProgramDatabase\"\nelse\ndebug_info = \"EditAndContinue\"\nend\nend\n_p(3,'<DebugInformationFormat>%s</DebugInformationFormat>',debug_info)\nend\nlocal function minimal_build(cfg)\nif premake.config.isdebugbuild(cfg) and cfg.flags.EnableMinimalRebuild then\n_p(3,'<MinimalRebuild>true</MinimalRebuild>')\nel" "se\n_p(3,'<MinimalRebuild>false</MinimalRebuild>')\nend\nend\nlocal function compile_language(cfg)\nif cfg.options.ForceCPP then\n_p(3,'<CompileAs>CompileAsCpp</CompileAs>')\nelse\nif cfg.language == \"C\" then\n_p(3,'<CompileAs>CompileAsC</CompileAs>')\nend\nend\nend\nlocal function forcedinclude_files(indent,cfg)\nif #cfg.forcedincludes > 0 then\n_p(indent,'<ForcedIncludeFiles>%s</ForcedIncludeFiles>'\n,premake.esc(path.translate(table.concat(cfg.forcedincludes, \";\"), '\\\\')))\nend\nend\nlocal function vs10_clcompile(cfg)\n_p(2,'<ClCompile>')\nlocal unsignedChar = \"/J \"\nlocal buildoptions = cfg.buildoptions\nif cfg.platform == \"Orbis\" then\nunsignedChar = \"-funsigned-char \";\n_p(3,'<GenerateDebugInformation>%s</GenerateDebugInformation>', tostring(cfg.flags.Symbols ~= nil))\nend\nif cfg.platform == \"NX32\" or cfg.platform == \"NX64\" then\nunsignedChar = \"-funsigned-char \";\n_p(3,'<GenerateDebugInformation>%s</GenerateDebugInformation>', tostring(cfg.flags.Symbols ~= nil))\nend\nif cfg.language " "== \"C\" and not cfg.options.ForceCPP then\nbuildoptions = table.join(buildoptions, cfg.buildoptions_c)\nelse\nbuildoptions = table.join(buildoptions, cfg.buildoptions_cpp)\nend\n_p(3,'<AdditionalOptions>%s %s%%(AdditionalOptions)</AdditionalOptions>'\n, table.concat(premake.esc(buildoptions), \" \")\n, iif(cfg.flags.UnsignedChar and cfg.platform ~= \"TegraAndroid\", unsignedChar, \" \")\n)\nif cfg.platform == \"TegraAndroid\" then\n_p(3,'<SignedChar>%s</SignedChar>', tostring(cfg.flags.UnsignedChar == nil))\n_p(3,'<GenerateDebugInformation>%s</GenerateDebugInformation>', tostring(cfg.flags.Symbols ~= nil))\nif cfg.androidcppstandard then\n_p(3,'<CppLanguageStandard>%s</CppLanguageStandard>', cfg.androidcppstandard)\nend\nend\nif cfg.platform == \"Orbis\" then\nlocal opt = optimisation(cfg)\nif opt == \"Disabled\" then\n_p(3,'<OptimizationLevel>Level0</OptimizationLevel>')\nelseif opt == \"MinSpace\" then\n_p(3,'<OptimizationLevel>Levelz</OptimizationLevel>') -- Oz is more aggressive than Os\nelseif opt == \"M" "axSpeed\" then\n_p(3,'<OptimizationLevel>Level3</OptimizationLevel>')\nelse\n_p(3,'<OptimizationLevel>Level2</OptimizationLevel>')\nend\nelseif cfg.platform == \"TegraAndroid\" then\nlocal opt = optimisation(cfg)\nif opt == \"Disabled\" then\n_p(3,'<OptimizationLevel>O0</OptimizationLevel>')\nelseif opt == \"MinSpace\" then\n_p(3,'<OptimizationLevel>Os</OptimizationLevel>')\nelseif opt == \"MaxSpeed\" then\n_p(3,'<OptimizationLevel>O3</OptimizationLevel>')\nelse\n_p(3,'<OptimizationLevel>O2</OptimizationLevel>')\nend\nelseif cfg.platform == \"NX32\" or cfg.platform == \"NX64\" then\nlocal opt = optimisation(cfg)\nif opt == \"Disabled\" then\n_p(3,'<OptimizationLevel>O0</OptimizationLevel>')\nelseif opt == \"MinSpace\" then\n_p(3,'<OptimizationLevel>Os</OptimizationLevel>')\nelseif opt == \"MaxSpeed\" then\n_p(3,'<OptimizationLevel>O3</OptimizationLevel>')\nelse\n_p(3,'<OptimizationLevel>O2</OptimizationLevel>')\nend\nelse\n_p(3,'<Optimization>%s</Optimization>', optimisation(cfg))\nend\ninclude_dirs(3, cfg)\nu" "sing_dirs(3, cfg)\npreprocessor(3, cfg)\nminimal_build(cfg)\nif premake.config.isoptimizedbuild(cfg.flags) then\nif cfg.flags.NoOptimizeLink and cfg.flags.NoEditAndContinue then\n_p(3, '<StringPooling>false</StringPooling>')\n_p(3, '<FunctionLevelLinking>false</FunctionLevelLinking>')\nelse\n_p(3, '<StringPooling>true</StringPooling>')\n_p(3, '<FunctionLevelLinking>true</FunctionLevelLinking>')\nend\nelse\n_p(3, '<FunctionLevelLinking>true</FunctionLevelLinking>')\nif cfg.flags.NoRuntimeChecks then\n_p(3, '<BasicRuntimeChecks>Default</BasicRuntimeChecks>')\nelseif not cfg.flags.Managed then\n_p(3, '<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>')\nend\nif cfg.flags.ExtraWarnings then\nend\nend\nif cfg.platform == \"Durango\" or cfg.flags.NoWinRT then\n_p(3, '<CompileAsWinRT>false</CompileAsWinRT>')\nend\n_p(3, '<RuntimeLibrary>%s</RuntimeLibrary>', runtime(cfg))\nif cfg.flags.NoBufferSecurityCheck then\n_p(3, '<BufferSecurityCheck>false</BufferSecurityCheck>')\nend\nif not cfg.flags.NoMultiProcessor" "Compilation and not cfg.flags.EnableMinimalRebuild then\n_p(3, '<MultiProcessorCompilation>true</MultiProcessorCompilation>')\nelse\n_p(3, '<MultiProcessorCompilation>false</MultiProcessorCompilation>')\nend\nprecompiled_header(cfg)\nif cfg.platform == \"Orbis\" then\nif cfg.flags.PedanticWarnings then\n_p(3, '<Warnings>MoreWarnings</Warnings>')\n_p(3, '<ExtraWarnings>true</ExtraWarnings>')\nelseif cfg.flags.ExtraWarnings then\n_p(3, '<Warnings>NormalWarnings</Warnings>')\n_p(3, '<ExtraWarnings>true</ExtraWarnings>')\nelseif cfg.flags.MinimumWarnings then\n_p(3, '<Warnings>WarningsOff</Warnings>')\n_p(3, '<ExtraWarnings>false</ExtraWarnings>')\nelse\n_p(3, '<Warnings>NormalWarnings</Warnings>')\n_p(3, '<ExtraWarnings>false</ExtraWarnings>')\nend\nif cfg.flags.FatalWarnings then\n_p(3, '<WarningsAsErrors>true</WarningsAsErrors>')\nend\nelseif cfg.platform == \"TegraAndroid\" then\nif cfg.flags.PedanticWarnings or cfg.flags.ExtraWarnings then\n_p(3, '<Warnings>AllWarnings</Warnings>')\nelseif cfg.flags.MinimumWa" "rnings then\n_p(3, '<Warnings>DisableAllWarnings</Warnings>')\nelse\n_p(3, '<Warnings>NormalWarnings</Warnings>')\nend\nif cfg.flags.FatalWarnings then\n_p(3, '<WarningsAsErrors>true</WarningsAsErrors>')\nend\nelseif cfg.platform == \"NX32\" or cfg.platform == \"NX64\" then\nif cfg.flags.PedanticWarnings then\n_p(3, '<Warnings>MoreWarnings</Warnings>')\n_p(3, '<ExtraWarnings>true</ExtraWarnings>')\nelseif cfg.flags.ExtraWarnings then\n_p(3, '<Warnings>NormalWarnings</Warnings>')\n_p(3, '<ExtraWarnings>true</ExtraWarnings>')\nelseif cfg.flags.MinimumWarnings then\n_p(3, '<Warnings>WarningsOff</Warnings>')\n_p(3, '<ExtraWarnings>false</ExtraWarnings>')\nelse\n_p(3, '<Warnings>NormalWarnings</Warnings>')\n_p(3, '<ExtraWarnings>false</ExtraWarnings>')\nend\nif cfg.flags.FatalWarnings then\n_p(3, '<WarningsAsErrors>true</WarningsAsErrors>')\nend\nelse\nif cfg.flags.PedanticWarnings then\n_p(3, '<WarningLevel>EnableAllWarnings</WarningLevel>')\nelseif cfg.flags.ExtraWarnings then\n_p(3, '<WarningLevel>Level4</Warnin" "gLevel>')\nelseif cfg.flags.MinimumWarnings then\n_p(3, '<WarningLevel>Level1</WarningLevel>')\nelse\n_p(3 ,'<WarningLevel>Level3</WarningLevel>')\nend\nend\nif cfg.flags.FatalWarnings then\n_p(3, '<TreatWarningAsError>true</TreatWarningAsError>')\nend\nif premake.action.current() == premake.action.get(\"vs2017\") or\n premake.action.current() == premake.action.get(\"vs2019\") then\ncppstandard_vs2017_or_2019(cfg)\nend\nexceptions(cfg)\nrtti(cfg)\ncalling_convention(cfg)\nwchar_t_builtin(cfg)\nsse(cfg)\nfloating_point(cfg)\ndebug_info(cfg)\nif cfg.flags.Symbols then\nif cfg.kind == \"StaticLib\" then\n_p(3, '<ProgramDataBaseFileName>$(OutDir)%s.pdb</ProgramDataBaseFileName>'\n, path.getbasename(cfg.buildtarget.name)\n)\nelse\n_p(3, '<ProgramDataBaseFileName>$(IntDir)%s.compile.pdb</ProgramDataBaseFileName>'\n, path.getbasename(cfg.buildtarget.name)\n)\nend\nend\nif cfg.flags.Hotpatchable then\n_p(3, '<CreateHotpatchableImage>true</CreateHotpatchableImage>')\nend\nif cfg.flags.NoFramePointer then\n_p(3, '<Omi" "tFramePointers>true</OmitFramePointers>')\nend\nif cfg.flags.UseFullPaths then\n_p(3, '<UseFullPaths>true</UseFullPaths>')\nend\nif cfg.flags.NoJMC then\n_p(3,'<SupportJustMyCode>false</SupportJustMyCode>' )\nend\ncompile_language(cfg)\nforcedinclude_files(3,cfg);\nif vstudio.diagformat then\n_p(3, '<DiagnosticsFormat>%s</DiagnosticsFormat>', vstudio.diagformat)\nelse\n_p(3, '<DiagnosticsFormat>Caret</DiagnosticsFormat>')\nend\n_p(2,'</ClCompile>')\nend\nlocal function event_hooks(cfg)\nif #cfg.postbuildcommands> 0 then\n _p(2,'<PostBuildEvent>')\n_p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.postbuildcommands, \"\", \"\", \"\\r\\n\")))\n_p(2,'</PostBuildEvent>')\nend\nif #cfg.prebuildcommands> 0 then\n _p(2,'<PreBuildEvent>')\n_p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.prebuildcommands, \"\", \"\", \"\\r\\n\")))\n_p(2,'</PreBuildEvent>')\nend\nif #cfg.prelinkcommands> 0 then\n _p(2,'<PreLinkEvent>')\n_p(3,'<Command>%s</Command>',premake.esc(table.implode(cfg.prelinkcomman" "ds, \"\", \"\", \"\\r\\n\")))\n_p(2,'</PreLinkEvent>')\nend\nend\nlocal function additional_options(indent,cfg)\nif #cfg.linkoptions > 0 then\n_p(indent,'<AdditionalOptions>%s %%(AdditionalOptions)</AdditionalOptions>',\ntable.concat(premake.esc(cfg.linkoptions), \" \"))\nend\nend\nlocal function link_target_machine(index,cfg)\nlocal platforms = {x32 = 'MachineX86', x64 = 'MachineX64'}\nif platforms[cfg.platform] then\n_p(index,'<TargetMachine>%s</TargetMachine>', platforms[cfg.platform])\nend\nend\nlocal function item_def_lib(cfg)\nif cfg.kind == 'StaticLib' and cfg.platform ~= \"Xbox360\" then\n_p(1,'<Lib>')\n_p(2,'<OutputFile>$(OutDir)%s</OutputFile>',cfg.buildtarget.name)\nadditional_options(2,cfg)\nlink_target_machine(2,cfg)\n_p(1,'</Lib>')\nend\nend\nlocal function import_lib(cfg)\nif cfg.kind == \"SharedLib\" then\nlocal implibname = cfg.linktarget.fullpath\n_p(3,'<ImportLibrary>%s</ImportLibrary>',iif(cfg.flags.NoImportLib, cfg.objectsdir .. \"\\\\\" .. path.getname(implibname), implibname))\nend\nend" "\nlocal function hasmasmfiles(prj)\nlocal files = vc2010.getfilegroup(prj, \"MASM\")\nreturn #files > 0\nend\nlocal function ismanagedprj(prj, cfgname, pltname)\nlocal cfg = premake.getconfig(prj, cfgname, pltname)\nreturn cfg.flags.Managed == true\nend\nlocal function getcfglinks(cfg)\nlocal haswholearchive = #cfg.wholearchive > 0\nlocal msvcnaming = premake.getnamestyle(cfg) == \"windows\"\nlocal iscppprj = premake.iscppproject(cfg)\nlocal isnetprj = premake.isdotnetproject(cfg)\nlocal linkobjs = {}\nlocal links = iif(haswholearchive\n, premake.getlinks(cfg, \"all\", \"object\")\n, premake.getlinks(cfg, \"system\", \"fullpath\")\n)\nfor _, link in ipairs(links) do\nlocal name = nil\nlocal directory = nil\nlocal whole = nil\nif type(link) == \"table\" then\nif not ismanagedprj(link.project, cfg.name, cfg.platform) then\nname = link.linktarget.basename\ndirectory = path.rebase(link.linktarget.directory, link.location, cfg.location)\nwhole = table.icontains(cfg.wholearchiv" "e, link.project.name)\nend\nelse\nname = link\nwhole = table.icontains(cfg.wholearchive, link)\nend\nif name then\nif haswholearchive and msvcnaming then\nif iscppprj then\nname = name .. \".lib\"\nelseif isnetprj then\nname = name .. \".dll\"\nend\nend\ntable.insert(linkobjs, {name=name, directory=directory, wholearchive=whole})\nend\nend\nreturn linkobjs\nend\nlocal function vs10_masm(prj, cfg)\nif hasmasmfiles(prj) then\n_p(2, '<MASM>')\n_p(3,'<AdditionalOptions>%s %%(AdditionalOptions)</AdditionalOptions>'\n, table.concat(premake.esc(table.join(cfg.buildoptions, cfg.buildoptions_asm)), \" \")\n)\nlocal includedirs = table.join(cfg.userincludedirs, cfg.includedirs, cfg.systemincludedirs)\nif #includedirs > 0 then\n_p(3, '<IncludePaths>%s;%%(IncludePaths)</IncludePaths>'\n, premake.esc(path.translate(table.concat(includedirs, \";\"), '\\\\'))\n)\nend\nlocal defines = table.join(cfg.defines)\ntable.insertflat(defines, iif(premake.config.isdebugbuild(cfg), \"_DEBUG\", {}))\ntable.insert(defines, iif(c" "fg.platform == \"x64\" or cfg.platform == \"ARM64\", \"_WIN64\", \"_WIN32\"))\ntable.insert(defines, iif(prj.kind == \"SharedLib\", \"_EXPORT=EXPORT\", \"_EXPORT=\"))\n_p(3, '<PreprocessorDefinitions>%s;%%(PreprocessorDefinitions)</PreprocessorDefinitions>'\n, premake.esc(table.concat(defines, \";\"))\n)\nif cfg.flags.FatalWarnings then\n_p(3,'<TreatWarningsAsErrors>true</TreatWarningsAsErrors>')\nend\nif cfg.flags.MinimumWarnings then\n_p(3,'<WarningLevel>0</WarningLevel>')\nelse\n_p(3,'<WarningLevel>3</WarningLevel>')\nend\n_p(2, '</MASM>')\nend\nend\nlocal function additional_manifest(cfg)\nif(cfg.dpiawareness ~= nil) then\n_p(2,'<Manifest>')\nif(cfg.dpiawareness == \"None\") then\n_p(3, '<EnableDpiAwareness>false</EnableDpiAwareness>')\nend\nif(cfg.dpiawareness == \"High\") then\n_p(3, '<EnableDpiAwareness>true</EnableDpiAwareness>')\nend\nif(cfg.dpiawareness == \"HighPerMonitor\") then\n_p(3, '<EnableDpiAwareness>PerMonitorHighDPIAware</EnableDpiAwareness>')\nend\n_p(2,'</Manifest>')\nend\nend\nfunction v" "c2010.link(cfg)\nlocal vs2017OrLater = premake.action.current() == premake.action.get(\"vs2017\") or\n premake.action.current() == premake.action.get(\"vs2019\")\nlocal links = getcfglinks(cfg)\n_p(2,'<Link>')\n_p(3,'<SubSystem>%s</SubSystem>', iif(cfg.kind == \"ConsoleApp\", \"Console\", \"Windows\"))\nif vs2017OrLater and cfg.flags.FullSymbols then\n_p(3,'<GenerateDebugInformation>DebugFull</GenerateDebugInformation>')\nelse\n_p(3,'<GenerateDebugInformation>%s</GenerateDebugInformation>', tostring(cfg.flags.Symbols ~= nil))\nend\nif cfg.flags.Symbols then\n_p(3, '<ProgramDatabaseFile>$(OutDir)%s.pdb</ProgramDatabaseFile>'\n, path.getbasename(cfg.buildtarget.name)\n)\nend\nif premake.config.islinkeroptimizedbuild(cfg.flags) then\nif cfg.platform == \"Orbis\" then\n_p(3,'<DataStripping>StripFuncsAndData</DataStripping>')\n_p(3,'<DuplicateStripping>true</DuplicateStripping>')\nelse\n_p(3,'<EnableCOMDATFolding>true</EnableCOMDATFolding>')\n_p(3,'<OptimizeReferences>true</OptimizeReferences>')\nend\nelseif cf" "g.platform == \"Orbis\" and premake.config.iseditandcontinue(cfg) then\n_p(3,'<EditAndContinue>true</EditAndContinue>')\nend\nif cfg.finalizemetasource ~= nil then\n_p(3,'<FinalizeMetaSource>%s</FinalizeMetaSource>', premake.esc(cfg.finalizemetasource))\nend\nif cfg.kind ~= 'StaticLib' then\nvc2010.additionalDependencies(3, cfg, links)\nvc2010.additionalLibraryDirectories(3, cfg, links)\n_p(3,'<OutputFile>$(OutDir)%s</OutputFile>', cfg.buildtarget.name)\nif vc2010.config_type(cfg) == 'Application' and not cfg.flags.WinMain and not cfg.flags.Managed then\nif cfg.flags.Unicode then\n_p(3,'<EntryPointSymbol>wmainCRTStartup</EntryPointSymbol>')\nelse\n_p(3,'<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>')\nend\nend\nimport_lib(cfg)\nlocal deffile = premake.findfile(cfg, \".def\")\nif deffile then\n_p(3,'<ModuleDefinitionFile>%s</ModuleDefinitionFile>', deffile)\nend\nlink_target_machine(3,cfg)\nadditional_options(3,cfg)\nif cfg.flags.NoWinMD and vstudio.iswinrt() and prj.kind == \"WindowedApp\" then\n_p(3,'<G" "enerateWindowsMetadata>false</GenerateWindowsMetadata>' )\nend\nend\nif cfg.platform == \"TegraAndroid\" then\nif cfg.androidlinker then\n_p(3,'<UseLinker>%s</UseLinker>',cfg.androidlinker)\nend\nend\nif cfg.flags.Hotpatchable then\n_p(3, '<CreateHotPatchableImage>Enabled</CreateHotPatchableImage>')\nend\nif cfg.flags.GenerateMapFiles then\n_p(3, '<GenerateMapFile>true</GenerateMapFile>')\nend\n_p(2,'</Link>')\nif #cfg.wholearchive > 0 then\n_p(2, '<ProjectReference>')\n_p(3, '<LinkLibraryDependencies>false</LinkLibraryDependencies>')\n_p(2, '</ProjectReference>')\nend\nend\nfunction vc2010.additionalLibraryDirectories(tab, cfg, links)\nlocal dirs = cfg.libdirs\nfor _, link in ipairs(links) do\nif link.directory and not table.icontains(dirs, link.directory) then\ntable.insert(dirs, link.directory)\nend\nend\n_p(tab, '<AdditionalLibraryDirectories>%s;%%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>'\n, premake.esc(path.translate(table.concat(dirs, ';'), '\\\\'))\n)\nend\nfunction vc2010.additiona" "lDependencies(tab, cfg, links)\nif #links > 0 then\nlocal deps = \"\"\nif cfg.platform == \"Orbis\" then\nlocal iswhole = false\nfor _, link in ipairs(links) do\nif link.wholearchive and not iswhole then\ndeps = deps .. \"--whole-archive;\"\niswhole = true\nelseif not link.wholearchive and iswhole then\ndeps = deps .. \"--no-whole-archive;\"\niswhole = false\nend\ndeps = deps .. \"-l\" .. link.name .. \";\"\nend\nelse\nfor _, link in ipairs(links) do\nif link.wholearchive then\ndeps = deps .. \"/WHOLEARCHIVE:\" .. link.name .. \";\"\nelse\ndeps = deps .. link.name .. \";\"\nend\nend\nend\nif cfg.platform == \"TegraAndroid\" then\ndeps = \"-Wl,--start-group;\" .. deps .. \";-Wl,--end-group\"\nend\n_p(tab, '<AdditionalDependencies>%s;%s</AdditionalDependencies>'\n, deps\n, iif(cfg.platform == \"Durango\"\n, '%(XboxExtensionsDependencies)'\n, '%(AdditionalDependencies)'\n)\n)\nelseif cfg.platform == \"Durango\" then\n_p(tab, '<AdditionalDependencies>%%(XboxExtensionsDependencies)</AdditionalDependencies>')\nend\n" "end\nfunction ant_build(prj, cfg)\nif cfg.platform == \"TegraAndroid\" then\nlocal files = vc2010.getfilegroup(prj, \"AndroidBuild\")\n_p(2,'<AntBuild>')\nif #files > 0 then\n_p(3,'<AndroidManifestLocation>%s</AndroidManifestLocation>',path.translate(files[1].name))\nend\nlocal isdebugbuild = premake.config.isdebugbuild(cfg)\n_p(3,'<AntBuildType>%s</AntBuildType>',iif(isdebugbuild, 'Debug','Release'))\n_p(3,'<Debuggable>%s</Debuggable>',tostring(cfg.flags.AntBuildDebuggable ~= nil))\nif #cfg.antbuildjavasourcedirs > 0 then\nlocal dirs = table.concat(cfg.antbuildjavasourcedirs,\";\")\n_p(3,'<JavaSourceDir>%s</JavaSourceDir>',dirs)\nend\nif #cfg.antbuildjardirs > 0 then\nlocal dirs = table.concat(cfg.antbuildjardirs,\";\")\n_p(3,'<JarDirectories>%s</JarDirectories>',dirs)\nend\nif #cfg.antbuildjardependencies > 0 then\nlocal dirs = table.concat(cfg.antbuildjardependencies,\";\")\n_p(3,'<JarDependencies>%s</JarDependencies>',dirs)\nend\nif #cfg.antbuildnativelibdirs > 0 then\nlocal dirs = table.concat(cfg.antbuil" "dnativelibdirs,\";\")\n_p(3,'<NativeLibDirectories>%s</NativeLibDirectories>',dirs)\nend\nif #cfg.antbuildnativelibdependencies > 0 then\nlocal dirs = table.concat(cfg.antbuildnativelibdependencies,\";\")\n_p(3,'<NativeLibDependencies>%s</NativeLibDependencies>',dirs)\nend\nif #cfg.antbuildassetsdirs > 0 then\nlocal dirs = table.concat(cfg.antbuildassetsdirs,\";\")\n_p(3,'<AssetsDirectories>%s</AssetsDirectories>',dirs)\nend\n_p(2,'</AntBuild>')\nend\nend\nlocal function item_definitions(prj)\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\n_p(1,'<ItemDefinitionGroup ' ..if_config_and_platform() ..'>'\n,premake.esc(cfginfo.name))\nvs10_clcompile(cfg)\nresource_compile(cfg)\nitem_def_lib(cfg)\nvc2010.link(cfg)\nant_build(prj, cfg)\nevent_hooks(cfg)\nvs10_masm(prj, cfg)\nadditional_manifest(cfg)\n_p(1,'</ItemDefinitionGroup>')\nend\nend\nfunction vc2010.getfilegroup(prj, group)\nlocal sortedfiles = prj.vc2010sortedfiles\ni" "f not sortedfiles then\nsortedfiles = {\nClCompile = {},\nClInclude = {},\nMASM = {},\nObject = {},\nNone = {},\nResourceCompile = {},\nAppxManifest = {},\nAndroidBuild = {},\nNatvis = {},\nImage = {},\nDeploymentContent = {}\n}\nlocal foundAppxManifest = false\nfor file in premake.project.eachfile(prj, true) do\nif path.issourcefilevs(file.name) then\ntable.insert(sortedfiles.ClCompile, file)\nelseif path.iscppheader(file.name) then\nif not table.icontains(prj.removefiles, file) then\ntable.insert(sortedfiles.ClInclude, file)\nend\nelseif path.isobjectfile(file.name) then\ntable.insert(sortedfiles.Object, file)\nelseif path.isresourcefile(file.name) then\ntable.insert(sortedfiles.ResourceCompile, file)\nelseif path.isimagefile(file.name) then\ntable.insert(sortedfiles.Image, file)\nelseif path.isappxmanifest(file.name) then\nfoundAppxManifest = true\ntable.insert(sortedfiles.AppxManifest, file)\nelseif path.isandroidbuildfile(file.name) then\ntable.insert(sortedfiles.AndroidBuild, file)\nelseif path.isnatvis(" "file.name) then\ntable.insert(sortedfiles.Natvis, file)\nelseif path.isasmfile(file.name) then\ntable.insert(sortedfiles.MASM, file)\nelseif file.flags and table.icontains(file.flags, \"DeploymentContent\") then\ntable.insert(sortedfiles.DeploymentContent, file)\nelse\ntable.insert(sortedfiles.None, file)\nend\nend\nif vstudio.iswinrt() and prj.kind == \"WindowedApp\" and not foundAppxManifest then\nvstudio.needAppxManifest = true\nlocal fcfg = {}\nfcfg.name = prj.name .. \"/Package.appxmanifest\"\nfcfg.vpath = premake.project.getvpath(prj, fcfg.name)\ntable.insert(sortedfiles.AppxManifest, fcfg)\nlocal logo = {}\nlogo.name = prj.name .. \"/Logo.png\"\nlogo.vpath = logo.name\ntable.insert(sortedfiles.Image, logo)\nlocal smallLogo = {}\nsmallLogo.name = prj.name .. \"/SmallLogo.png\"\nsmallLogo.vpath = smallLogo.name\ntable.insert(sortedfiles.Image, smallLogo)\nlocal storeLogo = {}\nstoreLogo.name = prj.name .. \"/StoreLogo.png\"\nstoreLogo.vpath = storeLogo.name\ntable.insert(sortedfiles.Image, storeLogo)\n" "local splashScreen = {}\nsplashScreen.name = prj.name .. \"/SplashScreen.png\"\nsplashScreen.vpath = splashScreen.name\ntable.insert(sortedfiles.Image, splashScreen)\nend\nprj.vc2010sortedfiles = sortedfiles\nend\nreturn sortedfiles[group]\nend\nfunction vc2010.files(prj)\nvc2010.simplefilesgroup(prj, \"ClInclude\")\nvc2010.compilerfilesgroup(prj)\nvc2010.simplefilesgroup(prj, \"Object\")\nvc2010.simplefilesgroup(prj, \"None\")\nvc2010.customtaskgroup(prj)\nvc2010.simplefilesgroup(prj, \"ResourceCompile\")\nvc2010.simplefilesgroup(prj, \"AppxManifest\")\nvc2010.simplefilesgroup(prj, \"AndroidBuild\")\nvc2010.simplefilesgroup(prj, \"Natvis\")\nvc2010.deploymentcontentgroup(prj, \"Image\")\nvc2010.deploymentcontentgroup(prj, \"DeploymentContent\", \"None\")\nend\nfunction vc2010.customtaskgroup(prj)\nlocal files = { }\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask in ipairs(custombuildtask or {}) do\nlocal fcfg = { }\nfcfg.name = path.getrelative(prj.location,buildtask[1])\nfc" "fg.vpath = path.trimdots(fcfg.name)\ntable.insert(files, fcfg)\nend\nend\nif #files > 0 then\n_p(1,'<ItemGroup>')\nlocal groupedBuildTasks = {}\nlocal buildTaskNames = {}\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask in ipairs(custombuildtask or {}) do\nif (groupedBuildTasks[buildtask[1]] == nil) then\ngroupedBuildTasks[buildtask[1]] = {}\ntable.insert(buildTaskNames, buildtask[1])\nend\ntable.insert(groupedBuildTasks[buildtask[1]], buildtask)\nend\nend\nfor _, name in ipairs(buildTaskNames) do\ncustombuildtask = groupedBuildTasks[name]\n_p(2,'<CustomBuild Include=\\\"%s\\\">', path.translate(path.getrelative(prj.location,name), \"\\\\\"))\n_p(3,'<FileType>Text</FileType>')\nlocal cmd = \"\"\nlocal outputs = \"\"\nfor _, buildtask in ipairs(custombuildtask or {}) do\nfor _, cmdline in ipairs(buildtask[4] or {}) do\ncmd = cmd .. cmdline\nlocal num = 1\nfor _, depdata in ipairs(buildtask[3] or {}) do\ncmd = string.gsub(cmd,\"%$%(\" .. num ..\"%)\", string.format(\"%s \",path." "getrelative(prj.location,depdata)))\nnum = num + 1\nend\ncmd = string.gsub(cmd, \"%$%(<%)\", string.format(\"%s \",path.getrelative(prj.location,buildtask[1])))\ncmd = string.gsub(cmd, \"%$%(@%)\", string.format(\"%s \",path.getrelative(prj.location,buildtask[2])))\ncmd = cmd .. \"\\r\\n\"\nend\noutputs = outputs .. path.getrelative(prj.location,buildtask[2]) .. \";\"\nend\n_p(3,'<Command>%s</Command>',cmd)\n_p(3,'<Outputs>%s%%(Outputs)</Outputs>',outputs)\n_p(3,'<SubType>Designer</SubType>')\n_p(3,'<Message></Message>')\n_p(2,'</CustomBuild>')\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.simplefilesgroup(prj, section, subtype)\nlocal configs = prj.solution.vstudio_configs\nlocal files = vc2010.getfilegroup(prj, section)\nif #files > 0 then\nlocal config_mappings = {}\nfor _, cfginfo in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\nif cfg.pchheader and cfg.pchsource and not cfg.flags.NoPCH then\nconfig_mappings[cfginfo] = path.translate(cfg.pchsou" "rce, \"\\\\\")\nend\nend\n_p(1,'<ItemGroup>')\nfor _, file in ipairs(files) do\nlocal prjexcluded = table.icontains(prj.excludes, file.name)\nlocal excludedcfgs = {}\nif not prjexcluded then\nfor _, vsconfig in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)\nlocal fileincfg = table.icontains(cfg.files, file.name)\nlocal cfgexcluded = table.icontains(cfg.excludes, file.name)\nif not fileincfg or cfgexcluded then\ntable.insert(excludedcfgs, vsconfig.name)\nend\nend\nend\nif subtype or prjexcluded or #excludedcfgs > 0 then\n_p(2, '<%s Include=\\\"%s\\\">', section, path.translate(file.name, \"\\\\\"))\nif prjexcluded then\n_p(3, '<ExcludedFromBuild>true</ExcludedFromBuild>')\nelse\nfor _, cfgname in ipairs(excludedcfgs) do\n_p(3, '<ExcludedFromBuild '\n.. if_config_and_platform()\n.. '>true</ExcludedFromBuild>'\n, premake.esc(cfgname)\n)\nend\nend\nif subtype then\n_p(3, '<SubType>%s</SubType>', subtype)\nend\n_p(2,'</%s>', section)\nelse\n_p(2, '<%s Include=" "\\\"%s\\\" />', section, path.translate(file.name, \"\\\\\"))\nend\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.deploymentcontentgroup(prj, section, filetype)\nif filetype == nil then\nfiletype = section\nend\nlocal files = vc2010.getfilegroup(prj, section)\nif #files > 0 then\n_p(1,'<ItemGroup>')\nfor _, file in ipairs(files) do\n_p(2,'<%s Include=\\\"%s\\\">', filetype, path.translate(file.name, \"\\\\\"))\n_p(3,'<DeploymentContent>true</DeploymentContent>')\n_p(3,'<Link>%s</Link>', path.translate(file.vpath, \"\\\\\"))\n_p(2,'</%s>', filetype)\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.compilerfilesgroup(prj)\nlocal configs = prj.solution.vstudio_configs\nlocal files = vc2010.getfilegroup(prj, \"ClCompile\")\nif #files > 0 then\nlocal config_mappings = {}\nfor _, cfginfo in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\nif cfg.pchheader and cfg.pchsource and not cfg.flags.NoPCH then\nconfig_mappings[cfginfo] = path.translate(cfg.pchs" "ource, \"\\\\\")\nend\nend\n_p(1,'<ItemGroup>')\nlocal existingBasenames = {};\nfor _, file in ipairs(files) do\nlocal filename = string.lower(path.getbasename(file.name))\nlocal disambiguation = existingBasenames[filename] or 0;\nexistingBasenames[filename] = disambiguation + 1\nlocal translatedpath = path.translate(file.name, \"\\\\\")\n_p(2, '<ClCompile Include=\\\"%s\\\">', translatedpath)\nfor _, vsconfig in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)\nlocal namestyle = premake.getnamestyle(cfg)\nif namestyle == \"TegraAndroid\" or namestyle == \"NX\" then\n_p(3, '<ObjectFileName '.. if_config_and_platform() .. '>$(IntDir)%s.o</ObjectFileName>', premake.esc(vsconfig.name), premake.esc(path.translate(path.trimdots(path.removeext(file.name)))) )\nelse\nif disambiguation > 0 then\n_p(3, '<ObjectFileName '.. if_config_and_platform() .. '>$(IntDir)%s\\\\</ObjectFileName>', premake.esc(vsconfig.name), tostring(disambiguation))\nend\nend\nend\nif path.iscx" "file(file.name) then\n_p(3, '<CompileAsWinRT>true</CompileAsWinRT>')\n_p(3, '<RuntimeTypeInfo>true</RuntimeTypeInfo>')\n_p(3, '<PrecompiledHeader>NotUsing</PrecompiledHeader>')\nend\nif vstudio.iswinrt() and string.len(file.name) > 2 and string.sub(file.name, -2) == \".c\" then\n_p(3,'<CompileAsWinRT>FALSE</CompileAsWinRT>')\nend\nfor _, cfginfo in ipairs(configs) do\nif config_mappings[cfginfo] and translatedpath == config_mappings[cfginfo] then\n_p(3,'<PrecompiledHeader '.. if_config_and_platform() .. '>Create</PrecompiledHeader>', premake.esc(cfginfo.name))\nconfig_mappings[cfginfo] = nil --only one source file per pch\nend\nend\nlocal nopch = table.icontains(prj.nopch, file.name)\nfor _, vsconfig in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)\nif nopch or table.icontains(cfg.nopch, file.name) then\n_p(3,'<PrecompiledHeader '.. if_config_and_platform() .. '>NotUsing</PrecompiledHeader>', premake.esc(vsconfig.name))\nend\nend\nlocal excluded = table.i" "contains(prj.excludes, file.name)\nfor _, vsconfig in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)\nlocal fileincfg = table.icontains(cfg.files, file.name)\nlocal cfgexcluded = table.icontains(cfg.excludes, file.name)\nif excluded or not fileincfg or cfgexcluded then\n_p(3, '<ExcludedFromBuild '\n.. if_config_and_platform()\n.. '>true</ExcludedFromBuild>'\n, premake.esc(vsconfig.name)\n)\nend\nend\nif prj.flags and prj.flags.Managed then\nlocal prjforcenative = table.icontains(prj.forcenative, file.name)\nfor _,vsconfig in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)\nif prjforcenative or table.icontains(cfg.forcenative, file.name) then\n_p(3, '<CompileAsManaged ' .. if_config_and_platform() .. '>false</CompileAsManaged>', premake.esc(vsconfig.name))\nend\nend\nend\n_p(2,'</ClCompile>')\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.masmfiles(prj)\nlocal configs = prj.solution.vstudio_configs" "\nlocal files = vc2010.getfilegroup(prj, \"MASM\")\nif #files > 0 then\n_p(1, '<ItemGroup>')\nfor _, file in ipairs(files) do\nlocal translatedpath = path.translate(file.name, \"\\\\\")\n_p(2, '<MASM Include=\"%s\">', translatedpath)\nlocal excluded = table.icontains(prj.excludes, file.name)\nfor _, vsconfig in ipairs(configs) do\nlocal cfg = premake.getconfig(prj, vsconfig.src_buildcfg, vsconfig.src_platform)\nlocal fileincfg = table.icontains(cfg.files, file.name)\nlocal cfgexcluded = table.icontains(cfg.excludes, file.name)\nif excluded or not fileincfg or cfgexcluded then\n_p(3, '<ExcludedFromBuild '\n.. if_config_and_platform()\n.. '>true</ExcludedFromBuild>'\n, premake.esc(vsconfig.name)\n)\nend\nend\n_p(2, '</MASM>')\nend\n_p(1, '</ItemGroup>')\nend\nend\nfunction vc2010.header(targets)\nio.eol = \"\\r\\n\"\n_p('<?xml version=\"1.0\" encoding=\"utf-8\"?>')\nlocal t = \"\"\nif targets then\nt = ' DefaultTargets=\"' .. targets .. '\"'\nend\n_p('<Project%s ToolsVersion=\"%s\" xmlns=\"http://schemas.microso" "ft.com/developer/msbuild/2003\">', t, action.vstudio.toolsVersion)\nend\nfunction premake.vs2010_vcxproj(prj)\nlocal usemasm = hasmasmfiles(prj)\nio.indent = \" \"\nvc2010.header(\"Build\")\nvs2010_config(prj)\nvs2010_globals(prj)\n_p(1,'<Import Project=\"$(VCTargetsPath)\\\\Microsoft.Cpp.Default.props\" />')\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\nvc2010.configurationPropertyGroup(cfg, cfginfo)\nend\n_p(1,'<Import Project=\"$(VCTargetsPath)\\\\Microsoft.Cpp.props\" />')\n_p(1,'<ImportGroup Label=\"ExtensionSettings\">')\nif usemasm then\n_p(2, '<Import Project=\"$(VCTargetsPath)\\\\BuildCustomizations\\\\masm.props\" />')\nend\n_p(1,'</ImportGroup>')\nimport_props(prj)\n_p(1,'<PropertyGroup Label=\"UserMacros\" />')\nvc2010.outputProperties(prj)\nitem_definitions(prj)\nvc2010.files(prj)\nvc2010.clrReferences(prj)\nvc2010.projectReferences(prj)\nvc2010.sdkReferences(prj)\nvc2010.masmfiles(prj)\n_p(1,'<Import Pr" "oject=\"$(VCTargetsPath)\\\\Microsoft.Cpp.targets\" />')\n_p(1,'<ImportGroup Label=\"ExtensionTargets\">')\nif usemasm then\n_p(2, '<Import Project=\"$(VCTargetsPath)\\\\BuildCustomizations\\\\masm.targets\" />')\nend\n_p(1,'</ImportGroup>')\n_p('</Project>')\nend\nfunction vc2010.clrReferences(prj)\nif #prj.clrreferences == 0 then\nreturn\nend\n_p(1,'<ItemGroup>')\nfor _, ref in ipairs(prj.clrreferences) do\nif os.isfile(ref) then\nlocal assembly = path.getbasename(ref)\n_p(2,'<Reference Include=\"%s\">', assembly)\n_p(3,'<HintPath>%s</HintPath>', path.getrelative(prj.location, ref))\n_p(2,'</Reference>')\nelse\n_p(2,'<Reference Include=\"%s\" />', ref)\nend\nend\n_p(1,'</ItemGroup>')\nend\nfunction vc2010.projectReferences(prj)\nlocal deps = premake.getdependencies(prj)\nif #deps == 0 and #prj.vsimportreferences == 0 then\nreturn\nend\nlocal function compareuuid(a, b) return a.uuid < b.uuid end\ntable.sort(deps, compareuuid)\ntable.sort(table.join(prj.vsimportreferences), compareuuid)\n_p(1,'<ItemGroup>')\nf" "or _, dep in ipairs(deps) do\nlocal deppath = path.getrelative(prj.location, vstudio.projectfile(dep))\n_p(2,'<ProjectReference Include=\\\"%s\\\">', path.translate(deppath, \"\\\\\"))\n_p(3,'<Project>{%s}</Project>', dep.uuid)\nif vstudio.iswinrt() then\n_p(3,'<ReferenceOutputAssembly>false</ReferenceOutputAssembly>')\nend\n_p(2,'</ProjectReference>')\nend\nfor _, ref in ipairs(prj.vsimportreferences) do\nlocal slnrelpath = path.rebase(ref, prj.location, sln.location)\nlocal iprj = premake.vstudio.getimportprj(slnrelpath, prj.solution)\n_p(2,'<ProjectReference Include=\\\"%s\\\">', ref)\n_p(3,'<Project>{%s}</Project>', iprj.uuid)\n_p(2,'</ProjectReference>')\nend\n_p(1,'</ItemGroup>')\nend\nfunction vc2010.sdkReferences(prj)\nlocal refs = prj.sdkreferences\nif #refs > 0 then\n_p(1,'<ItemGroup>')\nfor _, ref in ipairs(refs) do\n_p(2,'<SDKReference Include=\\\"%s\\\" />', ref)\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.debugdir(cfg)\nlocal isnx = (cfg.platform == \"NX32\" or cfg.platform == \"NX64\")" "\nlocal debuggerFlavor =\n iif(isnx, 'OasisNXDebugger'\n, iif(cfg.platform == \"Orbis\", 'ORBISDebugger'\n, iif(cfg.platform == \"Durango\", 'XboxOneVCppDebugger'\n, iif(cfg.platform == \"TegraAndroid\", 'AndroidDebugger'\n, iif(vstudio.iswinrt(), 'AppHostLocalDebugger'\n, 'WindowsLocalDebugger'\n)))))\n_p(2, '<DebuggerFlavor>%s</DebuggerFlavor>', debuggerFlavor)\nif cfg.debugdir and not vstudio.iswinrt() then\n_p(2, '<LocalDebuggerWorkingDirectory>%s</LocalDebuggerWorkingDirectory>'\n, path.translate(cfg.debugdir, '\\\\')\n)\nend\nif cfg.debugcmd then\n_p(2, '<LocalDebuggerCommand>%s</LocalDebuggerCommand>', cfg.debugcmd)\nend\nif cfg.debugargs then\n_p(2, '<LocalDebuggerCommandArguments>%s</LocalDebuggerCommandArguments>'\n, table.concat(cfg.debugargs, \" \")\n)\nend\nif cfg.debugenvs and #cfg.debugenvs > 0 then\n_p(2, '<LocalDebuggerEnvironment>%s%s</LocalDebuggerEnvironment>'\n, table.concat(cfg.debugenvs, \"\\n\")\n, i" "if(cfg.flags.DebugEnvsInherit,'\\n$(LocalDebuggerEnvironment)', '')\n)\nif cfg.flags.DebugEnvsDontMerge then\n_p(2, '<LocalDebuggerMergeEnvironment>false</LocalDebuggerMergeEnvironment>')\nend\nend\nif cfg.deploymode then\n_p(2, '<DeployMode>%s</DeployMode>', cfg.deploymode)\nend\nif cfg.platform == \"TegraAndroid\" then\nif cfg.androiddebugintentparams then\n_p(2, '<IntentParams>%s</IntentParams>'\n, table.concat(cfg.androiddebugintentparams, \" \")\n)\nend\nend\nend\nfunction premake.vs2010_vcxproj_user(prj)\nio.indent = \" \"\nvc2010.header()\nfor _, cfginfo in ipairs(prj.solution.vstudio_configs) do\nlocal cfg = premake.getconfig(prj, cfginfo.src_buildcfg, cfginfo.src_platform)\n_p(' <PropertyGroup '.. if_config_and_platform() ..'>', premake.esc(cfginfo.name))\nvc2010.debugdir(cfg)\n_p(' </PropertyGroup>')\nend\n_p('</Project>')\nend\nlocal png1x1data = {\n0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, -- .PNG........IHDR\n0x00, 0x00, 0x00, 0x01, 0x00, 0x" "00, 0x00, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x25, 0xdb, 0x56, -- .............%.V\n0xca, 0x00, 0x00, 0x00, 0x03, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0xa7, 0x7a, 0x3d, 0xda, -- .....PLTE....z=.\n0x00, 0x00, 0x00, 0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00, 0x00, -- [email protected]...\n0x0a, 0x49, 0x44, 0x41, 0x54, 0x08, 0xd7, 0x63, 0x60, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0xe2, -- .IDAT..c`.......\n0x21, 0xbc, 0x33, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, -- !.3....IEND.B`.\n}\nfunction png1x1(obj, filename)\nfilename = premake.project.getfilename(obj, filename)\nlocal f, err = io.open(filename, \"wb\")\nif f then\nfor _, byte in ipairs(png1x1data) do\nf:write(string.char(byte))\nend\nf:close()\nend\nend\nfunction premake.vs2010_appxmanifest(prj)\nio.indent = \" \"\nio.eol = \"\\r\\n\"\n_p('<?xml version=\"1.0\" encoding=\"utf-8\"?>')\nif vstudio.storeapp == \"10.0\" then\n_p('<Package')\n_p(1, 'xmlns=\"http://schemas.microsoft.com/appx/m" "anifest/foundation/windows10\"')\n_p(1, 'xmlns:mp=\"http://schemas.microsoft.com/appx/2014/phone/manifest\"')\n_p(1, 'xmlns:uap=\"http://schemas.microsoft.com/appx/manifest/uap/windows10\"')\n_p(1, 'IgnorableNamespaces=\"uap mp\">')\nelseif vstudio.storeapp == \"durango\" then\n_p('<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\" xmlns:mx=\"http://schemas.microsoft.com/appx/2013/xbox/manifest\" IgnorableNamespaces=\"mx\">')\nend\n_p(1, '<Identity')\n_p(2, 'Name=\"' .. prj.uuid .. '\"')\n_p(2, 'Publisher=\"CN=Publisher\"')\n_p(2, 'Version=\"1.0.0.0\" />')\nif vstudio.storeapp == \"10.0\" then\n_p(1, '<mp:PhoneIdentity')\n_p(2, 'PhoneProductId=\"' .. prj.uuid .. '\"')\n_p(2, 'PhonePublisherId=\"00000000-0000-0000-0000-000000000000\"/>')\nend\n_p(1, '<Properties>')\n_p(2, '<DisplayName>' .. prj.name .. '</DisplayName>')\n_p(2, '<PublisherDisplayName>PublisherDisplayName</PublisherDisplayName>')\n_p(2, '<Logo>' .. prj.name .. '\\\\StoreLogo.png</Logo>')\npng1x1(prj, \"%%/StoreLogo.png\")\n_p(2, '" "<Description>' .. prj.name .. '</Description>')\n_p(1,'</Properties>')\nif vstudio.storeapp == \"10.0\" then\n_p(1, '<Dependencies>')\n_p(2, '<TargetDeviceFamily Name=\"Windows.Universal\" MinVersion=\"10.0.10069.0\" MaxVersionTested=\"10.0.10069.0\" />')\n_p(1, '</Dependencies>')\nelseif vstudio.storeapp == \"durango\" then\n_p(1, '<Prerequisites>')\n_p(2, '<OSMinVersion>6.2</OSMinVersion>')\n_p(2, '<OSMaxVersionTested>6.2</OSMaxVersionTested>')\n_p(1, '</Prerequisites>')\nend\n_p(1, '<Resources>')\n_p(2, '<Resource Language=\"en-us\"/>')\n_p(1, '</Resources>')\n_p(1, '<Applications>')\n_p(2, '<Application Id=\"App\"')\n_p(3, 'Executable=\"$targetnametoken$.exe\"')\n_p(3, 'EntryPoint=\"' .. prj.name .. '.App\">')\nif vstudio.storeapp == \"10.0\" then\n_p(3, '<uap:VisualElements')\n_p(4, 'DisplayName=\"' .. prj.name .. '\"')\n_p(4, 'Square150x150Logo=\"' .. prj.name .. '\\\\Logo.png\"')\npng1x1(prj, \"%%/Logo.png\")\nif vstudio.storeapp == \"10.0\" then\n_p(4, 'Square44x44Logo=\"' .. prj.name .. '\\\\SmallLogo" ".png\"')\npng1x1(prj, \"%%/SmallLogo.png\")\nelse\n_p(4, 'Square30x30Logo=\"' .. prj.name .. '\\\\SmallLogo.png\"')\npng1x1(prj, \"%%/SmallLogo.png\")\nend\n_p(4, 'Description=\"' .. prj.name .. '\"')\n_p(4, 'BackgroundColor=\"transparent\">')\n_p(4, '<uap:SplashScreen Image=\"' .. prj.name .. '\\\\SplashScreen.png\" />')\npng1x1(prj, \"%%/SplashScreen.png\")\n_p(3, '</uap:VisualElements>')\nelseif vstudio.storeapp == \"durango\" then\n_p(3, '<VisualElements')\n_p(4, 'DisplayName=\"' .. prj.name .. '\"')\n_p(4, 'Logo=\"' .. prj.name .. '\\\\Logo.png\"')\npng1x1(prj, \"%%/Logo.png\")\n_p(4, 'SmallLogo=\"' .. prj.name .. '\\\\SmallLogo.png\"')\npng1x1(prj, \"%%/SmallLogo.png\")\n_p(4, 'Description=\"' .. prj.name .. '\"')\n_p(4, 'ForegroundText=\"light\"')\n_p(4, 'BackgroundColor=\"transparent\">')\n_p(5, '<SplashScreen Image=\"' .. prj.name .. '\\\\SplashScreen.png\" />')\npng1x1(prj, \"%%/SplashScreen.png\")\n_p(3, '</VisualElements>')\n_p(3, '<Extensions>')\n_p(4, '<mx:Extension Category=\"xbox.system.resourc" "es\">')\n_p(4, '<mx:XboxSystemResources />')\n_p(4, '</mx:Extension>')\n_p(3, '</Extensions>')\nend\n_p(2, '</Application>')\n_p(1, '</Applications>')\n_p('</Package>')\nend\n", /* actions/vstudio/vstudio_vcxproj_filters.lua */ "local vc2010 = premake.vstudio.vc2010\nlocal project = premake.project\nfunction vc2010.filteridgroup(prj)\nlocal filters = { }\nlocal filterfound = false\nfor file in premake.project.eachfile(prj, true) do\nlocal folders = string.explode(file.vpath, \"/\", true)\nlocal path = \"\"\nfor i = 1, #folders - 1 do\nif not filterfound then\nfilterfound = true\n_p(1,'<ItemGroup>')\nend\npath = path .. folders[i]\nif not filters[path] then\nfilters[path] = true\n_p(2, '<Filter Include=\"%s\">', path)\n_p(3, '<UniqueIdentifier>{%s}</UniqueIdentifier>', os.uuid(path))\n_p(2, '</Filter>')\nend\npath = path .. \"\\\\\"\nend\nend\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask in ipairs(custombuildtask or {}) do\nlocal folders = string.explode(path.trimdots(path.getrelative(prj.location,buildtask[1])), \"/\", true)\nlocal path = \"\"\nfor i = 1, #folders - 1 do\nif not filterfound then\nfilterfound = true\n_p(1,'<ItemGroup>')\nend\npath = path .. folders[i]\nif not filters[path] then\nfilt" "ers[path] = true\n_p(2, '<Filter Include=\"%s\">', path)\n_p(3, '<UniqueIdentifier>{%s}</UniqueIdentifier>', os.uuid(path))\n_p(2, '</Filter>')\nend\npath = path .. \"\\\\\"\nend\nend\nend\nif filterfound then\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.filefiltergroup(prj, section, kind)\nlocal files = vc2010.getfilegroup(prj, section) or {}\nif kind == nill then\nkind = section\nend\nif (section == \"CustomBuild\") then\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask in ipairs(custombuildtask or {}) do\nlocal fcfg = { }\nfcfg.name = path.getrelative(prj.location,buildtask[1])\nfcfg.vpath = path.trimdots(fcfg.name)\ntable.insert(files, fcfg)\nend\nend\nend\nif #files > 0 then\n_p(1,'<ItemGroup>')\nfor _, file in ipairs(files) do\nlocal filter\nif file.name ~= file.vpath then\nfilter = path.getdirectory(file.vpath)\nelse\nfilter = path.getdirectory(file.name)\nend\nif filter ~= \".\" then\n_p(2,'<%s Include=\\\"%s\\\">', kind, path.translate(file.name, \"\\\\\"))\n_p(3,'<" "Filter>%s</Filter>', path.translate(filter, \"\\\\\"))\n_p(2,'</%s>', kind)\nelse\n_p(2,'<%s Include=\\\"%s\\\" />', kind, path.translate(file.name, \"\\\\\"))\nend\nend\n_p(1,'</ItemGroup>')\nend\nend\nfunction vc2010.generate_filters(prj)\nio.indent = \" \"\nvc2010.header()\nvc2010.filteridgroup(prj)\nvc2010.filefiltergroup(prj, \"None\")\nvc2010.filefiltergroup(prj, \"ClInclude\")\nvc2010.filefiltergroup(prj, \"ClCompile\")\nvc2010.filefiltergroup(prj, \"Object\")\nvc2010.filefiltergroup(prj, \"ResourceCompile\")\nvc2010.filefiltergroup(prj, \"CustomBuild\")\nvc2010.filefiltergroup(prj, \"AppxManifest\")\nvc2010.filefiltergroup(prj, \"Natvis\")\nvc2010.filefiltergroup(prj, \"Image\")\nvc2010.filefiltergroup(prj, \"DeploymentContent\", \"None\")\nvc2010.filefiltergroup(prj, \"MASM\")\n_p('</Project>')\nend\n", /* actions/vstudio/vs2010.lua */ "local vc2010 = premake.vstudio.vc2010\nlocal vstudio = premake.vstudio\nnewaction\n{\ntrigger = \"vs2010\",\nshortname = \"Visual Studio 2010\",\ndescription = \"Generate Microsoft Visual Studio 2010 project files\",\nos = \"windows\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\", \"C#\"},\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"%%.sln\", vstudio.sln2005.generate)\nend,\nonproject = function(prj)\nif premake.isdotnetproject(prj) then\npremake.generate(prj, \"%%.csproj\", vstudio.cs2005.generate)\npremake.generate(prj, \"%%.csproj.user\", vstudio.cs2005.generate_user)\nelse\npremake.generate(prj, \"%%.vcxproj\", premake.vs2010_vcxproj)\npremake.generate(prj, \"%%.vcxproj.user\", premake.vs2010_vcxproj_user)\npremake.generate(prj, \"%%.vcxproj.filters\", vstudio.vc2010.generate_filters)\nend\nend,\noncleanso" "lution = premake.vstudio.cleansolution,\noncleanproject = premake.vstudio.cleanproject,\noncleantarget = premake.vstudio.cleantarget,\nvstudio = {\nproductVersion = \"8.0.30703\",\nsolutionVersion = \"11\",\ntargetFramework = \"4.0\",\ntoolsVersion = \"4.0\",\nsupports64bitEditContinue = false,\nintDirAbsolute = false,\n}\n}\n", /* actions/vstudio/vs2012.lua */ "premake.vstudio.vc2012 = {}\nlocal vc2012 = premake.vstudio.vc2012\nlocal vstudio = premake.vstudio\nnewaction\n{\ntrigger = \"vs2012\",\nshortname = \"Visual Studio 2012\",\ndescription = \"Generate Microsoft Visual Studio 2012 project files\",\nos = \"windows\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\", \"C#\"},\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"%%.sln\", vstudio.sln2005.generate)\nend,\nonproject = function(prj)\nif premake.isdotnetproject(prj) then\npremake.generate(prj, \"%%.csproj\", vstudio.cs2005.generate)\npremake.generate(prj, \"%%.csproj.user\", vstudio.cs2005.generate_user)\nelse\npremake.generate(prj, \"%%.vcxproj\", premake.vs2010_vcxproj)\npremake.generate(prj, \"%%.vcxproj.user\", premake.vs2010_vcxproj_user)\npremake.generate(prj, \"%%.vcxproj.filters\", vstudio.vc2010.generate_f" "ilters)\nend\nend,\noncleansolution = premake.vstudio.cleansolution,\noncleanproject = premake.vstudio.cleanproject,\noncleantarget = premake.vstudio.cleantarget,\nvstudio = {\nsolutionVersion = \"12\",\ntargetFramework = \"4.5\",\ntoolsVersion = \"4.0\",\nsupports64bitEditContinue = false,\nintDirAbsolute = false,\n}\n}\n", /* actions/vstudio/vs2013.lua */ "premake.vstudio.vc2013 = {}\nlocal vc2013 = premake.vstudio.vc2013\nlocal vstudio = premake.vstudio\nnewaction\n{\ntrigger = \"vs2013\",\nshortname = \"Visual Studio 2013\",\ndescription = \"Generate Microsoft Visual Studio 2013 project files\",\nos = \"windows\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\", \"C#\"},\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"%%.sln\", vstudio.sln2005.generate)\nend,\nonproject = function(prj)\nif premake.isdotnetproject(prj) then\npremake.generate(prj, \"%%.csproj\", vstudio.cs2005.generate)\npremake.generate(prj, \"%%.csproj.user\", vstudio.cs2005.generate_user)\nelse\npremake.vstudio.needAppxManifest = false\npremake.generate(prj, \"%%.vcxproj\", premake.vs2010_vcxproj)\npremake.generate(prj, \"%%.vcxproj.user\", premake.vs2010_vcxproj_user)\npremake.generate(prj, \"%%.vc" "xproj.filters\", vstudio.vc2010.generate_filters)\nif premake.vstudio.needAppxManifest then\npremake.generate(prj, \"%%/Package.appxmanifest\", premake.vs2010_appxmanifest)\nend\nend\nend,\noncleansolution = premake.vstudio.cleansolution,\noncleanproject = premake.vstudio.cleanproject,\noncleantarget = premake.vstudio.cleantarget,\nvstudio = {\nsolutionVersion = \"12\",\ntargetFramework = \"4.5\",\ntoolsVersion = \"12.0\",\nsupports64bitEditContinue = false,\nintDirAbsolute = false,\n}\n}\n", /* actions/vstudio/vs2015.lua */ "premake.vstudio.vc2015 = {}\nlocal vc2015 = premake.vstudio.vc2015\nlocal vstudio = premake.vstudio\nnewaction\n{\ntrigger = \"vs2015\",\nshortname = \"Visual Studio 2015\",\ndescription = \"Generate Microsoft Visual Studio 2015 project files\",\nos = \"windows\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\", \"C#\" },\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"%%.sln\", vstudio.sln2005.generate)\nend,\nonproject = function(prj)\nif premake.isdotnetproject(prj) then\npremake.generate(prj, \"%%.csproj\", vstudio.cs2005.generate)\npremake.generate(prj, \"%%.csproj.user\", vstudio.cs2005.generate_user)\nelse\npremake.vstudio.needAppxManifest = false\npremake.generate(prj, \"%%.vcxproj\", premake.vs2010_vcxproj)\npremake.generate(prj, \"%%.vcxproj.user\", premake.vs2010_vcxproj_user)\npremake.generate(prj, \"%%.v" "cxproj.filters\", vstudio.vc2010.generate_filters)\nif premake.vstudio.needAppxManifest then\npremake.generate(prj, \"%%/Package.appxmanifest\", premake.vs2010_appxmanifest)\nend\nend\nend,\noncleansolution = premake.vstudio.cleansolution,\noncleanproject = premake.vstudio.cleanproject,\noncleantarget = premake.vstudio.cleantarget,\nvstudio = {\nsolutionVersion = \"12\",\ntargetFramework = \"4.5\",\ntoolsVersion = \"14.0\",\nwindowsTargetPlatformVersion = \"8.1\",\nsupports64bitEditContinue = true,\nintDirAbsolute = false,\n}\n}\n", /* actions/vstudio/vs2017.lua */ "premake.vstudio.vc2017 = {}\nlocal vc2017 = premake.vstudio.vc2017\nlocal vstudio = premake.vstudio\nnewaction\n{\ntrigger = \"vs2017\",\nshortname = \"Visual Studio 2017\",\ndescription = \"Generate Microsoft Visual Studio 2017 project files\",\nos = \"windows\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\", \"C#\" },\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"%%.sln\", vstudio.sln2005.generate)\nend,\nonproject = function(prj)\nif premake.isdotnetproject(prj) then\npremake.generate(prj, \"%%.csproj\", vstudio.cs2005.generate)\npremake.generate(prj, \"%%.csproj.user\", vstudio.cs2005.generate_user)\nelse\npremake.vstudio.needAppxManifest = false\npremake.generate(prj, \"%%.vcxproj\", premake.vs2010_vcxproj)\npremake.generate(prj, \"%%.vcxproj.user\", premake.vs2010_vcxproj_user)\npremake.generate(prj, \"%%.v" "cxproj.filters\", vstudio.vc2010.generate_filters)\nif premake.vstudio.needAppxManifest then\npremake.generate(prj, \"%%/Package.appxmanifest\", premake.vs2010_appxmanifest)\nend\nend\nend,\noncleansolution = premake.vstudio.cleansolution,\noncleanproject = premake.vstudio.cleanproject,\noncleantarget = premake.vstudio.cleantarget,\nvstudio = {\nsolutionVersion = \"12\",\ntargetFramework = \"4.5.2\",\ntoolsVersion = \"15.0\",\nwindowsTargetPlatformVersion = \"8.1\",\nsupports64bitEditContinue = true,\nintDirAbsolute = false,\n}\n}\n", /* actions/vstudio/vs2019.lua */ "premake.vstudio.vc2019 = {}\nlocal vc2019 = premake.vstudio.vc2019\nlocal vstudio = premake.vstudio\nnewaction\n{\ntrigger = \"vs2019\",\nshortname = \"Visual Studio 2019\",\ndescription = \"Generate Microsoft Visual Studio 2019 project files\",\nos = \"windows\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\", \"C#\" },\nvalid_tools = {\ncc = { \"msc\" },\ndotnet = { \"msnet\" },\n},\nonsolution = function(sln)\npremake.generate(sln, \"%%.sln\", vstudio.sln2005.generate)\nend,\nonproject = function(prj)\nif premake.isdotnetproject(prj) then\npremake.generate(prj, \"%%.csproj\", vstudio.cs2005.generate)\npremake.generate(prj, \"%%.csproj.user\", vstudio.cs2005.generate_user)\nelse\npremake.vstudio.needAppxManifest = false\npremake.generate(prj, \"%%.vcxproj\", premake.vs2010_vcxproj)\npremake.generate(prj, \"%%.vcxproj.user\", premake.vs2010_vcxproj_user)\npremake.generate(prj, \"%%.v" "cxproj.filters\", vstudio.vc2010.generate_filters)\nif premake.vstudio.needAppxManifest then\npremake.generate(prj, \"%%/Package.appxmanifest\", premake.vs2010_appxmanifest)\nend\nend\nend,\noncleansolution = premake.vstudio.cleansolution,\noncleanproject = premake.vstudio.cleanproject,\noncleantarget = premake.vstudio.cleantarget,\nvstudio = {\nsolutionVersion = \"12\",\ntargetFramework = \"4.7.2\",\ntoolsVersion = \"16.0\",\nwindowsTargetPlatformVersion = \"10.0\",\nsupports64bitEditContinue = true,\nintDirAbsolute = false,\n}\n}\n", /* actions/xcode/_xcode.lua */ "premake.xcode = { }\nfunction premake.xcode.checkproject(prj)\nlocal last\nfor cfg in premake.eachconfig(prj) do\nif last and last ~= cfg.kind then\nerror(\"Project '\" .. prj.name .. \"' uses more than one target kind; not supported by Xcode\", 0)\nend\nlast = cfg.kind\nend\nend\npremake.xcode.toolset = \"macosx\"\n", /* actions/xcode/xcode_common.lua */ "premake.xcode.parameters = { }\nlocal xcode = premake.xcode\nlocal tree = premake.tree\nfunction xcode.getbuildcategory(node)\nlocal categories = {\n[\".a\"] = \"Frameworks\",\n[\".h\"] = \"Headers\",\n[\".hh\"] = \"Headers\",\n[\".hpp\"] = \"Headers\",\n[\".hxx\"] = \"Headers\",\n[\".inl\"] = \"Headers\",\n[\".c\"] = \"Sources\",\n[\".cc\"] = \"Sources\",\n[\".cpp\"] = \"Sources\",\n[\".cxx\"] = \"Sources\",\n[\".c++\"] = \"Sources\",\n[\".dylib\"] = \"Frameworks\",\n[\".bundle\"] = \"Frameworks\",\n[\".framework\"] = \"Frameworks\",\n[\".tbd\"] = \"Frameworks\",\n[\".m\"] = \"Sources\",\n[\".mm\"] = \"Sources\",\n[\".S\"] = \"Sources\",\n[\".strings\"] = \"Resources\",\n[\".nib\"] = \"Resources\",\n[\".xib\"] = \"Resources\",\n[\".icns\"] = \"Resources\",\n[\".bmp\"] = \"Resources\",\n[\".wav\"] = \"Resources\",\n[\".xcassets\"] = \"Resources\",\n[\".xcdatamodeld\"] = \"Sources\",\n[\".swift\"] = \"Sources\",\n}\nreturn categories[path.getextension(node.name)] or\ncategories[string.lower(path.getextension(" "node.name))]\nend\nfunction xcode.getconfigname(cfg)\nlocal name = cfg.name\nif #cfg.project.solution.xcode.platforms > 1 then\nname = name .. \" \" .. premake.action.current().valid_platforms[cfg.platform]\nend\nreturn name\nend\nfunction xcode.getfiletype(node)\nlocal types = {\n[\".c\"] = \"sourcecode.c.c\",\n[\".cc\"] = \"sourcecode.cpp.cpp\",\n[\".cpp\"] = \"sourcecode.cpp.cpp\",\n[\".css\"] = \"text.css\",\n[\".cxx\"] = \"sourcecode.cpp.cpp\",\n[\".c++\"] = \"sourcecode.cpp.cpp\",\n[\".entitlements\"] = \"text.xml\",\n[\".bundle\"] = \"wrapper.cfbundle\",\n[\".framework\"] = \"wrapper.framework\",\n[\".tbd\"] = \"sourcecode.text-based-dylib-definition\",\n[\".gif\"] = \"image.gif\",\n[\".h\"] = \"sourcecode.c.h\",\n[\".hh\"] = \"sourcecode.cpp.h\",\n[\".hpp\"] = \"sourcecode.cpp.h\",\n[\".hxx\"] = \"sourcecode.cpp.h\",\n[\".inl\"] = \"sourcecode.cpp.h\",\n[\".html\"] = \"text.html\",\n[\".lua\"] = \"sourceco" "de.lua\",\n[\".m\"] = \"sourcecode.c.objc\",\n[\".mm\"] = \"sourcecode.cpp.objcpp\",\n[\".S\"] = \"sourcecode.asm\",\n[\".nib\"] = \"wrapper.nib\",\n[\".pch\"] = \"sourcecode.c.h\",\n[\".plist\"] = \"text.plist.xml\",\n[\".strings\"] = \"text.plist.strings\",\n[\".xib\"] = \"file.xib\",\n[\".icns\"] = \"image.icns\",\n[\".bmp\"] = \"image.bmp\",\n[\".wav\"] = \"audio.wav\",\n[\".xcassets\"] = \"folder.assetcatalog\",\n[\".xcdatamodeld\"] = \"wrapper.xcdatamodeld\",\n[\".swift\"] = \"sourcecode.swift\",\n}\nreturn types[path.getextension(node.path)] or\n(types[string.lower(path.getextension(node.path))] or \"text\")\nend\nfunction xcode.getfiletypeForced(node)\nlocal types = {\n[\".c\"] = \"sourcecode.cpp.cpp\",\n[\".cc\"] = \"sourcecode.cpp.cpp\",\n[\".cpp\"] = \"sourcecode.cpp.cpp\",\n[\".css\"] = \"text.css\",\n[\".cxx\"] = \"sourcecode.cpp.cpp\",\n[\".c++\"] = \"sourcecode.cpp.cpp\",\n[\".entitlements" "\"] = \"text.xml\",\n[\".bundle\"] = \"wrapper.cfbundle\",\n[\".framework\"] = \"wrapper.framework\",\n[\".tbd\"] = \"wrapper.framework\",\n[\".gif\"] = \"image.gif\",\n[\".h\"] = \"sourcecode.cpp.h\",\n[\".hh\"] = \"sourcecode.cpp.h\",\n[\".hpp\"] = \"sourcecode.cpp.h\",\n[\".hxx\"] = \"sourcecode.cpp.h\",\n[\".inl\"] = \"sourcecode.cpp.h\",\n[\".html\"] = \"text.html\",\n[\".lua\"] = \"sourcecode.lua\",\n[\".m\"] = \"sourcecode.cpp.objcpp\",\n[\".mm\"] = \"sourcecode.cpp.objcpp\",\n[\".nib\"] = \"wrapper.nib\",\n[\".pch\"] = \"sourcecode.cpp.h\",\n[\".plist\"] = \"text.plist.xml\",\n[\".strings\"] = \"text.plist.strings\",\n[\".xib\"] = \"file.xib\",\n[\".icns\"] = \"image.icns\",\n[\".bmp\"] = \"image.bmp\",\n[\".wav\"] = \"audio.wav\",\n[\".xcassets\"] = \"folder.assetcatalog\",\n[\".xcdatamodeld\"] = \"wrapper.xcdatamodeld\",\n[\".swift\"] = \"sourcecode.swift\",\n}\nreturn types[path.ge" "textension(node.path)] or\n(types[string.lower(path.getextension(node.path))] or \"text\")\nend\nfunction xcode.getproducttype(node)\nlocal types = {\nConsoleApp = \"com.apple.product-type.tool\",\nWindowedApp = node.cfg.options.SkipBundling and \"com.apple.product-type.tool\" or \"com.apple.product-type.application\",\nStaticLib = \"com.apple.product-type.library.static\",\nSharedLib = \"com.apple.product-type.library.dynamic\",\nBundle = node.cfg.options.SkipBundling and \"com.apple.product-type.tool\" or \"com.apple.product-type.bundle\",\n}\nreturn types[node.cfg.kind]\nend\nfunction xcode.gettargettype(node)\nlocal types = {\nConsoleApp = \"\\\"compiled.mach-o.executable\\\"\",\nWindowedApp = node.cfg.options.SkipBundling and \"\\\"compiled.mach-o.executable\\\"\" or \"wrapper.application\",\nStaticLib = \"archive.ar\",\nSharedLib = \"\\\"compiled.mach-o.dylib\\\"\",\nBundle = node.cfg.options.SkipBundling and \"\\\"compiled.mach-o.bundle\\\"\" or \"wrapper.cfbundle\",\n}\nreturn types" "[node.cfg.kind]\nend\nfunction xcode.getxcodeprojname(prj)\nlocal fname = premake.project.getfilename(prj, \"%%.xcodeproj\")\nreturn fname\nend\nfunction xcode.isframework(fname)\nreturn (path.getextension(fname) == \".framework\" or path.getextension(fname) == \".tbd\")\nend\nfunction xcode.uuid(param)\nreturn os.uuid(param):upper():gsub('-',''):sub(0,24)\nend\nfunction xcode.newid(node, usage)\nlocal base = ''\nlocal prj = node.project\nif prj == nil then\nlocal parent = node.parent\nwhile parent ~= nil do\nif parent.project ~= nil then\nprj = parent.project\nbreak\nend\nparent = parent.parent\nend\nend\nif prj ~= nil then\nprj.uuidcounter = (prj.uuidcounter or 0) + 1\nbase = base .. prj.name .. \"$\" .. prj.uuidcounter .. \"$\"\nend\nbase = base .. \"$\" .. (node.path or node.name or \"\")\nbase = base .. \"$\" .. (usage or \"\")\nreturn xcode.uuid(base)\nend\nfunction xcode.getscriptphaselabel(cmd, count, cfg)\nreturn string.format(\"\\\"Script Phase %s [%s] (%s)\\\"\", count, cmd:match(\"(%w+)(.+)\"), iif" "(cfg, xcode.getconfigname(cfg), \"all\"))\nend\nfunction xcode.getcopyphaselabel(type, count, target)\nreturn string.format(\"\\\"Copy %s %s [%s]\\\"\", type, count, target)\nend\nfunction xcode.preparesolution(sln)\nsln.xcode = { }\nsln.xcode.platforms = premake.filterplatforms(sln, premake.action.current().valid_platforms, \"Universal\")\nfor prj in premake.solution.eachproject(sln) do\nlocal cfg = premake.getconfig(prj, prj.configurations[1], sln.xcode.platforms[1])\nlocal node = premake.tree.new(path.getname(cfg.buildtarget.bundlepath))\nnode.cfg = cfg\nnode.id = premake.xcode.newid(node, \"product\")\nnode.targetid = premake.xcode.newid(node, \"target\")\nprj.xcode = {}\nprj.xcode.projectnode = node\nend\nend\nfunction xcode.printlist(list, tag, sort)\nif #list > 0 then\nif sort ~= nil and sort == true then\ntable.sort(list)\nend\n_p(4,'%s = (', tag)\nfor _, item in ipairs(list) do\nlocal escaped_item = item:gsub(\"\\\"\", \"\\\\\\\\\\\\\\\"\"):gsub(\"'\", \"\\\\\\\\'\")\n_p(5, '\"%s\",', escaped_item)\ne" "nd\n_p(4,');')\nend\nend\nfunction xcode.quotestr(str)\nif str:match(\"[^a-zA-Z0-9$._/]\") == nil then\nreturn str\nend\nreturn \"\\\"\" .. str:gsub(\"[\\\"\\\\\\\"]\", \"\\\\%0\") .. \"\\\"\"\nend\nfunction xcode.Header(tr, objversion)\n_p('// !$*UTF8*$!')\n_p('{')\n_p(1,'archiveVersion = 1;')\n_p(1,'classes = {')\n_p(1,'};')\n_p(1,'objectVersion = %d;', objversion)\n_p(1,'objects = {')\n_p('')\nend\nfunction xcode.PBXBuildFile(tr)\nlocal function gatherCopyFiles(which)\nlocal copyfiles = {}\nlocal targets = tr.project[which]\nif #targets > 0 then\nfor _, t in ipairs(targets) do\nfor __, tt in ipairs(t) do\ntable.insertflat(copyfiles, tt[2])\nend\nend\nend\nreturn table.translate(copyfiles, path.getname)\nend\nlocal function gatherCopyFrameworks(which)\nlocal copyfiles = {}\nlocal targets = tr.project[which]\nif #targets > 0 then\ntable.insertflat(copyfiles, targets)\nend\nreturn table.translate(copyfiles, path.getname)\nend\nlocal copyfiles = table.flatten({\ngatherCopyFiles('xcodecopyresources'),\ngatherCop" "yFrameworks('xcodecopyframeworks')\n})\n_p('/* Begin PBXBuildFile section */')\ntree.traverse(tr, {\nonnode = function(node)\nif node.buildid then\n_p(2,'%s /* %s in %s */ = {isa = PBXBuildFile; fileRef = %s /* %s */; };',\nnode.buildid, node.name, xcode.getbuildcategory(node), node.id, node.name)\nend\nif table.icontains(copyfiles, node.name) then\n_p(2,'%s /* %s in %s */ = {isa = PBXBuildFile; fileRef = %s /* %s */; %s };',\nxcode.uuid(node.name .. 'in CopyFiles'), node.name, 'CopyFiles', node.id, node.name,\niif(xcode.isframework(node.name), \"settings = {ATTRIBUTES = (CodeSignOnCopy, ); };\", \"\")\n)\nend\nend\n})\n_p('/* End PBXBuildFile section */')\n_p('')\nend\nfunction xcode.PBXContainerItemProxy(tr)\nif #tr.projects.children > 0 then\n_p('/* Begin PBXContainerItemProxy section */')\nfor _, node in ipairs(tr.projects.children) do\n_p(2,'%s /* PBXContainerItemProxy */ = {', node.productproxyid)\n_p(3,'isa = PBXContainerItemProxy;')\n_p(3,'containerPortal = %s /* %s */;', node.id, path.getname(node.pat" "h))\n_p(3,'proxyType = 2;')\n_p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.id)\n_p(3,'remoteInfo = \"%s\";', node.project.xcode.projectnode.name)\n_p(2,'};')\n_p(2,'%s /* PBXContainerItemProxy */ = {', node.targetproxyid)\n_p(3,'isa = PBXContainerItemProxy;')\n_p(3,'containerPortal = %s /* %s */;', node.id, path.getname(node.path))\n_p(3,'proxyType = 1;')\n_p(3,'remoteGlobalIDString = %s;', node.project.xcode.projectnode.targetid)\n_p(3,'remoteInfo = \"%s\";', node.project.xcode.projectnode.name)\n_p(2,'};')\nend\n_p('/* End PBXContainerItemProxy section */')\n_p('')\nend\nend\nfunction xcode.PBXFileReference(tr,prj)\n_p('/* Begin PBXFileReference section */')\ntree.traverse(tr, {\nonleaf = function(node)\nif not node.path then\nreturn\nend\nif node.kind == \"product\" then\n_p(2,'%s /* %s */ = {isa = PBXFileReference; explicitFileType = %s; includeInIndex = 0; name = \"%s\"; path = \"%s\"; sourceTree = BUILT_PRODUCTS_DIR; };',\nnode.id, node.name, xcode.gettargettype(node), node.name, path" ".getname(node.cfg.buildtarget.bundlepath))\nelseif node.parent.parent == tr.projects then\nlocal relpath = path.getrelative(tr.project.location, node.parent.project.location)\n_p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = \"%s\"; path = \"%s\"; sourceTree = SOURCE_ROOT; };',\nnode.parent.id, node.parent.name, node.parent.name, path.join(relpath, node.parent.name))\nelse\nlocal pth, src\nif xcode.isframework(node.path) then\nlocal nodePath = node.path\nlocal _, matchEnd, variable = string.find(nodePath, \"^%$%((.+)%)/\")\nif variable then\nnodePath = string.sub(nodePath, matchEnd + 1)\nend\nif string.find(nodePath,'/') then\nif string.find(nodePath,'^%.')then\nnodePath = path.getabsolute(path.join(tr.project.location, nodePath))\nend\npth = nodePath\nelseif path.getextension(nodePath)=='.tbd' then\npth = \"/usr/lib/\" .. nodePath\nelse\npth = \"/System/Library/Frameworks/\" .. nodePath\nend\nif variable then\nsrc = variable\nif string.find(pth, '^/') then\npth " "= string.sub(pth, 2)\nend\nelse\nsrc = \"<absolute>\"\nend\nelse\nsrc = \"<group>\"\nif node.location then\npth = node.location\nelseif node.parent.isvpath then\npth = node.cfg.name\nelse\npth = tree.getlocalpath(node)\nend\nend\nif (not prj.options.ForceCPP) then\n_p(2,'%s /* %s */ = {isa = PBXFileReference; lastKnownFileType = %s; name = \"%s\"; path = \"%s\"; sourceTree = \"%s\"; };',\nnode.id, node.name, xcode.getfiletype(node), node.name, pth, src)\nelse\n_p(2,'%s /* %s */ = {isa = PBXFileReference; explicitFileType = %s; name = \"%s\"; path = \"%s\"; sourceTree = \"%s\"; };',\nnode.id, node.name, xcode.getfiletypeForced(node), node.name, pth, src)\nend\nend\nend\n})\n_p('/* End PBXFileReference section */')\n_p('')\nend\nfunction xcode.PBXFrameworksBuildPhase(tr)\n_p('/* Begin PBXFrameworksBuildPhase section */')\n_p(2,'%s /* Frameworks */ = {', tr.products.children[1].fxstageid)\n_p(3,'isa = PBXFrameworksBuildPhase;')\n_p(3,'buildActionMask = 2147483647;')\n_p(3,'files = (')\ntree.traverse(tr.frameworks" ", {\nonleaf = function(node)\n_p(4,'%s /* %s in Frameworks */,', node.buildid, node.name)\nend\n})\ntree.traverse(tr.projects, {\nonleaf = function(node)\n_p(4,'%s /* %s in Frameworks */,', node.buildid, node.name)\nend\n})\n_p(3,');')\n_p(3,'runOnlyForDeploymentPostprocessing = 0;')\n_p(2,'};')\n_p('/* End PBXFrameworksBuildPhase section */')\n_p('')\nend\nfunction xcode.PBXGroup(tr)\n_p('/* Begin PBXGroup section */')\ntree.traverse(tr, {\nonnode = function(node)\nif (node.path and #node.children == 0) or node.kind == \"vgroup\" then\nreturn\nend\nif node.parent == tr.projects then\n_p(2,'%s /* Products */ = {', node.productgroupid)\nelse\n_p(2,'%s /* %s */ = {', node.id, node.name)\nend\n_p(3,'isa = PBXGroup;')\n_p(3,'children = (')\nfor _, childnode in ipairs(node.children) do\n_p(4,'%s /* %s */,', childnode.id, childnode.name)\nend\n_p(3,');')\nif node.parent == tr.projects then\n_p(3,'name = Products;')\nelse\n_p(3,'name = \"%s\";', node.name)\nif node.location then\n_p(3,'path = \"%s\";', node.location)" "\nelseif node.path and not node.isvpath then\nlocal p = node.path\nif node.parent.path then\np = path.getrelative(node.parent.path, node.path)\nend\n_p(3,'path = \"%s\";', p)\nend\nend\n_p(3,'sourceTree = \"<group>\";')\n_p(2,'};')\nend\n}, true)\n_p('/* End PBXGroup section */')\n_p('')\nend\nfunction xcode.PBXNativeTarget(tr)\n_p('/* Begin PBXNativeTarget section */')\nfor _, node in ipairs(tr.products.children) do\nlocal name = tr.project.name\nlocal function hasBuildCommands(which)\nif #tr.project[which] > 0 then\nreturn true\nend\nfor _, cfg in ipairs(tr.configs) do\nif #cfg[which] > 0 then\nreturn true\nend\nend\nend\nlocal function dobuildblock(id, label, which, action)\nif hasBuildCommands(which) then\nlocal commandcount = 0\nfor _, cfg in ipairs(tr.configs) do\ncommandcount = commandcount + #cfg[which]\nend\nif commandcount > 0 then\naction(id, label)\nend\nend\nend\nlocal function doscriptphases(which, action)\nlocal i = 0\nfor _, cfg in ipairs(tr.configs) do\nlocal cfgcmds = cfg[which]\nif cfgcmds ~" "= nil then\nfor __, scripts in ipairs(cfgcmds) do\nfor ___, script in ipairs(scripts) do\nlocal cmd = script[1]\nlocal label = xcode.getscriptphaselabel(cmd, i, cfg)\nlocal id = xcode.uuid(label)\naction(id, label)\ni = i + 1\nend\nend\nend\nend\nend\nlocal function docopyresources(which, action)\nif hasBuildCommands(which) then\nlocal targets = tr.project[which]\nif #targets > 0 then\nlocal i = 0\nfor _, t in ipairs(targets) do\nfor __, tt in ipairs(t) do\nlocal label = xcode.getcopyphaselabel('Resources', i, tt[1])\nlocal id = xcode.uuid(label)\naction(id, label)\ni = i + 1\nend\nend\nend\nend\nend\nlocal function docopyframeworks(which, action)\nif hasBuildCommands(which) then\nlocal targets = tr.project[which]\nif #targets > 0 then\nlocal label = \"Copy Frameworks\"\nlocal id = xcode.uuid(label)\naction(id, label)\nend\nend\nend\nlocal function _p_label(id, label)\n_p(4, '%s /* %s */,', id, label)\nend\n_p(2,'%s /* %s */ = {', node.targetid, name)\n_p(3,'isa = PBXNativeTarget;')\n_p(3,'buildConfigurationLi" "st = %s /* Build configuration list for PBXNativeTarget \"%s\" */;', node.cfgsection, name)\n_p(3,'buildPhases = (')\ndobuildblock('9607AE1010C857E500CD1376', 'Prebuild', 'prebuildcommands', _p_label)\n_p(4,'%s /* Resources */,', node.resstageid)\n_p(4,'%s /* Sources */,', node.sourcesid)\ndobuildblock('9607AE3510C85E7E00CD1376', 'Prelink', 'prelinkcommands', _p_label)\n_p(4,'%s /* Frameworks */,', node.fxstageid)\ndobuildblock('9607AE3710C85E8F00CD1376', 'Postbuild', 'postbuildcommands', _p_label)\ndoscriptphases(\"xcodescriptphases\", _p_label)\ndocopyresources(\"xcodecopyresources\", _p_label)\nif tr.project.kind == \"WindowedApp\" then\ndocopyframeworks(\"xcodecopyframeworks\", _p_label)\nend\n_p(3,');')\n_p(3,'buildRules = (')\n_p(3,');')\n_p(3,'dependencies = (')\nfor _, node in ipairs(tr.projects.children) do\n_p(4,'%s /* PBXTargetDependency */,', node.targetdependid)\nend\n_p(3,');')\n_p(3,'name = \"%s\";', name)\nlocal p\nif node.cfg.kind == \"ConsoleApp\" then\np = \"$(HOME)/bin\"\nelseif node.cfg.ki" "nd == \"WindowedApp\" then\np = \"$(HOME)/Applications\"\nend\nif p then\n_p(3,'productInstallPath = \"%s\";', p)\nend\n_p(3,'productName = \"%s\";', name)\n_p(3,'productReference = %s /* %s */;', node.id, node.name)\n_p(3,'productType = \"%s\";', xcode.getproducttype(node))\n_p(2,'};')\nend\n_p('/* End PBXNativeTarget section */')\n_p('')\nend\nfunction xcode.PBXProject(tr, compatVersion)\n_p('/* Begin PBXProject section */')\n_p(2,'__RootObject_ /* Project object */ = {')\n_p(3,'isa = PBXProject;')\n_p(3,'buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject \"%s\" */;', tr.name)\n_p(3,'compatibilityVersion = \"Xcode %s\";', compatVersion)\n_p(3,'hasScannedForEncodings = 1;')\n_p(3,'mainGroup = %s /* %s */;', tr.id, tr.name)\n_p(3,'projectDirPath = \"\";')\nif #tr.projects.children > 0 then\n_p(3,'projectReferences = (')\nfor _, node in ipairs(tr.projects.children) do\n_p(4,'{')\n_p(5,'ProductGroup = %s /* Products */;', node.productgroupid)\n_p(5,'ProjectRef = %s /* %s" " */;', node.id, path.getname(node.path))\n_p(4,'},')\nend\n_p(3,');')\nend\n_p(3,'projectRoot = \"\";')\n_p(3,'targets = (')\nfor _, node in ipairs(tr.products.children) do\n_p(4,'%s /* %s */,', node.targetid, node.name)\nend\n_p(3,');')\n_p(2,'};')\n_p('/* End PBXProject section */')\n_p('')\nend\nfunction xcode.PBXReferenceProxy(tr)\nif #tr.projects.children > 0 then\n_p('/* Begin PBXReferenceProxy section */')\ntree.traverse(tr.projects, {\nonleaf = function(node)\n_p(2,'%s /* %s */ = {', node.id, node.name)\n_p(3,'isa = PBXReferenceProxy;')\n_p(3,'fileType = %s;', xcode.gettargettype(node))\n_p(3,'path = \"%s\";', node.path)\n_p(3,'remoteRef = %s /* PBXContainerItemProxy */;', node.parent.productproxyid)\n_p(3,'sourceTree = BUILT_PRODUCTS_DIR;')\n_p(2,'};')\nend\n})\n_p('/* End PBXReferenceProxy section */')\n_p('')\nend\nend\nfunction xcode.PBXResourcesBuildPhase(tr)\n_p('/* Begin PBXResourcesBuildPhase section */')\nfor _, target in ipairs(tr.products.children) do\n_p(2,'%s /* Resources */ = {', target.r" "esstageid)\n_p(3,'isa = PBXResourcesBuildPhase;')\n_p(3,'buildActionMask = 2147483647;')\n_p(3,'files = (')\ntree.traverse(tr, {\nonnode = function(node)\nif xcode.getbuildcategory(node) == \"Resources\" then\n_p(4,'%s /* %s in Resources */,', node.buildid, node.name)\nend\nend\n})\n_p(3,');')\n_p(3,'runOnlyForDeploymentPostprocessing = 0;')\n_p(2,'};')\nend\n_p('/* End PBXResourcesBuildPhase section */')\n_p('')\nend\nfunction xcode.PBXShellScriptBuildPhase(tr)\nlocal wrapperWritten = false\nlocal function doblock(id, name, commands, files)\nif commands ~= nil then\ncommands = table.flatten(commands)\nend\nif #commands > 0 then\nif not wrapperWritten then\n_p('/* Begin PBXShellScriptBuildPhase section */')\nwrapperWritten = true\nend\n_p(2,'%s /* %s */ = {', id, name)\n_p(3,'isa = PBXShellScriptBuildPhase;')\n_p(3,'buildActionMask = 2147483647;')\n_p(3,'files = (')\n_p(3,');')\n_p(3,'inputPaths = (');\nif files ~= nil then\nfiles = table.flatten(files)\nif #files > 0 then\nfor _, file in ipairs(files) do\n_p(" "4, '\"%s\",', file)\nend\nend\nend\n_p(3,');');\n_p(3,'name = %s;', name);\n_p(3,'outputPaths = (');\n_p(3,');');\n_p(3,'runOnlyForDeploymentPostprocessing = 0;');\n_p(3,'shellPath = /bin/sh;');\n_p(3,'shellScript = \"%s\";', table.concat(commands, \"\\\\n\"):gsub('\"', '\\\\\"'))\n_p(2,'};')\nend\nend\nlocal function wrapcommands(cmds, cfg)\nlocal commands = {}\nif #cmds > 0 then\ntable.insert(commands, 'if [ \"${CONFIGURATION}\" = \"' .. xcode.getconfigname(cfg) .. '\" ]; then')\nfor i = 1, #cmds do\nlocal cmd = cmds[i]\ncmd = cmd:gsub('\\\\','\\\\\\\\')\ntable.insert(commands, cmd)\nend\ntable.insert(commands, 'fi')\nend\nreturn commands\nend\nlocal function dobuildblock(id, name, which)\nlocal commands = {}\nfor _, cfg in ipairs(tr.configs) do\nlocal cfgcmds = wrapcommands(cfg[which], cfg)\nif #cfgcmds > 0 then\nfor i, cmd in ipairs(cfgcmds) do\ntable.insert(commands, cmd)\nend\nend\nend\ndoblock(id, name, commands)\nend\nlocal function doscriptphases(which)\nlocal i = 0\nfor _, cfg in ipairs(tr.configs) d" "o\nlocal cfgcmds = cfg[which]\nif cfgcmds ~= nil then\nfor __, scripts in ipairs(cfgcmds) do\nfor ___, script in ipairs(scripts) do\nlocal cmd = script[1]\nlocal files = script[2]\nlocal label = xcode.getscriptphaselabel(cmd, i, cfg)\nlocal id = xcode.uuid(label)\ndoblock(id, label, wrapcommands({cmd}, cfg), files)\ni = i + 1\nend\nend\nend\nend\nend\ndobuildblock(\"9607AE1010C857E500CD1376\", \"Prebuild\", \"prebuildcommands\")\ndobuildblock(\"9607AE3510C85E7E00CD1376\", \"Prelink\", \"prelinkcommands\")\ndobuildblock(\"9607AE3710C85E8F00CD1376\", \"Postbuild\", \"postbuildcommands\")\ndoscriptphases(\"xcodescriptphases\")\nif wrapperWritten then\n_p('/* End PBXShellScriptBuildPhase section */')\nend\nend\nfunction xcode.PBXSourcesBuildPhase(tr,prj)\n_p('/* Begin PBXSourcesBuildPhase section */')\nfor _, target in ipairs(tr.products.children) do\n_p(2,'%s /* Sources */ = {', target.sourcesid)\n_p(3,'isa = PBXSourcesBuildPhase;')\n_p(3,'buildActionMask = 2147483647;')\n_p(3,'files = (')\ntree.traverse(tr, {\no" "nleaf = function(node)\nif xcode.getbuildcategory(node) == \"Sources\" then\nif not table.icontains(prj.excludes, node.cfg.name) then -- if not excluded\n_p(4,'%s /* %s in Sources */,', node.buildid, node.name)\nend\nend\nend\n})\n_p(3,');')\n_p(3,'runOnlyForDeploymentPostprocessing = 0;')\n_p(2,'};')\nend\n_p('/* End PBXSourcesBuildPhase section */')\n_p('')\nend\nfunction xcode.PBXCopyFilesBuildPhase(tr)\nlocal wrapperWritten = false\nlocal function doblock(id, name, folderSpec, path, files)\nif #files > 0 then\nif not wrapperWritten then\n_p('/* Begin PBXCopyFilesBuildPhase section */')\nwrapperWritten = true\nend\n_p(2,'%s /* %s */ = {', id, name)\n_p(3,'isa = PBXCopyFilesBuildPhase;')\n_p(3,'buildActionMask = 2147483647;')\n_p(3,'dstPath = \\\"%s\\\";', path)\n_p(3,'dstSubfolderSpec = \\\"%s\\\";', folderSpec)\n_p(3,'files = (')\ntree.traverse(tr, {\nonleaf = function(node)\nif table.icontains(files, node.name) then\n_p(4,'%s /* %s in %s */,',\nxcode.uuid(node.name .. 'in CopyFiles'), node.name, 'CopyFile" "s')\nend\nend\n})\n_p(3,');')\n_p(3,'runOnlyForDeploymentPostprocessing = 0;');\n_p(2,'};')\nend\nend\nlocal function docopyresources(which)\nlocal targets = tr.project[which]\nif #targets > 0 then\nlocal i = 0\nfor _, t in ipairs(targets) do\nfor __, tt in ipairs(t) do\nlocal label = xcode.getcopyphaselabel('Resources', i, tt[1])\nlocal id = xcode.uuid(label)\nlocal files = table.translate(table.flatten(tt[2]), path.getname)\ndoblock(id, label, 7, tt[1], files)\ni = i + 1\nend\nend\nend\nend\nlocal function docopyframeworks(which)\nlocal targets = tr.project[which]\nif #targets > 0 then\nlocal label = \"Copy Frameworks\"\nlocal id = xcode.uuid(label)\nlocal files = table.translate(table.flatten(targets), path.getname)\ndoblock(id, label, 10, \"\", files)\nend\nend\ndocopyresources(\"xcodecopyresources\")\nif tr.project.kind == \"WindowedApp\" then\ndocopyframeworks(\"xcodecopyframeworks\")\nend\nif wrapperWritten then\n_p('/* End PBXCopyFilesBuildPhase section */')\nend\nend\nfunction xcode.PBXVariantGroup(tr" ")\n_p('/* Begin PBXVariantGroup section */')\ntree.traverse(tr, {\nonbranch = function(node)\nif node.kind == \"vgroup\" then\n_p(2,'%s /* %s */ = {', node.id, node.name)\n_p(3,'isa = PBXVariantGroup;')\n_p(3,'children = (')\nfor _, lang in ipairs(node.children) do\n_p(4,'%s /* %s */,', lang.id, lang.name)\nend\n_p(3,');')\n_p(3,'name = %s;', node.name)\n_p(3,'sourceTree = \"<group>\";')\n_p(2,'};')\nend\nend\n})\n_p('/* End PBXVariantGroup section */')\n_p('')\nend\nfunction xcode.PBXTargetDependency(tr)\nif #tr.projects.children > 0 then\n_p('/* Begin PBXTargetDependency section */')\ntree.traverse(tr.projects, {\nonleaf = function(node)\n_p(2,'%s /* PBXTargetDependency */ = {', node.parent.targetdependid)\n_p(3,'isa = PBXTargetDependency;')\n_p(3,'name = \"%s\";', node.name)\n_p(3,'targetProxy = %s /* PBXContainerItemProxy */;', node.parent.targetproxyid)\n_p(2,'};')\nend\n})\n_p('/* End PBXTargetDependency section */')\n_p('')\nend\nend\nfunction xcode.cfg_excluded_files(prj, cfg)\nlocal excluded = {}\nloc" "al function exclude_pattern(file)\nif path.isabsolute(file) then\nreturn file\nend\nlocal start, term = file:findlast(\"/%.%./\")\nif term then\nreturn path.join(\"*\", file:sub(term + 1))\nend\nstart, term = file:find(\"%.%./\")\nif start == 1 then\nreturn path.join(\"*\", file:sub(term + 1))\nend\nreturn path.join(\"*\", file)\nend\nlocal function add_file(file)\nlocal name = exclude_pattern(file)\nif not table.icontains(excluded, name) then\ntable.insert(excluded, name)\nend\nend\nlocal function verify_file(file)\nlocal name = exclude_pattern(file)\nif table.icontains(excluded, name) then\nerror(\"'\" .. file .. \"' would be excluded by the rule to exclude '\" .. name .. \"'\")\nend\nend\nfor _, file in ipairs(cfg.excludes) do\nadd_file(file)\nend\nfor _, file in ipairs(prj.allfiles) do\nif not table.icontains(prj.excludes, file) and not table.icontains(cfg.excludes, file) then\nif not table.icontains(cfg.files, file) then\nadd_file(file)\nelse\nverify_file(file)\nend\nend\nend\ntable.sort(excluded)\nreturn" " excluded\nend\nfunction xcode.XCBuildConfiguration_Impl(tr, id, opts, cfg)\nlocal cfgname = xcode.getconfigname(cfg)\n_p(2,'%s /* %s */ = {', id, cfgname)\n_p(3,'isa = XCBuildConfiguration;')\n_p(3,'buildSettings = {')\nfor k, v in table.sortedpairs(opts) do\nif type(v) == \"table\" then\nif #v > 0 then\n_p(4,'%s = (', k)\nfor i, v2 in ipairs(v) do\n_p(5,'%s,', xcode.quotestr(tostring(v2)))\nend\n_p(4,');')\nend\nelse\n_p(4,'%s = %s;', k, xcode.quotestr(tostring(v)))\nend\nend\n_p(3,'};')\n_p(3,'name = %s;', xcode.quotestr(cfgname))\n_p(2,'};')\nend\nlocal function add_options(options, extras)\nfor _, tbl in ipairs(extras) do\nfor tkey, tval in pairs(tbl) do\noptions[tkey] = tval\nend\nend\nend\nlocal function add_wholearchive_links(opts, cfg)\nif #cfg.wholearchive > 0 then\nlocal linkopts = {}\nfor _, depcfg in ipairs(premake.getlinks(cfg, \"siblings\", \"object\")) do\nif table.icontains(cfg.wholearchive, depcfg.project.name) then\nlocal linkpath = path.rebase(depcfg.linktarget.fullpath, depcfg.location, cf" "g.location)\ntable.insert(linkopts, \"-force_load\")\ntable.insert(linkopts, linkpath)\nend\nend\nif opts.OTHER_LDFLAGS then\nlinkopts = table.join(linkopts, opts.OTHER_LDFLAGS)\nend\nopts.OTHER_LDFLAGS = linkopts\nend\nend\nfunction xcode.XCBuildConfiguration(tr, prj, opts)\n_p('/* Begin XCBuildConfiguration section */')\nfor _, target in ipairs(tr.products.children) do\nfor _, cfg in ipairs(tr.configs) do\nlocal values = opts.ontarget(tr, target, cfg)\nadd_options(values, cfg.xcodetargetopts)\nxcode.XCBuildConfiguration_Impl(tr, cfg.xcode.targetid, values, cfg)\nend\nend\nfor _, cfg in ipairs(tr.configs) do\nlocal values = opts.onproject(tr, prj, cfg)\nadd_options(values, cfg.xcodeprojectopts)\nadd_wholearchive_links(values, cfg)\nxcode.XCBuildConfiguration_Impl(tr, cfg.xcode.projectid, values, cfg)\nend\n_p('/* End XCBuildConfiguration section */')\n_p('')\nend\nfunction xcode.XCBuildConfigurationList(tr)\nlocal sln = tr.project.solution\n_p('/* Begin XCConfigurationList section */')\nfor _, target in ipair" "s(tr.products.children) do\n_p(2,'%s /* Build configuration list for PBXNativeTarget \"%s\" */ = {', target.cfgsection, target.name)\n_p(3,'isa = XCConfigurationList;')\n_p(3,'buildConfigurations = (')\nfor _, cfg in ipairs(tr.configs) do\n_p(4,'%s /* %s */,', cfg.xcode.targetid, xcode.getconfigname(cfg))\nend\n_p(3,');')\n_p(3,'defaultConfigurationIsVisible = 0;')\n_p(3,'defaultConfigurationName = \"%s\";', xcode.getconfigname(tr.configs[1]))\n_p(2,'};')\nend\n_p(2,'1DEB928908733DD80010E9CD /* Build configuration list for PBXProject \"%s\" */ = {', tr.name)\n_p(3,'isa = XCConfigurationList;')\n_p(3,'buildConfigurations = (')\nfor _, cfg in ipairs(tr.configs) do\n_p(4,'%s /* %s */,', cfg.xcode.projectid, xcode.getconfigname(cfg))\nend\n_p(3,');')\n_p(3,'defaultConfigurationIsVisible = 0;')\n_p(3,'defaultConfigurationName = \"%s\";', xcode.getconfigname(tr.configs[1]))\n_p(2,'};')\n_p('/* End XCConfigurationList section */')\n_p('')\nend\nfunction xcode.Footer()\n_p(1,'};')\n_p('\\trootObject = __RootObject_ /*" " Project object */;')\n_p('}')\nend\n", /* actions/xcode/xcode_project.lua */ "local xcode = premake.xcode\nlocal tree = premake.tree\nfunction xcode.buildprjtree(prj)\nlocal tr = premake.project.buildsourcetree(prj, true)\ntr.configs = {}\nfor _, cfgname in ipairs(prj.solution.configurations) do\nfor _, platform in ipairs(prj.solution.xcode.platforms) do\nlocal cfg = premake.getconfig(prj, cfgname, platform)\ncfg.xcode = {}\ncfg.xcode.targetid = xcode.newid(prj.xcode.projectnode, \"tgt:\"..platform..cfgname)\ncfg.xcode.projectid = xcode.newid(tr, \"prj:\"..platform..cfgname)\ntable.insert(tr.configs, cfg)\nend\nend\ntree.traverse(tr, {\nonbranch = function(node)\nif path.getextension(node.name) == \".lproj\" then\nlocal lang = path.getbasename(node.name) -- \"English\", \"French\", etc.\nfor _, filenode in ipairs(node.children) do\nlocal grpnode = node.parent.children[filenode.name]\nif not grpnode then\ngrpnode = tree.insert(node.parent, tree.new(filenode.name))\ngrpnode.kind = \"vgroup\"\nend\nfilenode.name = path.getbasename(lang)\ntree.insert(grpnode, filenode)\nend\ntree.remove(no" "de)\nend\nend\n})\ntree.traverse(tr, {\nonbranch = function(node)\nif path.getextension(node.name) == \".xcassets\" then\nnode.children = {}\nend\nend\n})\ntr.frameworks = tree.new(\"Frameworks\")\nfor cfg in premake.eachconfig(prj) do\nfor _, link in ipairs(premake.getlinks(cfg, \"system\", \"fullpath\")) do\nlocal name = path.getname(link)\nif xcode.isframework(name) and not tr.frameworks.children[name] then\nnode = tree.insert(tr.frameworks, tree.new(name))\nnode.path = link\nend\nend\nend\nif #tr.frameworks.children > 0 then\ntree.insert(tr, tr.frameworks)\nend\ntr.products = tree.insert(tr, tree.new(\"Products\"))\ntr.projects = tree.new(\"Projects\")\nfor _, dep in ipairs(premake.getdependencies(prj, \"sibling\", \"object\")) do\nlocal xcpath = xcode.getxcodeprojname(dep)\nlocal xcnode = tree.insert(tr.projects, tree.new(path.getname(xcpath)))\nxcnode.path = xcpath\nxcnode.project = dep\nxcnode.productgroupid = xcode.newid(xcnode, \"prodgrp\")\nxcnode.productproxyid = xcode.newid(xcnode, \"prodprox\")\nx" "cnode.targetproxyid = xcode.newid(xcnode, \"targprox\")\nxcnode.targetdependid = xcode.newid(xcnode, \"targdep\")\nlocal cfg = premake.getconfig(dep, prj.configurations[1])\nnode = tree.insert(xcnode, tree.new(cfg.linktarget.name))\nnode.path = cfg.linktarget.fullpath\nnode.cfg = cfg\nend\nif #tr.projects.children > 0 then\ntree.insert(tr, tr.projects)\nend\ntree.traverse(tr, {\nonbranchexit = function(node)\nfor _, child in ipairs(node.children) do\nif (child.location) then\nif (node.location) then\nwhile (not string.startswith(child.location, node.location)) do\nnode.location = path.getdirectory(node.location)\nend\nelse\nnode.location = path.getdirectory(child.location)\nend\nend\nend\nend,\nonleaf = function(node)\nif (node.cfg) then\nnode.location = node.cfg.name\nend\nend\n}, true)\ntree.traverse(tr, {\nonbranchexit = function(node, depth)\nif (node.location and node.parent and node.parent.location) then\nnode.location = path.getrelative(node.parent.location, node.location)\nend\nend,\nonleaf = function" "(node, depth)\nif (node.location and node.parent and node.parent.location) then\nnode.location = path.getrelative(node.parent.location, node.location)\nend\nend\n}, true)\ntree.traverse(tr, {\nonnode = function(node)\nnode.id = xcode.newid(node)\nif xcode.getbuildcategory(node) then\nnode.buildid = xcode.newid(node, \"build\")\nend\nif string.endswith(node.name, \"Info.plist\") then\ntr.infoplist = node\nend\nif string.endswith(node.name, \".entitlements\") then\ntr.entitlements = node\nend\nend\n}, true)\nnode = tree.insert(tr.products, prj.xcode.projectnode)\nnode.kind = \"product\"\nnode.path = node.cfg.buildtarget.fullpath\nnode.cfgsection = xcode.newid(node, \"cfg\")\nnode.resstageid = xcode.newid(node, \"rez\")\nnode.sourcesid = xcode.newid(node, \"src\")\nnode.fxstageid = xcode.newid(node, \"fxs\")\nreturn tr\nend\n", /* actions/xcode/xcode_scheme.lua */ "local premake = premake\nlocal xcode = premake.xcode\nlocal function buildableref(indent, prj, cfg)\ncfg = cfg or premake.eachconfig(prj)()\n_p(indent + 0, '<BuildableReference')\n_p(indent + 1, 'BuildableIdentifier = \"primary\"')\n_p(indent + 1, 'BlueprintIdentifier = \"%s\"', prj.xcode.projectnode.targetid)\n_p(indent + 1, 'BuildableName = \"%s\"', cfg.buildtarget.name)\n_p(indent + 1, 'BlueprintName = \"%s\"', prj.name)\n_p(indent + 1, 'ReferencedContainer = \"container:%s.xcodeproj\">', prj.name)\n_p(indent + 0, '</BuildableReference>')\nend\nlocal function cmdlineargs(indent, cfg)\nif #cfg.debugargs > 0 then\n_p(indent, '<CommandLineArguments>')\nfor _, arg in ipairs(cfg.debugargs) do\n_p(indent + 1, '<CommandLineArgument')\n_p(indent + 2, 'argument = \"%s\"', arg)\n_p(indent + 2, 'isEnabled = \"YES\">')\n_p(indent + 1, '</CommandLineArgument>')\nend\n_p(indent, '</CommandLineArguments>')\nend\nend\nlocal function envvars(indent, cfg)\nif #cfg.debugenvs > 0 then\n_p(indent, '<EnvironmentVariables>')\nf" "or _, arg in ipairs(cfg.debugenvs) do\nlocal eq = arg:find(\"=\")\nlocal k = arg:sub(1, eq)\nlocal v = arg:sub(eq + 1)\n_p(indent + 1, '<EnvironmentVariable')\n_p(indent + 2, 'key = \"%s\"', arg:sub(1, eq))\n_p(indent + 2, 'value = \"%s\"', arg:sub(eq))\n_p(indent + 2, 'isEnabled = \"YES\">')\n_p(indent + 1, '</EnvironmentVariable>')\nend\n_p(indent, '</EnvironmentVariables>')\nend\nend\nlocal function workingdir(dir)\nif not path.isabsolute(dir) then\ndir = \"$PROJECT_DIR/\" .. dir\nend\nreturn dir\nend\nlocal function bestconfig(prj, fordebug)\nlocal bestcfg = nil\nlocal bestscore = -1\nfor cfg in premake.eachconfig(prj) do\nlocal score = 0\nif cfg.platform == \"Native\" then\nscore = score + 10\nend\nif fordebug and cfg.name == \"Debug\" then\nscore = score + 1\nend\nif not fordebug and cfg.name == \"Release\" then\nscore = score + 1\nend\nif score > bestscore then\nbestcfg = cfg\nbestscore = score\nend\nend\nreturn bestcfg\nend\nfunction xcode.scheme(tobuild, primary, schemecfg)\n_p('<?xml version=\"1.0\" " "encoding=\"UTF-8\"?>')\n_p('<Scheme')\n_p(1, 'LastUpgradeVersion = \"0940\"')\n_p(1, 'version = \"1.3\">')\n_p(1, '<BuildAction')\n_p(2, 'parallelizeBuildables = \"YES\"')\n_p(2, 'buildImplicitDependencies = \"YES\">')\n_p(2, '<BuildActionEntries>')\nfor _, prj in ipairs(tobuild) do\n_p(3, '<BuildActionEntry')\n_p(4, 'buildForTesting = \"YES\"')\n_p(4, 'buildForRunning = \"YES\"')\n_p(4, 'buildForProfiling = \"YES\"')\n_p(4, 'buildForArchiving = \"YES\"')\n_p(4, 'buildForAnalyzing = \"YES\">')\nbuildableref(4, prj)\n_p(3, '</BuildActionEntry>')\nend\nlocal debugcfg = schemecfg or bestconfig(primary, true)\nlocal releasecfg = schemecfg or bestconfig(primary, false)\nlocal debugname = xcode.getconfigname(debugcfg)\nlocal releasename = xcode.getconfigname(releasecfg)\n_p(2, '</BuildActionEntries>')\n_p(1, '</BuildAction>')\n_p(1, '<TestAction')\n_p(2, 'buildConfiguration = \"%s\"', debugname)\n_p(2, 'selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"')\n_p(2, 'selectedLauncherIdentifier" " = \"Xcode.DebuggerFoundation.Launcher.LLDB\"')\n_p(2, 'shouldUseLaunchSchemeArgsEnv = \"YES\">')\n_p(2, '<Testables>')\n_p(2, '</Testables>')\n_p(2, '<MacroExpansion>')\nbuildableref(3, primary, debugcfg)\n_p(2, '</MacroExpansion>')\n_p(2, '<AdditionalOptions>')\n_p(2, '</AdditionalOptions>')\n_p(1, '</TestAction>')\n_p(1, '<LaunchAction')\n_p(2, 'buildConfiguration = \"%s\"', debugname)\n_p(2, 'selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"')\n_p(2, 'selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"')\n_p(2, 'launchStyle = \"0\"')\nif debugcfg.debugdir then\n_p(2, 'useCustomWorkingDirectory = \"YES\"')\n_p(2, 'customWorkingDirectory = \"%s\"', workingdir(debugcfg.debugdir))\nelse\n_p(2, 'useCustomWorkingDirectory = \"NO\"')\nend\n_p(2, 'ignoresPersistentStateOnLaunch = \"NO\"')\n_p(2, 'debugDocumentVersioning = \"YES\"')\n_p(2, 'debugServiceExtension = \"internal\"')\n_p(2, 'allowLocationSimulation = \"YES\">')\nif debugcfg.debugcmd then\n_p(2, '<PathRunnable')" "\n_p(3, 'runnableDebuggingMode = \"0\"')\n_p(3, 'FilePath = \"%s\">', debugcfg.debugcmd)\n_p(2, '</PathRunnable>')\nelse\n_p(2, '<BuildableProductRunnable')\n_p(3, 'runnableDebuggingMode = \"0\">')\nbuildableref(3, primary, debugcfg)\n_p(2, '</BuildableProductRunnable>')\nend\ncmdlineargs(2, debugcfg)\nenvvars(2, debugcfg)\n_p(2, '<AdditionalOptions>')\n_p(2, '</AdditionalOptions>')\n_p(1, '</LaunchAction>')\n_p(1, '<ProfileAction')\n_p(2, 'buildConfiguration = \"%s\"', releasename)\n_p(2, 'shouldUseLaunchSchemeArgsEnv = \"YES\"')\n_p(2, 'savedToolIdentifier = \"\"')\nif releasecfg.debugdir then\n_p(2, 'useCustomWorkingDirectory = \"YES\"')\n_p(2, 'customWorkingDirectory = \"%s\"', workingdir(releasecfg.debugdir))\nelse\n_p(2, 'useCustomWorkingDirectory = \"NO\"')\nend\n_p(2, 'debugDocumentVersioning = \"YES\">')\n_p(2, '<BuildableProductRunnable')\n_p(3, 'runnableDebuggingMode = \"0\">')\nbuildableref(3, primary, releasecfg)\n_p(2, '</BuildableProductRunnable>')\ncmdlineargs(2, releasecfg)\nenvvars(2, release" "cfg)\n_p(1, '</ProfileAction>')\n_p(1, '<AnalyzeAction')\n_p(2, 'buildConfiguration = \"%s\">', debugname)\n_p(1, '</AnalyzeAction>')\n_p(1, '<ArchiveAction')\n_p(2, 'buildConfiguration = \"%s\"', releasename)\n_p(2, 'revealArchiveInOrganizer = \"YES\">')\n_p(1, '</ArchiveAction>')\n_p('</Scheme>')\nend\nfunction xcode.generate_schemes(prj, base_path)\nif (prj.kind == \"ConsoleApp\" or prj.kind == \"WindowedApp\") or (prj.options and prj.options.XcodeLibrarySchemes) then\nif prj.options and prj.options.XcodeSchemeNoConfigs then\npremake.generate(prj, path.join(base_path, \"%%.xcscheme\"),\nfunction(prj) xcode.scheme({prj}, prj) end)\nelse\nfor cfg in premake.eachconfig(prj) do\npremake.generate(prj, path.join(base_path, \"%% \" .. cfg.name .. \".xcscheme\"),\nfunction(prj) xcode.scheme({prj}, prj, cfg) end)\nend\nend\nend\nend\n", /* actions/xcode/xcode_workspace.lua */ "local premake = premake\nlocal xcode = premake.xcode\nxcode.allscheme = false\nfunction xcode.workspace_head()\n_p('<?xml version=\"1.0\" encoding=\"UTF-8\"?>')\n_p('<Workspace')\n_p(1,'version = \"1.0\">')\nend\nfunction xcode.workspace_tail()\n_p('</Workspace>')\nend\nfunction xcode.workspace_file_ref(prj, indent)\nlocal projpath = path.getrelative(prj.solution.location, prj.location)\nif projpath == '.' then projpath = ''\nelse projpath = projpath ..'/'\nend\n_p(indent, '<FileRef')\n_p(indent + 1, 'location = \"group:%s\">', projpath .. prj.name .. '.xcodeproj')\n_p(indent, '</FileRef>')\nend\nfunction xcode.workspace_group(grp, indent)\n_p(indent, '<Group')\n_p(indent + 1, 'location = \"container:\"')\n_p(indent + 1, 'name = \"%s\">', grp.name)\nlocal function comparenames(a, b)\nreturn a.name < b.name\nend\nlocal groups = table.join(grp.groups)\nlocal projects = table.join(grp.projects)\ntable.sort(groups, comparenames)\ntable.sort(projects, comparenames)\nfor _, child in ipairs(groups) do\nxcode.workspac" "e_group(child, indent + 1)\nend\nfor _, prj in ipairs(projects) do\nxcode.workspace_file_ref(prj, indent + 1)\nend\n_p(indent, '</Group>')\nend\nfunction xcode.workspace_generate(sln)\nxcode.preparesolution(sln)\nxcode.workspace_head()\nxcode.reorderProjects(sln)\nfor grp in premake.solution.eachgroup(sln) do\nif grp.parent == nil then\nxcode.workspace_group(grp, 1)\nend\nend\nfor prj in premake.solution.eachproject(sln) do\nif prj.group == nil then\nxcode.workspace_file_ref(prj, 1)\nend\nend\nxcode.workspace_tail()\nend\nfunction xcode.workspace_scheme(sln)\nif not xcode.allscheme then\nreturn false\nend\nlocal projects = {}\nlocal primary = nil\nfor prj in premake.solution.eachproject(sln) do\nif not primary or (sln.startproject == prj.name) then\nprimary = prj\nend\ntable.insert(projects, prj)\nend\nxcode.scheme(projects, primary)\nend\nfunction xcode.workspace_settings(sln)\n_p('<?xml version=\"1.0\" encoding=\"UTF-8\"?>')\n_p('<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/D" "TDs/PropertyList-1.0.dtd\">')\n_p('<plist version=\"1.0\">')\n_p('<dict>')\n_p(1, '<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>')\n_p(1, '<false/>')\n_p('</dict>')\n_p('</plist>')\nend\nfunction xcode.reorderProjects(sln)\nif sln.startproject then\nfor i, prj in ipairs(sln.projects) do\nif sln.startproject == prj.name then\nlocal cur = prj.group\nwhile cur ~= nil do\nfor j, group in ipairs(sln.groups) do\nif group == cur then\ntable.remove(sln.groups, j)\nbreak\nend\nend\ntable.insert(sln.groups, 1, cur)\ncur = cur.parent\nend\ntable.remove(sln.projects, i)\ntable.insert(sln.projects, 1, prj)\nbreak\nend\nend\nend\nend\n", /* actions/xcode/xcode8.lua */ "local premake = premake\npremake.xcode8 = { }\nlocal xcode = premake.xcode\nlocal xcode8 = premake.xcode8\nfunction xcode8.XCBuildConfiguration_Target(tr, target, cfg)\nlocal cfgname = xcode.getconfigname(cfg)\nlocal installpaths = {\nConsoleApp = \"/usr/local/bin\",\nWindowedApp = \"$(HOME)/Applications\",\nSharedLib = \"/usr/local/lib\",\nStaticLib = \"/usr/local/lib\",\nBundle = \"$(LOCAL_LIBRARY_DIR)/Bundles\",\n}\nlocal options = {\nALWAYS_SEARCH_USER_PATHS = \"NO\",\nGCC_DYNAMIC_NO_PIC = \"NO\",\nGCC_MODEL_TUNING = \"G5\",\nINSTALL_PATH = installpaths[cfg.kind],\nPRODUCT_NAME = cfg.buildtarget.basename,\n}\nif not cfg.flags.Symbols then\noptions.DEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\"\nend\nif cfg.kind ~= \"StaticLib\" and cfg.buildtarget.prefix ~= \"\" then\noptions.EXECUTABLE_PREFIX = cfg.buildtarget.prefix\nend\nif cfg.targetextension then\nlocal ext = cfg.targetextension\noptions.EXECUTABLE_EXTENSION = iif(ext:startswith(\".\"), ext:sub(2), ext)\nend\nif cfg.flags.ObjcARC then\noptions.CLA" "NG_ENABLE_OBJC_ARC = \"YES\"\nend\nlocal outdir = path.getdirectory(cfg.buildtarget.bundlepath)\nif outdir ~= \".\" then\noptions.CONFIGURATION_BUILD_DIR = outdir\nend\nif tr.infoplist then\noptions.INFOPLIST_FILE = tr.infoplist.cfg.name\nend\nlocal infoplist_file = nil\nfor _, v in ipairs(cfg.files) do\nif (string.find (string.lower (v), 'info.plist') ~= nil) then\ninfoplist_file = string.format('$(SRCROOT)/%s', v)\nend\nend\nif infoplist_file ~= nil then\noptions.INFOPLIST_FILE = infoplist_file\nend\nlocal action = premake.action.current()\nlocal get_opt = function(opt, def)\nreturn (opt and #opt > 0) and opt or def\nend\nlocal iosversion = get_opt(cfg.iostargetplatformversion, action.xcode.iOSTargetPlatformVersion)\nlocal macosversion = get_opt(cfg.macostargetplatformversion, action.xcode.macOSTargetPlatformVersion)\nlocal tvosversion = get_opt(cfg.tvostargetplatformversion, action.xcode.tvOSTargetPlatformVersion)\nif iosversion then\noptions.IPHONEOS_DEPLOYMENT_TARGET = iosversion\nelseif macosversion then" "\noptions.MACOSX_DEPLOYMENT_TARGET = macosversion\nelseif tvosversion then\noptions.TVOS_DEPLOYMENT_TARGET = tvosversion\nend\nif cfg.kind == \"Bundle\" and not cfg.options.SkipBundling then\noptions.PRODUCT_BUNDLE_IDENTIFIER = \"genie.\" .. cfg.buildtarget.basename:gsub(\"%s+\", \".\") --replace spaces with .\nlocal ext = cfg.targetextension\nif ext then\noptions.WRAPPER_EXTENSION = iif(ext:startswith(\".\"), ext:sub(2), ext)\nelse\noptions.WRAPPER_EXTENSION = \"bundle\"\nend\nend\nreturn options\nend\nfunction xcode8.XCBuildConfiguration_Project(tr, prj, cfg)\nlocal cfgname = xcode.getconfigname(cfg)\nlocal archs = {\nNative = nil,\nx32 = \"i386\",\nx64 = \"x86_64\",\nUniversal32 = \"$(ARCHS_STANDARD_32_BIT)\",\nUniversal64 = \"$(ARCHS_STANDARD_64_BIT)\",\nUniversal = \"$(ARCHS_STANDARD_32_64_BIT)\",\n}\nlocal checks = {\n[\"-ffast-math\"] = cfg.flags.FloatFast,\n[\"-ffloat-store\"] = cfg.flags.FloatStrict,\n[\"-fomit-frame-pointer\"] = cfg.flags.NoFramePointer,\n}\nloc" "al cflags = { }\nfor flag, check in pairs(checks) do\nif check then\ntable.insert(cflags, flag)\nend\nend\nlocal ldflags = { }\nfor _, lib in ipairs(premake.getlinks(cfg, \"system\")) do\nif not xcode.isframework(lib) then\ntable.insert(ldflags, \"-l\" .. lib)\nend\nend\nlocal options = {\nARCHS = archs[cfg.platform],\nCLANG_WARN__DUPLICATE_METHOD_MATCH = \"YES\",\nCLANG_WARN_BOOL_CONVERSION = \"YES\",\nCLANG_WARN_CONSTANT_CONVERSION = \"YES\",\nCLANG_WARN_EMPTY_BODY = \"YES\",\nCLANG_WARN_ENUM_CONVERSION = \"YES\",\nCLANG_WARN_INFINITE_RECURSION = \"YES\",\nCLANG_WARN_INT_CONVERSION = \"YES\",\nCLANG_WARN_SUSPICIOUS_MOVE = \"YES\",\nCLANG_WARN_UNREACHABLE_CODE = \"YES\",\nCONFIGURATION_TEMP_DIR = \"$(OBJROOT)\",\nENABLE_STRICT_OBJC_MSGSEND = \"YES\",\nENABLE_TESTABILITY = \"YES\",\nGCC_C_LANGUAGE_STANDARD = \"gnu99\",\nGCC_NO_COMMON_BLOCKS = \"YES\",\nGCC_PREP" "ROCESSOR_DEFINITIONS = cfg.defines,\nGCC_SYMBOLS_PRIVATE_EXTERN = \"NO\",\nGCC_WARN_64_TO_32_BIT_CONVERSION = \"YES\",\nGCC_WARN_ABOUT_RETURN_TYPE = \"YES\",\nGCC_WARN_UNDECLARED_SELECTOR = \"YES\",\nGCC_WARN_UNINITIALIZED_AUTOS = \"YES\",\nGCC_WARN_UNUSED_FUNCTION = \"YES\",\nGCC_WARN_UNUSED_VARIABLE = \"YES\",\nHEADER_SEARCH_PATHS = table.join(cfg.includedirs, cfg.systemincludedirs),\nLIBRARY_SEARCH_PATHS = cfg.libdirs,\nOBJROOT = cfg.objectsdir,\nONLY_ACTIVE_ARCH = \"YES\",\nOTHER_CFLAGS = table.join(cflags, cfg.buildoptions, cfg.buildoptions_c),\nOTHER_CPLUSPLUSFLAGS = table.join(cflags, cfg.buildoptions, cfg.buildoptions_cpp),\nOTHER_LDFLAGS = table.join(ldflags, cfg.linkoptions),\nSDKROOT = xcode.toolset,\nUSER_HEADER_SEARCH_PATHS = cfg.userincludedirs,\n}\nif tr.entitlements then\nop" "tions.CODE_SIGN_ENTITLEMENTS = tr.entitlements.cfg.name\nend\nlocal targetdir = path.getdirectory(cfg.buildtarget.bundlepath)\nif targetdir ~= \".\" then\noptions.CONFIGURATION_BUILD_DIR = \"$(SYMROOT)\"\noptions.SYMROOT = targetdir\nend\nif cfg.flags.Symbols then\noptions.COPY_PHASE_STRIP = \"NO\"\nend\nlocal excluded = xcode.cfg_excluded_files(prj, cfg)\nif #excluded > 0 then\noptions.EXCLUDED_SOURCE_FILE_NAMES = excluded\nend\nif cfg.flags.NoExceptions then\noptions.GCC_ENABLE_CPP_EXCEPTIONS = \"NO\"\nend\nif cfg.flags.NoRTTI then\noptions.GCC_ENABLE_CPP_RTTI = \"NO\"\nend\nif cfg.flags.Symbols and not cfg.flags.NoEditAndContinue then\noptions.GCC_ENABLE_FIX_AND_CONTINUE = \"YES\"\nend\nif cfg.flags.NoExceptions then\noptions.GCC_ENABLE_OBJC_EXCEPTIONS = \"NO\"\nend\nif cfg.flags.Optimize or cfg.flags.OptimizeSize then\noptions.GCC_OPTIMIZATION_LEVEL = \"s\"\nelseif cfg.flags.OptimizeSpeed then\noptions.GCC_OPTIMIZATION_LEVEL = 3\nelse\noptions.GCC_OPTIMIZATION_LEVEL = 0\nend\nif cfg.pchheader and not cfg.f" "lags.NoPCH then\noptions.GCC_PRECOMPILE_PREFIX_HEADER = \"YES\"\nlocal pch = cfg.pchheader\nfor _, incdir in ipairs(cfg.includedirs) do\nlocal abspath = path.getabsolute(path.join(cfg.project.location, incdir))\nlocal testname = path.join(abspath, pch)\nif os.isfile(testname) then\npch = path.getrelative(cfg.location, testname)\nbreak\nend\nend\noptions.GCC_PREFIX_HEADER = pch\nend\nif cfg.flags.FatalWarnings then\noptions.GCC_TREAT_WARNINGS_AS_ERRORS = \"YES\"\nend\nif cfg.kind == \"Bundle\" then\noptions.MACH_O_TYPE = \"mh_bundle\"\nend\nif cfg.flags.StaticRuntime then\noptions.STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = \"static\"\nend\nif cfg.flags.PedanticWarnings or cfg.flags.ExtraWarnings then\noptions.WARNING_CFLAGS = \"-Wall\"\nend\nif cfg.flags.Cpp11 then\noptions.CLANG_CXX_LANGUAGE_STANDARD = \"c++11\"\nelseif cfg.flags.Cpp14 or cfg.flags.CppLatest then\noptions.CLANG_CXX_LANGUAGE_STANDARD = \"c++14\"\nelseif cfg.flags.Cpp17 then\nif premake.action.current() == premake.action.get(\"xcode8\") then\nerror(\"X" "Code8 does not support C++17.\")\nend\nend\nfor _, val in ipairs(premake.xcode.parameters) do\nlocal eqpos = string.find(val, \"=\")\nif eqpos ~= nil then\nlocal key = string.trim(string.sub(val, 1, eqpos - 1))\nlocal value = string.trim(string.sub(val, eqpos + 1))\noptions[key] = value\nend\nend\nreturn options\nend\nfunction xcode8.project(prj)\nlocal tr = xcode.buildprjtree(prj)\nxcode.Header(tr, 48)\nxcode.PBXBuildFile(tr)\nxcode.PBXContainerItemProxy(tr)\nxcode.PBXFileReference(tr,prj)\nxcode.PBXFrameworksBuildPhase(tr)\nxcode.PBXGroup(tr)\nxcode.PBXNativeTarget(tr)\nxcode.PBXProject(tr, \"8.0\")\nxcode.PBXReferenceProxy(tr)\nxcode.PBXResourcesBuildPhase(tr)\nxcode.PBXShellScriptBuildPhase(tr)\nxcode.PBXCopyFilesBuildPhase(tr)\nxcode.PBXSourcesBuildPhase(tr,prj)\nxcode.PBXVariantGroup(tr)\nxcode.PBXTargetDependency(tr)\nxcode.XCBuildConfiguration(tr, prj, {\nontarget = xcode8.XCBuildConfiguration_Target,\nonproject = xcode8.XCBuildConfiguration_Project,\n})\nxcode.XCBuildConfigurationList(tr)\nxcode.Foote" "r(tr)\nend\nnewaction\n{\ntrigger = \"xcode8\",\nshortname = \"Xcode 8\",\ndescription = \"Generate Apple Xcode 8 project files\",\nos = \"macosx\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\" },\nvalid_tools = {\ncc = { \"gcc\" },\n},\nvalid_platforms = {\nNative = \"Native\",\nx32 = \"Native 32-bit\",\nx64 = \"Native 64-bit\",\nUniversal = \"Universal\",\n},\ndefault_platform = \"Native\",\nonsolution = function(sln)\npremake.generate(sln, \"%%.xcworkspace/contents.xcworkspacedata\", xcode.workspace_generate)\npremake.generate(sln, \"%%.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings\", xcode.workspace_settings)\npremake.generate(sln, \"%%.xcworkspace/xcshareddata/xcschemes/-ALL-.xcscheme\", xcode.workspace_scheme)\nend,\nonproject = function(prj)\npremake.generate(prj, \"%%.xcodeproj/project.pbxproj\", xcode8.project)\nxcode.generate_schemes(prj, \"%%.xcodeproj/xcshareddata/" "xcschemes\")\nend,\noncleanproject = function(prj)\npremake.clean.directory(prj, \"%%.xcodeproj\")\npremake.clean.directory(prj, \"%%.xcworkspace\")\nend,\noncheckproject = xcode.checkproject,\nxcode = {\niOSTargetPlatformVersion = nil,\nmacOSTargetPlatformVersion = nil,\ntvOSTargetPlatformVersion = nil,\n},\n}\n", /* actions/xcode/xcode9.lua */ "local premake = premake\npremake.xcode9 = { }\nlocal xcode = premake.xcode\nlocal xcode8 = premake.xcode8\nlocal xcode9 = premake.xcode9\nfunction xcode9.XCBuildConfiguration_Project(tr, prj, cfg)\nlocal options = xcode8.XCBuildConfiguration_Project(tr, prj, cfg)\nif cfg.flags.Cpp17 or cfg.flags.CppLatest then\noptions.CLANG_CXX_LANGUAGE_STANDARD = \"c++17\"\nend\nreturn table.merge(options, {\nCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = \"YES\",\nCLANG_WARN_COMMA = \"YES\",\nCLANG_WARN_NON_LITERAL_NULL_CONVERSION = \"YES\",\nCLANG_WARN_OBJC_LITERAL_CONVERSION = \"YES\",\nCLANG_WARN_RANGE_LOOP_ANALYSIS = \"YES\",\nCLANG_WARN_STRICT_PROTOTYPES = \"YES\",\n})\nend\nfunction xcode9.project(prj)\nlocal tr = xcode.buildprjtree(prj)\nxcode.Header(tr, 48)\nxcode.PBXBuildFile(tr)\nxcode.PBXContainerItemProxy(tr)\nxcode.PBXFileReference(tr,prj)\nxcode.PBXFrameworksBuildPhase(tr)\nxcode.PBXGroup(tr)\nxcode.PBXNativeTarget(tr)\nxcode.PBXProject(tr, \"8.0\")\nxcode.PBXReferenceProxy(tr)\nxcode.PBXResourcesBuildPhase(tr)\nxc" "ode.PBXShellScriptBuildPhase(tr)\nxcode.PBXCopyFilesBuildPhase(tr)\nxcode.PBXSourcesBuildPhase(tr,prj)\nxcode.PBXVariantGroup(tr)\nxcode.PBXTargetDependency(tr)\nxcode.XCBuildConfiguration(tr, prj, {\nontarget = xcode8.XCBuildConfiguration_Target,\nonproject = xcode9.XCBuildConfiguration_Project,\n})\nxcode.XCBuildConfigurationList(tr)\nxcode.Footer(tr)\nend\nnewaction\n{\ntrigger = \"xcode9\",\nshortname = \"Xcode 9\",\ndescription = \"Generate Apple Xcode 9 project files\",\nos = \"macosx\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\" },\nvalid_tools = {\ncc = { \"gcc\" },\n},\nvalid_platforms = {\nNative = \"Native\",\nx32 = \"Native 32-bit\",\nx64 = \"Native 64-bit\",\nUniversal = \"Universal\",\n},\ndefault_platform = \"Native\",\nonsolution = function(sln)\npremake.generate(sln, \"%%.xcworkspace/contents.xcworkspacedata\", xcode.workspace_generate)\npremake.generate(sln, \"%%.x" "cworkspace/xcshareddata/WorkspaceSettings.xcsettings\", xcode.workspace_settings)\npremake.generate(sln, \"%%.xcworkspace/xcshareddata/xcschemes/-ALL-.xcscheme\", xcode.workspace_scheme)\nend,\nonproject = function(prj)\npremake.generate(prj, \"%%.xcodeproj/project.pbxproj\", xcode9.project)\nxcode.generate_schemes(prj, \"%%.xcodeproj/xcshareddata/xcschemes\")\nend,\noncleanproject = function(prj)\npremake.clean.directory(prj, \"%%.xcodeproj\")\npremake.clean.directory(prj, \"%%.xcworkspace\")\nend,\noncheckproject = xcode.checkproject,\nxcode = {\niOSTargetPlatformVersion = nil,\nmacOSTargetPlatformVersion = nil,\ntvOSTargetPlatformVersion = nil,\n},\n}\n", /* actions/xcode/xcode10.lua */ "local premake = premake\npremake.xcode10 = { }\nlocal xcode = premake.xcode\nlocal xcode8 = premake.xcode8\nlocal xcode9 = premake.xcode9\nlocal xcode10 = premake.xcode10\nfunction xcode10.XCBuildConfiguration_Project(tr, prj, cfg)\nlocal options = xcode9.XCBuildConfiguration_Project(tr, prj, cfg)\nreturn table.merge(options, {\nCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = \"YES\",\nCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = \"YES\",\nCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = \"YES\",\nCLANG_WARN_COMMA = \"YES\",\nCLANG_WARN_NON_LITERAL_NULL_CONVERSION = \"YES\",\nCLANG_WARN_OBJC_LITERAL_CONVERSION = \"YES\",\nCLANG_WARN_RANGE_LOOP_ANALYSIS = \"YES\",\nCLANG_WARN_STRICT_PROTOTYPES = \"YES\",\n})\nend\nfunction xcode10.XCBuildConfiguration_Target(tr, target, cfg)\nlocal options = xcode8.XCBuildConfiguration_Target(tr, target, cfg)\nif not cfg.flags.ObjcARC then\noptions.CLANG_ENABLE_OBJC_WEAK = \"YES\"\nend\nreturn options\nend\nfunction xcode10.project(prj)\nlocal tr = xcode.buildprjtree(prj)\nxcode.Header(tr, 48)" "\nxcode.PBXBuildFile(tr)\nxcode.PBXContainerItemProxy(tr)\nxcode.PBXFileReference(tr,prj)\nxcode.PBXFrameworksBuildPhase(tr)\nxcode.PBXGroup(tr)\nxcode.PBXNativeTarget(tr)\nxcode.PBXProject(tr, \"8.0\")\nxcode.PBXReferenceProxy(tr)\nxcode.PBXResourcesBuildPhase(tr)\nxcode.PBXShellScriptBuildPhase(tr)\nxcode.PBXCopyFilesBuildPhase(tr)\nxcode.PBXSourcesBuildPhase(tr,prj)\nxcode.PBXVariantGroup(tr)\nxcode.PBXTargetDependency(tr)\nxcode.XCBuildConfiguration(tr, prj, {\nontarget = xcode10.XCBuildConfiguration_Target,\nonproject = xcode10.XCBuildConfiguration_Project,\n})\nxcode.XCBuildConfigurationList(tr)\nxcode.Footer(tr)\nend\nnewaction\n{\ntrigger = \"xcode10\",\nshortname = \"Xcode 10\",\ndescription = \"Generate Apple Xcode 10 project files\",\nos = \"macosx\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\" },\nvalid_tools = {\ncc = { \"gcc\" },\n},\nvalid_platforms = {\nNative = \"Nat" "ive\",\nx32 = \"Native 32-bit\",\nx64 = \"Native 64-bit\",\nUniversal = \"Universal\",\n},\ndefault_platform = \"Native\",\nonsolution = function(sln)\npremake.generate(sln, \"%%.xcworkspace/contents.xcworkspacedata\", xcode.workspace_generate)\npremake.generate(sln, \"%%.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings\", xcode.workspace_settings)\npremake.generate(sln, \"%%.xcworkspace/xcshareddata/xcschemes/-ALL-.xcscheme\", xcode.workspace_scheme)\nend,\nonproject = function(prj)\npremake.generate(prj, \"%%.xcodeproj/project.pbxproj\", xcode10.project)\nxcode.generate_schemes(prj, \"%%.xcodeproj/xcshareddata/xcschemes\")\nend,\noncleanproject = function(prj)\npremake.clean.directory(prj, \"%%.xcodeproj\")\npremake.clean.directory(prj, \"%%.xcworkspace\")\nend,\noncheckproject = xcode.checkproject,\nxcode = {\niOSTargetPlatformVersion = nil,\nmacOSTargetPlatformVersion = nil,\ntvOSTargetPlatformVersion = nil,\n},\n}\n", /* actions/xcode/xcode11.lua */ "local premake = premake\npremake.xcode11 = { }\nlocal xcode = premake.xcode\nlocal xcode10 = premake.xcode10\nlocal xcode11 = premake.xcode11\nfunction xcode11.XCBuildConfiguration_Target(tr, target, cfg)\nlocal options = xcode10.XCBuildConfiguration_Target(tr, target, cfg)\noptions.CODE_SIGN_IDENTITY = \"-\"\nreturn options\nend\nfunction xcode11.project(prj)\nlocal tr = xcode.buildprjtree(prj)\nxcode.Header(tr, 48)\nxcode.PBXBuildFile(tr)\nxcode.PBXContainerItemProxy(tr)\nxcode.PBXFileReference(tr,prj)\nxcode.PBXFrameworksBuildPhase(tr)\nxcode.PBXGroup(tr)\nxcode.PBXNativeTarget(tr)\nxcode.PBXProject(tr, \"8.0\")\nxcode.PBXReferenceProxy(tr)\nxcode.PBXResourcesBuildPhase(tr)\nxcode.PBXShellScriptBuildPhase(tr)\nxcode.PBXCopyFilesBuildPhase(tr)\nxcode.PBXSourcesBuildPhase(tr,prj)\nxcode.PBXVariantGroup(tr)\nxcode.PBXTargetDependency(tr)\nxcode.XCBuildConfiguration(tr, prj, {\nontarget = xcode11.XCBuildConfiguration_Target,\nonproject = xcode10.XCBuildConfiguration_Project,\n})\nxcode.XCBuildConfigurationList" "(tr)\nxcode.Footer(tr)\nend\nnewaction\n{\ntrigger = \"xcode11\",\nshortname = \"Xcode 11\",\ndescription = \"Generate Apple Xcode 11 project files\",\nos = \"macosx\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\" },\nvalid_tools = {\ncc = { \"gcc\" },\n},\nvalid_platforms = { Native = \"Native\" },\ndefault_platform = \"Native\",\nonsolution = function(sln)\npremake.generate(sln, \"%%.xcworkspace/contents.xcworkspacedata\", xcode.workspace_generate)\npremake.generate(sln, \"%%.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings\", xcode.workspace_settings)\npremake.generate(sln, \"%%.xcworkspace/xcshareddata/xcschemes/-ALL-.xcscheme\", xcode.workspace_scheme)\nend,\nonproject = function(prj)\npremake.generate(prj, \"%%.xcodeproj/project.pbxproj\", xcode11.project)\nxcode.generate_schemes(prj, \"%%.xcodeproj/xcshareddata/xcschemes\")\nend,\noncleanproject = function(prj)\npremake.cl" "ean.directory(prj, \"%%.xcodeproj\")\npremake.clean.directory(prj, \"%%.xcworkspace\")\nend,\noncheckproject = xcode.checkproject,\nxcode = {\niOSTargetPlatformVersion = nil,\nmacOSTargetPlatformVersion = nil,\ntvOSTargetPlatformVersion = nil,\n},\n}\n", /* actions/fastbuild/_fastbuild.lua */ "premake.fastbuild = { }\nlocal fastbuild = premake.fastbuild\nnewaction\n{\ntrigger = \"vs2015-fastbuild\",\nshortname = \"FASTBuild VS2015\",\ndescription = \"Generate FASTBuild configuration files for Visual Studio 2015.\",\nvalid_kinds = {\n\"ConsoleApp\",\n\"WindowedApp\",\n\"StaticLib\",\n\"SharedLib\",\n\"Bundle\",\n},\nvalid_languages = {\n\"C\",\n\"C++\"\n},\nvalid_tools = {\ncc = {\n\"msc\"\n},\n},\nonsolution = function(sln)\npremake.generate(sln, \"fbuild.bff\", premake.fastbuild.solution)\nend,\nonproject = function(prj)\npremake.generate(prj, \"%%.bff\", premake.fastbuild.project)\nend,\noncleansolution = function(sln)\npremake.clean.file(sln, \"fbuild.bff\")\nend,\noncleanproject = function(prj)\npremake.clean.file(prj, \"%%.bff\")\nend,\n}\n", /* actions/fastbuild/fastbuild_project.lua */ "-- Generates a FASTBuild config file for a project.\nlocal function add_trailing_backslash(dir)\nif dir:len() > 0 and dir:sub(-1) ~= \"\\\\\" then\nreturn dir..\"\\\\\"\nend\nreturn dir\nend\nlocal function compile(indentlevel, prj, cfg, commonbasepath)\nlocal firstflag = true\nfor _, cfgexclude in ipairs(cfg.excludes) do\nif path.issourcefile(cfgexclude) then\nif firstflag then\n_p(indentlevel, '// Excluded files:')\nfirstflag = false\nend\n_p(indentlevel, \".CompilerInputFiles - '%s'\", cfgexclude)\nend\nend\nif not firstflag then\n_p('')\nend\n_p(indentlevel, \".CompilerOutputPath = '%s'\", add_trailing_backslash(cfg.objectsdir))\n_p(indentlevel, \".Defines = ''\")\nfor _, define in ipairs(cfg.defines) do\n_p(indentlevel+1, \"+ ' /D%s'\", define)\nend\nif cfg.kind == 'SharedLib' then\n_p(indentlevel+1, \"+ ' /D_WINDLL'\")\nend\n_p(indentlevel, \".IncludeDirs = ''\")\nlocal sortedincdirs = table.join(cfg.userincludedirs, cfg.includedirs, cfg.systemincludedirs)\nlocal function getpathnodecount(p)\nlocal nodef" "inder = string.gmatch(p, \"[^\\\\/]+\")\nlocal result = 0\nlocal node = nodefinder()\nwhile node do\nresult = result + ((node ~= '.' and 1) or 0)\nnode = nodefinder()\nend\nreturn result\nend\nlocal stepsfrombase = {}\nfor _, includedir in ipairs(sortedincdirs) do\nstepsfrombase[includedir] = getpathnodecount(path.getrelative(commonbasepath, includedir))\nend\nlocal function includesort(a, b)\nif stepsfrombase[a] == stepsfrombase[b] then\nreturn a < b\nelse\nreturn stepsfrombase[a] < stepsfrombase[b]\nend\nend\ntable.sort(sortedincdirs, includesort)\nfor _, includedir in ipairs(sortedincdirs) do\n_p(indentlevel+1, \"+ ' /I\\\"%s\\\"'\", includedir)\nend\n_p(indentlevel+1, \"+ .MSVCIncludes\")\nlocal compileroptions = {\n'\"%1\"',\n'/nologo',\n'/c',\n'/Gm-',\n'/Zc:inline',\n'/errorReport:prompt',\n'/FS',\n}\nif cfg.options.ForceCPP then\ntable.insert(compileroptions, '/TP')\nend\nif cfg.flags.PedanticWarnings\nor cfg.flags.ExtraWarnings\nthen\ntable.insert(compileroptions, '/W4')\nend\nif (cfg.flags.NativeWChar" " == false or\ncfg.flags.NoNativeWChar) then\ntable.insert(compileroptions, '/Zc:wchar_t-')\nend\nif (cfg.flags.EnableMinimalRebuild or\ncfg.flags.NoMultiProcessorCompilation) then\nend\nif cfg.flags.FloatFast then\ntable.insert(compileroptions, '/fp:fast')\nelseif cfg.flags.FloatStrict then\ntable.insert(compileroptions, '/fp:strict')\nelse\ntable.insert(compileroptions, '/fp:precise')\nend\nif cfg.flags.FastCall then\ntable.insert(compileroptions, '/Gr')\nelseif cfg.flags.StdCall then\ntable.insert(compileroptions, '/Gd')\nend\nif cfg.flags.UnsignedChar then\ntable.insert(compileroptions, '/J')\nend\nif premake.config.isdebugbuild(cfg) then\nif cfg.flags.StaticRuntime then\ntable.insert(compileroptions, '/MTd')\nelse\ntable.insert(compileroptions, '/MDd')\nend\nelse\nif cfg.flags.StaticRuntime then\ntable.insert(compileroptions, '/MT')\nelse\ntable.insert(compileroptions, '/MD')\nend\nend\nif cfg.flags.Symbols then\nif (cfg.flags.C7DebugInfo) then\ntable.insert(compileroptions, '/Z7')\nelse\nif premake.config" ".iseditandcontinue(cfg) then\ntable.insert(compileroptions, '/ZI')\nelse\ntable.insert(compileroptions, '/Zi')\nend\nlocal targetdir = add_trailing_backslash(cfg.buildtarget.directory)\ntable.insert(compileroptions, string.format(\"/Fd\\\"%s%s.pdb\\\"\", targetdir, cfg.buildtarget.basename))\nend\nend\nlocal isoptimised = true\nif (cfg.flags.Optimize) then\ntable.insert(compileroptions, '/Ox')\nelseif (cfg.flags.OptimizeSize) then\ntable.insert(compileroptions, '/O1')\nelseif (cfg.flags.OptimizeSpeed) then\ntable.insert(compileroptions, '/O2')\nelse\nisoptimised = false\nend\nif isoptimised then\nif cfg.flags.NoOptimizeLink and cfg.flags.NoEditAndContinue then\ntable.insert(compileroptions, '/GF-')\ntable.insert(compileroptions, '/Gy-')\nelse\ntable.insert(compileroptions, '/GF')\ntable.insert(compileroptions, '/Gy')\nend\nelse\ntable.insert(compileroptions, '/Gy')\ntable.insert(compileroptions, '/Od')\ntable.insert(compileroptions, '/RTC1')\nend\nif cfg.flags.FatalWarnings then\ntable.insert(compileroptions, " "'/WX')\nelse\ntable.insert(compileroptions, '/WX-')\nend\nif cfg.platform == 'x32' then\nif cfg.flags.EnableSSE2 then\ntable.insert(compileroptions, '/arch:SSE2')\nelseif cfg.flags.EnableSSE then\ntable.insert(compileroptions, '/arch:SSE')\nend\nend\nif cfg.flags.NoExceptions then\nelse\nif cfg.flags.SEH then\ntable.insert(compileroptions, '/EHa')\nelse\ntable.insert(compileroptions, '/EHsc')\nend\nend\nif cfg.flags.NoRTTI then\ntable.insert(compileroptions, '/GR-')\nelse\ntable.insert(compileroptions, '/GR')\nend\nif cfg.flags.NoFramePointer then\ntable.insert(compileroptions, '/Oy-')\nelse\ntable.insert(compileroptions, '/Oy')\nend\nfor _, addloption in ipairs(cfg.buildoptions) do\ntable.insert(compileroptions, addloption)\nend\n_p(indentlevel, \".CompilerOptions = ''\")\nfor _, option in ipairs(compileroptions) do\n_p(indentlevel+1, \"+ ' %s'\", option)\nend\n_p(indentlevel+1, \"+ .IncludeDirs\")\n_p(indentlevel+1, \"+ .Defines\")\nif not cfg.flags.NoPCH and cfg.pchheader then\n_p(indentlevel, \".CompilerIn" "putFiles - '%s'\", cfg.pchsource)\n_p(indentlevel, \".PCHInputFile = '%s'\", cfg.pchsource)\n_p(indentlevel, \".PCHOutputFile = .CompilerOutputPath + '%s.pch'\", prj.name)\n_p(indentlevel, \".CompilerOptions + ' /Fp\\\"' + .CompilerOutputPath + '%s.pch\\\"'\", prj.name)\n_p(indentlevel, \".PCHOptions = .CompilerOptions\")\n_p(indentlevel+1, \"+ ' /Yc\\\"%s\\\"'\", cfg.pchheader)\n_p(indentlevel+1, \"+ ' /Fo\\\"%%3\\\"'\")\n_p(indentlevel, \".CompilerOptions + ' /Yu\\\"%s\\\"'\", cfg.pchheader)\nend\n_p(indentlevel+1, \"+ ' /Fo\\\"%%2\\\"'\") -- make sure the previous property is .CompilerOptions\nend\nlocal function library(prj, cfg, useconfig, commonbasepath)\n_p(1, \"Library('%s-%s-%s')\", prj.name, cfg.name, cfg.platform)\n_p(1, '{')\nuseconfig(2)\ncompile(2, prj, cfg, commonbasepath)\nlocal librarianoptions = {\n'\"%1\"',\n'/OUT:\"%2\"',\n'/NOLOGO',\n}\nif cfg.platform == 'x64' then\ntable.insert(librarianoptions, '/MACHINE:X64')\nelse\ntable.insert(librarianoptions, '/MACHINE:X86')\nend\n_p(2, \".Libraria" "nOptions = ''\")\nfor _, option in ipairs(librarianoptions) do\n_p(3, \"+ ' %s'\", option)\nend\n_p(2, \".LibrarianOutput = '%s'\", cfg.buildtarget.fullpath)\n_p(1, '}')\n_p('')\nend\nlocal function binary(prj, cfg, useconfig, bintype, commonbasepath)\n_p(1, \"ObjectList('%s_obj-%s-%s')\", prj.name, cfg.name, cfg.platform)\n_p(1, '{')\nuseconfig(2)\ncompile(2, prj, cfg, commonbasepath)\n_p(1, '}')\n_p('')\n_p(1, \"%s('%s-%s-%s')\", bintype, prj.name, cfg.name, cfg.platform)\n_p(1, '{')\nuseconfig(2)\n_p(2, '.Libraries = {')\n_p(3, \"'%s_obj-%s-%s',\", prj.name, cfg.name, cfg.platform) -- Refer to the ObjectList\nlocal sorteddeplibs = {}\nfor _, deplib in ipairs(premake.getlinks(cfg, \"dependencies\", \"basename\")) do\ntable.insert(sorteddeplibs, string.format(\"'%s-%s-%s',\", deplib, cfg.name, cfg.platform))\nend\ntable.sort(sorteddeplibs)\nfor _, deplib in ipairs(sorteddeplibs) do\n_p(3, deplib)\nend\n_p(3, '}')\n_p(2, '.LinkerLinkObjects = false')\nlocal linkeroptions = {\n'\"%1\"',\n'/OUT:\"%2\"',\n'/NOLOG" "O',\n'/errorReport:prompt',\n}\nlocal subsystemversion = '\",5.02\"'\nif cfg.platform == 'x32' then\nsubsystemversion = '\",5.01\"'\nend\nif cfg.kind == 'ConsoleApp' then\ntable.insert(linkeroptions, '/SUBSYSTEM:CONSOLE'..subsystemversion)\nelse\ntable.insert(linkeroptions, '/SUBSYSTEM:WINDOWS'..subsystemversion)\nend\nif cfg.kind == 'SharedLib' then\ntable.insert(linkeroptions, '/DLL')\nend\nif cfg.platform == 'x64' then\ntable.insert(linkeroptions, '/MACHINE:X64')\nelse\ntable.insert(linkeroptions, '/MACHINE:X86')\nend\nfor _, libdir in ipairs(cfg.libdirs) do\ntable.insert(linkeroptions, string.format('/LIBPATH:%s', path.translate(libdir, '\\\\')))\nend\nif not cfg.flags.WinMain and (cfg.kind == 'ConsoleApp' or cfg.kind == 'WindowedApp') then\nif cfg.flags.Unicode then\ntable.insert(linkeroptions, '/ENTRY:wmainCRTStartup')\nelse\ntable.insert(linkeroptions, '/ENTRY:mainCRTStartup')\nend\nend\nlocal deffile = premake.findfile(cfg, \".def\")\nif deffile then\ntable.insert(linkeroptions, '/DEF:%s', deffile)\nen" "d\nif (cfg.flags.Symbols ~= nil) then\ntable.insert(linkeroptions, '/DEBUG')\nend\nif premake.config.islinkeroptimizedbuild(cfg.flags) then\ntable.insert(linkeroptions, '/OPT:REF')\ntable.insert(linkeroptions, '/OPT:ICF')\nend\ntable.insert(linkeroptions, '/INCREMENTAL'..((premake.config.isincrementallink(cfg) and '') or ':NO'))\nfor _, addloption in ipairs(cfg.linkoptions) do\ntable.insert(linkeroptions, addloption)\nend\nlocal linklibs = premake.getlinks(cfg, \"all\", \"fullpath\")\nfor _, linklib in ipairs(linklibs) do\ntable.insert(linkeroptions, path.getname(linklib))\nend\ntable.sort(linkeroptions)\n_p(2, \".LinkerOptions = ''\")\nfor _, option in ipairs(linkeroptions) do\n_p(3, \"+ ' %s'\", option)\nend\n_p(3, \"+ .MSVCLibPaths\")\n_p(2, \".LinkerOutput = '%s'\", cfg.buildtarget.fullpath)\n_p(1, '}')\n_p('')\nend\nlocal function executable(prj, cfg, useconfig, commonbasepath)\nbinary(prj, cfg, useconfig, 'Executable', commonbasepath)\nend\nlocal function dll(prj, cfg, useconfig, commonbasepath)\nbinary(" "prj, cfg, useconfig, 'DLL', commonbasepath)\nend\nlocal function alias(prj, cfg, target)\n_p(1, \"Alias('%s-%s-%s')\", prj.name, cfg.name, cfg.platform)\n_p(1, '{')\n_p(2, \".Targets = '%s'\", target)\n_p(1, '}')\n_p('')\nend\nfunction premake.fastbuild.project(prj)\nio.indent = ' '\n_p('// FASTBuild project configuration file autogenerated by GENie.')\n_p('')\n_p('{')\nlocal cppfiles = {}\nfor file in premake.project.eachfile(prj) do\nif path.issourcefile(file.name) then\ntable.insert(cppfiles, file.name)\nend\nend\nlocal commonbasepath = cppfiles[1]\nfor _, file in ipairs(cppfiles) do\ncommonbasepath = path.getcommonbasedir(commonbasepath..'/', file)\nend\n_p(1, \".CompilerInputFilesRoot = '%s/'\", commonbasepath)\n_p(1, '.CompilerInputFiles = {')\nfor _, file in ipairs(cppfiles) do\n_p(2, \"'%s',\", file)\nend\n_p(1, '}')\n_p('')\nlocal targetkindmap = {\nConsoleApp = executable,\nWindowedApp = executable,\nSharedLib = dll,\nStaticLib = library,\n}\nlocal useconfigmap = {\nx32 = function(indentlevel)\n_p" "(indentlevel, 'Using(.MSVCx86Config)')\n_p('')\nend,\nx64 = function(indentlevel)\n_p(indentlevel, 'Using(.MSVCx64Config)')\n_p('')\nend,\n}\nlocal nativeplatform = (os.is64bit() and 'x64') or 'x32'\nfor _, platform in ipairs(prj.solution.platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\nif cfg.platform == 'Native' then\nalias(prj, cfg, string.format('%s-%s-%s', prj.name, cfg.name, nativeplatform))\nelse\ntargetkindmap[prj.kind](prj, cfg, useconfigmap[cfg.platform], commonbasepath)\nend\nend\nend\n_p('}')\nend\n", /* actions/fastbuild/fastbuild_solution.lua */ "-- Generates a FASTBuild config file for a solution.\nfunction premake.fastbuild.solution(sln)\nio.indent = ' '\n_p('// FastBuild solution configuration file. Generated by GENie.')\n_p('//------------------------------------------------------------------------------------')\n_p('// %s', sln.name)\n_p('//------------------------------------------------------------------------------------')\n_p('#import VS140COMNTOOLS')\nlocal is64bit = os.is64bit()\nlocal target64 = (is64bit and ' amd64') or ' x86_amd64'\nlocal target32 = (is64bit and ' amd64_x86') or ''\nlocal getvcvarscontent = [[\n@set INCLUDE=\n@set LIB=\n@set CommandPromptType=\n@set PreferredToolArchitecture=\n@set Platform=\n@set Path=%SystemRoot%\\System32;%SystemRoot%;%SystemRoot%\\System32\\wbem\n@call \"%VS140COMNTOOLS%..\\..\\VC\\vcvarsall.bat\" %1\n@echo %INCLUDE%\n@echo %LIB%\n@echo %CommandPromptType%\n@echo %PreferredToolArchitecture%\n@echo %Platform%\n@echo %Path%\n]]\nlocal getvcvarsfilepath = os.getenv('TEMP')..'\\\\getvcvars.bat'\nlocal" " getvcvarsfile = assert(io.open(getvcvarsfilepath, 'w'))\ngetvcvarsfile:write(getvcvarscontent)\ngetvcvarsfile:close()\nlocal vcvarsrawx86 = os.outputof(string.format('call \"%s\"%s', getvcvarsfilepath, target32))\nlocal vcvarsrawx64 = os.outputof(string.format('call \"%s\"%s', getvcvarsfilepath, target64))\nos.remove(getvcvarsfilepath)\nlocal msvcvars = {}\nmsvcvars.x32 = {}\nmsvcvars.x64 = {}\nlocal includeslibssplitter = string.gmatch(vcvarsrawx64, \"[^\\n]+\")\nmsvcvars.x64.includesraw = includeslibssplitter()\nmsvcvars.x64.libpathsraw = includeslibssplitter()\nmsvcvars.x64.commandprompttype = includeslibssplitter()\nmsvcvars.x64.preferredtoolarchitecture = includeslibssplitter()\nmsvcvars.x64.platform = includeslibssplitter()\nmsvcvars.x64.pathraw = includeslibssplitter()\nincludeslibssplitter = string.gmatch(vcvarsrawx86, \"[^\\n]+\")\nmsvcvars.x32.includesraw = includeslibssplitter()\nmsvcvars.x32.libpathsraw = includeslibssplitter()\nmsvcvars.x32.commandprompttype = includeslibssplitter()\nmsvcvars.x32" ".preferredtoolarchitecture = includeslibssplitter()\nmsvcvars.x32.platform = includeslibssplitter()\nmsvcvars.x32.pathraw = includeslibssplitter()\nlocal function printincludes(includesraw)\n_p(1, \".MSVCIncludes = ''\")\nfor i in string.gmatch(includesraw, \"[^;]+\") do\n_p(2, \"+ ' /I\\\"%s\\\"'\", i)\nend\nend\nlocal function printlibpaths(libpathsraw)\n_p(1, \".MSVCLibPaths = ''\")\nfor i in string.gmatch(libpathsraw, \"[^;]+\") do\n_p(2, \"+ ' /LIBPATH:\\\"%s\\\"'\", i)\nend\nend\nif is64bit then\n_p('.MSVCx64Config =')\n_p('[')\n_p(1, \".Compiler = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\amd64\\\\cl.exe'\")\n_p(1, \".Librarian = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\amd64\\\\lib.exe'\")\n_p(1, \".Linker = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\amd64\\\\link.exe'\")\nprintincludes(msvcvars.x64.includesraw)\nprintlibpaths(msvcvars.x64.libpathsraw)\n_p(']')\n_p('')\n_p('.MSVCx86Config =')\n_p('[')\n_p(1, \".Compiler = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\amd64_x86\\\\cl.exe'\")\n_p(1, \"." "Librarian = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\amd64_x86\\\\lib.exe'\")\n_p(1, \".Linker = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\amd64_x86\\\\link.exe'\")\nprintincludes(msvcvars.x32.includesraw)\nprintlibpaths(msvcvars.x32.libpathsraw)\n_p(']')\n_p('')\nelse\n_p('.MSVCx64Config =')\n_p('[')\n_p(1, \".Compiler = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\x86_amd64\\\\cl.exe'\")\n_p(1, \".Librarian = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\x86_amd64\\\\lib.exe'\")\n_p(1, \".Linker = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\x86_amd64\\\\link.exe'\")\nprintincludes(msvcvars.x64.includesraw)\nprintlibpaths(msvcvars.x64.libpathsraw)\n_p(']')\n_p('')\n_p('.MSVCx86Config =')\n_p('[')\n_p(1, \".Compiler = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\cl.exe'\")\n_p(1, \".Librarian = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\lib.exe'\")\n_p(1, \".Linker = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin\\\\link.exe'\")\nprintincludes(msvcvars.x32.includesraw)\nprintlibpaths(msvcvars.x32.libpathsraw)\n_p(']')" "\n_p('')\nend\nlocal msvcbin = '$VS140COMNTOOLS$..\\\\..\\\\VC\\\\bin' .. ((is64bit and '\\\\amd64') or '')\n_p('#import Path')\n_p('#import TMP')\n_p('#import SystemRoot')\n_p('')\n_p('Settings')\n_p('{')\n_p(1, '.Environment = {')\n_p(2, \"'Path=%s;$Path$',\", msvcbin)\n_p(2, \"'TMP=$TMP$',\")\n_p(2, \"'SystemRoot=$SystemRoot$',\")\n_p(2, '}')\n_p('}')\n_p('')\nlocal function projkindsort(a, b)\nlocal projvaluemap = {\nConsoleApp = 3,\nWindowedApp = 3,\nSharedLib = 2,\nStaticLib = 1,\n}\nif projvaluemap[a.kind] == projvaluemap[b.kind] then\nreturn a.name < b.name\nelse\nreturn projvaluemap[a.kind] < projvaluemap[b.kind]\nend\nend\nlocal sortedprojs = {}\nfor prj in premake.solution.eachproject(sln) do\ntable.insert(sortedprojs, prj)\nend\ntable.sort(sortedprojs, projkindsort)\nfor _, prj in ipairs(sortedprojs) do\nlocal fname = premake.project.getbasename(prj.name, '%%.bff')\nfname = path.join(prj.location, fname)\nfname = path.getrelative(sln.location, fname)\n_p('#include \"%s\"', fname)\nend\n_p('')" "\n_p('.ProjectVariants = {')\nfor _, plat in ipairs(sln.platforms) do\nfor _, cfg in ipairs(sln.configurations) do\n_p(1, \"'%s-%s',\", cfg, plat)\nend\nend\n_p('}')\n_p('')\n_p('ForEach(.Variant in .ProjectVariants)')\n_p('{')\n_p(1, \"Alias('all-$Variant$')\")\n_p(1, '{')\n_p(2, '.Targets = {')\nfor _, prj in ipairs(sortedprojs) do\n_p(3, \"'%s-$Variant$',\", prj.name)\nend\n_p(2, '}')\n_p(1, '}')\n_p('}')\nend\n", /* actions/ninja/_ninja.lua */ "premake.ninja = { }\nlocal p = premake\nnewaction\n{\ntrigger = \"ninja\",\nshortname = \"ninja\",\ndescription = \"Generate Ninja build files\",\nmodule = \"ninja\",\nvalid_kinds = {\"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\"},\nvalid_languages = {\"C\", \"C++\", \"Swift\"},\nvalid_tools = {\ncc = { \"gcc\" },\nswift = { \"swift\" },\n},\nonsolution = function(sln)\nio.eol = \"\\r\\n\"\nio.indent = \"\\t\"\nio.escaper(p.ninja.esc)\np.generate(sln, \"Makefile\", p.ninja.generate_solution)\nio.indent = \" \"\np.ninja.generate_ninja_builds(sln)\nend,\nonproject = function(prj)\nio.eol = \"\\r\\n\"\nio.indent = \" \"\nio.escaper(p.ninja.esc)\np.ninja.generate_project(prj)\nend,\noncleansolution = function(sln)\nfor _,name in ipairs(sln.configurations) do\npremake.clean.file(sln, p.ninja.get_solution_name(sln, name))\nend\nend,\noncleanproject = function(prj)\nend,\noncleantarget = function(prj)\nend,\n}\n", /* actions/ninja/ninja_base.lua */ "local ninja = premake.ninja\nfunction ninja.esc(value)\nif value then\nvalue = string.gsub(value, \"%$\", \"$$\") -- TODO maybe there is better way\nvalue = string.gsub(value, \":\", \"$:\")\nvalue = string.gsub(value, \"\\n\", \"$\\n\")\nvalue = string.gsub(value, \" \", \"$ \")\nend\nreturn value\nend\nfunction ninja.shesc(value)\nif type(value) == \"table\" then\nlocal result = {}\nlocal n = #value\nfor i = 1, n do\ntable.insert(result, ninja.shesc(value[i]))\nend\nreturn result\nend\nif value:find(\" \") then\nreturn \"\\\"\" .. value .. \"\\\"\"\nend\nreturn value\nend\nfunction ninja.list(value)\nif #value > 0 then\nreturn \" \" .. table.concat(value, \" \")\nelse\nreturn \"\"\nend\nend\nfunction ninja.arglist(arg, value)\nif #value > 0 then\nlocal args = {}\nfor _, val in ipairs(value) do\ntable.insert(args, string.format(\"%s %s\", arg, val))\nend\nreturn table.concat(args, \" \")\nelse\nreturn \"\"\nend\nend\nfunction ninja.generate_project(prj)\nif prj.language == \"Swift\" then\nninja.generate_swift" "(prj)\nelse\nninja.generate_cpp(prj)\nend\nend\nlocal function innerget(self, key)\nreturn rawget(getmetatable(self), key) or self.__inner[key]\nend\nlocal prj_proxy = { __index = innerget }\nlocal cfg_proxy = { __index = innerget }\nfunction new_prj_proxy(prj)\nprj = prj.project or prj\nlocal v = { __inner = prj }\nlocal __configs = {}\nfor key, cfg in pairs(prj.__configs) do\nif key ~= \"\" then\n__configs[key] = ninja.get_proxy(\"cfg\", cfg)\nelse\n__configs[key] = cfg\nend\nend\nv.__configs = __configs\nreturn setmetatable(v, prj_proxy)\nend\nlocal function rebasekeys(t, keys, old, new)\nfor _,key in ipairs(keys) do\nt[key] = path.rebase(t[key], old, new)\nend\nreturn t\nend\nlocal function rebasearray(t, old, new)\nlocal res = { }\nfor _,f in ipairs(t) do\ntable.insert(res, path.rebase(f, old, new))\nend\nreturn res\nend\nfunction new_cfg_proxy(cfg)\nlocal keys = { \"directory\", \"fullpath\", \"bundlepath\" }\nlocal old = cfg.location\nlocal new = path.join(cfg.location, cfg.shortname)\nlocal v = {\n__in" "ner = cfg,\nlocation = new,\nobjectsdir = path.rebase(cfg.objectsdir, old, new),\nbuildtarget = rebasekeys(table.deepcopy(cfg.buildtarget), keys, old, new),\nlinktarget = rebasekeys(table.deepcopy(cfg.linktarget), keys, old, new),\n}\nv.files = rebasearray(cfg.files, old, new)\nv.includedirs = rebasearray(cfg.includedirs, old, new)\nv.libdirs = rebasearray(cfg.libdirs, old, new)\nv.userincludedirs = rebasearray(cfg.userincludedirs, old, new)\nv.systemincludedirs = rebasearray(cfg.systemincludedirs, old, new)\nv.swiftmodulemaps = rebasearray(cfg.swiftmodulemaps, old, new)\nreturn setmetatable(v, cfg_proxy)\nend\nfunction cfg_proxy:getprojectfilename(fullpath)\nlocal name = self.project.name .. \".ninja\"\nif fullpath ~= nil then\nreturn path.join(self.location, name)\nend\nreturn name\nend\nfunction cfg_proxy:getoutputfilename()\nreturn path.join(self.buildtarget.directory, self.buildtarget.name)\nend\nlocal proxy_cache = { \nprj = { new = new_prj_proxy }, \ncfg = { new = ne" "w_cfg_proxy },\n}\nfunction get_proxy(cache, obj)\nif not cache[obj] then\ncache[obj] = cache.new(obj)\nend\nreturn cache[obj]\nend\nfunction ninja.get_proxy(typ, obj)\nif not proxy_cache[typ] then\nerror(\"invalid proxy type\")\nend\nreturn get_proxy(proxy_cache[typ], obj)\nend\n", /* actions/ninja/ninja_solution.lua */ "local ninja = premake.ninja\nlocal p = premake\nlocal solution = p.solution\nfunction ninja.generate_solution(sln)\nlocal cc = premake[_OPTIONS.cc]\nlocal platforms = premake.filterplatforms(sln, cc.platforms, \"Native\")\n_p('# %s solution makefile autogenerated by GENie', premake.action.current().shortname)\n_p('# Type \"make help\" for usage help')\n_p('')\n_p('NINJA=ninja')\n_p('ifndef config')\n_p(' config=%s', _MAKE.esc(premake.getconfigname(sln.configurations[1], platforms[1], true)))\n_p('endif')\n_p('')\nlocal projects = table.extract(sln.projects, \"name\")\ntable.sort(projects)\n_p('')\n_p('.PHONY: all clean help $(PROJECTS)')\n_p('')\n_p('all:')\nif (not sln.messageskip) or (not table.contains(sln.messageskip, \"SkipBuildingMessage\")) then\n_p(1, '@echo \"==== Building all ($(config)) ====\"')\nend\n_p(1, '@${NINJA} -C ${config} all')\n_p('')\nfor _, prj in ipairs(sln.projects) do\nlocal prjx = ninja.get_proxy(\"prj\", prj)\n_p('%s:', _MAKE.esc(prj.name))\nif (not sln.messageskip) or (not table.c" "ontains(sln.messageskip, \"SkipBuildingMessage\")) then\n_p(1, '@echo \"==== Building %s ($(config)) ====\"', prj.name)\nend\n_p(1, '@${NINJA} -C ${config} %s', prj.name)\n_p('')\nend\n_p('clean:')\n_p(1, '@${NINJA} -C ${config} -t clean')\n_p('')\n_p('help:')\n_p(1,'@echo \"Usage: make [config=name] [target]\"')\n_p(1,'@echo \"\"')\n_p(1,'@echo \"CONFIGURATIONS:\"')\nlocal cfgpairs = { }\nfor _, platform in ipairs(platforms) do\nfor _, cfgname in ipairs(sln.configurations) do\n_p(1,'@echo \" %s\"', premake.getconfigname(cfgname, platform, true))\nend\nend\n_p(1,'@echo \"\"')\n_p(1,'@echo \"TARGETS:\"')\n_p(1,'@echo \" all (default)\"')\n_p(1,'@echo \" clean\"')\nfor _, prj in ipairs(sln.projects) do\n_p(1,'@echo \" %s\"', prj.name)\nend\n_p(1,'@echo \"\"')\n_p(1,'@echo \"For more information, see https://github.com/bkaradzic/genie\"')\nend\nlocal generate\nlocal function getconfigs(sln, name, plat)\nlocal cfgs = {}\nfor prj in solution.eachproject(sln) do\nprj = ninja.get_proxy(\"prj\", prj)\nfor cfg " "in p.eachconfig(prj, plat) do\nif cfg.name == name then\ntable.insert(cfgs, cfg)\nend\nend\nend\nreturn cfgs\nend\nfunction ninja.generate_ninja_builds(sln)\nlocal cc = premake[_OPTIONS.cc]\nsln.getlocation = function(cfg, plat)\nreturn path.join(sln.location, premake.getconfigname(cfg, plat, true))\nend\nlocal platforms = premake.filterplatforms(sln, cc.platforms, \"Native\")\nfor _,plat in ipairs(platforms) do\nfor _,name in ipairs(sln.configurations) do\np.generate(sln, ninja.get_solution_name(sln, name, plat), function(sln)\ngenerate(getconfigs(sln, name, plat))\nend)\nend\nend\nend\nfunction ninja.get_solution_name(sln, cfg, plat)\nreturn path.join(sln.getlocation(cfg, plat), \"build.ninja\")\nend\nfunction generate(prjcfgs)\nlocal cfgs = {}\nlocal cfg_start = nil\nlocal cfg_first = nil\nlocal cfg_first_lib = nil\n_p(\"# solution build file\")\n_p(\"# generated with GENie ninja\")\n_p(\"\")\n_p(\"# build projects\")\nfor _,cfg in ipairs(prjcfgs) do\nlocal key = cfg.project.name\nif not c" "fgs[key] then cfgs[key] = \"\" end\ncfgs[key] = cfg:getoutputfilename() .. \" \"\nif not cfgs[\"all\"] then cfgs[\"all\"] = \"\" end\ncfgs[\"all\"] = cfgs[\"all\"] .. cfg:getoutputfilename() .. \" \"\nif (cfg_start == nil) and (cfg.solution.startproject == key) then\ncfg_start = key\nend\nif (cfg_first == nil) and (cfg.kind == \"ConsoleApp\" or cfg.kind == \"WindowedApp\") then\ncfg_first = key\nend\nif (cfg_first_lib == nil) and (cfg.kind == \"StaticLib\" or cfg.kind == \"SharedLib\") then\ncfg_first_lib = key\nend\n_p(\"subninja \" .. cfg:getprojectfilename())\nend\n_p(\"\")\n_p(\"# targets\")\nfor cfg, outputs in iter.sortByKeys(cfgs) do\n_p(\"build \" .. cfg .. \": phony \" .. outputs)\nend\n_p(\"\")\n_p(\"# default target\")\n_p(\"default \" .. (cfg_start or cfg_first or cfg_first_lib))\n_p(\"\")\nend\n", /* actions/ninja/ninja_cpp.lua */ "premake.ninja.cpp = { }\nlocal ninja = premake.ninja\nlocal cpp = premake.ninja.cpp\nlocal p = premake\nlocal function wrap_ninja_cmd(c)\nif os.is(\"windows\") then\nreturn 'cmd /c \"' .. c .. '\"'\nelse\nreturn c\nend\nend\nfunction ninja.generate_cpp(prj)\nlocal pxy = ninja.get_proxy(\"prj\", prj)\nlocal tool = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, tool.platforms, \"Native\")\nfor _, platform in ipairs(platforms) do\nfor cfg in p.eachconfig(pxy, platform) do\np.generate(cfg, cfg:getprojectfilename(), function() cpp.generate_config(prj, cfg) end)\nend\nend\nend\nfunction cpp.generate_config(prj, cfg)\nlocal tool = premake.gettool(prj)\n_p('# Ninja build project file autogenerated by GENie')\n_p('# https://github.com/bkaradzic/GENie')\n_p(\"\")\n_p(\"ninja_required_version = 1.7\")\n_p(\"\")\nlocal flags = {\ndefines = ninja.list(tool.getdefines(cfg.defines)),\nincludes = ninja.list(table.join(tool.getincludedirs(cfg.includedirs), tool.getquoteincludedirs(cfg.us" "erincludedirs), tool.getsystemincludedirs(cfg.systemincludedirs))),\ncppflags = ninja.list(tool.getcppflags(cfg)),\nasmflags = ninja.list(table.join(tool.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_asm)),\ncflags = ninja.list(table.join(tool.getcflags(cfg), cfg.buildoptions, cfg.buildoptions_c)),\ncxxflags = ninja.list(table.join(tool.getcflags(cfg), tool.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_cpp)),\nobjcflags = ninja.list(table.join(tool.getcflags(cfg), tool.getcxxflags(cfg), cfg.buildoptions, cfg.buildoptions_objc)),\n}\n_p(\"\")\n_p(\"# core rules for \" .. cfg.name)\n_p(\"rule cc\")\n_p(\" command = \" .. wrap_ninja_cmd(tool.cc .. \" $defines $includes $flags -MMD -MF $out.d -c -o $out $in\"))\n_p(\" description = cc $out\")\n_p(\" depfile = $out.d\")\n_p(\" deps = gcc\")\n_p(\"\")\n_p(\"rule cxx\")\n_p(\" command = \" .. wrap_ninja_cmd(tool.cxx .. \" $defines $includes $flags -MMD -MF $out.d -c -o $out $in\"))\n_p(\" description = cxx $out\")\n_p(\" de" "pfile = $out.d\")\n_p(\" deps = gcc\")\n_p(\"\")\nif cfg.flags.UseObjectResponseFile then\n_p(\"rule ar\")\n_p(\" command = \" .. wrap_ninja_cmd(tool.ar .. \" $flags $out @$out.rsp \" .. (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\")))\n_p(\" description = ar $out\")\n_p(\" rspfile = $out.rsp\")\n_p(\" rspfile_content = $in $libs\")\n_p(\"\")\nelse\n_p(\"rule ar\")\n_p(\" command = \" .. wrap_ninja_cmd(tool.ar .. \" $flags $out $in $libs\" .. (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\")))\n_p(\" description = ar $out\")\n_p(\"\")\nend\nlocal link = iif(cfg.language == \"C\", tool.cc, tool.cxx)\n_p(\"rule link\")\nlocal startgroup = ''\nlocal endgroup = ''\nif (cfg.flags.LinkSupportCircularDependencies) then\nstartgroup = '-Wl,--start-group'\nendgroup = '-Wl,--end-group'\nend\nlocal rspfile_content = \"$all_outputfiles $walibs \" .. string.format(\"%s $libs %s\", startgroup, en" "dgroup)\nif cfg.flags.UseLDResponseFile then\n_p(\" command = \" .. wrap_ninja_cmd(\"$pre_link \" .. link .. \" -o $out @$out.rsp $all_ldflags $post_build\"))\n_p(\" description = link $out\")\n_p(\" rspfile = $out.rsp\")\n_p(\" rspfile_content = %s\", rspfile_content)\n_p(\"\")\nelse\n_p(\" command = \" .. wrap_ninja_cmd(\"$pre_link \" .. link .. \" -o $out \" .. rspfile_content .. \" $all_ldflags $post_build\"))\n_p(\" description = link $out\")\n_p(\"\")\nend\n_p(\"rule exec\")\n_p(\" command = \" .. wrap_ninja_cmd(\"$command\"))\n_p(\" description = Run $type commands\")\n_p(\"\")\nif #cfg.prebuildcommands > 0 then\n_p(\"build __prebuildcommands_\" .. premake.esc(prj.name) .. \": exec\")\n_p(1, \"command = \" .. wrap_ninja_cmd(\"echo Running pre-build commands && \" .. table.implode(cfg.prebuildcommands, \"\", \"\", \" && \")))\n_p(1, \"type = pre-build\")\n_p(\"\")\nend\ncfg.pchheader_full = cfg.pchheader\nfor _, incdir in ipairs(cfg.includedirs) do\nlocal ab" "spath = path.getabsolute(path.join(cfg.project.location, cfg.shortname, incdir))\nlocal testname = path.join(abspath, cfg.pchheader_full)\nif os.isfile(testname) then\ncfg.pchheader_full = path.getrelative(cfg.location, testname)\nbreak\nend\nend\ncpp.custombuildtask(prj, cfg)\ncpp.dependencyRules(prj, cfg)\ncpp.file_rules(prj, cfg, flags)\nlocal objfiles = {}\nfor _, file in ipairs(cfg.files) do\nif path.issourcefile(file) then\ntable.insert(objfiles, cpp.objectname(cfg, file))\nend\nend\n_p('')\ncpp.linker(prj, cfg, objfiles, tool, flags)\n_p(\"\")\nend\nfunction cpp.custombuildtask(prj, cfg)\nlocal cmd_index = 1\nlocal seen_commands = {}\nlocal command_by_name = {}\nlocal command_files = {}\nlocal prebuildsuffix = #cfg.prebuildcommands > 0 and \"||__prebuildcommands_\" .. premake.esc(prj.name) or \"\"\nfor _, custombuildtask in ipairs(prj.custombuildtask or {}) do\nfor _, buildtask in ipairs(custombuildtask or {}) do\nfor _, cmd in ipairs(buildtask[4] or {}) do\nlocal num = 1\nfor _, depdata in ipairs(build" "task[3] or {}) do\ncmd = string.gsub(cmd,\"%$%(\" .. num ..\"%)\", string.format(\"%s \", path.getrelative(cfg.location, depdata)))\nnum = num + 1\nend\ncmd = string.gsub(cmd, '%$%(<%)', '$in')\ncmd = string.gsub(cmd, '%$%(@%)', '$out')\nlocal cmd_name -- shortened command name\nif seen_commands[cmd] == nil then\nlocal _, _, name = string.find(cmd, '([.%w]+)%s')\nname = 'cmd' .. cmd_index .. '_' .. string.gsub(name, '[^%w]', '_')\nseen_commands[cmd] = {\nname = name,\nindex = cmd_index,\n}\ncmd_index = cmd_index + 1\ncmd_name = name\nelse\ncmd_name = seen_commands[cmd].name\nend\nlocal index = seen_commands[cmd].index\nif command_files[index] == nil then\ncommand_files[index] = {}\nend\nlocal cmd_set = command_files[index]\ntable.insert(cmd_set, {\nbuildtask[1],\nbuildtask[2],\nbuildtask[3],\nseen_commands[cmd].name,\n})\ncommand_files[index] = cmd_set\ncommand_by_name[cmd_name] = cmd\nend\nend\nend\n_p(\"# custom build rules\")\nfor command, details in pairs(seen_commands) do\n_p(\"rule \" .. details.name)\n_" "p(1, \"command = \" .. wrap_ninja_cmd(command))\nend\nfor cmd_index, cmdsets in ipairs(command_files) do\nfor _, cmdset in ipairs(cmdsets) do\nlocal file_in = path.getrelative(cfg.location, cmdset[1])\nlocal file_out = path.getrelative(cfg.location, cmdset[2])\nlocal deps = ''\nfor i, dep in ipairs(cmdset[3]) do\ndeps = deps .. path.getrelative(cfg.location, dep) .. ' '\nend\n_p(\"build \" .. file_out .. ': ' .. cmdset[4] .. ' ' .. file_in .. ' | ' .. deps .. prebuildsuffix)\n_p(\"\")\nend\nend\nend\nfunction cpp.dependencyRules(prj, cfg)\nlocal extra_deps = {}\nlocal order_deps = {}\nlocal extra_flags = {}\nfor _, dependency in ipairs(prj.dependency or {}) do\nfor _, dep in ipairs(dependency or {}) do\nlocal objfilename = cpp.objectname(cfg, path.getrelative(prj.location, dep[1]))\nlocal dependency = path.getrelative(cfg.location, dep[2])\nif extra_deps[objfilename] == nil then\nextra_deps[objfilename] = {}\nend\ntable.insert(extra_deps[objfilename], dependency)\nend\nend\nlocal pchfilename = cfg.pchheader_fu" "ll and cpp.pchname(cfg, cfg.pchheader_full) or ''\nfor _, file in ipairs(cfg.files) do\nlocal objfilename = file == cfg.pchheader and cpp.pchname(cfg, file) or cpp.objectname(cfg, file)\nif path.issourcefile(file) or file == cfg.pchheader then\nif #cfg.prebuildcommands > 0 then\nif order_deps[objfilename] == nil then\norder_deps[objfilename] = {}\nend\ntable.insert(order_deps[objfilename], '__prebuildcommands_' .. premake.esc(prj.name))\nend\nend\nif path.issourcefile(file) then\nif cfg.pchheader_full and not cfg.flags.NoPCH then\nlocal nopch = table.icontains(prj.nopch, file)\nif not nopch then\nlocal suffix = path.isobjcfile(file) and '_objc' or ''\nif extra_deps[objfilename] == nil then\nextra_deps[objfilename] = {}\nend\ntable.insert(extra_deps[objfilename], pchfilename .. suffix .. \".gch\")\nif extra_flags[objfilename] == nil then\nextra_flags[objfilename] = {}\nend\ntable.insert(extra_flags[objfilename], '-include ' .. pchfilename .. suffix)\nend\nend\nend\nend\ncfg.extra_deps = extra_deps\ncfg.order_de" "ps = order_deps\ncfg.extra_flags = extra_flags\nend\nfunction cpp.objectname(cfg, file)\nreturn path.join(cfg.objectsdir, path.trimdots(path.removeext(file)) .. \".o\")\nend\nfunction cpp.pchname(cfg, file)\nreturn path.join(cfg.objectsdir, path.trimdots(file))\nend\nfunction cpp.file_rules(prj,cfg, flags)\n_p(\"# build files\")\nfor _, file in ipairs(cfg.files) do\n_p(\"# FILE: \" .. file)\nif cfg.pchheader_full == file then\nlocal pchfilename = cpp.pchname(cfg, file)\nlocal extra_deps = #cfg.extra_deps and '| ' .. table.concat(cfg.extra_deps[pchfilename] or {}, ' ') or ''\nlocal order_deps = #cfg.order_deps and '|| ' .. table.concat(cfg.order_deps[pchfilename] or {}, ' ') or ''\nlocal extra_flags = #cfg.extra_flags and ' ' .. table.concat(cfg.extra_flags[pchfilename] or {}, ' ') or ''\n_p(\"build \" .. pchfilename .. \".gch : cxx \" .. file .. extra_deps .. order_deps)\n_p(1, \"flags = \" .. flags['cxxflags'] .. extra_flags .. iif(prj.language == \"C\", \"-x c-header\", \"-x c++-header\"))\n_p(1, \"includ" "es = \" .. flags.includes)\n_p(1, \"defines = \" .. flags.defines)\n_p(\"build \" .. pchfilename .. \"_objc.gch : cxx \" .. file .. extra_deps .. order_deps)\n_p(1, \"flags = \" .. flags['objcflags'] .. extra_flags .. iif(prj.language == \"C\", \"-x objective-c-header\", \"-x objective-c++-header\"))\n_p(1, \"includes = \" .. flags.includes)\n_p(1, \"defines = \" .. flags.defines)\nelseif path.issourcefile(file) then\nlocal objfilename = cpp.objectname(cfg, file)\nlocal extra_deps = #cfg.extra_deps and '| ' .. table.concat(cfg.extra_deps[objfilename] or {}, ' ') or ''\nlocal order_deps = #cfg.order_deps and '|| ' .. table.concat(cfg.order_deps[objfilename] or {}, ' ') or ''\nlocal extra_flags = #cfg.extra_flags and ' ' .. table.concat(cfg.extra_flags[objfilename] or {}, ' ') or ''\nlocal cflags = \"cflags\"\nif path.isobjcfile(file) then\n_p(\"build \" .. objfilename .. \": cxx \" .. file .. extra_deps .. order_deps)\ncflags = \"objcflags\"\nelseif path.isasmfile(file) then\n_p(\"build \" .. objfilename ." ". \": cc \" .. file .. extra_deps .. order_deps)\ncflags = \"asmflags\"\nelseif path.iscfile(file) and not cfg.options.ForceCPP then\n_p(\"build \" .. objfilename .. \": cc \" .. file .. extra_deps .. order_deps)\nelse\n_p(\"build \" .. objfilename .. \": cxx \" .. file .. extra_deps .. order_deps)\ncflags = \"cxxflags\"\nend\n_p(1, \"flags = \" .. flags[cflags] .. extra_flags)\n_p(1, \"includes = \" .. flags.includes)\n_p(1, \"defines = \" .. flags.defines)\nelseif path.isresourcefile(file) then\nend\nend\n_p(\"\")\nend\nfunction cpp.linker(prj, cfg, objfiles, tool)\nlocal all_ldflags = ninja.list(table.join(tool.getlibdirflags(cfg), tool.getldflags(cfg), cfg.linkoptions))\nlocal prebuildsuffix = #cfg.prebuildcommands > 0 and (\"||__prebuildcommands_\" .. premake.esc(prj.name)) or \"\"\nlocal libs = {}\nlocal walibs = {}\nlocal lddeps = {}\nif #cfg.wholearchive > 0 then\nfor _, linkcfg in ipairs(premake.getlinks(cfg, \"siblings\", \"object\")) do\nlocal linkpath = path.rebase(" "linkcfg.linktarget.fullpath, linkcfg.location, cfg.location)\ntable.insert(lddeps, linkpath)\nif table.icontains(cfg.wholearchive, linkcfg.project.name) then\ntable.insert(walibs, table.concat(tool.wholearchive(linkpath), ' '))\nelse\ntable.insert(libs, linkpath)\nend\nend\nelse\nlddeps = premake.getlinks(cfg, \"siblings\", \"fullpath\")\nlibs = lddeps\nend\nlddeps = ninja.list(lddeps)\nlibs = ninja.list(libs) .. \" \" .. ninja.list(tool.getlinkflags(cfg))\nwalibs = ninja.list(walibs)\nlocal function writevars()\n_p(1, \"all_ldflags = \" .. all_ldflags)\n_p(1, \"libs = \" .. libs)\n_p(1, \"walibs = \" .. walibs)\n_p(1, \"all_outputfiles = \" .. table.concat(objfiles, \" \"))\nif #cfg.prelinkcommands > 0 then\n_p(1, 'pre_link = echo Running pre-link commands && ' .. table.implode(cfg.prelinkcommands, \"\", \"\", \" && \") .. \" && \")\nend\nif #cfg.postbuildcommands > 0 then\n_p(1, 'post_build = && echo Running post-build commands" " && ' .. table.implode(cfg.postbuildcommands, \"\", \"\", \" && \"))\nend\nend\nif cfg.kind == \"StaticLib\" then\nlocal ar_flags = ninja.list(tool.getarchiveflags(cfg, cfg, false))\n_p(\"# link static lib\")\n_p(\"build \" .. cfg:getoutputfilename() .. \": ar \" .. table.concat(objfiles, \" \") .. \" | \" .. lddeps .. prebuildsuffix)\n_p(1, \"flags = \" .. ninja.list(tool.getarchiveflags(cfg, cfg, false)))\n_p(1, \"all_outputfiles = \" .. table.concat(objfiles, \" \"))\nelseif cfg.kind == \"SharedLib\" or cfg.kind == \"Bundle\" then\nlocal output = cfg:getoutputfilename()\n_p(\"# link shared lib\")\n_p(\"build \" .. output .. \": link \" .. table.concat(objfiles, \" \") .. \" | \" .. lddeps .. prebuildsuffix)\nwritevars()\nelseif (cfg.kind == \"ConsoleApp\") or (cfg.kind == \"WindowedApp\") then\n_p(\"# link executable\")\n_p(\"build \" .. cfg:getoutputfilename() .. \": link \" .. table.concat(objfiles, \" \") .. \" | \" .. lddeps .. prebuildsuffix)\nwritevars()\nelse\np.error(\"ninja action doesn't support t" "his kind of target \" .. cfg.kind)\nend\nend\n", /* actions/ninja/ninja_swift.lua */ "local ninja = premake.ninja\nlocal swift = {}\nlocal p = premake\nfunction ninja.generate_swift(prj)\nlocal pxy = ninja.get_proxy(\"prj\", prj)\nlocal tool = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, tool.platforms, \"Native\")\nfor _, platform in ipairs(platforms) do\nfor cfg in p.eachconfig(pxy, platform) do\np.generate(cfg, cfg:getprojectfilename(), function() swift.generate_config(prj, cfg) end)\nend\nend\nend\nfunction swift.generate_config(prj, cfg)\nlocal tool = premake.gettool(prj)\nlocal flags = {\nswiftcflags = ninja.list(tool.getswiftcflags(cfg)),\nswiftlinkflags = ninja.list(tool.getswiftlinkflags(cfg)),\n}\n_p(\"# Swift project build file\")\n_p(\"# generated with GENie ninja\")\n_p(\"\")\n_p(\"ninja_required_version = 1.7\")\n_p(\"\")\n_p(\"out_dir = %s\", cfg.buildtarget.directory)\n_p(\"obj_dir = %s\", path.join(cfg.objectsdir, prj.name .. \".build\"))\n_p(\"target = $out_dir/%s\", cfg.buildtarget.name)\n_p(\"module_name = %s\", prj.name)\n_p(\"module_" "maps = %s\", ninja.list(tool.getmodulemaps(cfg)))\n_p(\"swiftc_flags = %s\", flags.swiftcflags)\n_p(\"swiftlink_flags = %s\", flags.swiftlinkflags)\n_p(\"ar_flags = %s\", ninja.list(tool.getarchiveflags(cfg, cfg, false)))\n_p(\"ld_flags = %s\", ninja.list(tool.getldflags(cfg)))\nif cfg.flags.Symbols then\n_p(\"symbols = $target.dSYM\")\nsymbols_command = string.format(\"&& %s $target -o $symbols\", tool.dsymutil)\nelse\n_p(\"symbols = \")\nsymbols_command = \"\"\nend\nlocal sdk = tool.get_sdk_path(cfg)\nif sdk then\n_p(\"toolchain_path = %s\", tool.get_toolchain_path(cfg))\n_p(\"sdk_path = %s\", sdk)\n_p(\"platform_path = %s\", tool.get_sdk_platform_path(cfg))\n_p(\"sdk = -sdk $sdk_path\")\nelse\n_p(\"sdk_path =\")\n_p(\"sdk =\")\nend\n_p(\"\")\n_p(\"# core rules for %s\", cfg.name)\n_p(\"rule swiftc\")\n_p(1, \"command = %s -frontend -c $in -enable-objc-interop $sdk -I $out_dir $swiftc_flags -module-cache-path $out_dir/ModuleCache -D SWIFT_PACKAGE $module_maps -emit-module-doc-path $out_dir/$module_name.swift" "doc -module-name $module_name -emit-module-path $out_dir/$module_name.swiftmodule -num-threads 8 $obj_files\", tool.swift)\n_p(1, \"description = compile $out\")\n_p(\"\")\n_p(\"rule swiftlink\")\n_p(1, \"command = %s $sdk -L $out_dir -o $out $swiftlink_flags $ld_flags $in %s\", tool.swiftc, symbols_command)\n_p(1, \"description = create executable\")\n_p(\"\")\n_p(\"rule ar\")\n_p(1, \"command = %s cr $ar_flags $out $in %s\", tool.ar, (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\"))\n_p(1, \"description = ar $out\")\n_p(\"\")\nlocal objfiles = {}\nfor _, file in ipairs(cfg.files) do\nif path.isswiftfile(file) then\ntable.insert(objfiles, swift.objectname(cfg, file))\nend\nend\nswift.file_rules(cfg, objfiles)\n_p(\"\")\nswift.linker(prj, cfg, objfiles, tool)\nend\nfunction swift.objectname(cfg, file)\nreturn path.join(\"$obj_dir\", path.getname(file)..\".o\")\nend\nfunction swift.file_rules(cfg, objfiles)\n_p(\"build %s: swiftc %s\", ninja.list(objfiles), ninja.list(cfg" ".files))\n_p(1, \"obj_files = %s\", ninja.arglist(\"-o\", objfiles))\nend\nfunction swift.linker(prj, cfg, objfiles, tool)\nlocal lddeps = ninja.list(premake.getlinks(cfg, \"siblings\", \"fullpath\")) \nif cfg.kind == \"StaticLib\" then\n_p(\"build $target: ar %s | %s \", ninja.list(objfiles), lddeps)\nelse\nlocal lddeps = ninja.list(premake.getlinks(cfg, \"siblings\", \"fullpath\"))\n_p(\"build $target: swiftlink %s | %s\", ninja.list(objfiles), lddeps)\nend\nend\n", /* actions/ninja/ninja_swift_incremental.lua */ "local ninja = premake.ninja\nlocal swift = { }\nlocal p = premake\nfunction ninja.generate_swift_incremental(prj)\nlocal pxy = ninja.get_proxy(\"prj\", prj)\nlocal tool = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, tool.platforms, \"Native\")\nfor _, platform in ipairs(platforms) do\nfor cfg in p.eachconfig(pxy, platform) do\np.generate(cfg, cfg:getprojectfilename(), function() swift.generate_config(prj, cfg) end)\nend\nend\nend\nfunction swift.generate_config(prj, cfg)\nlocal tool = premake.gettool(prj)\nlocal flags = {\nswiftcflags = ninja.list(table.join(tool.getswiftcflags(cfg), cfg.buildoptions_swiftc)),\n}\n_p(\"# Swift project build file\")\n_p(\"# generated with GENie ninja\")\n_p(\"\")\n_p(\"ninja_required_version = 1.7\")\n_p(\"\")\n_p(\"out_dir = %s\", cfg.buildtarget.directory)\n_p(\"obj_dir = %s\", path.join(cfg.objectsdir, prj.name .. \".build\"))\n_p(\"module_name = %s\", prj.name)\n_p(\"module_maps = %s\", ninja.list(tool.getmodulemaps(cfg)))\n_p(\"swiftc_f" "lags = %s\", flags.swiftcflags)\n_p(\"swiftlink_flags = %s\", flags.swiftlinkflags)\n_p(\"ar_flags = %s\", ninja.list(tool.getarchiveflags(cfg, cfg, false)))\nlocal sdk = tool.get_sdk_path(cfg)\nif sdk then\n_p(\"toolchain_path = %s\", tool.get_toolchain_path(cfg))\n_p(\"sdk_path = %s\", sdk)\n_p(\"platform_path = %s\", tool.get_sdk_platform_path(cfg))\n_p(\"sdk = -sdk $sdk_path\")\n_p(\"ld_baseflags = -force_load $toolchain_path/usr/lib/arc/libarclite_macosx.a -L $out_dir -F $platform_path/Developer/Library/Frameworks -syslibroot $sdk_path -lobjc -lSystem -L $toolchain_path/usr/lib/swift/macosx -rpath $toolchain_path/usr/lib/swift/macosx -macosx_version_min 10.10.0 -no_objc_category_merging\")\nelse\n_p(\"sdk_path =\")\n_p(\"sdk =\")\n_p(\"ld_baseflags =\")\nend\n_p(\"\")\n_p(\"# core rules for %s\", cfg.name)\n_p(\"rule swiftc\")\n_p(1, \"command = %s -frontend -c -primary-file $in $files $target -enable-objc-interop $sdk -I $out_dir -enable-testing -module-cache-path $out_dir/ModuleCache -D SWIFT_PACKAGE $m" "odule_maps -emit-module-doc-path $out_doc_name swiftc_flags -module-name $module_name -emit-module-path $out_module_name -emit-dependencies-path $out.d -emit-reference-dependencies-path $obj_dir/$basename.swiftdeps -o $out\", tool.swiftc)\n_p(1, \"description = compile $out\")\n_p(\"\")\n_p(\"rule swiftm\")\n_p(1, \"command = %s -frontend -emit-module $in $parse_as_library swiftc_flags $target -enable-objc-interop $sdk -I $out_dir -F $platform_path/Developer/Library/Frameworks -enable-testing -module-cache-path $out_dir/ModuleCache -D SWIFT_PACKAGE $module_maps -emit-module-doc-path $out_dir/$module_name.swiftdoc -module-name $module_name -o $out\", tool.swift)\n_p(1, \"description = generate module\")\n_p(\"\")\n_p(\"rule swiftlink\")\n_p(1, \"command = %s $target $sdk $swiftlink_flags -L $out_dir -o $out_dir/$module_name -F $platform_path/Developer/Library/Frameworks $in\", tool.swiftc)\n_p(1, \"description = linking $target\")\n_p(\"\")\n_p(\"rule ar\")\n_p(1, \"command = %s cr $ar_flags $out $in $libs %s\"" ", tool.ar, (os.is(\"MacOSX\") and \" 2>&1 > /dev/null | sed -e '/.o) has no symbols$$/d'\" or \"\"))\n_p(1, \"description = ar $out\")\n_p(\"\")\n_p(\"rule link\")\n_p(\" command = %s $in $ld_baseflags $all_ldflags $libs -o $out\", tool.ld)\n_p(\" description = link $out\")\n_p(\"\")\nswift.file_rules(cfg, flags)\nlocal objfiles = {}\nlocal modfiles = {}\nlocal docfiles = {}\nfor _, file in ipairs(cfg.files) do\nif path.issourcefile(file) then\ntable.insert(objfiles, swift.objectname(cfg, file))\ntable.insert(modfiles, swift.modulename(cfg, file))\ntable.insert(docfiles, swift.docname(cfg, file))\nend\nend\n_p(\"\")\nswift.linker(prj, cfg, {objfiles, modfiles, docfiles}, tool, flags)\n_p(\"\")\nend\nfunction swift.objectname(cfg, file)\nreturn path.join(\"$obj_dir\", path.getname(file)..\".o\")\nend\nfunction swift.modulename(cfg, file)\nreturn path.join(\"$obj_dir\", path.getname(file)..\".o.swiftmodule\")\nend\nfunction swift.docname(cfg, file)\nreturn path.join(\"$obj_dir\", path.getname(file)..\".o.swift" "doc\")\nend\nfunction swift.file_rules(cfg, flags)\n_p(\"# build files\")\nlocal sfiles = Set(cfg.files)\nfor _, file in ipairs(cfg.files) do\nif path.issourcefile(file) then\nif path.isswiftfile(file) then\nlocal objn = swift.objectname(cfg, file)\nlocal modn = swift.modulename(cfg, file)\nlocal docn = swift.docname(cfg, file)\n_p(\"build %s | %s %s: swiftc %s\", objn, modn, docn, file)\n_p(1, \"out_module_name = %s\", modn)\n_p(1, \"out_doc_name = %s\", docn)\n_p(1, \"files = \".. ninja.list(sfiles - {file}))\nbuild_flags = \"swiftcflags\"\nend\n_p(1, \"flags = \" .. flags[build_flags])\nelseif path.isresourcefile(file) then\nend\nend\n_p(\"\")\nend\nfunction swift.linker(prj, cfg, depfiles, tool)\nlocal all_ldflags = ninja.list(table.join(tool.getlibdirflags(cfg), tool.getldflags(cfg), cfg.linkoptions))\nlocal lddeps = ninja.list(premake.getlinks(cfg, \"siblings\", \"fullpath\")) \nlocal libs = lddeps .. \" \" .. ninja.list(tool.getlinkflags(cfg))\nlocal function writevars()\n_p(1, \"all_ldfl" "ags = \" .. all_ldflags)\n_p(1, \"libs = \" .. libs)\nend\nlocal objfiles, modfiles, docfiles = table.unpack(depfiles)\n_p(\"build $out_dir/$module_name.swiftmodule | $out_dir/$module_name.swiftdoc: swiftm %s | %s\", table.concat(modfiles, \" \"), table.concat(docfiles, \" \"))\n_p(\"\")\nlocal output = cfg:getoutputfilename()\nif cfg.kind == \"StaticLib\" then\nlocal ar_flags = ninja.list(tool.getarchiveflags(cfg, cfg, false))\n_p(\"build %s: ar %s | %s $out_dir/$module_name.swiftmodule $out_dir/$module_name.swiftdoc\", output, table.concat(objfiles, \" \"), lddeps)\n_p(1, \"flags = %s\", ninja.list(tool.getarchiveflags(cfg, cfg, false)))\nelseif cfg.kind == \"SharedLib\" then\n_p(\"build %s : swiftlink %s | %s $out_dir/$module_name.swiftmodule $out_dir/$module_name.swiftdoc\", output, table.concat(objfiles, \" \"), libs)\nwritevars()\nelseif (cfg.kind == \"ConsoleApp\") or (cfg.kind == \"WindowedApp\") then\n_p(\"build %s: swiftlink %s | %s $out_dir/$module_name.swiftmodule $out_dir/$module_name.swift" "doc\", output, table.concat(objfiles, \" \"), lddeps)\nelse\np.error(\"ninja action doesn't support this kind of target \" .. cfg.kind)\nend\nend\n", /* actions/qbs/_qbs.lua */ "premake.qbs = { }\nlocal qbs = premake.qbs\nnewaction\n{\ntrigger = \"qbs\",\nshortname = \"qbs\",\ndescription = \"Generate QBS build files\",\nmodule = \"qbs\",\nvalid_kinds = {\"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\"},\nvalid_languages = {\"C\", \"C++\"},\nvalid_tools = {\ncc = { \"gcc\", \"msc\" },\n},\nonsolution = function(sln)\nio.eol = \"\\n\"\nio.indent = \"\\t\"\nio.escaper(qbs.esc)\npremake.generate(sln, sln.name .. \".creator.qbs\", qbs.generate_solution)\nio.indent = \" \"\npremake.generate(sln, sln.name .. \".creator.qbs.user\", qbs.generate_user)\nend,\nonproject = function(prj)\nio.eol = \"\\n\"\nio.indent = \"\\t\"\nio.escaper(qbs.esc)\npremake.generate(prj, prj.name .. \".qbs\", qbs.generate_project)\nend,\n}\n", /* actions/qbs/qbs_base.lua */ "function premake.qbs.list(indent, name, table)\nif #table > 0 then\n_p(indent, '%s: [', name)\nfor _, item in ipairs(table) do\n_p(indent+1, '\"%s\",', item:gsub('\"', '\\\\\"'))\nend\n_p(indent+1, ']')\nend\nend", /* actions/qbs/qbs_solution.lua */ "local qbs = premake.qbs\nfunction qbs.generate_solution(sln)\n_p('/*')\n_p(' * QBS project file autogenerated by GENie')\n_p(' * https://github.com/bkaradzic/GENie')\n_p(' */')\n_p('')\n_p('import qbs')\n_p('')\n_p(0, 'Project {')\n_p(1, 'references: [')\nfor prj in premake.solution.eachproject(sln) do\n_p(2, '\"' .. prj.name .. '.qbs\",')\nend\n_p(1, ']')\n_p(0, '}')\nend\nlocal function is_app(kind)\nif kind == \"ConsoleApp\" or kind == \"WindowedApp\" then\nreturn true\nend\nreturn false\nend\nfunction qbs.generate_user(sln)\n_p(0, '<?xml version=\"1.0\" encoding=\"UTF-8\"?>')\n_p(0, '<!DOCTYPE QtCreatorProject>')\n_p(0, '<!-- QBS project file autogenerated by GENie https://github.com/bkaradzic/GENie -->')\n_p(0, '<qtcreator>')\nlocal startProject = 0\nlocal idx = 0\nfor prj in premake.solution.eachproject(sln) do\nif is_app(prj.kind) then\nif sln.startproject == prj.name then\nstartProject = idx\nend\nidx = idx + 1\nend\nend\n_p(1, '<data>')\n_p(2, '<variable>ProjectExplorer.Project.Target.0</variable>')\n" "_p(2, '<valuemap type=\"QVariantMap\">')\n_p(3, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DefaultDisplayName\">Desktop</value>')\n_p(3, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DisplayName\">Desktop</value>')\nlocal qbsguid = \"\"\nlocal qbsprofile = \"\"\nlocal qtcreatordir = \"\"\nif _OS == \"windows\" then\nqtcreatordir = path.join(os.getenv(\"APPDATA\"), \"QtProject/qtcreator\")\nelse\nqtcreatordir = path.join(os.getenv(\"HOME\"), \".config/QtProject/qtcreator\")\nend\nlocal file = io.open(path.join(qtcreatordir, \"qbs.conf\"))\nif file == nil then\nfile = io.open(path.join(qtcreatordir, \"qbs/1.6.0/qbs.conf\"))\nend\nif file ~= nil then\nfor line in file:lines() do\nif line == \"[org]\" then\nlocal str = 'qt-project\\\\qbs\\\\preferences\\\\qtcreator\\\\kit\\\\%'\nlocal index = string.len(str)+1\nfor line in file:lines() do\nif index == string.find(line, '7B', index) then\nline = string.sub(line, index+2)\nqbsguid = string.sub(line, 1, 36)\nqbspro" "file = string.sub(line, 41)\nbreak\nend\nend\nelse\nlocal str = '\\t<key>org.qt-project.qbs.preferences.qtcreator.kit.'\nlocal index = string.len(str)+1\nfor line in file:lines() do\nif qbsguid == \"\" and index == string.find(line, '{', index) then\nline = string.sub(line, index+1)\nqbsguid = string.sub(line, 1, 36)\nelseif qbsguid ~= \"\" then\nqbsprofile = string.sub(line, 10, 29)\nbreak\nend\nend\nend\nbreak\nend\nio.close(file)\nend\n_p(3, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.Id\">{%s}</value>', qbsguid)\n_p(3, '<value type=\"int\" key=\"ProjectExplorer.Target.ActiveBuildConfiguration\">0</value>')\n_p(3, '<value type=\"int\" key=\"ProjectExplorer.Target.ActiveDeployConfiguration\">0</value>')\n_p(3, '<value type=\"int\" key=\"ProjectExplorer.Target.ActiveRunConfiguration\">%d</value>', startProject)\nidx = 0\nfor _, cfgname in ipairs(sln.configurations) do\n_p(3, '<valuemap type=\"QVariantMap\" key=\"ProjectExplorer.Target.BuildConfiguration.%d\">', idx)\n_p(4, '<value type" "=\"QString\" key=\"ProjectExplorer.BuildConfiguration.BuildDirectory\">build</value>')\n_p(4, '<valuemap type=\"QVariantMap\" key=\"ProjectExplorer.BuildConfiguration.BuildStepList.0\">')\n_p(5, '<valuemap type=\"QVariantMap\" key=\"ProjectExplorer.BuildStepList.Step.0\">')\n_p(6, '<value type=\"bool\" key=\"ProjectExplorer.BuildStep.Enabled\">true</value>')\n_p(6, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DefaultDisplayName\"></value>')\n_p(6, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DisplayName\">Qbs Build</value>')\n_p(6, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.Id\">Qbs.BuildStep</value>')\n_p(6, '<value type=\"bool\" key=\"Qbs.CleanInstallRoot\">false</value>')\n_p(6, '<valuemap type=\"QVariantMap\" key=\"Qbs.Configuration\">')\n_p(7, '<value type=\"QString\" key=\"qbs.buildVariant\">%s</value>', cfgname:lower())\n_p(7, '<value type=\"QString\" key=\"qbs.profile\">%s</value>', qbsprofile)\n_p(6, '</valuemap>')\n_p(5, '</valuem" "ap>')\n_p(5, '<value type=\"int\" key=\"ProjectExplorer.BuildStepList.StepsCount\">1</value>')\n_p(5, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DefaultDisplayName\">Build</value>')\n_p(5, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DisplayName\"></value>')\n_p(5, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.Id\">ProjectExplorer.BuildSteps.Build</value>')\n_p(4, '</valuemap>')\n_p(4, '<valuemap type=\"QVariantMap\" key=\"ProjectExplorer.BuildConfiguration.BuildStepList.1\">')\n_p(5, '<valuemap type=\"QVariantMap\" key=\"ProjectExplorer.BuildStepList.Step.0\">')\n_p(6, '<value type=\"bool\" key=\"ProjectExplorer.BuildStep.Enabled\">true</value>')\n_p(6, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DefaultDisplayName\"></value>')\n_p(6, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DisplayName\">Qbs Clean</value>')\n_p(6, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.Id\">Qbs" ".CleanStep</value>')\n_p(6, '<value type=\"bool\" key=\"Qbs.CleanAll\">true</value>')\n_p(6, '<value type=\"bool\" key=\"Qbs.DryKeepGoing\">false</value>')\n_p(6, '<value type=\"bool\" key=\"Qbs.DryRun\">false</value>')\n_p(5, '</valuemap>')\n_p(5, '<value type=\"int\" key=\"ProjectExplorer.BuildStepList.StepsCount\">1</value>')\n_p(5, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DefaultDisplayName\">Clean</value>')\n_p(5, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DisplayName\"></value>')\n_p(5, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.Id\">ProjectExplorer.BuildSteps.Clean</value>')\n_p(4, '</valuemap>')\n_p(4, '<value type=\"int\" key=\"ProjectExplorer.BuildConfiguration.BuildStepListCount\">2</value>')\n_p(4, '<value type=\"bool\" key=\"ProjectExplorer.BuildConfiguration.ClearSystemEnvironment\">false</value>')\n_p(4, '<valuelist type=\"QVariantList\" key=\"ProjectExplorer.BuildConfiguration.UserEnvironmentChanges\"/>')\n_p(4, '<valu" "e type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DefaultDisplayName\">%s</value>', cfgname)\n_p(4, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DisplayName\"></value>')\n_p(4, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.Id\">Qbs.QbsBuildConfiguration</value>')\n_p(3, '</valuemap>')\nidx = idx + 1\nend\n_p(3, '<value type=\"int\" key=\"ProjectExplorer.Target.BuildConfigurationCount\">%d</value>', idx)\n_p(3, '<valuemap type=\"QVariantMap\" key=\"ProjectExplorer.Target.DeployConfiguration.0\">')\n_p(4, '<valuemap type=\"QVariantMap\" key=\"ProjectExplorer.BuildConfiguration.BuildStepList.0\">')\n_p(5, '<value type=\"int\" key=\"ProjectExplorer.BuildStepList.StepsCount\">0</value>')\n_p(5, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DefaultDisplayName\">Deploy</value>')\n_p(5, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DisplayName\"></value>')\n_p(5, '<value type=\"QString\" key=\"ProjectExplorer.ProjectCo" "nfiguration.Id\">ProjectExplorer.BuildSteps.Deploy</value>')\n_p(4, '</valuemap>')\n_p(4, '<value type=\"int\" key=\"ProjectExplorer.BuildConfiguration.BuildStepListCount\">1</value>')\n_p(4, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DefaultDisplayName\">Deploy locally</value>')\n_p(4, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DisplayName\">Qbs Install</value>')\n_p(4, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.Id\">Qbs.Deploy</value>')\n_p(3, '</valuemap>')\n_p(3, '<value type=\"int\" key=\"ProjectExplorer.Target.DeployConfigurationCount\">1</value>')\nidx = 0\nfor prj in premake.solution.eachproject(sln) do\nif is_app(prj.kind) then\n_p(3, '<valuemap type=\"QVariantMap\" key=\"ProjectExplorer.Target.RunConfiguration.%d\">', idx)\nif idx == startProject then\n_p(4, '<value type=\"int\" key=\"PE.EnvironmentAspect.Base\">2</value>')\nelse\n_p(4, '<value type=\"int\" key=\"PE.EnvironmentAspect.Base\">-1</value>')\nend\n_p(4, '<valuelist" " type=\"QVariantList\" key=\"PE.EnvironmentAspect.Changes\"/>')\n_p(4, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DefaultDisplayName\">%s</value>', prj.name)\n_p(4, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.DisplayName\"></value>')\n_p(4, '<value type=\"QString\" key=\"ProjectExplorer.ProjectConfiguration.Id\">Qbs.RunConfiguration:%s.%s---Qbs.RC.NameSeparator---%s</value>', prj.name, qbsprofile, prj.name)\n_p(4, '<value type=\"QString\" key=\"Qbs.RunConfiguration.CommandLineArguments\"></value>')\nlocal cfg = premake.getconfig(prj, nil, nil)\nif cfg.debugdir ~= nil then\n_p(4, '<value type=\"QString\" key=\"Qbs.RunConfiguration.WorkingDirectory\">%s</value>', cfg.debugdir)\nelse\n_p(4, '<value type=\"QString\" key=\"Qbs.RunConfiguration.WorkingDirectory\"></value>')\nend\n_p(3, '</valuemap>')\nidx = idx + 1\nend\nend\n_p(3, '<value type=\"int\" key=\"ProjectExplorer.Target.RunConfigurationCount\">%d</value>', idx)\n_p(2, '</valuemap>')\n_p(1, '</data>')\n_p(1," " '<data>')\n_p(2, '<variable>ProjectExplorer.Project.TargetCount</variable>')\n_p(2, '<value type=\"int\">1</value>')\n_p(1, '</data>')\n_p(1, '<data>')\n_p(2, '<variable>Version</variable>')\n_p(2, '<value type=\"int\">18</value>')\n_p(1, '</data>')\n_p(0, '</qtcreator>')\nend\n", /* actions/qbs/qbs_cpp.lua */ "local qbs = premake.qbs\nlocal function is_excluded(prj, cfg, file)\nif table.icontains(prj.excludes, file) then\nreturn true\nend\nif table.icontains(cfg.excludes, file) then\nreturn true\nend\nreturn false\nend\nfunction qbs.generate_project(prj)\nlocal indent = 0\n_p(indent, '/*')\n_p(indent, ' * QBS project file autogenerated by GENie')\n_p(indent, ' * https://github.com/bkaradzic/GENie')\n_p(indent, ' */')\n_p(indent, '')\n_p(indent, 'import qbs 1.0')\n_p(indent, '')\nif prj.kind == \"ConsoleApp\" then\n_p(indent, 'CppApplication {')\n_p(indent + 1, 'consoleApplication: true')\nelseif prj.kind == \"WindowedApp\" then\n_p(indent, 'CppApplication {')\n_p(indent + 1, 'consoleApplication: false')\nelseif prj.kind == \"StaticLib\" then\n_p(indent, 'StaticLibrary {')\nelseif prj.kind == \"SharedLib\" then\n_p(indent, 'DynamicLibrary {')\nend\nindent = indent + 1\n_p(indent, 'name: \"' .. prj.name .. '\"')\n_p(indent, 'Depends { name: \"cpp\" }')\nlocal deps = premake.getdependencies(prj)\nif #deps > 0 then\nfor" " _, depprj in ipairs(deps) do\n_p(indent, 'Depends { name: \"%s\" }', depprj.name)\nend\nend\nlocal cc = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\nif cfg.platform ~= \"Native\" then\n_p('');\n_p(indent, 'Properties { /* %s */', premake.getconfigname(cfg.name, cfg.platform, true))\nindent = indent + 1\nlocal arch = \"\"\nlocal linkerFlags = cfg.linkoptions\nif cfg.platform == \"x32\" then\narch = '&& qbs.architecture == \"x86\"'\nelseif cfg.platform == \"x64\" then\narch = '&& qbs.architecture == \"x86_64\"'\nend\nif cfg.name == \"Debug\" then\n_p(indent, 'condition: qbs.buildVariant == \"debug\" %s', arch)\nelse\n_p(indent, 'condition: qbs.buildVariant == \"release\" %s', arch)\nend\n_p(indent, 'targetName: \"%s\"', cfg.buildtarget.basename)\n_p(indent, 'destinationDirectory: \"%s\"', path.getabsolute('projects/qbs/' .. cfg.buildtarget.directory) .. '/')\nif c" "fg.flags.Cpp11 then\n_p(indent, 'cpp.cxxLanguageVersion: \"c++11\"')\nelseif cfg.flags.Cpp14 then\n_p(indent, 'cpp.cxxLanguageVersion: \"c++14\"')\nelseif cfg.flags.Cpp17 then\n_p(indent, 'cpp.cxxLanguageVersion: \"c++17\"')\nelse\n_p(indent, 'cpp.cxxLanguageVersion: \"c++98\"')\nend\nif os.is(\"windows\") then\nif not cfg.flags.WinMain and (cfg.kind == 'ConsoleApp' or cfg.kind == 'WindowedApp') then\nif cfg.flags.Unicode then\n_p(indent, 'cpp.entryPoint: \"wmainCRTStartup\"')\nelse\n_p(indent, 'cpp.entryPoint: \"mainCRTStartup\"')\nend\nend\nend\nqbs.list(\n indent\n, \"cpp.commonCompilerFlags\"\n, cfg.buildoptions\n)\nqbs.list(\n indent\n, \"cpp.cFlags\"\n, cfg.buildoptions_c\n)\nqbs.list(\n indent\n, \"cpp.cxxFlags\"\n, cfg.buildoptions_cpp\n)\nqbs.list(\n indent\n, \"cpp.objcFlags\"\n, cfg.buildoptions_objc\n)\nqbs.list(\n indent\n, \"cpp.objcxxFlags\"\n, cfg.buildoptions_objc\n)\nif cfg.flags.StaticRuntime then\n_p(indent, 'cpp.runtimeLibrary: \"static\"')\nelse\n_p(indent, 'cpp.runtimeLibrary: \"dyn" "amic\"')\nend\nif cfg.flags.PedanticWarnings\nor cfg.flags.ExtraWarnings\nthen\n_p(indent, 'cpp.warningLevel: \"all\"')\nelse\n_p(indent, 'cpp.warningLevel: \"default\"')\nend\nif cfg.flags.FatalWarnings then\n_p(indent, 'cpp.treatWarningsAsErrors: true')\nelse\n_p(indent, 'cpp.treatWarningsAsErrors: false')\nend\nif cfg.flags.NoRTTI then\n_p(indent, 'cpp.enableRtti: false')\nelse\n_p(indent, 'cpp.enableRtti: true')\nend\nif cfg.flags.NoExceptions then\n_p(indent, 'cpp.enableExceptions: false')\nelse\n_p(indent, 'cpp.enableExceptions: true')\nend\nif cfg.flags.Symbols then\n_p(indent, 'cpp.debugInformation: true')\nelse\n_p(indent, 'cpp.debugInformation: false')\nend\nif cfg.flags.Unicode then\n_p(indent, 'cpp.windowsApiCharacterSet: \"unicode\"')\nelse\n_p(indent, 'cpp.windowsApiCharacterSet: \"\"')\nend\nif not cfg.pchheader or cfg.flags.NoPCH then\n_p(indent, 'cpp.usePrecompiledHeader: false')\nelse\n_p(indent, 'cpp.usePrecompiledHeader: true')\n_p(indent, 'Group {')\n_p(indent+1, 'name: \"PCH\"')\n_p(inden" "t+1, 'files: [\"' .. cfg.pchheader .. '\"]')\n_p(indent+1, 'fileTags: [\"cpp_pch_src\"]')\n_p(indent, '}')\nend\nfor _, value in ipairs(cfg.flags) do\nif (value == \"Optimize\") then\nelseif (value == \"OptimizeSize\") then\n_p(indent, 'cpp.optimization: \"small\"')\nelseif (value == \"OptimizeSpeed\") then\n_p(indent, 'cpp.optimization: \"fast\"')\nend\nend\nqbs.list(\n indent\n, \"cpp.defines\"\n, cfg.defines\n)\nlocal sortedincdirs = table.join(cfg.userincludedirs, cfg.includedirs, cfg.systemincludedirs)\ntable.sort(sortedincdirs, includesort)\nqbs.list(\n indent\n, \"cpp.includePaths\"\n, sortedincdirs\n)\nqbs.list(\n indent\n, \"cpp.staticLibraries\"\n, premake.getlinks(cfg, \"system\", \"fullpath\")\n)\nqbs.list(\n indent\n, \"cpp.libraryPaths\"\n, cfg.libdirs\n)\nqbs.list(\n indent\n, \"cpp.linkerFlags\"\n, linkerFlags\n)\ntable.sort(prj.files)\nif #prj.files > 0 then\n_p(indent, 'files: [')\nfor _, file in ipairs(prj.files) do\nif path.iscfile(file)\nor path.iscppfile(file)\nor path.isobjcfile(fil" "e)\nor path.isresourcefile(file)\nor path.iscppheader(file) then\nif not is_excluded(prj, cfg, file) then\n_p(indent+1, '\"%s\",', file)\nend\nend\nend\n_p(indent+1, ']')\nend\nif #prj.excludes > 0 then\n_p(indent, 'excludeFiles: [')\ntable.sort(prj.excludes)\nfor _, file in ipairs(prj.excludes) do\nif path.issourcefile(file) then\n_p(indent+1, '\"%s\",', file)\nend\nend\n_p(indent+1, ']')\nend\nindent = indent - 1\n_p(indent, '}');\nend\nend\nend\nindent = indent - 1\n_p(indent, '}')\nend\n", /* actions/jcdb/_jcdb.lua */ "newaction {\ntrigger = \"jcdb\",\nshortname = \"compile_commands.json\",\ndescription = \"Generate a compile_commands.json file.\",\nvalid_kinds = { \"ConsoleApp\", \"WindowedApp\", \"StaticLib\", \"SharedLib\", \"Bundle\" },\nvalid_languages = { \"C\", \"C++\" },\nvalid_tools = { cc = { \"gcc\" } },\nonsolution = function(sln)\nlocal jsonpath = path.join(sln.location, \"compile_commands.json\")\npremake.generate(sln, jsonpath, premake.jcdb.generate)\nend,\n}\n", /* actions/jcdb/jcdb_solution.lua */ "premake.jcdb = {}\nlocal premake = premake\nlocal jcdb = premake.jcdb\nlocal encode_chars = {\n[0x22] = '\\\\\"',\n[0x5c] = \"\\\\\\\\\",\n[0x08] = \"\\\\b\",\n[0x0c] = \"\\\\f\",\n[0x0a] = \"\\\\n\",\n[0x0d] = \"\\\\r\",\n[0x09] = \"\\\\t\",\n}\nlocal function encode_string(s)\nlocal res = '\"'\nfor _, cp in utf8.codes(s) do\nif encode_chars[cp] then\nres = res..encode_chars[cp]\nelseif cp < 32 then\nres = res..string.format(\"\\\\u%04x\", cp)\nelse\nres = res..utf8.char(cp)\nend\nend\nreturn res..'\"'\nend\nlocal function escape_cmdline_arg(s)\nif s:find(\"%s\") then\ns = s:gsub(\"\\\\\", \"\\\\\\\\\")\ns = s:gsub('\"', '\\\\\"')\ns = '\"'..s..'\"'\nend\nreturn s\nend\nlocal function list(tbl)\nreturn iif(#tbl > 0, \" \"..table.concat(tbl, \" \"), \"\")\nend\nlocal function build_command(cfg, cc, file)\nlocal cmdline = \"\"\nlocal function app(s) cmdline = cmdline..s end\nif path.iscfile(file) or path.isasmfile(file) then\napp(cc.cc)\nelse\napp(cc.cxx)\nend\napp(list(cc.getcppflags(cfg)))\napp(list(cc.getdef" "ines(cfg.defines)))\napp(list(cc.getincludedirs(cfg.includedirs)))\napp(list(cc.getquoteincludedirs(cfg.userincludedirs)))\napp(list(cc.getsystemincludedirs(cfg.systemincludedirs)))\napp(list(cc.getcflags(cfg)))\nif path.iscppfile(file) then\napp(list(cc.getcxxflags(cfg)))\nend\nif path.isasmfile(file) then\napp(list(cfg.buildoptions))\napp(list(cfg.buildoptions_asm))\nelseif path.isobjcfile(file) then\nlocal opts = iif(path.iscfile(file), cfg.buildoptions_objc, cfg.buildoptions_objcpp)\napp(list(cc.getobjcflags(cfg)))\napp(list(cfg.buildoptions))\napp(list(opts))\nelseif path.iscfile(file) then\napp(list(cfg.buildoptions))\napp(list(cfg.buildoptions_c))\nelse\napp(list(cfg.buildoptions))\napp(list(cfg.buildoptions_cpp))\nend\nif cfg.pchheader and not cfg.flags.NoPCH then\napp(\" -include \")\napp(escape_cmdline_arg(cfg.pchheader))\nend\nfor _, i in ipairs(cfg.forcedincludes) do\napp(\" -include \")\napp(escape_cmdline_arg(i))\nend\nlocal base = path.trimdots(path.removeext(file))..\".o\"\nlocal output = path." "join(cfg.objectsdir, base)\napp(\" -o \")\napp(escape_cmdline_arg(output))\napp(\" -c \")\napp(escape_cmdline_arg(file))\nreturn cmdline\nend\nfunction jcdb.generate_config(prj, cfg, cc)\ntable.sort(cfg.files)\nlocal directory = path.getabsolute(prj.location)\nfor _, file in ipairs(cfg.files) do\nif path.iscppfile(file) or path.isasmfile(file) then\n_p(' { \"directory\": %s,', encode_string(directory))\n_p(' \"command\": %s,', encode_string(build_command(cfg, cc, file)))\n_p(' \"file\": %s },', encode_string(file))\nend\nend\nend\nfunction jcdb.generate_project(prj)\nlocal cc = premake.gettool(prj)\nlocal platforms = premake.filterplatforms(prj.solution, cc.platforms, \"Native\")\nfor _, platform in ipairs(platforms) do\nfor cfg in premake.eachconfig(prj, platform) do\njcdb.generate_config(prj, cfg, cc)\nend\nend\nend\nfunction jcdb.generate(sln)\nfor _, prj in ipairs(sln.projects) do\njcdb.generate_project(prj)\nend\nio.captured = io.captured:gsub(\",%s$\", \"\")\nio.captured = \"[\"..io.eol..io.captur" "ed..io.eol..\"]\"\nend\n", /* _premake_main.lua */ "_WORKING_DIR = os.getcwd()\nlocal function injectplatform(platform)\nif not platform then return true end\nplatform = premake.checkvalue(platform, premake.fields.platforms.allowed)\nfor sln in premake.solution.each() do\nlocal platforms = sln.platforms or { }\nif #platforms == 0 then\ntable.insert(platforms, \"Native\")\nend\nif not table.contains(platforms, \"Native\") then\nreturn false, sln.name .. \" does not target native platform\\nNative platform settings are required for the --platform feature.\"\nend\nif not table.contains(platforms, platform) then\ntable.insert(platforms, platform)\nend\nsln.platforms = platforms\nend\nreturn true\nend\nfunction _premake_main(scriptpath)\nif (scriptpath) then\nlocal scripts = dofile(scriptpath .. \"/_manifest.lua\")\nfor _,v in ipairs(scripts) do\ndofile(scriptpath .. \"/\" .. v)\nend\nend\nlocal profiler = newProfiler()\nif (nil ~= _OPTIONS[\"debug-profiler\"]) then\nprofiler:start()\nend\n_PREMAKE_COMMAND = path.getabsolute(_PREMAKE_COMMAND)\npremake.action" ".set(_ACTION)\nmath.randomseed(os.time())\nif (nil ~= _OPTIONS[\"file\"]) then\nlocal fname = _OPTIONS[\"file\"]\nif (os.isfile(fname)) then\ndofile(fname)\nelse\nerror(\"No genie script '\" .. fname .. \"' found!\", 2)\nend\nelse\nlocal dir, name = premake.findDefaultScript(path.getabsolute(\"./\"))\nif dir ~= nil then\nlocal cwd = os.getcwd()\nos.chdir(dir)\ndofile(name)\nos.chdir(cwd)\nend\nend\nif (_OPTIONS[\"version\"] or _OPTIONS[\"help\"] or not _ACTION) then\nprintf(\"GENie - Project generator tool %s\", _GENIE_VERSION_STR)\nprintf(\"https://github.com/bkaradzic/GENie\")\nif (not _OPTIONS[\"version\"]) then\npremake.showhelp()\nend\nreturn 1\nend\naction = premake.action.current()\nif (not action) then\nerror(\"Error: no such action '\" .. _ACTION .. \"'\", 0)\nend\nok, err = premake.option.validate(_OPTIONS)\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = premake.checktools()\nif (not ok) then error(\"Error: \" .. err, 0) end\nok, err = injectplatform(_OPTIONS[\"platform\"])\nif (not ok)" " then error(\"Error: \" .. err, 0) end\nprint(\"Building configurations...\")\npremake.bake.buildconfigs()\nok, err = premake.checkprojects()\nif (not ok) then error(\"Error: \" .. err, 0) end\npremake.stats = { }\npremake.stats.num_generated = 0\npremake.stats.num_skipped = 0\nprintf(\"Running action '%s'...\", action.trigger)\npremake.action.call(action.trigger)\nif (nil ~= _OPTIONS[\"debug-profiler\"]) then\nprofiler:stop()\nlocal filePath = path.getabsolute(\"GENie-profile.txt\")\nprint(\"Writing debug-profile report to ''\" .. filePath .. \"'.\")\nlocal outfile = io.open(filePath, \"w+\")\nprofiler:report(outfile, true)\noutfile:close()\nend\nprintf(\"Done. Generated %d/%d projects.\"\n, premake.stats.num_generated\n, premake.stats.num_generated+premake.stats.num_skipped\n)\nreturn 0\nend\n", 0 };
the_stack_data/12233.c
#include <sys/ioctl.h> #include <termios.h> #include <unistd.h> int tcsetpgrp(int fd, pid_t pgrp) { int pgrp_int = pgrp; return ioctl(fd, TIOCSPGRP, &pgrp_int); }
the_stack_data/493353.c
/* * Returns the number of * non-NULL bytes in string argument. */ strlen(s) register char *s; { register n; n = 0; while (*s++) n++; return(n); }
the_stack_data/159515656.c
// WARNING: bad unlock balance in __dev_queue_xmit // https://syzkaller.appspot.com/bug?id=c518a21747ead1f6e728fdef27f5f6d3d03900ab // status:dup // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <dirent.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <sched.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> #include <time.h> #include <unistd.h> #include <linux/capability.h> #include <linux/genetlink.h> #include <linux/if_addr.h> #include <linux/if_ether.h> #include <linux/if_link.h> #include <linux/if_tun.h> #include <linux/in6.h> #include <linux/ip.h> #include <linux/neighbour.h> #include <linux/net.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <linux/tcp.h> #include <linux/veth.h> unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[1024]; }; static struct nlmsg nlmsg; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(struct nlmsg* nlmsg, int typ) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_type = typ; nlmsg->pos += sizeof(*attr); nlmsg->nested[nlmsg->nesting++] = attr; } static void netlink_done(struct nlmsg* nlmsg) { struct nlattr* attr = nlmsg->nested[--nlmsg->nesting]; attr->nla_len = nlmsg->pos - (char*)attr; } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; unsigned n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != hdr->nlmsg_len) exit(1); n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (hdr->nlmsg_type == NLMSG_DONE) { *reply_len = 0; return 0; } if (n < sizeof(struct nlmsghdr)) exit(1); if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr)) exit(1); if (hdr->nlmsg_type != NLMSG_ERROR) exit(1); return -((struct nlmsgerr*)(hdr + 1))->error; } static int netlink_send(struct nlmsg* nlmsg, int sock) { return netlink_send_ext(nlmsg, sock, 0, NULL); } static int netlink_next_msg(struct nlmsg* nlmsg, unsigned int offset, unsigned int total_len) { struct nlmsghdr* hdr = (struct nlmsghdr*)(nlmsg->buf + offset); if (offset == total_len || offset + hdr->nlmsg_len > total_len) return -1; return hdr->nlmsg_len; } static void netlink_add_device_impl(struct nlmsg* nlmsg, const char* type, const char* name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); netlink_init(nlmsg, RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(nlmsg, IFLA_IFNAME, name, strlen(name)); netlink_nest(nlmsg, IFLA_LINKINFO); netlink_attr(nlmsg, IFLA_INFO_KIND, type, strlen(type)); } static void netlink_add_device(struct nlmsg* nlmsg, int sock, const char* type, const char* name) { netlink_add_device_impl(nlmsg, type, name); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_veth(struct nlmsg* nlmsg, int sock, const char* name, const char* peer) { netlink_add_device_impl(nlmsg, "veth", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_nest(nlmsg, VETH_INFO_PEER); nlmsg->pos += sizeof(struct ifinfomsg); netlink_attr(nlmsg, IFLA_IFNAME, peer, strlen(peer)); netlink_done(nlmsg); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_hsr(struct nlmsg* nlmsg, int sock, const char* name, const char* slave1, const char* slave2) { netlink_add_device_impl(nlmsg, "hsr", name); netlink_nest(nlmsg, IFLA_INFO_DATA); int ifindex1 = if_nametoindex(slave1); netlink_attr(nlmsg, IFLA_HSR_SLAVE1, &ifindex1, sizeof(ifindex1)); int ifindex2 = if_nametoindex(slave2); netlink_attr(nlmsg, IFLA_HSR_SLAVE2, &ifindex2, sizeof(ifindex2)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_virt_wifi(struct nlmsg* nlmsg, int sock, const char* name, const char* link) { netlink_add_device_impl(nlmsg, "virt_wifi", name); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_vlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t id, uint16_t proto) { netlink_add_device_impl(nlmsg, "vlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_VLAN_ID, &id, sizeof(id)); netlink_attr(nlmsg, IFLA_VLAN_PROTOCOL, &proto, sizeof(proto)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_macvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link) { netlink_add_device_impl(nlmsg, "macvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); uint32_t mode = MACVLAN_MODE_BRIDGE; netlink_attr(nlmsg, IFLA_MACVLAN_MODE, &mode, sizeof(mode)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } #define IFLA_IPVLAN_FLAGS 2 #define IPVLAN_MODE_L3S 2 #undef IPVLAN_F_VEPA #define IPVLAN_F_VEPA 2 static void netlink_add_ipvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t mode, uint16_t flags) { netlink_add_device_impl(nlmsg, "ipvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_IPVLAN_MODE, &mode, sizeof(mode)); netlink_attr(nlmsg, IFLA_IPVLAN_FLAGS, &flags, sizeof(flags)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_device_change(struct nlmsg* nlmsg, int sock, const char* name, bool up, const char* master, const void* mac, int macsize, const char* new_name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; hdr.ifi_index = if_nametoindex(name); netlink_init(nlmsg, RTM_NEWLINK, 0, &hdr, sizeof(hdr)); if (new_name) netlink_attr(nlmsg, IFLA_IFNAME, new_name, strlen(new_name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(nlmsg, IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(nlmsg, IFLA_ADDRESS, mac, macsize); int err = netlink_send(nlmsg, sock); (void)err; } static int netlink_add_addr(struct nlmsg* nlmsg, int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(nlmsg, RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, IFA_LOCAL, addr, addrsize); netlink_attr(nlmsg, IFA_ADDRESS, addr, addrsize); return netlink_send(nlmsg, sock); } static void netlink_add_addr4(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in_addr, sizeof(in_addr)); (void)err; } static void netlink_add_addr6(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in6_addr, sizeof(in6_addr)); (void)err; } static void netlink_add_neigh(struct nlmsg* nlmsg, int sock, const char* name, const void* addr, int addrsize, const void* mac, int macsize) { struct ndmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ndm_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ndm_ifindex = if_nametoindex(name); hdr.ndm_state = NUD_PERMANENT; netlink_init(nlmsg, RTM_NEWNEIGH, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, NDA_DST, addr, addrsize); netlink_attr(nlmsg, NDA_LLADDR, mac, macsize); int err = netlink_send(nlmsg, sock); (void)err; } static int tunfd = -1; static int tun_frags_enabled; #define TUN_IFACE "syz_tun" #define LOCAL_MAC 0xaaaaaaaaaaaa #define REMOTE_MAC 0xaaaaaaaaaabb #define LOCAL_IPV4 "172.20.20.170" #define REMOTE_IPV4 "172.20.20.187" #define LOCAL_IPV6 "fe80::aa" #define REMOTE_IPV6 "fe80::bb" #define IFF_NAPI 0x0010 #define IFF_NAPI_FRAGS 0x0020 static void initialize_tun(void) { tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); printf("otherwise fuzzing or reproducing might not work as intended\n"); return; } const int kTunFd = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); close(tunfd); tunfd = kTunFd; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, TUN_IFACE, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_NAPI | IFF_NAPI_FRAGS; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) exit(1); } if (ioctl(tunfd, TUNGETIFF, (void*)&ifr) < 0) exit(1); tun_frags_enabled = (ifr.ifr_flags & IFF_NAPI_FRAGS) != 0; char sysctl[64]; sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/accept_dad", TUN_IFACE); write_file(sysctl, "0"); sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/router_solicitations", TUN_IFACE); write_file(sysctl, "0"); int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); netlink_add_addr4(&nlmsg, sock, TUN_IFACE, LOCAL_IPV4); netlink_add_addr6(&nlmsg, sock, TUN_IFACE, LOCAL_IPV6); uint64_t macaddr = REMOTE_MAC; struct in_addr in_addr; inet_pton(AF_INET, REMOTE_IPV4, &in_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in_addr, sizeof(in_addr), &macaddr, ETH_ALEN); struct in6_addr in6_addr; inet_pton(AF_INET6, REMOTE_IPV6, &in6_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in6_addr, sizeof(in6_addr), &macaddr, ETH_ALEN); macaddr = LOCAL_MAC; netlink_device_change(&nlmsg, sock, TUN_IFACE, true, 0, &macaddr, ETH_ALEN, NULL); close(sock); } const int kInitNetNsFd = 239; #define DEVLINK_FAMILY_NAME "devlink" #define DEVLINK_CMD_PORT_GET 5 #define DEVLINK_CMD_RELOAD 37 #define DEVLINK_ATTR_BUS_NAME 1 #define DEVLINK_ATTR_DEV_NAME 2 #define DEVLINK_ATTR_NETDEV_NAME 7 #define DEVLINK_ATTR_NETNS_FD 138 static int netlink_devlink_id_get(struct nlmsg* nlmsg, int sock) { struct genlmsghdr genlhdr; struct nlattr* attr; int err, n; uint16_t id = 0; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, DEVLINK_FAMILY_NAME, strlen(DEVLINK_FAMILY_NAME) + 1); err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n); if (err) { return -1; } attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); /* recv ack */ return id; } static void netlink_devlink_netns_move(const char* bus_name, const char* dev_name, int netns_fd) { struct genlmsghdr genlhdr; int sock; int id, err; sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) exit(1); id = netlink_devlink_id_get(&nlmsg, sock); if (id == -1) goto error; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = DEVLINK_CMD_RELOAD; netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, DEVLINK_ATTR_BUS_NAME, bus_name, strlen(bus_name) + 1); netlink_attr(&nlmsg, DEVLINK_ATTR_DEV_NAME, dev_name, strlen(dev_name) + 1); netlink_attr(&nlmsg, DEVLINK_ATTR_NETNS_FD, &netns_fd, sizeof(netns_fd)); err = netlink_send(&nlmsg, sock); if (err) { } error: close(sock); } static struct nlmsg nlmsg2; static void initialize_devlink_ports(const char* bus_name, const char* dev_name, const char* netdev_prefix) { struct genlmsghdr genlhdr; int len, total_len, id, err, offset; uint16_t netdev_index; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) exit(1); int rtsock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rtsock == -1) exit(1); id = netlink_devlink_id_get(&nlmsg, sock); if (id == -1) goto error; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = DEVLINK_CMD_PORT_GET; netlink_init(&nlmsg, id, NLM_F_DUMP, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, DEVLINK_ATTR_BUS_NAME, bus_name, strlen(bus_name) + 1); netlink_attr(&nlmsg, DEVLINK_ATTR_DEV_NAME, dev_name, strlen(dev_name) + 1); err = netlink_send_ext(&nlmsg, sock, id, &total_len); if (err) { goto error; } offset = 0; netdev_index = 0; while ((len = netlink_next_msg(&nlmsg, offset, total_len)) != -1) { struct nlattr* attr = (struct nlattr*)(nlmsg.buf + offset + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg.buf + offset + len; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == DEVLINK_ATTR_NETDEV_NAME) { char* port_name; char netdev_name[IFNAMSIZ]; port_name = (char*)(attr + 1); snprintf(netdev_name, sizeof(netdev_name), "%s%d", netdev_prefix, netdev_index); netlink_device_change(&nlmsg2, rtsock, port_name, true, 0, 0, 0, netdev_name); break; } } offset += len; netdev_index++; } error: close(rtsock); close(sock); } static void initialize_devlink_pci(void) { int netns = open("/proc/self/ns/net", O_RDONLY); if (netns == -1) exit(1); int ret = setns(kInitNetNsFd, 0); if (ret == -1) exit(1); netlink_devlink_netns_move("pci", "0000:00:10.0", netns); ret = setns(netns, 0); if (ret == -1) exit(1); close(netns); initialize_devlink_ports("pci", "0000:00:10.0", "netpci"); } #define DEV_IPV4 "172.20.20.%d" #define DEV_IPV6 "fe80::%02x" #define DEV_MAC 0x00aaaaaaaaaa static void netdevsim_add(unsigned int addr, unsigned int port_count) { char buf[16]; sprintf(buf, "%u %u", addr, port_count); if (write_file("/sys/bus/netdevsim/new_device", buf)) { snprintf(buf, sizeof(buf), "netdevsim%d", addr); initialize_devlink_ports("netdevsim", buf, "netdevsim"); } } static void initialize_netdevices(void) { char netdevsim[16]; sprintf(netdevsim, "netdevsim%d", (int)procid); struct { const char* type; const char* dev; } devtypes[] = { {"ip6gretap", "ip6gretap0"}, {"bridge", "bridge0"}, {"vcan", "vcan0"}, {"bond", "bond0"}, {"team", "team0"}, {"dummy", "dummy0"}, {"nlmon", "nlmon0"}, {"caif", "caif0"}, {"batadv", "batadv0"}, {"vxcan", "vxcan1"}, {"netdevsim", netdevsim}, {"veth", 0}, {"xfrm", "xfrm0"}, }; const char* devmasters[] = {"bridge", "bond", "team"}; struct { const char* name; int macsize; bool noipv6; } devices[] = { {"lo", ETH_ALEN}, {"sit0", 0}, {"bridge0", ETH_ALEN}, {"vcan0", 0, true}, {"tunl0", 0}, {"gre0", 0}, {"gretap0", ETH_ALEN}, {"ip_vti0", 0}, {"ip6_vti0", 0}, {"ip6tnl0", 0}, {"ip6gre0", 0}, {"ip6gretap0", ETH_ALEN}, {"erspan0", ETH_ALEN}, {"bond0", ETH_ALEN}, {"veth0", ETH_ALEN}, {"veth1", ETH_ALEN}, {"team0", ETH_ALEN}, {"veth0_to_bridge", ETH_ALEN}, {"veth1_to_bridge", ETH_ALEN}, {"veth0_to_bond", ETH_ALEN}, {"veth1_to_bond", ETH_ALEN}, {"veth0_to_team", ETH_ALEN}, {"veth1_to_team", ETH_ALEN}, {"veth0_to_hsr", ETH_ALEN}, {"veth1_to_hsr", ETH_ALEN}, {"hsr0", 0}, {"dummy0", ETH_ALEN}, {"nlmon0", 0}, {"vxcan0", 0, true}, {"vxcan1", 0, true}, {"caif0", ETH_ALEN}, {"batadv0", ETH_ALEN}, {netdevsim, ETH_ALEN}, {"xfrm0", ETH_ALEN}, {"veth0_virt_wifi", ETH_ALEN}, {"veth1_virt_wifi", ETH_ALEN}, {"virt_wifi0", ETH_ALEN}, {"veth0_vlan", ETH_ALEN}, {"veth1_vlan", ETH_ALEN}, {"vlan0", ETH_ALEN}, {"vlan1", ETH_ALEN}, {"macvlan0", ETH_ALEN}, {"macvlan1", ETH_ALEN}, {"ipvlan0", ETH_ALEN}, {"ipvlan1", ETH_ALEN}, }; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) netlink_add_device(&nlmsg, sock, devtypes[i].type, devtypes[i].dev); for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) { char master[32], slave0[32], veth0[32], slave1[32], veth1[32]; sprintf(slave0, "%s_slave_0", devmasters[i]); sprintf(veth0, "veth0_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave0, veth0); sprintf(slave1, "%s_slave_1", devmasters[i]); sprintf(veth1, "veth1_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave1, veth1); sprintf(master, "%s0", devmasters[i]); netlink_device_change(&nlmsg, sock, slave0, false, master, 0, 0, NULL); netlink_device_change(&nlmsg, sock, slave1, false, master, 0, 0, NULL); } netlink_device_change(&nlmsg, sock, "bridge_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "bridge_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "hsr_slave_0", "veth0_to_hsr"); netlink_add_veth(&nlmsg, sock, "hsr_slave_1", "veth1_to_hsr"); netlink_add_hsr(&nlmsg, sock, "hsr0", "hsr_slave_0", "hsr_slave_1"); netlink_device_change(&nlmsg, sock, "hsr_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "hsr_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "veth0_virt_wifi", "veth1_virt_wifi"); netlink_add_virt_wifi(&nlmsg, sock, "virt_wifi0", "veth1_virt_wifi"); netlink_add_veth(&nlmsg, sock, "veth0_vlan", "veth1_vlan"); netlink_add_vlan(&nlmsg, sock, "vlan0", "veth0_vlan", 0, htons(ETH_P_8021Q)); netlink_add_vlan(&nlmsg, sock, "vlan1", "veth0_vlan", 1, htons(ETH_P_8021AD)); netlink_add_macvlan(&nlmsg, sock, "macvlan0", "veth1_vlan"); netlink_add_macvlan(&nlmsg, sock, "macvlan1", "veth1_vlan"); netlink_add_ipvlan(&nlmsg, sock, "ipvlan0", "veth0_vlan", IPVLAN_MODE_L2, 0); netlink_add_ipvlan(&nlmsg, sock, "ipvlan1", "veth0_vlan", IPVLAN_MODE_L3S, IPVLAN_F_VEPA); netdevsim_add((int)procid, 4); for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { char addr[32]; sprintf(addr, DEV_IPV4, i + 10); netlink_add_addr4(&nlmsg, sock, devices[i].name, addr); if (!devices[i].noipv6) { sprintf(addr, DEV_IPV6, i + 10); netlink_add_addr6(&nlmsg, sock, devices[i].name, addr); } uint64_t macaddr = DEV_MAC + ((i + 10ull) << 40); netlink_device_change(&nlmsg, sock, devices[i].name, true, 0, &macaddr, devices[i].macsize, NULL); } close(sock); } static void initialize_netdevices_init(void) { int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); struct { const char* type; int macsize; bool noipv6; bool noup; } devtypes[] = { {"nr", 7, true}, {"rose", 5, true, true}, }; unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) { char dev[32], addr[32]; sprintf(dev, "%s%d", devtypes[i].type, (int)procid); sprintf(addr, "172.30.%d.%d", i, (int)procid + 1); netlink_add_addr4(&nlmsg, sock, dev, addr); if (!devtypes[i].noipv6) { sprintf(addr, "fe88::%02x:%02x", i, (int)procid + 1); netlink_add_addr6(&nlmsg, sock, dev, addr); } int macsize = devtypes[i].macsize; uint64_t macaddr = 0xbbbbbb + ((unsigned long long)i << (8 * (macsize - 2))) + (procid << (8 * (macsize - 1))); netlink_device_change(&nlmsg, sock, dev, !devtypes[i].noup, 0, &macaddr, macsize, NULL); } close(sock); } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; if (errno == EBADFD) return -1; exit(1); } return rv; } static void flush_tun() { char data[1000]; while (read_tun(&data[0], sizeof(data)) != -1) { } } #define MAX_FDS 30 static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setsid(); int netns = open("/proc/self/ns/net", O_RDONLY); if (netns == -1) exit(1); if (dup2(netns, kInitNetNsFd) < 0) exit(1); close(netns); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); sandbox_common(); drop_caps(); initialize_netdevices_init(); if (unshare(CLONE_NEWNET)) { } initialize_devlink_pci(); initialize_tun(); initialize_netdevices(); loop(); exit(1); } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); int i; for (i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); flush_tun(); } static void close_fds() { int fd; for (fd = 3; fd < MAX_FDS; fd++) close(fd); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter; for (iter = 0;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); close_fds(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[8] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0}; void execute_one(void) { intptr_t res = 0; syscall(__NR_sendmsg, -1, 0ul, 0x48044ul); memcpy((void*)0x200001c0, "ip6tnl0\000\000\000\000\000\000\000\000\000", 16); *(uint64_t*)0x200001d0 = 0x20000000; *(uint32_t*)0x20000000 = 0; *(uint32_t*)0x20000004 = 0; *(uint32_t*)0x20000008 = 0; *(uint16_t*)0x2000000c = 0; *(uint8_t*)0x2000000e = 0; *(uint8_t*)0x2000000f = 0; *(uint8_t*)0x20000010 = 0; *(uint8_t*)0x20000011 = 0; *(uint8_t*)0x20000012 = 0; *(uint8_t*)0x20000013 = 0; *(uint32_t*)0x20000014 = 0; *(uint32_t*)0x20000018 = 0; *(uint16_t*)0x2000001c = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint32_t*)0x20000020 = 2; *(uint32_t*)0x20000024 = 0; *(uint32_t*)0x20000028 = 0; syscall(__NR_ioctl, -1, 0x89f3ul, 0x200001c0ul); syscall(__NR_socket, 0x10ul, 3ul, 0ul); syscall(__NR_socket, 0x10ul, 3ul, 0ul); syscall(__NR_bind, -1, 0ul, 0ul); res = syscall(__NR_socket, 0x10ul, 3ul, 0ul); if (res != -1) r[0] = res; res = syscall(__NR_socket, 0x10ul, 3ul, 0ul); if (res != -1) r[1] = res; res = syscall(__NR_socket, 0x10ul, 0x803ul, 0); if (res != -1) r[2] = res; *(uint64_t*)0x200001c0 = 0; *(uint32_t*)0x200001c8 = 0; *(uint64_t*)0x200001d0 = 0x20000180; *(uint64_t*)0x20000180 = 0; *(uint64_t*)0x20000188 = 0x3d2; *(uint64_t*)0x200001d8 = 1; *(uint64_t*)0x200001e0 = 0; *(uint64_t*)0x200001e8 = 0; *(uint32_t*)0x200001f0 = 0; syscall(__NR_sendmsg, r[2], 0x200001c0ul, 0ul); *(uint32_t*)0x20000280 = 0x19d; res = syscall(__NR_getsockname, r[2], 0x20000080ul, 0x20000280ul); if (res != -1) r[3] = *(uint32_t*)0x20000084; *(uint64_t*)0x20000180 = 0; *(uint32_t*)0x20000188 = 0; *(uint64_t*)0x20000190 = 0x200000c0; *(uint64_t*)0x200000c0 = 0x20000000; memcpy((void*)0x20000000, "\x34\x00\x00\x00\x10\x00\x01\x04\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00", 20); *(uint32_t*)0x20000014 = r[3]; memcpy((void*)0x20000018, "\x00\x00\x00\x00\x00\x00\x00\x00\x14\x00\x12\x00" "\x0c\x00\x01\x00\x62\x72\x69\x64\x67\x65\x00\x00" "\x00\x02\x00", 27); *(uint64_t*)0x200000c8 = 0x34; *(uint64_t*)0x20000198 = 1; *(uint64_t*)0x200001a0 = 0; *(uint64_t*)0x200001a8 = 0; *(uint32_t*)0x200001b0 = 0; syscall(__NR_sendmsg, r[1], 0x20000180ul, 0ul); res = syscall(__NR_socket, 0x200000000000011ul, 3ul, 0); if (res != -1) r[4] = res; res = syscall(__NR_socket, 0x10ul, 3ul, 0x10ul); if (res != -1) r[5] = res; memcpy((void*)0x200003c0, "netdevsim0\000\000\000\000\000\000", 16); *(uint32_t*)0x200003d0 = 0; res = syscall(__NR_ioctl, r[5], 0x8933ul, 0x200003c0ul); if (res != -1) r[6] = *(uint32_t*)0x200003d0; *(uint16_t*)0x20000240 = 0x11; *(uint16_t*)0x20000242 = htobe16(0); *(uint32_t*)0x20000244 = r[6]; *(uint16_t*)0x20000248 = 1; *(uint8_t*)0x2000024a = 0; *(uint8_t*)0x2000024b = 6; *(uint8_t*)0x2000024c = 0; *(uint8_t*)0x2000024d = 0; *(uint8_t*)0x2000024e = 0; *(uint8_t*)0x2000024f = 0; *(uint8_t*)0x20000250 = 0; *(uint8_t*)0x20000251 = 0; *(uint8_t*)0x20000252 = 0; *(uint8_t*)0x20000253 = 0; syscall(__NR_bind, r[4], 0x20000240ul, 0x14ul); *(uint32_t*)0x20000040 = 0x10eef0f1; res = syscall(__NR_getsockname, r[4], 0x20000500ul, 0x20000040ul); if (res != -1) r[7] = *(uint32_t*)0x20000504; *(uint64_t*)0x20000000 = 0; *(uint32_t*)0x20000008 = 0; *(uint64_t*)0x20000010 = 0x200000c0; *(uint64_t*)0x200000c0 = 0x20002700; *(uint32_t*)0x20002700 = 0x28; *(uint16_t*)0x20002704 = 0x10; *(uint16_t*)0x20002706 = 0x401; *(uint32_t*)0x20002708 = 0; *(uint32_t*)0x2000270c = 0; *(uint8_t*)0x20002710 = 0; *(uint8_t*)0x20002711 = 0; *(uint16_t*)0x20002712 = 0; *(uint32_t*)0x20002714 = r[7]; *(uint32_t*)0x20002718 = 0; *(uint32_t*)0x2000271c = 0; *(uint16_t*)0x20002720 = 8; *(uint16_t*)0x20002722 = 0xa; *(uint32_t*)0x20002724 = r[3]; *(uint64_t*)0x200000c8 = 0x28; *(uint64_t*)0x20000018 = 1; *(uint64_t*)0x20000020 = 0; *(uint64_t*)0x20000028 = 0; *(uint32_t*)0x20000030 = 0; syscall(__NR_sendmsg, r[0], 0x20000000ul, 0ul); syscall(__NR_sendmsg, -1, 0ul, 0ul); syscall(__NR_sendmsg, -1, 0ul, 0ul); syscall(__NR_ioctl, -1, 0x8933ul, 0ul); syscall(__NR_socket, 0x200000000000011ul, 3ul, 0); } int main(void) { syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 3ul, 0x32ul, -1, 0); do_sandbox_none(); return 0; }
the_stack_data/829390.c
enum MyCEnum { MyCVal = 5, MyNextVal = 6 }; struct MyCStruct { int es[2]; }; static const struct MyCStruct s = {{ MyCVal, MyNextVal }};
the_stack_data/6387360.c
#include <math.h> #include <stdio.h> #include <stdlib.h> #define ORDER 3 typedef struct _B_node { int n_keys; struct _B_node *child[ORDER]; int key[ORDER-1]; } B_node; struct return_package { short is_overflow; int overflowed_key; B_node *overflowed_child; // 오른쪽으로 삐져나간 child를 담아서 올림. }; B_node* make_empty_B_tree(); void free_B_tree(B_node*); void free_B_node(B_node*); struct return_package insert(B_node*,int); B_node* insert_to_B_tree(B_node*,int); int delete(B_node* root, int value); B_node* delete_to_B_tree(B_node* root, int value); void insert_key(int*,int,int,int); int delete_key(int*,int,int); int get_smallest_key(int*,int,int); int get_largest_key(int*,int); B_node* insert_subtree(B_node**,B_node*,int,int); B_node* delete_subtree(B_node** arr, int index, int len); B_node* push_front_subtree(B_node**,B_node*); B_node* push_back_subtree(B_node**,B_node*); int insert_rotation_test(B_node*,int); void insert_rotate_with_left(B_node*,int,int,int,B_node*); void insert_rotate_with_right(B_node*,int,int,int,B_node*); int delete_rotation_test(B_node* root, int src); void delete_rotate_with_right(B_node* root, int now_idx); struct return_package node_split(B_node*,int,int,B_node*); B_node* node_copy(B_node*,int,B_node*); void merge(B_node* root, int left_idx); int find_max(B_node*); void inorder(B_node*,FILE*); void swap(int*,int*); int main() { FILE *input = fopen("input.txt", "r"); FILE *output = fopen("output.txt", "w"); char mode[2]; int tmp_num; B_node *root = make_empty_B_tree(); while(fscanf(input, "%s", mode) == 1) { if(mode[0] == 'i') { fscanf(input, "%d", &tmp_num); root = insert_to_B_tree(root, tmp_num); } else if(mode[0] == 'p') { inorder(root, output); fprintf(output, "\n"); } else if(mode[0] == 'd') { fscanf(input, "%d", &tmp_num); root = delete_to_B_tree(root, tmp_num); } else { break; } } free_B_tree(root); //TODO fclose(input); fclose(output); return 0; } // 빈 B_node를 동적할당해서 return해줌. B_node* make_empty_B_tree() { int i; B_node* temp = malloc(sizeof(B_node)); temp->n_keys = 0; for(i = 0; i < ORDER; ++i) { temp->child[i] = NULL; } return temp; } // len + 1이상의 크기를 가질 수 있는 arr를 가정. 즉, 꽉 차있지 않은 arr. // arr의 index위치에 value를 삽입하고 그 이후 element는 한 칸씩 뒤로 옮겨줌. void insert_key(int* arr, int index, int value, int len) { int i; for(i = len; i > index; --i) { arr[i] = arr[i-1]; } arr[index] = value; } // insert 전용 rotate에 대한 함수이다. // root의 child중 src위치에서 difference만큼 왼쪽으로 떨어져 있는 child로 rotate를 진행한다. // src와 dst 사이의 모든 sibling들은 key가 꽉 찬 상태임을 가정한다. void insert_rotate_with_left(B_node* root, int src, int difference, int value, B_node* subtree) { int now_idx; int key_temp; int dst = src - difference; B_node *temp_node_prt; // subtree is rightmost subtree for(now_idx = src; now_idx != dst; --now_idx) { value = get_smallest_key(root->child[now_idx]->key, value, ORDER-1); swap(&value, &root->key[now_idx - 1]); subtree = push_back_subtree(root->child[now_idx]->child, subtree); } B_node *dst_node = root->child[dst]; dst_node->key[dst_node->n_keys++] = value; dst_node->child[dst_node->n_keys] = subtree; } // insert 전용 rotate에 대한 함수이다. // root의 child중 src위치에서 difference만큼 오른쪽으로 떨어져 있는 child로 rotate를 진행한다. // src와 dst 사이의 모든 sibling들은 key가 꽉 찬 상태임을 가정한다. void insert_rotate_with_right(B_node* root, int src, int difference, int value, B_node* subtree) { int now_idx; int key_temp; int dst = src + difference; B_node *temp_node_prt; for(now_idx = src; now_idx != dst; ++now_idx) { value = get_largest_key(root->child[now_idx]->key, value); swap(&value, &root->key[now_idx]); subtree = push_front_subtree(root->child[now_idx]->child, subtree); } insert_key(root->child[dst]->key, 0, value, root->child[dst]->n_keys++); push_front_subtree(root->child[dst]->child, subtree); } // argument로 받은 root에 key값을 insert함. // return type은 struct return_package로, 이번 호출에서 overflow가 발생했는지, 했다면 어떤 key와 subtree가 overflow되었는지 return함. struct return_package insert(B_node *root, int key) { int i, j; int temp_num, rotatable_index; int rotatable; struct return_package result, returned_by_child; for(i = 0; i < root->n_keys && root->key[i] < key; ++i); if(i < root->n_keys && root->key[i] == key) { result.is_overflow = 0; return result; } // if root is leaf-node if(!root->child[0]) { if(root->n_keys == ORDER-1) { //means that this leaf-node is full. So, make overflow. result.is_overflow = 1; result.overflowed_key = key; result.overflowed_child = NULL; return result; } else { insert_key(root->key, i, key, root->n_keys++); result.is_overflow = 0; return result; } } returned_by_child = insert(root->child[i], key); if(returned_by_child.is_overflow) { rotatable = insert_rotation_test(root, i); // 주석 해제시, rotation이 적용됨. // rotatable = 0; if(rotatable < 0) { insert_rotate_with_left(root, i, -rotatable, returned_by_child.overflowed_key, returned_by_child.overflowed_child); result.is_overflow = 0; return result; } else if(rotatable > 0) { insert_rotate_with_right(root, i, rotatable, returned_by_child.overflowed_key, returned_by_child.overflowed_child); result.is_overflow = 0; return result; } return node_split(root, i, returned_by_child.overflowed_key, returned_by_child.overflowed_child); } else { // overflow didn't occur. result.is_overflow = 0; return result; } } // inorder방식으로 B_tree의 key 값들을 fprint함. void inorder(B_node* root, FILE* output) { if(root == NULL) return; int i; for(i = 0; i < root->n_keys; ++i) { inorder(root->child[i], output); fprintf(output, "%d(%d) ", root->key[i], i); } inorder(root->child[root->n_keys], output); } // root의 child들 중 src위치의 child에서 다른 sibling에 insert용 rotation을 할 수 있는지 검사한 후, can_rotate값을 return // if (can_rotate == 0) -> can't rotate // if (can_rotate < 0) -> can rotate with left side // if (can_rotate > 0) -> can rotate with right side int insert_rotation_test(B_node* root, int src) { int can_rotate = 0, dst; //left rotate test for(dst = src - 1; dst >= 0; --dst) { if(root->child[dst]->n_keys < ORDER-1) { can_rotate = dst - src; break; } } //right rotate test for(dst = src + 1; dst <= root->n_keys && (!can_rotate || dst - src < can_rotate); ++dst) { if(root->child[dst]->n_keys < ORDER-1) { can_rotate = dst - src; break; } } return can_rotate; } // keys 배열이 꽉 차있는 상태라고 가정하고, value를 sorting된 자리에 삽입한 후 // 가장 작은 key값을 return함. 나머지 key값들은 순서대로 배열에 남아있음. int get_smallest_key(int* keys, int value, int len) { int i, j, result = keys[0]; if(keys[0] > value) return value; for(i = 0; i < len && keys[i] < value; ++i); for(j = 0; j < i - 1; ++j) { keys[j] = keys[j+1]; } keys[i-1] = value; return result; } // keys 배열이 꽉 차있는 상태라고 가정하고, value를 sorting된 자리에 삽입한 후 // 가장 큰 key값을 return함. 나머지 key값들은 순서대로 배열에 남아있음. int get_largest_key(int* keys, int value) { int i, j, result = keys[ORDER-2]; if(keys[ORDER-2] < value) return value; for(i = 0; keys[i] < value; ++i); for(j = ORDER-2; j > i; --j) { keys[j] = keys[j-1]; } keys[i] = value; return result; } // children 배열이 꽉 차있다고 가정함. // rightmost_value를 children의 오른쪽에 삽입하고 가장 왼쪽 값은 배열에서 빼낸 후 return. B_node* push_back_subtree(B_node** children, B_node* rightmost_value) { int i; B_node* result = children[0]; for(i = 0; i < ORDER - 1; ++i) { children[i] = children[i+1]; } children[ORDER-1] = rightmost_value; return result; } // children 배열이 꽉 차있다고 가정함. // leftmost_value를 children의 왼쪽에 삽입하고 가장 오른쪽 값은 배열에서 빼낸 후 return. B_node* push_front_subtree(B_node** children, B_node* leftmost_value) { int i; B_node* result = children[ORDER-1]; for(i = ORDER-1; i > 0; --i) { children[i] = children[i-1]; } children[0] = leftmost_value; return result; } // lhs가 pointing하는 값과 rhs가 pointing하는 값을 서로 바꿈. void swap(int *lhs, int *rhs) { int temp = *lhs; *lhs = *rhs; *rhs = temp; } // root노드의 child들 중 dst위치의 subtree에서 node_split을 수행함. // node_split 수행 후, root노드에서 overflow의 발생정보를 return. struct return_package node_split(B_node* root, int dst, int overflowed_key, B_node* overflowed_child) { struct return_package result; B_node* new_node = node_copy(root->child[dst], overflowed_key, overflowed_child); if(root->n_keys == ORDER - 1) { result.is_overflow = 1; result.overflowed_child = insert_subtree(root->child, new_node, dst + 1, ORDER); result.overflowed_key = root->child[dst]->key[--root->child[dst]->n_keys]; return result; } insert_key(root->key, dst, root->child[dst]->key[--root->child[dst]->n_keys], root->n_keys++); insert_subtree(root->child, new_node, dst + 1, root->n_keys); result.is_overflow = 0; return result; } // src_node의 정보와 overflowed_key overflowed_child 값을 이용하여 node_split에 필요한 추가 노드를 동적할당 한 후 세팅함. // result_node로 copy된 src_node의 정보는 src_node에서 제거됨. B_node* node_copy(B_node* src, int overflowed_key, B_node* overflowed_child) { B_node* result = make_empty_B_tree(); int i; overflowed_key = get_largest_key(src->key, overflowed_key); for(i = 0; i < (ORDER-1)/2 - 1; ++i) { result->key[i] = src->key[i + 1 + (int)ceil((ORDER-1)/2.0)]; result->child[i] = src->child[i + 1 + (int)ceil((ORDER-1)/2.0)]; } result->key[(ORDER-1)/2 - 1] = overflowed_key; result->n_keys = (ORDER-1)/2; src->n_keys -= (ORDER-1)/2 - 1; result->child[(ORDER-1)/2 - 1] = src->child[ORDER - 1]; result->child[(ORDER-1)/2] = overflowed_child; return result; } // len == ORDER면, 꽉 찬 children이라고 간주하고 넘친 값을 return. // len != ORDER면, 꽉 차지 않았다고 간주함. B_node* insert_subtree(B_node** children, B_node* subtree, int idx, int len) { if(len == ORDER) { if(idx == len) return subtree; B_node* temp = children[len-1]; int i; for(i = len-1; i > idx; --i) { children[i] = children[i-1]; } children[idx] = subtree; return temp; } int i; for(i = len; i > idx; --i) { children[i] = children[i-1]; } children[idx] = subtree; return NULL; } // 실제 가장 상위 node를 인자로 받아서 root node에서 필요한 추가 작업을 수행. // insert 함수를 호출하여 구현함. B_node* insert_to_B_tree(B_node* root, int key) { struct return_package total_result = insert(root, key); if(!total_result.is_overflow) return root; B_node* new_root = make_empty_B_tree(); B_node* new_right_subtree = node_copy(root, total_result.overflowed_key, total_result.overflowed_child); new_root->child[0] = root; new_root->child[1] = new_right_subtree; new_root->key[new_root->n_keys++] = root->key[--root->n_keys]; return new_root; } // postorder 방식을 이용하여 recursive하게 tree를 free함. void free_B_tree(B_node* root) { if(root == NULL) return; int i; for(i = 0; i <= root->n_keys; ++i) { free_B_tree(root->child[i]); } // printf("%d\n", root->key[0]); free(root); } // find max key value int find_max(B_node* root) { while(root->child[0]) { root = root->child[root->n_keys]; } return root->key[root->n_keys - 1]; } // delete the key that is given index-th key in given arr. // return deleted key value. int delete_key(int* arr, int index, int len) { int i; int result = arr[index]; for(i = index; i < len - 1; ++i) { arr[i] = arr[i+1]; } return result; } // delete the subtree that is given index-th subtree in given arr. // return deleted subtree value. B_node* delete_subtree(B_node** arr, int index, int len) { int i; B_node* result = arr[index]; for(i = index; i < len - 1; ++i) { arr[i] = arr[i+1]; } return result; } // test rotatable from root's src child to left or right sibling node /* return rotatable test result that -1 : can rotate with a left sibling. 0 : can't rotate with any siblings. +1 : can rotate with a right sibling. */ int delete_rotation_test(B_node* root, int src) { int left = src - 1, right = src + 1; if(left >= 0 && root->child[left]->n_keys > ceil(ORDER / 2.0) - 1) { return -1; } else if(right <= root->n_keys && root->child[right]->n_keys > ceil(ORDER / 2.0) - 1) { return 1; } else { return 0; } } // Function for rotate of delete. // Perform rotation with the closest left sibling. void delete_rotate_with_left(B_node* root, int now_idx) { B_node* dst_node = root->child[now_idx - 1]; int key = dst_node->key[dst_node->n_keys - 1]; B_node* subtree = dst_node->child[dst_node->n_keys]; dst_node->n_keys -= 1; swap(&key, &root->key[now_idx - 1]); insert_key(root->child[now_idx]->key, 0, key, root->child[now_idx]->n_keys); insert_subtree(root->child[now_idx]->child, subtree, 0, ++root->child[now_idx]->n_keys); } // Function for rotate of delete. // Perform rotation with the closest right sibling. void delete_rotate_with_right(B_node* root, int now_idx) { B_node* now_node = root->child[now_idx]; int key = delete_key(root->child[now_idx + 1]->key, 0, root->child[now_idx + 1]->n_keys); B_node* subtree = delete_subtree(root->child[now_idx + 1]->child, 0, root->child[now_idx + 1]->n_keys + 1); root->child[now_idx + 1]->n_keys -= 1; swap(&key, &root->key[now_idx]); now_node->key[now_node->n_keys] = key; now_node->child[++now_node->n_keys] = subtree; } // Merge root's left_idx-th child with the its closest right sibling. void merge(B_node* root, int left_idx) { int center_key = delete_key(root->key, left_idx, root->n_keys); B_node* left_node = root->child[left_idx]; B_node* right_node = root->child[left_idx + 1]; int left_n = left_node->n_keys; int i; for(i = right_node->n_keys; i > 0; --i) { left_node->key[left_n + i] = right_node->key[i - 1]; left_node->child[left_n + i + 1] = right_node->child[i]; } left_node->key[left_n] = center_key; left_node->child[left_n + 1] = right_node->child[0]; left_node->n_keys += right_node->n_keys + 1; free(delete_subtree(root->child, left_idx + 1, root->n_keys + 1)); root->n_keys -= 1; } // This function is internal function that is invoked by delete_to_B_node function. /* return a state value that 0 : underflow does not occur. 1 : underflow occurs. */ int delete(B_node* root, int value) { int i; for(i = 0; i < root->n_keys && root->key[i] < value; ++i); // if target key is found if(i < root->n_keys && root->key[i] == value) { //if root is leaf node if(root->child[0] == NULL) { delete_key(root->key, i, root->n_keys--); return root->n_keys < ceil(ORDER / 2.0) - 1; // return whether underflow occurs or not. } // root is non-leaf node. root->key[i] = find_max(root->child[i]); value = root->key[i]; } int is_underflow = delete(root->child[i], value); if(is_underflow) { int rotatable = delete_rotation_test(root, i); if(rotatable < 0) { delete_rotate_with_left(root, i); return 0; } else if(rotatable > 0) { delete_rotate_with_right(root, i); return 0; } else { merge(root, (i > 0) ? (i - 1) : i); return root->n_keys < ceil(ORDER / 2.0) - 1; } } else { return 0; } } // find the given key in given B-tree and delete it. // This function is external function that perform delete key of B-tree. B_node* delete_to_B_tree(B_node* root, int value) { int is_underflow = delete(root, value); if(is_underflow && root->child[0]) { B_node* result = root->child[0]; free(root); return result; } else { return root; } }
the_stack_data/87638110.c
void g_boxed_copy() {} ; void g_boxed_free() {} ; void g_boxed_type_register_static() {} ; void g_cclosure_marshal_BOOLEAN__FLAGS() {} ; void g_cclosure_marshal_STRING__OBJECT_POINTER() {} ; void g_cclosure_marshal_VOID__BOOLEAN() {} ; void g_cclosure_marshal_VOID__BOXED() {} ; void g_cclosure_marshal_VOID__CHAR() {} ; void g_cclosure_marshal_VOID__DOUBLE() {} ; void g_cclosure_marshal_VOID__ENUM() {} ; void g_cclosure_marshal_VOID__FLAGS() {} ; void g_cclosure_marshal_VOID__FLOAT() {} ; void g_cclosure_marshal_VOID__INT() {} ; void g_cclosure_marshal_VOID__LONG() {} ; void g_cclosure_marshal_VOID__OBJECT() {} ; void g_cclosure_marshal_VOID__PARAM() {} ; void g_cclosure_marshal_VOID__POINTER() {} ; void g_cclosure_marshal_VOID__STRING() {} ; void g_cclosure_marshal_VOID__UCHAR() {} ; void g_cclosure_marshal_VOID__UINT() {} ; void g_cclosure_marshal_VOID__UINT_POINTER() {} ; void g_cclosure_marshal_VOID__ULONG() {} ; void g_cclosure_marshal_VOID__VOID() {} ; void g_cclosure_new() {} ; void g_cclosure_new_object() {} ; void g_cclosure_new_object_swap() {} ; void g_cclosure_new_swap() {} ; void g_closure_add_finalize_notifier() {} ; void g_closure_add_invalidate_notifier() {} ; void g_closure_add_marshal_guards() {} ; void g_closure_get_type() {} ; void g_closure_invalidate() {} ; void g_closure_invoke() {} ; void g_closure_new_object() {} ; void g_closure_new_simple() {} ; void g_closure_ref() {} ; void g_closure_remove_finalize_notifier() {} ; void g_closure_remove_invalidate_notifier() {} ; void g_closure_set_marshal() {} ; void g_closure_set_meta_marshal() {} ; void g_closure_sink() {} ; void g_closure_unref() {} ; void g_enum_complete_type_info() {} ; void g_enum_get_value() {} ; void g_enum_get_value_by_name() {} ; void g_enum_get_value_by_nick() {} ; void g_enum_register_static() {} ; void g_flags_complete_type_info() {} ; void g_flags_get_first_value() {} ; void g_flags_get_value_by_name() {} ; void g_flags_get_value_by_nick() {} ; void g_flags_register_static() {} ; void g_gstring_get_type() {} ; void g_gtype_get_type() {} ; void g_hash_table_get_type() {} ; void g_initially_unowned_get_type() {} ; void g_io_channel_get_type() {} ; void g_io_condition_get_type() {} ; void g_object_add_toggle_ref() {} ; void g_object_add_weak_pointer() {} ; void g_object_class_find_property() {} ; void g_object_class_install_property() {} ; void g_object_class_list_properties() {} ; void g_object_class_override_property() {} ; void g_object_connect() {} ; void g_object_disconnect() {} ; void g_object_force_floating() {} ; void g_object_freeze_notify() {} ; void g_object_get() {} ; void g_object_get_data() {} ; void g_object_get_property() {} ; void g_object_get_qdata() {} ; void g_object_get_valist() {} ; void g_object_interface_find_property() {} ; void g_object_interface_install_property() {} ; void g_object_interface_list_properties() {} ; void g_object_is_floating() {} ; void g_object_new() {} ; void g_object_new_valist() {} ; void g_object_newv() {} ; void g_object_notify() {} ; void g_object_ref() {} ; void g_object_ref_sink() {} ; void g_object_remove_toggle_ref() {} ; void g_object_remove_weak_pointer() {} ; void g_object_run_dispose() {} ; void g_object_set() {} ; void g_object_set_data() {} ; void g_object_set_data_full() {} ; void g_object_set_property() {} ; void g_object_set_qdata() {} ; void g_object_set_qdata_full() {} ; void g_object_set_valist() {} ; void g_object_steal_data() {} ; void g_object_steal_qdata() {} ; void g_object_thaw_notify() {} ; void g_object_unref() {} ; void g_object_watch_closure() {} ; void g_object_weak_ref() {} ; void g_object_weak_unref() {} ; void g_param_spec_boolean() {} ; void g_param_spec_boxed() {} ; void g_param_spec_char() {} ; void g_param_spec_double() {} ; void g_param_spec_enum() {} ; void g_param_spec_flags() {} ; void g_param_spec_float() {} ; void g_param_spec_get_blurb() {} ; void g_param_spec_get_name() {} ; void g_param_spec_get_nick() {} ; void g_param_spec_get_qdata() {} ; void g_param_spec_get_redirect_target() {} ; void g_param_spec_gtype() {} ; void g_param_spec_int() {} ; void g_param_spec_int64() {} ; void g_param_spec_internal() {} ; void g_param_spec_long() {} ; void g_param_spec_object() {} ; void g_param_spec_override() {} ; void g_param_spec_param() {} ; void g_param_spec_pointer() {} ; void g_param_spec_pool_insert() {} ; void g_param_spec_pool_list() {} ; void g_param_spec_pool_list_owned() {} ; void g_param_spec_pool_lookup() {} ; void g_param_spec_pool_new() {} ; void g_param_spec_pool_remove() {} ; void g_param_spec_ref() {} ; void g_param_spec_ref_sink() {} ; void g_param_spec_set_qdata() {} ; void g_param_spec_set_qdata_full() {} ; void g_param_spec_sink() {} ; void g_param_spec_steal_qdata() {} ; void g_param_spec_string() {} ; void g_param_spec_uchar() {} ; void g_param_spec_uint() {} ; void g_param_spec_uint64() {} ; void g_param_spec_ulong() {} ; void g_param_spec_unichar() {} ; void g_param_spec_unref() {} ; void g_param_spec_value_array() {} ; void g_param_type_register_static() {} ; void g_param_value_convert() {} ; void g_param_value_defaults() {} ; void g_param_value_set_default() {} ; void g_param_value_validate() {} ; void g_param_values_cmp() {} ; void g_pointer_type_register_static() {} ; void g_signal_accumulator_true_handled() {} ; void g_signal_add_emission_hook() {} ; void g_signal_chain_from_overridden() {} ; void g_signal_connect_closure() {} ; void g_signal_connect_closure_by_id() {} ; void g_signal_connect_data() {} ; void g_signal_connect_object() {} ; void g_signal_emit() {} ; void g_signal_emit_by_name() {} ; void g_signal_emit_valist() {} ; void g_signal_emitv() {} ; void g_signal_get_invocation_hint() {} ; void g_signal_handler_block() {} ; void g_signal_handler_disconnect() {} ; void g_signal_handler_find() {} ; void g_signal_handler_is_connected() {} ; void g_signal_handler_unblock() {} ; void g_signal_handlers_block_matched() {} ; void g_signal_handlers_disconnect_matched() {} ; void g_signal_handlers_unblock_matched() {} ; void g_signal_has_handler_pending() {} ; void g_signal_list_ids() {} ; void g_signal_lookup() {} ; void g_signal_name() {} ; void g_signal_new() {} ; void g_signal_new_valist() {} ; void g_signal_newv() {} ; void g_signal_override_class_closure() {} ; void g_signal_parse_name() {} ; void g_signal_query() {} ; void g_signal_remove_emission_hook() {} ; void g_signal_stop_emission() {} ; void g_signal_stop_emission_by_name() {} ; void g_signal_type_cclosure_new() {} ; void g_source_set_closure() {} ; void g_strdup_value_contents() {} ; void g_strv_get_type() {} ; void g_type_add_class_cache_func() {} ; void g_type_add_interface_check() {} ; void g_type_add_interface_dynamic() {} ; void g_type_add_interface_static() {} ; void g_type_check_class_cast() {} ; void g_type_check_class_is_a() {} ; void g_type_check_instance() {} ; void g_type_check_instance_cast() {} ; void g_type_check_instance_is_a() {} ; void g_type_check_is_value_type() {} ; void g_type_check_value() {} ; void g_type_check_value_holds() {} ; void g_type_children() {} ; void g_type_class_add_private() {} ; void g_type_class_peek() {} ; void g_type_class_peek_parent() {} ; void g_type_class_peek_static() {} ; void g_type_class_ref() {} ; void g_type_class_unref() {} ; void g_type_class_unref_uncached() {} ; void g_type_create_instance() {} ; void g_type_default_interface_peek() {} ; void g_type_default_interface_ref() {} ; void g_type_default_interface_unref() {} ; void g_type_depth() {} ; void g_type_free_instance() {} ; void g_type_from_name() {} ; void g_type_fundamental() {} ; void g_type_fundamental_next() {} ; void g_type_get_plugin() {} ; void g_type_get_qdata() {} ; void g_type_init() {} ; void g_type_init_with_debug_flags() {} ; void g_type_instance_get_private() {} ; void g_type_interface_add_prerequisite() {} ; void g_type_interface_get_plugin() {} ; void g_type_interface_peek() {} ; void g_type_interface_peek_parent() {} ; void g_type_interface_prerequisites() {} ; void g_type_interfaces() {} ; void g_type_is_a() {} ; void g_type_module_add_interface() {} ; void g_type_module_get_type() {} ; void g_type_module_register_enum() {} ; void g_type_module_register_flags() {} ; void g_type_module_register_type() {} ; void g_type_module_set_name() {} ; void g_type_module_unuse() {} ; void g_type_module_use() {} ; void g_type_name() {} ; void g_type_name_from_class() {} ; void g_type_name_from_instance() {} ; void g_type_next_base() {} ; void g_type_parent() {} ; void g_type_plugin_complete_interface_info() {} ; void g_type_plugin_complete_type_info() {} ; void g_type_plugin_get_type() {} ; void g_type_plugin_unuse() {} ; void g_type_plugin_use() {} ; void g_type_qname() {} ; void g_type_query() {} ; void g_type_register_dynamic() {} ; void g_type_register_fundamental() {} ; void g_type_register_static() {} ; void g_type_register_static_simple() {} ; void g_type_remove_class_cache_func() {} ; void g_type_remove_interface_check() {} ; void g_type_set_qdata() {} ; void g_type_test_flags() {} ; void g_type_value_table_peek() {} ; void g_value_array_append() {} ; void g_value_array_copy() {} ; void g_value_array_free() {} ; void g_value_array_get_nth() {} ; void g_value_array_get_type() {} ; void g_value_array_insert() {} ; void g_value_array_new() {} ; void g_value_array_prepend() {} ; void g_value_array_remove() {} ; void g_value_array_sort() {} ; void g_value_array_sort_with_data() {} ; void g_value_copy() {} ; void g_value_dup_boxed() {} ; void g_value_dup_object() {} ; void g_value_dup_param() {} ; void g_value_dup_string() {} ; void g_value_fits_pointer() {} ; void g_value_get_boolean() {} ; void g_value_get_boxed() {} ; void g_value_get_char() {} ; void g_value_get_double() {} ; void g_value_get_enum() {} ; void g_value_get_flags() {} ; void g_value_get_float() {} ; void g_value_get_gtype() {} ; void g_value_get_int() {} ; void g_value_get_int64() {} ; void g_value_get_long() {} ; void g_value_get_object() {} ; void g_value_get_param() {} ; void g_value_get_pointer() {} ; void g_value_get_string() {} ; void g_value_get_type() {} ; void g_value_get_uchar() {} ; void g_value_get_uint() {} ; void g_value_get_uint64() {} ; void g_value_get_ulong() {} ; void g_value_init() {} ; void g_value_peek_pointer() {} ; void g_value_register_transform_func() {} ; void g_value_reset() {} ; void g_value_set_boolean() {} ; void g_value_set_boxed() {} ; void g_value_set_char() {} ; void g_value_set_double() {} ; void g_value_set_enum() {} ; void g_value_set_flags() {} ; void g_value_set_float() {} ; void g_value_set_gtype() {} ; void g_value_set_instance() {} ; void g_value_set_int() {} ; void g_value_set_int64() {} ; void g_value_set_long() {} ; void g_value_set_object() {} ; void g_value_set_param() {} ; void g_value_set_pointer() {} ; void g_value_set_static_boxed() {} ; void g_value_set_static_string() {} ; void g_value_set_string() {} ; void g_value_set_uchar() {} ; void g_value_set_uint() {} ; void g_value_set_uint64() {} ; void g_value_set_ulong() {} ; void g_value_take_boxed() {} ; void g_value_take_object() {} ; void g_value_take_param() {} ; void g_value_take_string() {} ; void g_value_transform() {} ; void g_value_type_compatible() {} ; void g_value_type_transformable() {} ; void g_value_unset() {} ; __asm__(".globl g_param_spec_types; .pushsection .data; .type g_param_spec_types,@object; .size g_param_spec_types, 8; g_param_spec_types: .long 0; .popsection");
the_stack_data/162644188.c
#include <stdio.h> int main() { const float PI=3.14; float r,sonuc; printf("r sayi giriniz: "); scanf("%f",&r); sonuc=PI*(r*r); printf("sonuc: %.3f",sonuc); return 0; } // baktık
the_stack_data/90765496.c
#include<stdio.h> int main(int argc, char const *argv[]){ float salary; scanf("%f", &salary); if(salary>=0.0 && salary<=5000.0){ //nothing } else if(salary>=5001.0 && salary<=10000.0){ salary = salary*(1+0.1); } else if(salary>=10001.0 && salary<=15000.0){ salary = salary*(1+0.15); } else if(salary>15000.0){ salary = salary*(1+0.2); } else{ puts("Data Erorr!\n"); } printf("salary: %.1f\n\n\n", salary); return 0; }
the_stack_data/122188.c
//{{BLOCK(Level2Splash) //====================================================================== // // Level2Splash, 256x256@4, // + palette 256 entries, not compressed // + 129 tiles (t|f|p reduced) not compressed // + regular map (in SBBs), not compressed, 32x32 // Total size: 512 + 4128 + 2048 = 6688 // // Time-stamp: 2018-12-04, 03:17:18 // Exported by Cearn's GBA Image Transmogrifier, v0.8.3 // ( http://www.coranac.com/projects/#grit ) // //====================================================================== const unsigned short Level2SplashTiles[2064] __attribute__((aligned(4)))= { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4444, 0x0000,0x4444,0x0000,0x4444,0x0000,0x4444,0x0000,0x4444, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4000, 0x0000,0x4000,0x0000,0x4000,0x0000,0x4000,0x0000,0x4000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0444,0x0000, 0x0444,0x0000,0x0444,0x0000,0x0444,0x0000,0x0444,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x4700,0x0000,0x4444,0x4100,0x4444,0x4100,0x4444, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4444,0x0004,0x4444,0x0444,0x4444,0x4444,0x4444,0x4444, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0004,0x0000, 0x0000,0x4444,0x0000,0x4444,0x0000,0x4444,0x0000,0x4444, 0x0000,0x4444,0x0000,0x4444,0x0000,0x4444,0x0000,0x4444, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x4600,0x0000,0x4400, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0xC000,0x00CB, 0x4440,0x4444,0x4444,0x4444,0x4444,0x4444,0x7444,0x4449, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x4444,0x0004,0x4444,0x0044,0x444C,0x0444,0x4440, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x000A,0x0000,0x0004,0x5000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4444,0x0003,0x4444,0x0000,0x4444,0x4000,0x0444,0x4C00, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0019, 0x4490,0x4444,0x444B,0x4444,0x4444,0x4444,0x4444,0x4498, 0x0000,0x4000,0x0000,0x4000,0x0000,0x4000,0x0000,0x4000, 0x0004,0x4000,0x0044,0x4000,0x0444,0x4000,0x2444,0x4000, 0x0444,0x0000,0x0444,0x0000,0x0444,0x0000,0x0444,0x0000, 0x0444,0x0000,0x0444,0x0000,0x0444,0x0000,0x0444,0x0000, 0x4100,0x4444,0x4100,0x0054,0x4800,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4301,0x4444,0x0000,0x4440,0x0000,0x4440,0x0000,0x4400, 0x0000,0x4400,0x0000,0x4420,0x0000,0x4440,0x0000,0x4444, 0x0004,0x0000,0x0074,0x0000,0x0044,0x0000,0x0044,0x0000, 0x0044,0x0000,0x0044,0x0000,0x0004,0x0000,0x0004,0x0000, 0x0000,0x4440,0x0000,0x4440,0x0000,0x4441,0x0000,0x4444, 0x0000,0x4444,0x0000,0x4444,0x0000,0x4444,0x0000,0x4444, 0x0044,0x4000,0x0004,0x2000,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0x4444,0x4444,0x0000,0x0000,0x0000,0x0000, 0x0444,0x4440,0xA444,0x4460,0x4444,0x4400,0x4444,0x4400, 0x4444,0x4000,0x4444,0x4000,0x0000,0x4000,0x0000,0x0000, 0x0004,0x4000,0x0044,0x4000,0x0044,0x4000,0x0044,0x4400, 0x0044,0x4400,0x0444,0x4400,0x0444,0x44D0,0x0444,0x4440, 0x0444,0x4400,0x0444,0x4400,0x0044,0x4440,0x0044,0x4440, 0x0044,0x4440,0x0004,0x4440,0x0004,0x4440,0x0002,0x4440, 0x0644,0xC000,0x0044,0x0000,0x4444,0x4444,0x4444,0x4444, 0x4444,0x4444,0x4444,0x4444,0x0004,0x0000,0x0004,0x0000, 0x4444,0x4000,0x4444,0x4000,0x4444,0x400A,0x4444,0x4004, 0x4444,0x4004,0x4444,0x4004,0x0000,0x4000,0x0000,0x4000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4000, 0x0000,0x4400,0x0000,0x4440,0x0000,0x4444,0x4000,0x4444, 0x4000,0x4444,0x4490,0x3444,0x4444,0x0044,0x4444,0x0064, 0x4444,0x0000,0x0444,0x0000,0x0044,0x0000,0x0009,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4444,0x4444, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4444, 0x0000,0x4444,0x0000,0x4440,0x0000,0x4440,0x0444,0x4440, 0x0444,0x4400,0x0444,0x4000,0x0444,0x0000,0x0444,0x0000, 0x0004,0x0000,0x0004,0x0000,0x0044,0x0000,0x4444,0x4300, 0x4444,0x4444,0x4444,0x4444,0x4444,0x4444,0x4440,0x4444, 0x8000,0x0000,0x8400,0x0000,0x8440,0x0000,0x8444,0x0000, 0x8444,0x0000,0x0444,0x0000,0x0044,0x0000,0x000C,0x0000, 0xA444,0x4440,0x4444,0x4445,0x4448,0x4444,0x4440,0x0444, 0x4440,0x0444,0x4400,0x0444,0x4400,0x0044,0x4400,0x0044, 0x0000,0x4440,0x0000,0x4440,0x0000,0x4400,0x0000,0x4400, 0x0000,0x4000,0x0000,0x6000,0x0000,0x0000,0x0000,0x0000, 0x0084,0x0000,0x0044,0x0000,0x0444,0x0000,0x4444,0x900B, 0x4444,0x4444,0x4444,0x4444,0x4446,0x4444,0x4400,0x4444, 0x0000,0x4000,0x4000,0x4000,0x4430,0x4000,0x4444,0x4000, 0x4444,0x4000,0x4444,0x4000,0x0444,0x4000,0x0004,0x4000, 0x4400,0x0444,0x4400,0x0044,0x4400,0x0044,0x4400,0x4444, 0x4490,0x4444,0x4410,0x4444,0x4410,0x4444,0x44B0,0x4444, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0044,0x0000, 0x0044,0x0000,0x0044,0x0000,0x0044,0x0000,0x0044,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4440, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0844,0x4444, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4444,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0044,0x4000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4444,0x4044, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4444,0x4444, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0420,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4400,0x4440, 0x4400,0x4444,0x4400,0xC004,0x4400,0x000C,0x4400,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x6002,0x4494, 0x6004,0x4444,0x6044,0x0044,0x6044,0x0054,0x6044,0x0004, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4700,0x0444, 0x4400,0x0444,0x0440,0x4400,0x4440,0x4444,0x4445,0x4444, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x44B0,0x0C44, 0x4440,0x0444,0x0644,0x5400,0x8446,0x0000,0x44A0,0x0044, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4443,0x0064, 0x4444,0x0044,0x0024,0x0040,0x0D44,0x0000,0x4445,0x0004, 0x0000,0x4444,0x0000,0x0044,0x5000,0x0014,0x0000,0x0044, 0x0000,0x4444,0x0000,0x4440,0x0000,0xC000,0x0000,0x0000, 0x0444,0x4444,0x0400,0x4000,0x0000,0x4000,0x0000,0x4000, 0x0000,0x4000,0x0544,0x4000,0x0444,0x4000,0x4440,0x4000, 0x4444,0x8000,0x0004,0x4000,0x0004,0x4000,0x0004,0x4000, 0x0004,0x4400,0x0004,0x4400,0x0004,0x4400,0x0004,0x44A0, 0x0944,0x4000,0x0444,0x4000,0x0444,0x4000,0x040C,0x4000, 0x4400,0x4000,0x4400,0x4000,0x4400,0x4000,0x4444,0x4004, 0x4444,0x4444,0x0004,0x0440,0x0004,0x0440,0x0004,0x0440, 0x0004,0x0944,0x4444,0x0004,0x4444,0x0004,0x0004,0x0044, 0x4444,0x4444,0x4400,0x0000,0x4400,0x0000,0x4400,0x0000, 0x4400,0x0000,0x4400,0x0000,0x4400,0x0000,0x4400,0x0000, 0x0000,0x6400,0x0000,0x6400,0x0000,0x6460,0x0000,0x4444, 0x0000,0x4444,0x0000,0x6450,0x0000,0x6450,0x0000,0x6450, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0044,0x4444, 0x4044,0x4444,0x4400,0x7007,0x4400,0x0000,0x4400,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0004,0x0000,0x0044,0x0000,0x0044,0x0000,0x0044,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4144,0x0644, 0x4444,0x0444,0x0444,0x4470,0x0044,0x4400,0x0044,0x4400, 0x0420,0x0000,0x0420,0x0000,0x0420,0x0000,0x0420,0x4400, 0x0420,0x4440,0x0420,0x0040,0x0420,0x0000,0x0420,0x44C0, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0144,0x0044, 0x0444,0x0A47,0x5440,0x0440,0x4423,0x0440,0x4444,0x3480, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x4400,0x0000, 0xA400,0x0000,0x0420,0x0000,0x0440,0x0000,0x0440,0x0000, 0x4400,0x0000,0x4400,0x000C,0x4400,0x40C4,0x4400,0x4444, 0x4400,0x0480,0x4400,0x0000,0x4400,0x0000,0x4400,0x0000, 0x6044,0x0004,0x6044,0x0004,0x60C4,0x0004,0x6004,0x0004, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0443,0x0000,0x0440,0x4000,0x4440,0x4400,0x4400,0xA444, 0x9000,0x0024,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0444,0x0004,0x5440,0x0044,0x5440,0x4444,0x5044, 0x4500,0x000D,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4000,0x0044,0x0000,0x0044,0x0004,0x0044,0x4444,0x00C4, 0x5480,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x8000,0x0000,0x5000,0x0004,0x5000,0x0C44,0x0000,0x4444, 0x0000,0x4200,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4400,0x4000,0xA440,0x4000,0x044A,0x4000,0x0944,0x4000, 0x0006,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0004,0x5440,0x0004,0x0440,0x0004,0x044A,0x0004,0x0044, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4555,0x4004,0x4000,0x4004,0x4000,0x4044,0x0000,0x4044, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0004,0x0044,0x0004,0x0440,0x0004,0x0440,0x0004,0x0440, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4400,0x0000,0x4400,0x0000,0x4400,0x0000,0x4400,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x6450,0x0000,0x6450,0x0000,0x44B0,0x0000,0x4400, 0x0000,0x4000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4400,0x0000,0x4400,0x0000,0x4020,0x4004,0x4044,0x4444, 0x0007,0x0A20,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0044,0x0000,0x0044,0x0000,0x0054,0x0000,0x0004,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0044,0x4400,0x0044,0x4400,0x0444,0x6440,0x4444,0x0444, 0xD044,0x0004,0x0044,0x0000,0x0044,0x0000,0x0044,0x0000, 0x0420,0x9440,0x0420,0x0240,0x0420,0x0440,0x0420,0x4440, 0x0000,0x4300,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4400,0x4400,0x4440,0x4400,0x4440,0x400C,0x44A4,0x4004, 0x4C03,0x4000,0x0000,0x4000,0x0000,0x4407,0x0000,0x4442, 0x0047,0x0000,0x0044,0x0000,0x0044,0x0000,0x0094,0x0000, 0x0004,0x0000,0x0004,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4400,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0044,0x0000,0x0044,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x4000,0x0000,0x4400, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x00A4,0x0000,0x0044,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x8800,0x0000,0x4400,0x0000, 0x0044,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x044B,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0xC000,0x0000,0x4900, 0x0000,0x4400,0x0000,0x0440,0x0000,0x0440,0x0000,0x0440, 0x0000,0x0000,0x0000,0x0000,0x0444,0x4000,0x4444,0x4000, 0x4400,0x4004,0x4000,0x4004,0x4000,0x4004,0x4000,0x4004, 0x0000,0x0000,0x0000,0x0000,0x4446,0x0000,0x4447,0x0000, 0xA044,0x0000,0x0004,0x0000,0x0004,0x0000,0x0004,0x0000, 0x0000,0x0000,0x0000,0x0000,0x4400,0x0094,0x4440,0x0444, 0x044B,0x0440,0x0447,0x0000,0x4440,0x0004,0x4800,0x0444, 0x0000,0x0000,0x0000,0x0000,0x4400,0x0004,0x4440,0x0044, 0x0744,0x0440,0x0044,0x0440,0x4444,0x0444,0x0044,0x0000, 0x0044,0x0000,0x0044,0x0000,0x0044,0x4400,0x0044,0x4440, 0x0044,0x0544,0x0044,0x0044,0x0044,0x4444,0x0044,0x0044, 0x0000,0x0000,0x0000,0x0000,0x0004,0x4400,0x0044,0x4440, 0x0440,0x044A,0x0440,0x0044,0x0444,0x0044,0x0000,0x0044, 0x0000,0x0024,0x0000,0x0024,0x44C4,0x4444,0x4444,0x4444, 0x0040,0x0024,0x0000,0x0024,0x0000,0x0024,0x0000,0x0024, 0x0000,0x4400,0x0000,0x2400,0x0000,0x4444,0x0000,0x4444, 0x0000,0x2400,0x0000,0x2400,0x0000,0x2400,0x0000,0x2400, 0x0000,0x0000,0x0000,0x0000,0x0044,0x0444,0x4044,0x4444, 0x4400,0x400B,0x4400,0x4000,0x6400,0x0000,0x6400,0x0000, 0x0000,0x0000,0x0000,0x0000,0x4000,0x44C4,0x4000,0x4444, 0x4004,0x8044,0x40A4,0x0004,0x4044,0x0004,0x4044,0x0004, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0440,0x0000,0x4440, 0x0000,0x4440,0x0000,0x4440,0x0000,0x0440,0x0000,0x0440, 0x0000,0x0000,0x0000,0x0000,0x0744,0x044C,0x0444,0x4444, 0x4490,0x4404,0x4400,0x4400,0x4400,0x4400,0x4400,0x4400, 0x0000,0x0000,0x0000,0x0000,0xB000,0x0744,0x4400,0xA444, 0x5400,0x4400,0x0000,0x4500,0x4000,0x4444,0x4400,0x4B74, 0x4400,0x0000,0x0000,0x0000,0x4400,0x2400,0x4400,0x2400, 0x4400,0x4400,0x4400,0x4400,0x4400,0x4400,0x4400,0x4400, 0x0000,0x0000,0x0000,0x0000,0x0448,0x0000,0x4444,0x0000, 0x4704,0x0004,0x4000,0x0004,0x4000,0x0004,0x4000,0x0004, 0x0000,0x0000,0x0000,0x0000,0x4000,0x4404,0x4000,0x4444, 0x4000,0xC044,0x4000,0x0084,0x4000,0x0004,0x4000,0x0004, 0x0000,0x0000,0x0000,0x0000,0x4802,0x0004,0x4404,0x0044, 0x0444,0x0044,0x0044,0x0042,0x0044,0x9042,0x0044,0x9042, 0x0000,0x0000,0x0000,0x0000,0x4400,0x0004,0x4440,0x0044, 0x0944,0x0448,0x0044,0x0440,0x4444,0x0444,0x0064,0x0000, 0x0000,0x0000,0x0000,0x0000,0x4044,0x0024,0x4444,0x0344, 0x0444,0x0443,0x0044,0x0440,0x0044,0x0440,0x0044,0x0440, 0x0000,0x0000,0x0000,0x0000,0x0546,0x5400,0x0546,0x5400, 0x0546,0x5400,0x0546,0x5400,0x0546,0x5400,0x0546,0x5400, 0x0000,0x0440,0x0000,0x4400,0x0000,0x4400,0x0000,0xA000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4000,0x4004,0x4000,0x4004,0x4444,0x4000,0x0444,0x4000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0004,0x0000,0x0004,0x0000,0x0004,0x0000,0x0004,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0440,0x00C2,0x0440,0x4442,0x0444,0x4440,0x0084, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0044,0x0300,0x0A44,0x0400,0x4440,0x0444,0x4400,0x0044, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0044,0x0044,0x0044,0x0744,0x0044,0x4440,0x0044,0x4400, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0600,0x0044,0x04C0,0x0844,0x0444,0x4440,0x0044,0x4400, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0024,0x0050,0x0044,0x0044,0x4444,0x0054,0x444A, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x2400,0x0000,0x2400,0x0000,0x2400,0x0000,0x2400, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4400,0x2000,0x4400,0x4000,0x4C00,0x4444,0x0000,0x6444, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4044,0x0004,0x4004,0x0004,0x4007,0x0004,0x4000,0x0004, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0440,0x0000,0x0440,0x0000,0x0440,0x0000,0x0440, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4400,0x4400,0x4400,0x4400,0x4400,0x4400,0x4400,0x4400, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x1440,0x4400,0x5440,0x4400,0x4400,0x4444,0x4000,0x4044, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4400,0x4400,0x4400,0x4400,0x4464,0x4400,0x4464,0x4400, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x4000,0x0004,0x4000,0x0004,0x4000,0x0004,0x4000,0x0004, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0044,0x0042,0x0044,0x0042,0x0044,0x0042,0x0044,0x0042, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0044,0x0700,0x0144,0x04A0,0x4449,0x0444,0x4430,0x0074, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0044,0x0440,0x0044,0x0440,0x0044,0x0440,0x0044,0x0440, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0746,0x5420,0x0440,0x5440,0x4440,0x5444,0x4400,0x5404, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; const unsigned short Level2SplashMap[1024] __attribute__((aligned(4)))= { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0001,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0002,0x0003,0x0000,0x0004,0x0005,0x0006,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0007,0x0000,0x0008,0x0009,0x000A,0x000B,0x000C,0x000D, 0x000E,0x000F,0x0000,0x0010,0x0011,0x0012,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0007,0x0000,0x0013,0x0014,0x0015,0x0016,0x0017,0x0018, 0x0019,0x000F,0x0000,0x001A,0x001B,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0007,0x001C,0x001D,0x001E,0x001F,0x0020,0x0021,0x0022, 0x0023,0x000F,0x0000,0x0024,0x001C,0x0025,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0026,0x0027,0x0028,0x0029,0x002A, 0x002B,0x0000,0x0000,0x0000,0x0000,0x002C,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x002D,0x002E, 0x002F,0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036, 0x0037,0x0038,0x0039,0x003A,0x003B,0x003C,0x003D,0x003E, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x003F,0x0040, 0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047,0x0048, 0x0049,0x004A,0x004B,0x004C,0x004D,0x004E,0x004F,0x0050, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0051,0x0000, 0x0000,0x0052,0x0000,0x0000,0x0053,0x0054,0x0000,0x0000, 0x0000,0x0000,0x0055,0x0000,0x0056,0x0000,0x0057,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0058,0x0059,0x005A,0x005B, 0x005C,0x005D,0x005E,0x005F,0x0060,0x0061,0x0062,0x0063, 0x0064,0x0065,0x0066,0x0067,0x0068,0x0069,0x006A,0x006B, 0x006C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x006D,0x006E,0x006F,0x0070, 0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,0x0078, 0x0079,0x007A,0x007B,0x007C,0x007C,0x007D,0x007E,0x007F, 0x0080,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; const unsigned short Level2SplashPal[256] __attribute__((aligned(4)))= { 0x20E0,0x5270,0x739B,0x35A7,0x7FFF,0x6316,0x4A2D,0x6B59, 0x56B2,0x41EA,0x77BD,0x5ED4,0x2D44,0x6737,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; //}}BLOCK(Level2Splash)
the_stack_data/48575795.c
#include <stdio.h> #include <malloc.h> #include <zconf.h> #include <memory.h> char** gameBoard = NULL; int currentPlayer = 1; void freeGameBoard() { free(gameBoard); //leak ;) gameBoard = NULL; } void initGame() { if(gameBoard != NULL) { freeGameBoard(); } gameBoard = malloc(sizeof(char*)*3); for(int i = 0; i < 3 ; ++i) { gameBoard[i] = malloc(sizeof(int) * 3); //invalid malloc size } for(int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { gameBoard[i][j] = ' '; } } currentPlayer = 1; } int seededPosition(int i) { static int seed = 42; seed = seed*13; return ((i+1) * seed); //OVERFLOW } void printBoard() { for(int i = 0; i < 3; ++i) { printf("_____________\n|"); for (int j = 0; j < 3; ++j) { printf(" %c |", gameBoard[i][j]); } printf("\n"); } printf("_____________\n\n\n"); } int isWon() { for(int i = 0; i < 3; ++i) { if (gameBoard[i][0] == gameBoard[i][1] && gameBoard[i][0] == gameBoard[i][2] && gameBoard[i][0] != ' ') return 1; if (gameBoard[0][i] == gameBoard[0][i] //copy paste error should be 1 instead of 0 && gameBoard[0][i] == gameBoard[2][i] && gameBoard[0][i] != ' ') return 1; } if (gameBoard[0][0] == gameBoard[1][1] && gameBoard[0][0] == gameBoard[2][2] && gameBoard[0][0] != ' ') return 1; if (gameBoard[0][2] == gameBoard[1][1] && gameBoard[0][2] == gameBoard[2][0] && gameBoard[0][2] != ' ') return 1; return 0; } int findWinningPlay(char playerChar, int* x, int* y) { *x = 0; *y = 0; for(int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { if(gameBoard[i][j] == ' ') { gameBoard[i][j] = playerChar; int won = isWon(); gameBoard[i][j] = ' '; if(won) { if(x == NULL || y == NULL) //using *y and *x before ... return 0; x = i; y = j; //forgot pointer return 1; } } } } //forgot return 0 } void play() { //set current player char player = currentPlayer ? 'O' : 'X'; currentPlayer = currentPlayer ? 0 : 1; { //check if it can win in one turn int x, y = 0; int success = findWinningPlay(currentPlayer, &x, &y); //currentPlayer instead of player if (success) { gameBoard[x][y] = player; return; } } { //check if it can lose in one turn int x, y = 0; int success = findWinningPlay(currentPlayer ? 'O' : 'X', &x, &y); if (success) { gameBoard[x][y] = player; return; } } int si = seededPosition(0); int sj = seededPosition(0); for(int i = 0; i < 3; ++i) { si = (si + 1) % 3; for (int j = 0; j < 3; ++j) { sj = (si + 1) % 3; //si instead of sj if (gameBoard[si][sj] == ' ') { gameBoard[si][sj] = player; return; } } } } int canPlay() { if(isWon()) return 0; for(int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++i) //invalid loop increment { if(gameBoard[i][j] == ' ');//TRAILING ; { return 1; } } } return 0; } void playGame() { initGame(); while(canPlay()) { play(); printBoard(); } if(isWon()) printf("'%s' has won ! \n", currentPlayer ? 'X' : 'O'); //%s instead of %c else printf("Draw :(\n"); freeGameBoard(); } int main() { int continuePlaying = 1; do{ playGame(); while(1) { char buff[3] = {0}; char message[22] = "play again ? yes/no\n"; printf("%s", message); char c; for (int i = 0; i < 3; ++i) { char c = (char) fgetc(stdin); //redefine char c if (c == '\n') break; buff[i] = c; } while (c != '\n') c = (char) fgetc(stdin); if (strcmp(buff, "no") == 0) { continuePlaying = 0; break; } else if (strcmp(buff, "yes") == 0) { break; } printf("I don't understand %s \n", buff); //overflow } } while(continuePlaying); return 0; }
the_stack_data/1232738.c
#include <math.h> void kendl1(float data1[], float data2[], unsigned long n, float *tau, float *z, float *prob) { float erfcc(float x); unsigned long n2=0,n1=0,k,j; long is=0; float svar,aa,a2,a1; for (j=1;j<n;j++) { for (k=(j+1);k<=n;k++) { a1=data1[j]-data1[k]; a2=data2[j]-data2[k]; aa=a1*a2; if (aa) { ++n1; ++n2; aa > 0.0 ? ++is : --is; } else { if (a1) ++n1; if (a2) ++n2; } } } *tau=is/(sqrt((double) n1)*sqrt((double) n2)); svar=(4.0*n+10.0)/(9.0*n*(n-1.0)); *z=(*tau)/sqrt(svar); *prob=erfcc(fabs(*z)/1.4142136); }
the_stack_data/231393756.c
#include <stdio.h> #include <stdlib.h> int erzeugeZahl(int min, int max) { int zahl; zahl = (rand() % ((max + 1) - min)) + min; } int gibZahlein(int i) { int eingabe; int n=0; char s[80]; do { printf("Bitte Zahl%d eingeben:", i); fgets(s, 80, stdin); n = sscanf(s, " %d", &eingabe); } while(n != 1 ); return eingabe; } void felderstellen(int f[], int min, int max) { for(int i = 0; i < 6; i++) { f[i] = erzeugeZahl(min, max); } } void feldeingabe(int f1[]) { int z = 0; for(int i = 1; i < 7; i++) { do { f1[i] = gibZahlein(i); } while(f1[i] > 46 || f1[i] < 1); } } void feldvergleichen(int f[], int f1[], int f2[], int zaehler) { f[6]; f1[6]; f2[6]; zaehler = 0; for(int i = 0; i < 6; i++) { for(int j = 0; j < 6; j++) { if(f1[i] == f[j]) { f2[i] = f1[i]; zaehler++; break; } } } /* if(zaehler==6) { printf("Gewonnen\n"); }else { printf("%d Richtig\n", zaehler); }*/ } void feldausgabe(int f10[], int zaehler) { f10[6]; if(zaehler > 0) { for(int i = 0; i < 6; i++) { printf("%d|", f10[i]); } } } int main () { srand(time(NULL)); int f[6]; int f1[6]; int f2[6]; int zaehler = 0; int g = 0; for(int i = 0; i < 10000000; i++) { felderstellen( f, 1, 46); felderstellen( f1, 1, 46); feldvergleichen( f, f1, f2, &zaehler); if(zaehler > 0) g++; } printf("%d", g); return 0; }
the_stack_data/165767810.c
/* Copyright (C) 1998, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <errno.h> #define __need_NULL #include <stddef.h> #include <signal.h> /* Set the disposition for SIG. */ __sighandler_t sigset (sig, disp) int sig; __sighandler_t disp; { struct sigaction act, oact; sigset_t set; #ifdef SIG_HOLD /* Handle SIG_HOLD first. */ if (disp == SIG_HOLD) { /* Create an empty signal set. */ if (__sigemptyset (&set) < 0) return SIG_ERR; /* Add the specified signal. */ if (__sigaddset (&set, sig) < 0) return SIG_ERR; /* Add the signal set to the current signal mask. */ if (__sigprocmask (SIG_BLOCK, &set, NULL) < 0) return SIG_ERR; return SIG_HOLD; } #endif /* SIG_HOLD */ /* Check signal extents to protect __sigismember. */ if (disp == SIG_ERR || sig < 1 || sig >= NSIG) { __set_errno (EINVAL); return SIG_ERR; } act.sa_handler = disp; if (__sigemptyset (&act.sa_mask) < 0) return SIG_ERR; act.sa_flags = 0; if (__sigaction (sig, &act, &oact) < 0) return SIG_ERR; /* Create an empty signal set. */ if (__sigemptyset (&set) < 0) return SIG_ERR; /* Add the specified signal. */ if (__sigaddset (&set, sig) < 0) return SIG_ERR; /* Remove the signal set from the current signal mask. */ if (__sigprocmask (SIG_UNBLOCK, &set, NULL) < 0) return SIG_ERR; return oact.sa_handler; }
the_stack_data/123200.c
/* * Copyright © 2011 inria. All rights reserved. * See COPYING in top-level directory. */ #include <hwloc.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> /* intensive testing of two grouping cases (2+1 and 2+2+1) */ int main(void) { hwloc_topology_t topology; hwloc_obj_t obj; unsigned indexes[5]; float distances[5*5]; unsigned depth; unsigned width; /* group 3 numa nodes as 1 group of 2 and 1 on the side */ hwloc_topology_init(&topology); hwloc_topology_set_synthetic(topology, "node:3 pu:1"); indexes[0] = 0; indexes[1] = 1; indexes[2] = 2; distances[0] = 1; distances[1] = 4; distances[2] = 4; distances[3] = 4; distances[4] = 1; distances[5] = 2; distances[6] = 4; distances[7] = 2; distances[8] = 1; hwloc_topology_set_distance_matrix(topology, HWLOC_OBJ_PU, 3, indexes, distances); hwloc_topology_load(topology); /* 2 groups at depth 1 */ depth = hwloc_get_type_depth(topology, HWLOC_OBJ_GROUP); assert(depth == 1); width = hwloc_get_nbobjs_by_depth(topology, depth); assert(width == 1); /* 3 node at depth 2 */ depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NODE); assert(depth == 2); width = hwloc_get_nbobjs_by_depth(topology, depth); assert(width == 3); /* find the root obj */ obj = hwloc_get_root_obj(topology); assert(obj->arity == 2); /* check its children */ assert(obj->children[0]->type == HWLOC_OBJ_NODE); assert(obj->children[0]->depth == 2); assert(obj->children[0]->arity == 1); assert(obj->children[1]->type == HWLOC_OBJ_GROUP); assert(obj->children[1]->depth == 1); assert(obj->children[1]->arity == 2); hwloc_topology_destroy(topology); /* group 5 sockets as 2 group of 2 and 1 on the side, all of them below a common node object */ hwloc_topology_init(&topology); hwloc_topology_set_synthetic(topology, "node:1 socket:5 pu:1"); indexes[0] = 0; indexes[1] = 1; indexes[2] = 2; indexes[3] = 3; indexes[4] = 4; distances[ 0] = 1; distances[ 1] = 2; distances[ 2] = 4; distances[ 3] = 4; distances[ 4] = 4; distances[ 5] = 2; distances[ 6] = 1; distances[ 7] = 4; distances[ 8] = 4; distances[ 9] = 4; distances[10] = 4; distances[11] = 4; distances[12] = 1; distances[13] = 4; distances[14] = 4; distances[15] = 4; distances[16] = 4; distances[17] = 4; distances[18] = 1; distances[19] = 2; distances[20] = 4; distances[21] = 4; distances[22] = 4; distances[23] = 2; distances[24] = 1; hwloc_topology_set_distance_matrix(topology, HWLOC_OBJ_SOCKET, 5, indexes, distances); hwloc_topology_load(topology); /* 1 node at depth 1 */ depth = hwloc_get_type_depth(topology, HWLOC_OBJ_NODE); assert(depth == 1); width = hwloc_get_nbobjs_by_depth(topology, depth); assert(width == 1); /* 2 groups at depth 2 */ depth = hwloc_get_type_depth(topology, HWLOC_OBJ_GROUP); assert(depth == 2); width = hwloc_get_nbobjs_by_depth(topology, depth); assert(width == 2); /* 5 sockets at depth 3 */ depth = hwloc_get_type_depth(topology, HWLOC_OBJ_SOCKET); assert(depth == 3); width = hwloc_get_nbobjs_by_depth(topology, depth); assert(width == 5); /* find the node obj */ obj = hwloc_get_root_obj(topology); assert(obj->arity == 1); obj = obj->children[0]; assert(obj->type == HWLOC_OBJ_NODE); assert(obj->arity == 3); /* check its children */ assert(obj->children[0]->type == HWLOC_OBJ_GROUP); assert(obj->children[0]->depth == 2); assert(obj->children[0]->arity == 2); assert(obj->children[1]->type == HWLOC_OBJ_SOCKET); assert(obj->children[1]->depth == 3); assert(obj->children[1]->arity == 1); assert(obj->children[2]->type == HWLOC_OBJ_GROUP); assert(obj->children[2]->depth == 2); assert(obj->children[2]->arity == 2); hwloc_topology_destroy(topology); return 0; }
the_stack_data/104546.c
int main() { int number; int error; switch(number) { case 1: error = 0; break; case 2: error = 0; break; default: error = -5; break; } error = 1; return 0; }
the_stack_data/165768806.c
/* FILE: pipe-new.c */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/wait.h> #define MSGSIZE 5 int main (int argc, char **argv) { int pid, j, piped[2]; /* pid per fork, j per indice, piped per pipe */ char mess[MSGSIZE]; /* array usato dal figlio per inviare stringa al padre */ char inpbuf [MSGSIZE]; int pidFiglio, status, ritorno; if (argc != 2) { printf("Numero dei parametri errato %d: ci vuole un singolo parametro\n", argc); exit(1); }/* si crea una pipe */ if (pipe(piped) < 0 ){ printf("Errore creazione pipe\n"); exit(2); } if ((pid = fork()) < 0){ printf("Errore creazione figlio\n"); exit(3); } if (pid == 0) { /* figlio */ int fd; //close(piped[0]);/* il figlio CHIUDE il lato di lettura */ if ((fd = open(argv[1], O_RDONLY)) < 0){ printf("Errore in apertura file %s\n", argv[1]); exit(-1); /* torniamo al padre un -1 che sara' interpretato come 255e quindi identificato come errore */ } printf("Figlio %d sta per iniziare a scrivere una serie di messaggi, ognuno di lunghezza %d, sulla pipe dopo averli letti dal file passato come parametro\n", getpid(), MSGSIZE); j=0; /* il figlio inizializza la sua variabile j per contare i messaggi che ha mandato al padre */ while (read(fd, mess, MSGSIZE)) /* il contenuto del file e' tale che in mess ci saranno 4 caratteri e il terminatore di linea */{ /* il padre ha concordato con il figlio che gli mandera' solo stringhe e quindi dobbiamo sostituire il terminatore di linea con il terminatore di stringa */ mess[MSGSIZE-1]='\0'; write(piped[1], mess, MSGSIZE); j++; } printf("Figlio %d scritto %d messaggi sulla pipe\n", getpid(), j); exit(0); } /* padre */ //close (piped [1]); /* il padre CHIUDE il lato di scrittura */ printf("Padre %d sta per iniziare a leggere i messaggi dalla pipe\n", getpid()); j=0; /* il padre inizializza la sua variabile j per verificare quanti messaggi ha mandato il figlio */ while (read ( piped[0], inpbuf, MSGSIZE)) { /* dato che il figlio gli ha inviato delle stringhe, il padre le puo' scrivere direttamente con una printf */ printf("%d: %s\n", j, inpbuf); j++; } printf("Padre %d letto %d messaggi dalla pipe\n", getpid(), j); /* padre aspetta il figlio */ pidFiglio = wait(&status); if (pidFiglio < 0) { printf("Errore wait\n"); exit(5); } if ((status & 0xFF) != 0) { printf("Figlio con pid %d terminato in modo anomalo\n", pidFiglio); } else { ritorno = (int)((status >> 8) & 0xFF); printf("Il figlio con pid=%d ha ritornato %d (se 255 problemi!)\n", pidFiglio,ritorno); } exit(0); }
the_stack_data/45450279.c
//Random sample from N(0,1) distribution. P(X > 1) = ? #include<stdio.h> #include<math.h> #include<stdlib.h> #include<time.h> int main() { int i,j,n,c=0; float u1,u2,x,y,prob; printf("Enter the number of observations to be generated:\n"); scanf("%d",&n); srand(time(0)); printf("The random sample is:\n\n"); for(i=1;i<=n;i++) { u1=rand()/(float)RAND_MAX; u2=rand()/(float)RAND_MAX; x=sqrt(-2*log(u1))*sin(2*3.14*u2); printf("%f\t",x); if(x>1) c++; } prob=c/(float)n; printf("\n\nP(X > 1) = %f\n",prob); }
the_stack_data/86076527.c
void kernel_heat_3d(int tsteps, int n, double A[ 120 + 0][120 + 0][120 + 0], double B[ 120 + 0][120 + 0][120 + 0]) { int t, i, j, k; #pragma clang loop(i1, j1, k1) tile sizes(128, 16, 8) for (t = 1; t <= 500; t++) { #pragma clang loop id(i1) for (i = 1; i < n-1; i++) { #pragma clang loop id(j1) for (j = 1; j < n-1; j++) { #pragma clang loop id(k1) for (k = 1; k < n-1; k++) { B[i][j][k] = 0.125 * (A[i+1][j][k] - 2.0 * A[i][j][k] + A[i-1][j][k]) + 0.125 * (A[i][j+1][k] - 2.0 * A[i][j][k] + A[i][j-1][k]) + 0.125 * (A[i][j][k+1] - 2.0 * A[i][j][k] + A[i][j][k-1]) + A[i][j][k]; } } } #pragma clang loop(i2, j2, k2) tile sizes(128, 16, 8) #pragma clang loop id(i2) for (i = 1; i < n-1; i++) { #pragma clang loop id(j2) for (j = 1; j < n-1; j++) { #pragma clang loop id(k2) for (k = 1; k < n-1; k++) { A[i][j][k] = 0.125 * (B[i+1][j][k] - 2.0 * B[i][j][k] + B[i-1][j][k]) + 0.125 * (B[i][j+1][k] - 2.0 * B[i][j][k] + B[i][j-1][k]) + 0.125 * (B[i][j][k+1] - 2.0 * B[i][j][k] + B[i][j][k-1]) + B[i][j][k]; } } } } }
the_stack_data/89199105.c
/** fixed, 8 july 1997 */ /* test file for lclint */ # include <stdlib.h> static void func1 (char *x) { char *s = x; int i1; float f; s += 5; s += 'c'; /* bad types */ i1 += f; /* i1 used before def, f used before def */ } static void func2() { int i1; int i2; i1 = i2; /* i2 used before def */ } int main () { func1 (NULL); /* null passed */ func2 (); return (EXIT_SUCCESS); }
the_stack_data/144854.c
/* ** 2015-05-25 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** ** This is a utility program designed to aid running regressions tests on ** the SQLite library using data from an external fuzzer, such as American ** Fuzzy Lop (AFL) (http://lcamtuf.coredump.cx/afl/). ** ** This program reads content from an SQLite database file with the following ** schema: ** ** CREATE TABLE db( ** dbid INTEGER PRIMARY KEY, -- database id ** dbcontent BLOB -- database disk file image ** ); ** CREATE TABLE xsql( ** sqlid INTEGER PRIMARY KEY, -- SQL script id ** sqltext TEXT -- Text of SQL statements to run ** ); ** CREATE TABLE IF NOT EXISTS readme( ** msg TEXT -- Human-readable description of this test collection ** ); ** ** For each database file in the DB table, the SQL text in the XSQL table ** is run against that database. All README.MSG values are printed prior ** to the start of the test (unless the --quiet option is used). If the ** DB table is empty, then all entries in XSQL are run against an empty ** in-memory database. ** ** This program is looking for crashes, assertion faults, and/or memory leaks. ** No attempt is made to verify the output. The assumption is that either all ** of the database files or all of the SQL statements are malformed inputs, ** generated by a fuzzer, that need to be checked to make sure they do not ** present a security risk. ** ** This program also includes some command-line options to help with ** creation and maintenance of the source content database. The command ** ** ./fuzzcheck database.db --load-sql FILE... ** ** Loads all FILE... arguments into the XSQL table. The --load-db option ** works the same but loads the files into the DB table. The -m option can ** be used to initialize the README table. The "database.db" file is created ** if it does not previously exist. Example: ** ** ./fuzzcheck new.db --load-sql *.sql ** ./fuzzcheck new.db --load-db *.db ** ./fuzzcheck new.db -m 'New test cases' ** ** The three commands above will create the "new.db" file and initialize all ** tables. Then do "./fuzzcheck new.db" to run the tests. ** ** DEBUGGING HINTS: ** ** If fuzzcheck does crash, it can be run in the debugger and the content ** of the global variable g.zTextName[] will identify the specific XSQL and ** DB values that were running when the crash occurred. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> #include <ctype.h> #include "sqlite3.h" #define ISSPACE(X) isspace((unsigned char)(X)) #define ISDIGIT(X) isdigit((unsigned char)(X)) #ifdef __unix__ # include <signal.h> # include <unistd.h> #endif #ifdef SQLITE_OSS_FUZZ # include <stddef.h> # include <stdint.h> #endif /* ** Files in the virtual file system. */ typedef struct VFile VFile; struct VFile { char *zFilename; /* Filename. NULL for delete-on-close. From malloc() */ int sz; /* Size of the file in bytes */ int nRef; /* Number of references to this file */ unsigned char *a; /* Content of the file. From malloc() */ }; typedef struct VHandle VHandle; struct VHandle { sqlite3_file base; /* Base class. Must be first */ VFile *pVFile; /* The underlying file */ }; /* ** The value of a database file template, or of an SQL script */ typedef struct Blob Blob; struct Blob { Blob *pNext; /* Next in a list */ int id; /* Id of this Blob */ int seq; /* Sequence number */ int sz; /* Size of this Blob in bytes */ unsigned char a[1]; /* Blob content. Extra space allocated as needed. */ }; /* ** Maximum number of files in the in-memory virtual filesystem. */ #define MX_FILE 10 /* ** Maximum allowed file size */ #define MX_FILE_SZ 10000000 /* ** All global variables are gathered into the "g" singleton. */ static struct GlobalVars { const char *zArgv0; /* Name of program */ VFile aFile[MX_FILE]; /* The virtual filesystem */ int nDb; /* Number of template databases */ Blob *pFirstDb; /* Content of first template database */ int nSql; /* Number of SQL scripts */ Blob *pFirstSql; /* First SQL script */ unsigned int uRandom; /* Seed for the SQLite PRNG */ char zTestName[100]; /* Name of current test */ } g; /* ** Print an error message and quit. */ static void fatalError(const char *zFormat, ...){ va_list ap; if( g.zTestName[0] ){ fprintf(stderr, "%s (%s): ", g.zArgv0, g.zTestName); }else{ fprintf(stderr, "%s: ", g.zArgv0); } va_start(ap, zFormat); vfprintf(stderr, zFormat, ap); va_end(ap); fprintf(stderr, "\n"); exit(1); } /* ** Timeout handler */ #ifdef __unix__ static void timeoutHandler(int NotUsed){ (void)NotUsed; fatalError("timeout\n"); } #endif /* ** Set the an alarm to go off after N seconds. Disable the alarm ** if N==0 */ static void setAlarm(int N){ #ifdef __unix__ alarm(N); #else (void)N; #endif } #ifndef SQLITE_OMIT_PROGRESS_CALLBACK /* ** This an SQL progress handler. After an SQL statement has run for ** many steps, we want to interrupt it. This guards against infinite ** loops from recursive common table expressions. ** ** *pVdbeLimitFlag is true if the --limit-vdbe command-line option is used. ** In that case, hitting the progress handler is a fatal error. */ static int progressHandler(void *pVdbeLimitFlag){ if( *(int*)pVdbeLimitFlag ) fatalError("too many VDBE cycles"); return 1; } #endif /* ** Reallocate memory. Show and error and quit if unable. */ static void *safe_realloc(void *pOld, int szNew){ void *pNew = realloc(pOld, szNew<=0 ? 1 : szNew); if( pNew==0 ) fatalError("unable to realloc for %d bytes", szNew); return pNew; } /* ** Initialize the virtual file system. */ static void formatVfs(void){ int i; for(i=0; i<MX_FILE; i++){ g.aFile[i].sz = -1; g.aFile[i].zFilename = 0; g.aFile[i].a = 0; g.aFile[i].nRef = 0; } } /* ** Erase all information in the virtual file system. */ static void reformatVfs(void){ int i; for(i=0; i<MX_FILE; i++){ if( g.aFile[i].sz<0 ) continue; if( g.aFile[i].zFilename ){ free(g.aFile[i].zFilename); g.aFile[i].zFilename = 0; } if( g.aFile[i].nRef>0 ){ fatalError("file %d still open. nRef=%d", i, g.aFile[i].nRef); } g.aFile[i].sz = -1; free(g.aFile[i].a); g.aFile[i].a = 0; g.aFile[i].nRef = 0; } } /* ** Find a VFile by name */ static VFile *findVFile(const char *zName){ int i; if( zName==0 ) return 0; for(i=0; i<MX_FILE; i++){ if( g.aFile[i].zFilename==0 ) continue; if( strcmp(g.aFile[i].zFilename, zName)==0 ) return &g.aFile[i]; } return 0; } /* ** Find a VFile by name. Create it if it does not already exist and ** initialize it to the size and content given. ** ** Return NULL only if the filesystem is full. */ static VFile *createVFile(const char *zName, int sz, unsigned char *pData){ VFile *pNew = findVFile(zName); int i; if( pNew ) return pNew; for(i=0; i<MX_FILE && g.aFile[i].sz>=0; i++){} if( i>=MX_FILE ) return 0; pNew = &g.aFile[i]; if( zName ){ int nName = (int)strlen(zName)+1; pNew->zFilename = safe_realloc(0, nName); memcpy(pNew->zFilename, zName, nName); }else{ pNew->zFilename = 0; } pNew->nRef = 0; pNew->sz = sz; pNew->a = safe_realloc(0, sz); if( sz>0 ) memcpy(pNew->a, pData, sz); return pNew; } /* ** Implementation of the "readfile(X)" SQL function. The entire content ** of the file named X is read and returned as a BLOB. NULL is returned ** if the file does not exist or is unreadable. */ static void readfileFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ const char *zName; FILE *in; long nIn; void *pBuf; zName = (const char*)sqlite3_value_text(argv[0]); if( zName==0 ) return; in = fopen(zName, "rb"); if( in==0 ) return; fseek(in, 0, SEEK_END); nIn = ftell(in); rewind(in); pBuf = sqlite3_malloc64( nIn ); if( pBuf && 1==fread(pBuf, nIn, 1, in) ){ sqlite3_result_blob(context, pBuf, nIn, sqlite3_free); }else{ sqlite3_free(pBuf); } fclose(in); } /* ** Implementation of the "writefile(X,Y)" SQL function. The argument Y ** is written into file X. The number of bytes written is returned. Or ** NULL is returned if something goes wrong, such as being unable to open ** file X for writing. */ static void writefileFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ FILE *out; const char *z; sqlite3_int64 rc; const char *zFile; (void)argc; zFile = (const char*)sqlite3_value_text(argv[0]); if( zFile==0 ) return; out = fopen(zFile, "wb"); if( out==0 ) return; z = (const char*)sqlite3_value_blob(argv[1]); if( z==0 ){ rc = 0; }else{ rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out); } fclose(out); sqlite3_result_int64(context, rc); } /* ** Load a list of Blob objects from the database */ static void blobListLoadFromDb( sqlite3 *db, /* Read from this database */ const char *zSql, /* Query used to extract the blobs */ int onlyId, /* Only load where id is this value */ int *pN, /* OUT: Write number of blobs loaded here */ Blob **ppList /* OUT: Write the head of the blob list here */ ){ Blob head; Blob *p; sqlite3_stmt *pStmt; int n = 0; int rc; char *z2; if( onlyId>0 ){ z2 = sqlite3_mprintf("%s WHERE rowid=%d", zSql, onlyId); }else{ z2 = sqlite3_mprintf("%s", zSql); } rc = sqlite3_prepare_v2(db, z2, -1, &pStmt, 0); sqlite3_free(z2); if( rc ) fatalError("%s", sqlite3_errmsg(db)); head.pNext = 0; p = &head; while( SQLITE_ROW==sqlite3_step(pStmt) ){ int sz = sqlite3_column_bytes(pStmt, 1); Blob *pNew = safe_realloc(0, sizeof(*pNew)+sz ); pNew->id = sqlite3_column_int(pStmt, 0); pNew->sz = sz; pNew->seq = n++; pNew->pNext = 0; memcpy(pNew->a, sqlite3_column_blob(pStmt,1), sz); pNew->a[sz] = 0; p->pNext = pNew; p = pNew; } sqlite3_finalize(pStmt); *pN = n; *ppList = head.pNext; } /* ** Free a list of Blob objects */ static void blobListFree(Blob *p){ Blob *pNext; while( p ){ pNext = p->pNext; free(p); p = pNext; } } /* Return the current wall-clock time */ static sqlite3_int64 timeOfDay(void){ static sqlite3_vfs *clockVfs = 0; sqlite3_int64 t; if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0); if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){ clockVfs->xCurrentTimeInt64(clockVfs, &t); }else{ double r; clockVfs->xCurrentTime(clockVfs, &r); t = (sqlite3_int64)(r*86400000.0); } return t; } /* Methods for the VHandle object */ static int inmemClose(sqlite3_file *pFile){ VHandle *p = (VHandle*)pFile; VFile *pVFile = p->pVFile; pVFile->nRef--; if( pVFile->nRef==0 && pVFile->zFilename==0 ){ pVFile->sz = -1; free(pVFile->a); pVFile->a = 0; } return SQLITE_OK; } static int inmemRead( sqlite3_file *pFile, /* Read from this open file */ void *pData, /* Store content in this buffer */ int iAmt, /* Bytes of content */ sqlite3_int64 iOfst /* Start reading here */ ){ VHandle *pHandle = (VHandle*)pFile; VFile *pVFile = pHandle->pVFile; if( iOfst<0 || iOfst>=pVFile->sz ){ memset(pData, 0, iAmt); return SQLITE_IOERR_SHORT_READ; } if( iOfst+iAmt>pVFile->sz ){ memset(pData, 0, iAmt); iAmt = (int)(pVFile->sz - iOfst); memcpy(pData, pVFile->a, iAmt); return SQLITE_IOERR_SHORT_READ; } memcpy(pData, pVFile->a + iOfst, iAmt); return SQLITE_OK; } static int inmemWrite( sqlite3_file *pFile, /* Write to this file */ const void *pData, /* Content to write */ int iAmt, /* bytes to write */ sqlite3_int64 iOfst /* Start writing here */ ){ VHandle *pHandle = (VHandle*)pFile; VFile *pVFile = pHandle->pVFile; if( iOfst+iAmt > pVFile->sz ){ if( iOfst+iAmt >= MX_FILE_SZ ){ return SQLITE_FULL; } pVFile->a = safe_realloc(pVFile->a, (int)(iOfst+iAmt)); if( iOfst > pVFile->sz ){ memset(pVFile->a + pVFile->sz, 0, (int)(iOfst - pVFile->sz)); } pVFile->sz = (int)(iOfst + iAmt); } memcpy(pVFile->a + iOfst, pData, iAmt); return SQLITE_OK; } static int inmemTruncate(sqlite3_file *pFile, sqlite3_int64 iSize){ VHandle *pHandle = (VHandle*)pFile; VFile *pVFile = pHandle->pVFile; if( pVFile->sz>iSize && iSize>=0 ) pVFile->sz = (int)iSize; return SQLITE_OK; } static int inmemSync(sqlite3_file *pFile, int flags){ return SQLITE_OK; } static int inmemFileSize(sqlite3_file *pFile, sqlite3_int64 *pSize){ *pSize = ((VHandle*)pFile)->pVFile->sz; return SQLITE_OK; } static int inmemLock(sqlite3_file *pFile, int type){ return SQLITE_OK; } static int inmemUnlock(sqlite3_file *pFile, int type){ return SQLITE_OK; } static int inmemCheckReservedLock(sqlite3_file *pFile, int *pOut){ *pOut = 0; return SQLITE_OK; } static int inmemFileControl(sqlite3_file *pFile, int op, void *pArg){ return SQLITE_NOTFOUND; } static int inmemSectorSize(sqlite3_file *pFile){ return 512; } static int inmemDeviceCharacteristics(sqlite3_file *pFile){ return SQLITE_IOCAP_SAFE_APPEND | SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | SQLITE_IOCAP_POWERSAFE_OVERWRITE; } /* Method table for VHandle */ static sqlite3_io_methods VHandleMethods = { /* iVersion */ 1, /* xClose */ inmemClose, /* xRead */ inmemRead, /* xWrite */ inmemWrite, /* xTruncate */ inmemTruncate, /* xSync */ inmemSync, /* xFileSize */ inmemFileSize, /* xLock */ inmemLock, /* xUnlock */ inmemUnlock, /* xCheck... */ inmemCheckReservedLock, /* xFileCtrl */ inmemFileControl, /* xSectorSz */ inmemSectorSize, /* xDevchar */ inmemDeviceCharacteristics, /* xShmMap */ 0, /* xShmLock */ 0, /* xShmBarrier */ 0, /* xShmUnmap */ 0, /* xFetch */ 0, /* xUnfetch */ 0 }; /* ** Open a new file in the inmem VFS. All files are anonymous and are ** delete-on-close. */ static int inmemOpen( sqlite3_vfs *pVfs, const char *zFilename, sqlite3_file *pFile, int openFlags, int *pOutFlags ){ VFile *pVFile = createVFile(zFilename, 0, (unsigned char*)""); VHandle *pHandle = (VHandle*)pFile; if( pVFile==0 ){ return SQLITE_FULL; } pHandle->pVFile = pVFile; pVFile->nRef++; pFile->pMethods = &VHandleMethods; if( pOutFlags ) *pOutFlags = openFlags; return SQLITE_OK; } /* ** Delete a file by name */ static int inmemDelete( sqlite3_vfs *pVfs, const char *zFilename, int syncdir ){ VFile *pVFile = findVFile(zFilename); if( pVFile==0 ) return SQLITE_OK; if( pVFile->nRef==0 ){ free(pVFile->zFilename); pVFile->zFilename = 0; pVFile->sz = -1; free(pVFile->a); pVFile->a = 0; return SQLITE_OK; } return SQLITE_IOERR_DELETE; } /* Check for the existance of a file */ static int inmemAccess( sqlite3_vfs *pVfs, const char *zFilename, int flags, int *pResOut ){ VFile *pVFile = findVFile(zFilename); *pResOut = pVFile!=0; return SQLITE_OK; } /* Get the canonical pathname for a file */ static int inmemFullPathname( sqlite3_vfs *pVfs, const char *zFilename, int nOut, char *zOut ){ sqlite3_snprintf(nOut, zOut, "%s", zFilename); return SQLITE_OK; } /* Always use the same random see, for repeatability. */ static int inmemRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){ memset(zBuf, 0, nBuf); memcpy(zBuf, &g.uRandom, nBuf<sizeof(g.uRandom) ? nBuf : sizeof(g.uRandom)); return nBuf; } /* ** Register the VFS that reads from the g.aFile[] set of files. */ static void inmemVfsRegister(int makeDefault){ static sqlite3_vfs inmemVfs; sqlite3_vfs *pDefault = sqlite3_vfs_find(0); inmemVfs.iVersion = 3; inmemVfs.szOsFile = sizeof(VHandle); inmemVfs.mxPathname = 200; inmemVfs.zName = "inmem"; inmemVfs.xOpen = inmemOpen; inmemVfs.xDelete = inmemDelete; inmemVfs.xAccess = inmemAccess; inmemVfs.xFullPathname = inmemFullPathname; inmemVfs.xRandomness = inmemRandomness; inmemVfs.xSleep = pDefault->xSleep; inmemVfs.xCurrentTimeInt64 = pDefault->xCurrentTimeInt64; sqlite3_vfs_register(&inmemVfs, makeDefault); }; /* ** Allowed values for the runFlags parameter to runSql() */ #define SQL_TRACE 0x0001 /* Print each SQL statement as it is prepared */ #define SQL_OUTPUT 0x0002 /* Show the SQL output */ /* ** Run multiple commands of SQL. Similar to sqlite3_exec(), but does not ** stop if an error is encountered. */ static void runSql(sqlite3 *db, const char *zSql, unsigned runFlags){ const char *zMore; sqlite3_stmt *pStmt; while( zSql && zSql[0] ){ zMore = 0; pStmt = 0; sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore); if( zMore==zSql ) break; if( runFlags & SQL_TRACE ){ const char *z = zSql; int n; while( z<zMore && ISSPACE(z[0]) ) z++; n = (int)(zMore - z); while( n>0 && ISSPACE(z[n-1]) ) n--; if( n==0 ) break; if( pStmt==0 ){ printf("TRACE: %.*s (error: %s)\n", n, z, sqlite3_errmsg(db)); }else{ printf("TRACE: %.*s\n", n, z); } } zSql = zMore; if( pStmt ){ if( (runFlags & SQL_OUTPUT)==0 ){ while( SQLITE_ROW==sqlite3_step(pStmt) ){} }else{ int nCol = -1; while( SQLITE_ROW==sqlite3_step(pStmt) ){ int i; if( nCol<0 ){ nCol = sqlite3_column_count(pStmt); }else if( nCol>0 ){ printf("--------------------------------------------\n"); } for(i=0; i<nCol; i++){ int eType = sqlite3_column_type(pStmt,i); printf("%s = ", sqlite3_column_name(pStmt,i)); switch( eType ){ case SQLITE_NULL: { printf("NULL\n"); break; } case SQLITE_INTEGER: { printf("INT %s\n", sqlite3_column_text(pStmt,i)); break; } case SQLITE_FLOAT: { printf("FLOAT %s\n", sqlite3_column_text(pStmt,i)); break; } case SQLITE_TEXT: { printf("TEXT [%s]\n", sqlite3_column_text(pStmt,i)); break; } case SQLITE_BLOB: { printf("BLOB (%d bytes)\n", sqlite3_column_bytes(pStmt,i)); break; } } } } } sqlite3_finalize(pStmt); } } } /* ** Rebuild the database file. ** ** (1) Remove duplicate entries ** (2) Put all entries in order ** (3) Vacuum */ static void rebuild_database(sqlite3 *db){ int rc; rc = sqlite3_exec(db, "BEGIN;\n" "CREATE TEMP TABLE dbx AS SELECT DISTINCT dbcontent FROM db;\n" "DELETE FROM db;\n" "INSERT INTO db(dbid, dbcontent) SELECT NULL, dbcontent FROM dbx ORDER BY 2;\n" "DROP TABLE dbx;\n" "CREATE TEMP TABLE sx AS SELECT DISTINCT sqltext FROM xsql;\n" "DELETE FROM xsql;\n" "INSERT INTO xsql(sqlid,sqltext) SELECT NULL, sqltext FROM sx ORDER BY 2;\n" "DROP TABLE sx;\n" "COMMIT;\n" "PRAGMA page_size=1024;\n" "VACUUM;\n", 0, 0, 0); if( rc ) fatalError("cannot rebuild: %s", sqlite3_errmsg(db)); } /* ** Return the value of a hexadecimal digit. Return -1 if the input ** is not a hex digit. */ static int hexDigitValue(char c){ if( c>='0' && c<='9' ) return c - '0'; if( c>='a' && c<='f' ) return c - 'a' + 10; if( c>='A' && c<='F' ) return c - 'A' + 10; return -1; } /* ** Interpret zArg as an integer value, possibly with suffixes. */ static int integerValue(const char *zArg){ sqlite3_int64 v = 0; static const struct { char *zSuffix; int iMult; } aMult[] = { { "KiB", 1024 }, { "MiB", 1024*1024 }, { "GiB", 1024*1024*1024 }, { "KB", 1000 }, { "MB", 1000000 }, { "GB", 1000000000 }, { "K", 1000 }, { "M", 1000000 }, { "G", 1000000000 }, }; int i; int isNeg = 0; if( zArg[0]=='-' ){ isNeg = 1; zArg++; }else if( zArg[0]=='+' ){ zArg++; } if( zArg[0]=='0' && zArg[1]=='x' ){ int x; zArg += 2; while( (x = hexDigitValue(zArg[0]))>=0 ){ v = (v<<4) + x; zArg++; } }else{ while( ISDIGIT(zArg[0]) ){ v = v*10 + zArg[0] - '0'; zArg++; } } for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){ if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){ v *= aMult[i].iMult; break; } } if( v>0x7fffffff ) fatalError("parameter too large - max 2147483648"); return (int)(isNeg? -v : v); } /* ** Print sketchy documentation for this utility program */ static void showHelp(void){ printf("Usage: %s [options] SOURCE-DB ?ARGS...?\n", g.zArgv0); printf( "Read databases and SQL scripts from SOURCE-DB and execute each script against\n" "each database, checking for crashes and memory leaks.\n" "Options:\n" " --cell-size-check Set the PRAGMA cell_size_check=ON\n" " --dbid N Use only the database where dbid=N\n" " --export-db DIR Write databases to files(s) in DIR. Works with --dbid\n" " --export-sql DIR Write SQL to file(s) in DIR. Also works with --sqlid\n" " --help Show this help text\n" " -q|--quiet Reduced output\n" " --limit-mem N Limit memory used by test SQLite instance to N bytes\n" " --limit-vdbe Panic if any test runs for more than 100,000 cycles\n" " --load-sql ARGS... Load SQL scripts fro files into SOURCE-DB\n" " --load-db ARGS... Load template databases from files into SOURCE_DB\n" " -m TEXT Add a description to the database\n" " --native-vfs Use the native VFS for initially empty database files\n" " --oss-fuzz Enable OSS-FUZZ testing\n" " --prng-seed N Seed value for the PRGN inside of SQLite\n" " --rebuild Rebuild and vacuum the database file\n" " --result-trace Show the results of each SQL command\n" " --sqlid N Use only SQL where sqlid=N\n" " --timeout N Abort if any single test needs more than N seconds\n" " -v|--verbose Increased output. Repeat for more output.\n" ); } int main(int argc, char **argv){ sqlite3_int64 iBegin; /* Start time of this program */ int quietFlag = 0; /* True if --quiet or -q */ int verboseFlag = 0; /* True if --verbose or -v */ char *zInsSql = 0; /* SQL statement for --load-db or --load-sql */ int iFirstInsArg = 0; /* First argv[] to use for --load-db or --load-sql */ sqlite3 *db = 0; /* The open database connection */ sqlite3_stmt *pStmt; /* A prepared statement */ int rc; /* Result code from SQLite interface calls */ Blob *pSql; /* For looping over SQL scripts */ Blob *pDb; /* For looping over template databases */ int i; /* Loop index for the argv[] loop */ int onlySqlid = -1; /* --sqlid */ int onlyDbid = -1; /* --dbid */ int nativeFlag = 0; /* --native-vfs */ int rebuildFlag = 0; /* --rebuild */ int vdbeLimitFlag = 0; /* --limit-vdbe */ int timeoutTest = 0; /* undocumented --timeout-test flag */ int runFlags = 0; /* Flags sent to runSql() */ char *zMsg = 0; /* Add this message */ int nSrcDb = 0; /* Number of source databases */ char **azSrcDb = 0; /* Array of source database names */ int iSrcDb; /* Loop over all source databases */ int nTest = 0; /* Total number of tests performed */ char *zDbName = ""; /* Appreviated name of a source database */ const char *zFailCode = 0; /* Value of the TEST_FAILURE environment variable */ int cellSzCkFlag = 0; /* --cell-size-check */ int sqlFuzz = 0; /* True for SQL fuzz testing. False for DB fuzz */ int iTimeout = 120; /* Default 120-second timeout */ int nMem = 0; /* Memory limit */ int nMemThisDb = 0; /* Memory limit set by the CONFIG table */ char *zExpDb = 0; /* Write Databases to files in this directory */ char *zExpSql = 0; /* Write SQL to files in this directory */ void *pHeap = 0; /* Heap for use by SQLite */ int ossFuzz = 0; /* enable OSS-FUZZ testing */ int ossFuzzThisDb = 0; /* ossFuzz value for this particular database */ sqlite3_vfs *pDfltVfs; /* The default VFS */ iBegin = timeOfDay(); #ifdef __unix__ signal(SIGALRM, timeoutHandler); #endif g.zArgv0 = argv[0]; zFailCode = getenv("TEST_FAILURE"); pDfltVfs = sqlite3_vfs_find(0); inmemVfsRegister(1); for(i=1; i<argc; i++){ const char *z = argv[i]; if( z[0]=='-' ){ z++; if( z[0]=='-' ) z++; if( strcmp(z,"cell-size-check")==0 ){ cellSzCkFlag = 1; }else if( strcmp(z,"dbid")==0 ){ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); onlyDbid = integerValue(argv[++i]); }else if( strcmp(z,"export-db")==0 ){ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); zExpDb = argv[++i]; }else if( strcmp(z,"export-sql")==0 ){ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); zExpSql = argv[++i]; }else if( strcmp(z,"help")==0 ){ showHelp(); return 0; }else if( strcmp(z,"limit-mem")==0 ){ #if !defined(SQLITE_ENABLE_MEMSYS3) && !defined(SQLITE_ENABLE_MEMSYS5) fatalError("the %s option requires -DSQLITE_ENABLE_MEMSYS5 or _MEMSYS3", argv[i]); #else if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); nMem = integerValue(argv[++i]); #endif }else if( strcmp(z,"limit-vdbe")==0 ){ vdbeLimitFlag = 1; }else if( strcmp(z,"load-sql")==0 ){ zInsSql = "INSERT INTO xsql(sqltext) VALUES(CAST(readfile(?1) AS text))"; iFirstInsArg = i+1; break; }else if( strcmp(z,"load-db")==0 ){ zInsSql = "INSERT INTO db(dbcontent) VALUES(readfile(?1))"; iFirstInsArg = i+1; break; }else if( strcmp(z,"m")==0 ){ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); zMsg = argv[++i]; }else if( strcmp(z,"native-vfs")==0 ){ nativeFlag = 1; }else if( strcmp(z,"oss-fuzz")==0 ){ ossFuzz = 1; }else if( strcmp(z,"prng-seed")==0 ){ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); g.uRandom = atoi(argv[++i]); }else if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){ quietFlag = 1; verboseFlag = 0; }else if( strcmp(z,"rebuild")==0 ){ rebuildFlag = 1; }else if( strcmp(z,"result-trace")==0 ){ runFlags |= SQL_OUTPUT; }else if( strcmp(z,"sqlid")==0 ){ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); onlySqlid = integerValue(argv[++i]); }else if( strcmp(z,"timeout")==0 ){ if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]); iTimeout = integerValue(argv[++i]); }else if( strcmp(z,"timeout-test")==0 ){ timeoutTest = 1; #ifndef __unix__ fatalError("timeout is not available on non-unix systems"); #endif }else if( strcmp(z,"verbose")==0 || strcmp(z,"v")==0 ){ quietFlag = 0; verboseFlag++; if( verboseFlag>1 ) runFlags |= SQL_TRACE; }else { fatalError("unknown option: %s", argv[i]); } }else{ nSrcDb++; azSrcDb = safe_realloc(azSrcDb, nSrcDb*sizeof(azSrcDb[0])); azSrcDb[nSrcDb-1] = argv[i]; } } if( nSrcDb==0 ) fatalError("no source database specified"); if( nSrcDb>1 ){ if( zMsg ){ fatalError("cannot change the description of more than one database"); } if( zInsSql ){ fatalError("cannot import into more than one database"); } } /* Process each source database separately */ for(iSrcDb=0; iSrcDb<nSrcDb; iSrcDb++){ rc = sqlite3_open_v2(azSrcDb[iSrcDb], &db, SQLITE_OPEN_READONLY, pDfltVfs->zName); if( rc ){ fatalError("cannot open source database %s - %s", azSrcDb[iSrcDb], sqlite3_errmsg(db)); } rc = sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS db(\n" " dbid INTEGER PRIMARY KEY, -- database id\n" " dbcontent BLOB -- database disk file image\n" ");\n" "CREATE TABLE IF NOT EXISTS xsql(\n" " sqlid INTEGER PRIMARY KEY, -- SQL script id\n" " sqltext TEXT -- Text of SQL statements to run\n" ");" "CREATE TABLE IF NOT EXISTS readme(\n" " msg TEXT -- Human-readable description of this file\n" ");", 0, 0, 0); if( rc ) fatalError("cannot create schema: %s", sqlite3_errmsg(db)); if( zMsg ){ char *zSql; zSql = sqlite3_mprintf( "DELETE FROM readme; INSERT INTO readme(msg) VALUES(%Q)", zMsg); rc = sqlite3_exec(db, zSql, 0, 0, 0); sqlite3_free(zSql); if( rc ) fatalError("cannot change description: %s", sqlite3_errmsg(db)); } ossFuzzThisDb = ossFuzz; /* If the CONFIG(name,value) table exists, read db-specific settings ** from that table */ if( sqlite3_table_column_metadata(db,0,"config",0,0,0,0,0,0)==SQLITE_OK ){ rc = sqlite3_prepare_v2(db, "SELECT name, value FROM config", -1, &pStmt, 0); if( rc ) fatalError("cannot prepare query of CONFIG table: %s", sqlite3_errmsg(db)); while( SQLITE_ROW==sqlite3_step(pStmt) ){ const char *zName = (const char *)sqlite3_column_text(pStmt,0); if( zName==0 ) continue; if( strcmp(zName, "oss-fuzz")==0 ){ ossFuzzThisDb = sqlite3_column_int(pStmt,1); if( verboseFlag ) printf("Config: oss-fuzz=%d\n", ossFuzzThisDb); } if( strcmp(zName, "limit-mem")==0 ){ #if !defined(SQLITE_ENABLE_MEMSYS3) && !defined(SQLITE_ENABLE_MEMSYS5) fatalError("the limit-mem option requires -DSQLITE_ENABLE_MEMSYS5" " or _MEMSYS3"); #else nMemThisDb = sqlite3_column_int(pStmt,1); if( verboseFlag ) printf("Config: limit-mem=%d\n", nMemThisDb); #endif } } sqlite3_finalize(pStmt); } if( zInsSql ){ sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0, readfileFunc, 0, 0); rc = sqlite3_prepare_v2(db, zInsSql, -1, &pStmt, 0); if( rc ) fatalError("cannot prepare statement [%s]: %s", zInsSql, sqlite3_errmsg(db)); rc = sqlite3_exec(db, "BEGIN", 0, 0, 0); if( rc ) fatalError("cannot start a transaction"); for(i=iFirstInsArg; i<argc; i++){ sqlite3_bind_text(pStmt, 1, argv[i], -1, SQLITE_STATIC); sqlite3_step(pStmt); rc = sqlite3_reset(pStmt); if( rc ) fatalError("insert failed for %s", argv[i]); } sqlite3_finalize(pStmt); rc = sqlite3_exec(db, "COMMIT", 0, 0, 0); if( rc ) fatalError("cannot commit the transaction: %s", sqlite3_errmsg(db)); rebuild_database(db); sqlite3_close(db); return 0; } if( zExpDb!=0 || zExpSql!=0 ){ sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0, writefileFunc, 0, 0); if( zExpDb!=0 ){ const char *zExDb = "SELECT writefile(printf('%s/db%06d.db',?1,dbid),dbcontent)," " dbid, printf('%s/db%06d.db',?1,dbid), length(dbcontent)" " FROM db WHERE ?2<0 OR dbid=?2;"; rc = sqlite3_prepare_v2(db, zExDb, -1, &pStmt, 0); if( rc ) fatalError("cannot prepare statement [%s]: %s", zExDb, sqlite3_errmsg(db)); sqlite3_bind_text64(pStmt, 1, zExpDb, strlen(zExpDb), SQLITE_STATIC, SQLITE_UTF8); sqlite3_bind_int(pStmt, 2, onlyDbid); while( sqlite3_step(pStmt)==SQLITE_ROW ){ printf("write db-%d (%d bytes) into %s\n", sqlite3_column_int(pStmt,1), sqlite3_column_int(pStmt,3), sqlite3_column_text(pStmt,2)); } sqlite3_finalize(pStmt); } if( zExpSql!=0 ){ const char *zExSql = "SELECT writefile(printf('%s/sql%06d.txt',?1,sqlid),sqltext)," " sqlid, printf('%s/sql%06d.txt',?1,sqlid), length(sqltext)" " FROM xsql WHERE ?2<0 OR sqlid=?2;"; rc = sqlite3_prepare_v2(db, zExSql, -1, &pStmt, 0); if( rc ) fatalError("cannot prepare statement [%s]: %s", zExSql, sqlite3_errmsg(db)); sqlite3_bind_text64(pStmt, 1, zExpSql, strlen(zExpSql), SQLITE_STATIC, SQLITE_UTF8); sqlite3_bind_int(pStmt, 2, onlySqlid); while( sqlite3_step(pStmt)==SQLITE_ROW ){ printf("write sql-%d (%d bytes) into %s\n", sqlite3_column_int(pStmt,1), sqlite3_column_int(pStmt,3), sqlite3_column_text(pStmt,2)); } sqlite3_finalize(pStmt); } sqlite3_close(db); return 0; } /* Load all SQL script content and all initial database images from the ** source db */ blobListLoadFromDb(db, "SELECT sqlid, sqltext FROM xsql", onlySqlid, &g.nSql, &g.pFirstSql); if( g.nSql==0 ) fatalError("need at least one SQL script"); blobListLoadFromDb(db, "SELECT dbid, dbcontent FROM db", onlyDbid, &g.nDb, &g.pFirstDb); if( g.nDb==0 ){ g.pFirstDb = safe_realloc(0, sizeof(Blob)); memset(g.pFirstDb, 0, sizeof(Blob)); g.pFirstDb->id = 1; g.pFirstDb->seq = 0; g.nDb = 1; sqlFuzz = 1; } /* Print the description, if there is one */ if( !quietFlag ){ zDbName = azSrcDb[iSrcDb]; i = (int)strlen(zDbName) - 1; while( i>0 && zDbName[i-1]!='/' && zDbName[i-1]!='\\' ){ i--; } zDbName += i; sqlite3_prepare_v2(db, "SELECT msg FROM readme", -1, &pStmt, 0); if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){ printf("%s: %s\n", zDbName, sqlite3_column_text(pStmt,0)); } sqlite3_finalize(pStmt); } /* Rebuild the database, if requested */ if( rebuildFlag ){ if( !quietFlag ){ printf("%s: rebuilding... ", zDbName); fflush(stdout); } rebuild_database(db); if( !quietFlag ) printf("done\n"); } /* Close the source database. Verify that no SQLite memory allocations are ** outstanding. */ sqlite3_close(db); if( sqlite3_memory_used()>0 ){ fatalError("SQLite has memory in use before the start of testing"); } /* Limit available memory, if requested */ if( nMemThisDb>0 ){ sqlite3_shutdown(); pHeap = realloc(pHeap, nMemThisDb); if( pHeap==0 ){ fatalError("failed to allocate %d bytes of heap memory", nMem); } sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nMemThisDb, 128); } /* Reset the in-memory virtual filesystem */ formatVfs(); /* Run a test using each SQL script against each database. */ if( !verboseFlag && !quietFlag ) printf("%s:", zDbName); for(pSql=g.pFirstSql; pSql; pSql=pSql->pNext){ for(pDb=g.pFirstDb; pDb; pDb=pDb->pNext){ int openFlags; const char *zVfs = "inmem"; sqlite3_snprintf(sizeof(g.zTestName), g.zTestName, "sqlid=%d,dbid=%d", pSql->id, pDb->id); if( verboseFlag ){ printf("%s\n", g.zTestName); fflush(stdout); }else if( !quietFlag ){ static int prevAmt = -1; int idx = pSql->seq*g.nDb + pDb->id - 1; int amt = idx*10/(g.nDb*g.nSql); if( amt!=prevAmt ){ printf(" %d%%", amt*10); fflush(stdout); prevAmt = amt; } } createVFile("main.db", pDb->sz, pDb->a); sqlite3_randomness(0,0); if( ossFuzzThisDb ){ #ifndef SQLITE_OSS_FUZZ fatalError("--oss-fuzz not supported: recompile with -DSQLITE_OSS_FUZZ"); #else extern int LLVMFuzzerTestOneInput(const uint8_t*, size_t); LLVMFuzzerTestOneInput((const uint8_t*)pSql->a, (size_t)pSql->sz); #endif }else{ openFlags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE; if( nativeFlag && pDb->sz==0 ){ openFlags |= SQLITE_OPEN_MEMORY; zVfs = 0; } rc = sqlite3_open_v2("main.db", &db, openFlags, zVfs); if( rc ) fatalError("cannot open inmem database"); sqlite3_limit(db, SQLITE_LIMIT_LENGTH, 100000000); sqlite3_limit(db, SQLITE_LIMIT_LIKE_PATTERN_LENGTH, 50); if( cellSzCkFlag ) runSql(db, "PRAGMA cell_size_check=ON", runFlags); setAlarm(iTimeout); #ifndef SQLITE_OMIT_PROGRESS_CALLBACK if( sqlFuzz || vdbeLimitFlag ){ sqlite3_progress_handler(db, 100000, progressHandler, &vdbeLimitFlag); } #endif do{ runSql(db, (char*)pSql->a, runFlags); }while( timeoutTest ); setAlarm(0); sqlite3_close(db); } if( sqlite3_memory_used()>0 ) fatalError("memory leak"); reformatVfs(); nTest++; g.zTestName[0] = 0; /* Simulate an error if the TEST_FAILURE environment variable is "5". ** This is used to verify that automated test script really do spot ** errors that occur in this test program. */ if( zFailCode ){ if( zFailCode[0]=='5' && zFailCode[1]==0 ){ fatalError("simulated failure"); }else if( zFailCode[0]!=0 ){ /* If TEST_FAILURE is something other than 5, just exit the test ** early */ printf("\nExit early due to TEST_FAILURE being set\n"); iSrcDb = nSrcDb-1; goto sourcedb_cleanup; } } } } if( !quietFlag && !verboseFlag ){ printf(" 100%% - %d tests\n", g.nDb*g.nSql); } /* Clean up at the end of processing a single source database */ sourcedb_cleanup: blobListFree(g.pFirstSql); blobListFree(g.pFirstDb); reformatVfs(); } /* End loop over all source databases */ if( !quietFlag ){ sqlite3_int64 iElapse = timeOfDay() - iBegin; printf("fuzzcheck: 0 errors out of %d tests in %d.%03d seconds\n" "SQLite %s %s\n", nTest, (int)(iElapse/1000), (int)(iElapse%1000), sqlite3_libversion(), sqlite3_sourceid()); } free(azSrcDb); free(pHeap); return 0; }
the_stack_data/178265582.c
const unsigned char afterboss_psg[] = { 0x8c,0x65,0x90,0xa3,0x59,0xb3,0xce,0x4f,0xd3,0xe6,0xf3,0x38,0xa4,0xcf,0x38,0x91, 0xf5,0x38,0xa5,0xc0,0x50,0xf6,0x38,0x92,0xf8,0x38,0x93,0xa4,0xcf,0x4f,0xf9,0x38, 0xfb,0x38,0x94,0xa3,0xce,0xfc,0x38,0x95,0xb2,0xd2,0xfe,0x38,0xa2,0xcd,0xff,0x38, 0x96,0x38,0xa1,0xcc,0x38,0x90,0xa4,0x5c,0xb3,0xcd,0x50,0x08,0x08,0x00,0xa5,0xce, 0x08,0x0e,0x00,0xa6,0xcf,0x0a,0x15,0x00,0xa5,0xce,0x09,0x1e,0x00,0xa4,0xcd,0x0b, 0x25,0x00,0xa3,0xcc,0x08,0x2e,0x00,0xa2,0xcb,0x38,0x90,0xac,0x5f,0xb3,0xce,0x52, 0x08,0x08,0x00,0xad,0x09,0x0d,0x00,0xae,0xc0,0x53,0x0a,0x15,0x00,0xad,0xcf,0x52, 0x09,0x1e,0x00,0xac,0x0c,0x24,0x00,0xab,0x09,0x2d,0x00,0xaa,0xcc,0x38,0x86,0x6a, 0x08,0x35,0x00,0xc3,0x55,0xd3,0xe5,0xf3,0x38,0xa5,0xc4,0x08,0x0e,0x00,0xa6,0xc5, 0x0a,0x15,0x00,0xa5,0xc4,0x09,0x1e,0x00,0xa4,0xc3,0x0b,0x25,0x00,0xa3,0xc2,0x08, 0x2e,0x00,0xa2,0xc1,0x38,0x97,0x38,0xa3,0xc2,0x38,0x98,0x38,0xa4,0xc3,0x38,0xb1, 0xd1,0x38,0x99,0xa5,0xc4,0x39,0xa6,0xc5,0x38,0x9a,0x38,0xa5,0xc4,0x39,0xa4,0xc3, 0x09,0x59,0x00,0xc3,0x59,0x08,0x85,0x00,0xad,0xc4,0x08,0x0e,0x00,0xae,0xc5,0x0a, 0x15,0x00,0xad,0xc4,0x09,0x1e,0x00,0xac,0xc3,0x0b,0x25,0x00,0xab,0xc2,0x08,0x2e, 0x00,0xaa,0xc1,0x38,0x89,0x78,0x90,0xae,0x52,0xb3,0xc7,0x56,0xd3,0xe4,0xfe,0x38, 0xaf,0xc8,0xfd,0x38,0x91,0x38,0xa0,0x53,0xc9,0x38,0x92,0x38,0x93,0xaf,0x52,0xc8, 0x39,0x94,0xae,0xc7,0x09,0x25,0x00,0x38,0xad,0xc6,0x38,0x96,0x38,0xac,0xc5,0x38, 0x97,0xfb,0x08,0x07,0x01,0x98,0x38,0xae,0xc7,0x09,0xae,0x00,0xaf,0xc8,0xfa,0x39, 0x08,0xf6,0x00,0x9a,0x38,0x08,0xfd,0x00,0xae,0xc7,0xf9,0x38,0x9b,0x38,0xad,0xc6, 0x39,0xac,0xc5,0x38,0x9c,0xf8,0x08,0x2d,0x01,0xae,0xc7,0x39,0xaf,0xc8,0xf7,0x38, 0x9d,0x08,0xf5,0x00,0x39,0x08,0xfd,0x00,0x9e,0xae,0xc7,0xf6,0x39,0xad,0xb2,0xc6, 0xd2,0x08,0x30,0x01,0x9f,0xf5,0x08,0x2d,0x01,0x08,0x39,0x01,0xb3,0xc8,0xd3,0xf4, 0x39,0xa0,0x53,0xc9,0x39,0x08,0xfd,0x00,0xae,0xc7,0xf3,0x39,0xad,0xb4,0xc6,0xd4, 0x08,0x30,0x01,0xae,0xc7,0xf2,0x38,0xb5,0xd5,0x38,0xb7,0xd7,0x38,0xb8,0xd8,0x38, 0xb9,0xd9,0x38,0xbb,0xdb,0xf1,0x38,0xbc,0xdc,0x38,0xbe,0xde,0x38,0xbf,0xdf,0x3a, 0xf0,0x3f,0x3f,0x3f,0x3f,0x3f,0x3c,0xf1,0x3b,0xe4,0x39,0xf2,0x39,0xf3,0x38,0xf4, 0x39,0xf5,0x38,0xf6,0x39,0xf7,0x39,0xe4,0xf2,0x39,0xf3,0x39,0xf4,0x38,0xf5,0x39, 0xf6,0x38,0xf7,0x39,0xf8,0x39,0xe4,0xf3,0x39,0x0b,0x9f,0x01,0x38,0xf8,0x39,0xf9, 0x39,0xe4,0xf4,0x39,0x0b,0xae,0x01,0x38,0xf9,0x39,0xfa,0x39,0xe4,0xf5,0x39,0xf6, 0x39,0xf7,0x08,0xbc,0x01,0x38,0xfa,0x39,0xfb,0x39,0xe4,0x08,0xa3,0x01,0xf8,0x08, 0xc7,0x01,0x38,0xfb,0x39,0xfc,0x39,0xe4,0x08,0xb2,0x01,0xf9,0x08,0xd5,0x01,0x38, 0xfc,0x39,0xfd,0x39,0xe4,0x08,0xbd,0x01,0xfa,0x08,0xe2,0x01,0x38,0xfd,0x39,0xfe, 0x39,0xe4,0x08,0xc8,0x01,0xfb,0x08,0xef,0x01,0x38,0xfe,0x39,0xff,0x39,0xe4,0x08, 0xd6,0x01,0xfc,0x08,0xfc,0x01,0x38,0xff,0x3b,0xe4,0x08,0xe3,0x01,0xfd,0x08,0x09, 0x02,0x3c,0xe4,0x08,0xf0,0x01,0xfe,0x38,0xff,0x3e,0xe4,0x08,0xfd,0x01,0xff,0x3f, 0xe4,0xfe,0x39,0xff,0x3f,0x39,0xe4,0x3f,0x3f,0x3f,0x00}; const unsigned char firetiles_bin[] = { 0x01,0x0e,0x31,0x3e,0x02,0x05,0x3a,0x3d,0x03,0x0c,0x33,0x3c,0x02,0x09,0x36,0x3d, 0x01,0x04,0x3b,0x3e,0x02,0x0d,0x32,0x3d,0x03,0x08,0x37,0x3c,0x01,0x0c,0x33,0x3e, 0x40,0x90,0x6c,0xbc,0xc0,0x30,0xcc,0x3c,0x80,0x30,0xcc,0x7c,0x80,0x50,0xac,0x7c, 0x80,0x70,0x8c,0x7c,0xc0,0x20,0xdc,0x3c,0x00,0xb0,0x4c,0xfc,0xc0,0x30,0xcc,0x3c, 0x03,0x04,0x3b,0x3c,0x01,0x0c,0x33,0x3e,0x03,0x08,0x37,0x3c,0x01,0x06,0x19,0x1e, 0x00,0x06,0x19,0x1f,0x03,0x08,0x37,0x3c,0x01,0x04,0x3b,0x3e,0x03,0x0c,0x33,0x3c, 0x00,0xb0,0x4c,0xfc,0xc0,0x20,0xdc,0x3c,0x40,0xb0,0x4c,0xbc,0xa0,0x18,0xe6,0x5e, 0xe0,0x08,0xf6,0x1e,0x40,0xb0,0x4c,0xbc,0x80,0x50,0xac,0x7c,0xc0,0x30,0xcc,0x3c, 0x02,0x09,0x36,0x3d,0x01,0x0c,0x33,0x3e,0x01,0x06,0x19,0x1e,0x01,0x02,0x1d,0x1e, 0x00,0x06,0x19,0x1f,0x01,0x04,0x1b,0x1e,0x03,0x0c,0x33,0x3c,0x02,0x09,0x36,0x3d, 0x80,0x50,0xac,0x7c,0xc0,0x10,0xec,0x3c,0xe0,0x08,0xf6,0x1e,0x60,0x98,0x66,0x9e, 0xc0,0x18,0xe6,0x3e,0xe0,0x18,0xe6,0x1e,0x80,0x60,0x9c,0x7c,0xc0,0x30,0xcc,0x3c, 0x03,0x04,0x3b,0x3c,0x01,0x04,0x1b,0x1e,0x01,0x06,0x19,0x1e,0x01,0x04,0x1b,0x1e, 0x01,0x06,0x19,0x1e,0x01,0x02,0x1d,0x1e,0x00,0x06,0x19,0x1f,0x03,0x04,0x3b,0x3c, 0xc0,0x30,0xcc,0x3c,0x40,0x98,0x66,0xbe,0xe0,0x18,0xe6,0x1e,0xe0,0x08,0xf6,0x1e, 0xa0,0x58,0xa6,0x5e,0xc0,0x18,0xe6,0x3e,0xe0,0x08,0xf6,0x1e,0xc0,0x30,0xcc,0x3c, 0x01,0x0c,0x33,0x3e,0x01,0x02,0x1d,0x1e,0x00,0x06,0x19,0x1f,0x00,0x03,0x0c,0x0f, 0x00,0x01,0x0e,0x0f,0x01,0x06,0x19,0x1e,0x00,0x02,0x1d,0x1f,0x03,0x0c,0x33,0x3c, 0x40,0x90,0x6c,0xbc,0xe0,0x18,0xe6,0x1e,0xa0,0x48,0xb6,0x5e,0xf0,0x0c,0xf3,0x0f, 0xf0,0x04,0xfb,0x0f,0x60,0x88,0x76,0x9e,0xe0,0x18,0xe6,0x1e,0xc0,0x30,0xcc,0x3c, 0x01,0x0c,0x33,0x3e,0x01,0x02,0x1d,0x1e,0x00,0x03,0x0c,0x0f,0x00,0x02,0x0d,0x0f, 0x00,0x03,0x0c,0x0f,0x00,0x01,0x0e,0x0f,0x01,0x06,0x19,0x1e,0x02,0x08,0x37,0x3d, 0xc0,0x20,0xdc,0x3c,0xa0,0x58,0xa6,0x5e,0xf0,0x00,0xff,0x0f,0xd0,0x0c,0xf3,0x2f, 0xf0,0x0c,0xf3,0x0f,0xf0,0x04,0xfb,0x0f,0xa0,0x58,0xa6,0x5e,0xc0,0x20,0xdc,0x3c, 0x03,0x0c,0x33,0x3c,0x01,0x04,0x1b,0x1e,0x00,0x03,0x0c,0x0f,0x00,0x01,0x86,0x87, 0x00,0x00,0x87,0x87,0x00,0x03,0x0c,0x0f,0x00,0x06,0x19,0x1f,0x03,0x08,0x37,0x3c, 0xc0,0x10,0xec,0x3c,0xe0,0x18,0xe6,0x1e,0xa0,0x4c,0xb3,0x5f,0x78,0x02,0xfd,0x87, 0x58,0xa6,0x59,0xa7,0xe0,0x14,0xeb,0x1f,0xe0,0x18,0xe6,0x1e,0x80,0x70,0x8c,0x7c, 0x00,0x06,0x19,0x1f,0x00,0x03,0x0c,0x0f,0x00,0x01,0x86,0x87,0x00,0x00,0xc3,0xc3, 0x00,0x00,0xc3,0xc3,0x00,0x00,0x87,0x87,0x00,0x03,0x0c,0x0f,0x01,0x04,0x1b,0x1e, 0xc0,0x18,0xe6,0x3e,0xf0,0x0c,0xf3,0x0f,0x70,0x06,0xf9,0x8f,0x2c,0x53,0xac,0xd3, 0x34,0xc9,0x36,0xcb,0x58,0x86,0x79,0xa7,0x70,0x08,0xf7,0x8f,0xe0,0x18,0xe6,0x1e, 0x01,0x04,0x1b,0x1e,0x00,0x03,0x0c,0x0f,0x00,0x00,0xc3,0xc3,0x00,0x80,0x61,0xe1, 0x00,0x80,0x61,0xe1,0x00,0x00,0xc3,0xc3,0x00,0x03,0x0c,0x0f,0x00,0x06,0x19,0x1f, 0xa0,0x48,0xb6,0x5e,0x70,0x0c,0xf3,0x8f,0x2c,0xd3,0x2c,0xd3,0x1a,0x41,0xbe,0xe5, 0x1c,0x61,0x9e,0xe3,0x3c,0x83,0x7c,0xc3,0xf0,0x08,0xf7,0x0f,0xa0,0x48,0xb6,0x5e, 0x01,0x06,0x19,0x1e,0x00,0x01,0x0e,0x0f,0x00,0x01,0x86,0x87,0x00,0x00,0xc3,0xc3, 0x00,0x00,0xc3,0xc3,0x00,0x01,0x86,0x87,0x00,0x03,0x0c,0x0f,0x01,0x04,0x1b,0x1e, 0xe0,0x18,0xe6,0x1e,0x60,0x14,0xeb,0x9f,0x38,0x86,0x79,0xc7,0x30,0xcb,0x34,0xcf, 0x3c,0x41,0xbe,0xc3,0x58,0xa6,0x59,0xa7,0x70,0x08,0xf7,0x8f,0xe0,0x08,0xf6,0x1e, 0x03,0x0c,0x33,0x3c,0x01,0x04,0x1b,0x1e,0x00,0x03,0x0c,0x0f,0x00,0x01,0x86,0x87, 0x00,0x01,0x86,0x87,0x00,0x02,0x0d,0x0f,0x01,0x06,0x19,0x1e,0x03,0x08,0x37,0x3c, 0x40,0xb0,0x4c,0xbc,0xe0,0x18,0xe6,0x1e,0xe0,0x0c,0xf3,0x1f,0x58,0x20,0xdf,0xa7, 0x68,0x96,0x69,0x97,0xb0,0x4c,0xb3,0x4f,0xe0,0x00,0xfe,0x1e,0x00,0x30,0xcc,0xfc, 0x03,0x0c,0x33,0x3c,0x01,0x04,0x1b,0x1e,0x00,0x03,0x0c,0x0f,0x00,0x03,0x0c,0x0f, 0x00,0x02,0x0d,0x0f,0x00,0x03,0x0c,0x0f,0x01,0x04,0x1b,0x1e,0x03,0x0c,0x33,0x3c, 0xc0,0x30,0xcc,0x3c,0xe0,0x08,0xf6,0x1e,0x30,0x44,0xbb,0xcf,0xe0,0x0c,0xf3,0x1f, 0x50,0xac,0x53,0xaf,0xf0,0x04,0xfb,0x0f,0xe0,0x08,0xf6,0x1e,0x40,0xb0,0x4c,0xbc, 0x02,0x0c,0x33,0x3d,0x01,0x06,0x19,0x1e,0x01,0x04,0x1b,0x1e,0x00,0x03,0x0c,0x0f, 0x00,0x02,0x0d,0x0f,0x01,0x06,0x19,0x1e,0x01,0x02,0x1d,0x1e,0x03,0x0c,0x33,0x3c, 0xc0,0x10,0xec,0x3c,0x60,0x98,0x66,0x9e,0xc0,0x18,0xe6,0x3e,0xd0,0x0c,0xf3,0x2f, 0xa0,0x4c,0xb3,0x5f,0xc0,0x18,0xe6,0x3e,0x60,0x98,0x66,0x9e,0xc0,0x10,0xec,0x3c, 0x02,0x0c,0x33,0x3d,0x01,0x02,0x1d,0x1e,0x01,0x06,0x19,0x1e,0x01,0x04,0x1b,0x1e, 0x01,0x02,0x1d,0x1e,0x01,0x06,0x19,0x1e,0x00,0x06,0x19,0x1f,0x01,0x0c,0x33,0x3e, 0x80,0x70,0x8c,0x7c,0xc0,0x18,0xe6,0x3e,0x60,0x98,0x66,0x9e,0xe0,0x08,0xf6,0x1e, 0xa0,0x58,0xa6,0x5e,0xe0,0x08,0xf6,0x1e,0xa0,0x18,0xe6,0x5e,0x40,0xb0,0x4c,0xbc, 0x03,0x04,0x3b,0x3c,0x01,0x0c,0x33,0x3e,0x01,0x06,0x19,0x1e,0x01,0x02,0x1d,0x1e, 0x01,0x06,0x19,0x1e,0x00,0x05,0x1a,0x1f,0x03,0x0c,0x33,0x3c,0x03,0x08,0x37,0x3c, 0xc0,0x10,0xec,0x3c,0xc0,0x30,0xcc,0x3c,0xa0,0x18,0xe6,0x5e,0xa0,0x58,0xa6,0x5e, 0xe0,0x08,0xf6,0x1e,0xc0,0x18,0xe6,0x3e,0xc0,0x20,0xdc,0x3c,0x40,0xb0,0x4c,0xbc, 0x03,0x0c,0x33,0x3c,0x00,0x0d,0x32,0x3f,0x03,0x08,0x37,0x3c,0x01,0x06,0x19,0x1e, 0x01,0x04,0x1b,0x1e,0x03,0x0c,0x33,0x3c,0x02,0x09,0x36,0x3d,0x03,0x0c,0x33,0x3c, 0xc0,0x30,0xcc,0x3c,0x80,0x30,0xcc,0x7c,0xc0,0x10,0xec,0x3c,0x60,0x90,0x6e,0x9e, 0xc0,0x18,0xe6,0x3e,0x80,0x30,0xcc,0x7c,0xc0,0x10,0xec,0x3c,0x80,0x70,0x8c,0x7c}; const unsigned char fortressphantom_psgcompr[] = { 0x10,0x00,0xaa,0xef,0x00,0x04,0xc2,0x00,0x01,0x05,0x0c,0x18,0x30,0x20,0xf2,0x01, 0x04,0x08,0x00,0xaa,0xef,0x00,0x20,0xc2,0x00,0x80,0xa0,0x30,0x18,0x0c,0x20,0xf2, 0x80,0x20,0x10,0x00,0xaa,0xf7,0x00,0x04,0x43,0x00,0x30,0x18,0x0c,0x05,0x01,0x20, 0x4f,0x08,0x04,0x01,0x00,0xaa,0xf7,0x00,0x20,0x43,0x00,0x0c,0x18,0x30,0xa0,0x80, 0x20,0x4f,0x10,0x20,0x80,0x00,0xaa,0xee,0x00,0x04,0x10,0xc2,0x00,0x01,0x05,0x05, 0x1d,0x25,0x20,0xf0,0x05,0x0d,0x01,0x0f,0x20,0xf7,0x08,0xaa,0xfe,0x00,0x08,0xc2, 0x00,0x80,0xa0,0xa0,0xb8,0xa4,0xf0,0x00,0xa0,0xb0,0x80,0xf0,0x20,0xf7,0x10,0xaa, 0x77,0x00,0x10,0x04,0x43,0x00,0x25,0x1d,0x05,0x05,0x01,0x20,0x0f,0x0f,0x01,0x0d, 0x05,0x20,0xef,0x08,0xaa,0x7f,0x00,0x08,0x43,0x00,0xa4,0xb8,0xa0,0xa0,0x80,0x0f, 0x00,0xf0,0x80,0xb0,0xa0,0x20,0xef,0x10,0xbe,0xa8,0x00,0x02,0x21,0x01,0x40,0x14, 0x00,0x02,0x18,0x31,0x28,0x02,0x4b,0x13,0x00,0x02,0x02,0x2a,0x1a,0x03,0x7f,0x07, 0xad,0x00,0x02,0x20,0x40,0xbe,0xa8,0x00,0x40,0x84,0x80,0x02,0x28,0x00,0x40,0x18, 0x8c,0x14,0x40,0xd2,0xc8,0x00,0x40,0x40,0x54,0x58,0xc0,0xfe,0xe0,0xad,0x00,0x40, 0x04,0x02,0xbe,0x15,0x00,0x14,0x40,0x01,0x21,0x02,0x13,0x4b,0x02,0x28,0x31,0x18, 0x02,0x00,0x07,0x7f,0x03,0x1a,0x2a,0x02,0x02,0x00,0xb5,0x00,0x40,0x20,0x02,0xbe, 0x15,0x00,0x28,0x02,0x80,0x84,0x40,0xc8,0xd2,0x40,0x14,0x8c,0x18,0x40,0x00,0xe0, 0xfe,0xc0,0x58,0x54,0x40,0x40,0x00,0xb5,0x00,0x02,0x04,0x40,0xfe,0x00,0x35,0x50, 0x64,0x04,0x5d,0x01,0x03,0x04,0x05,0x40,0x53,0x00,0xc1,0x12,0x44,0x00,0x05,0x14, 0x33,0x00,0x61,0x10,0x10,0x9b,0x00,0x35,0x20,0x41,0xfe,0x00,0xac,0x0a,0x26,0x20, 0xba,0x80,0xc0,0x20,0xa0,0x02,0xca,0x00,0x83,0x48,0x22,0x00,0xa0,0x28,0xcc,0x00, 0x86,0x08,0x08,0x9b,0x00,0xac,0x04,0x82,0xfa,0x03,0x01,0x1c,0x04,0x44,0x20,0x30, 0x00,0x54,0x12,0xc1,0x00,0x52,0x40,0x05,0x04,0x13,0x00,0x10,0x10,0x20,0x33,0x14, 0xf9,0x00,0x20,0x30,0xfa,0xc0,0x80,0x38,0x20,0x22,0x06,0x0c,0x00,0x2a,0x48,0x83, 0x00,0x48,0x00,0xa0,0x20,0x13,0x00,0x08,0x08,0x04,0xcc,0x28,0xf1,0x00,0x02,0x06, 0x0c}; const unsigned char norefuge_psg[] = { 0x89,0x78,0x97,0xa4,0x5c,0xb7,0xc6,0x6a,0xd7,0xe0,0xff,0x38,0x8b,0xa6,0xc8,0x38, 0x87,0x72,0x96,0xa3,0x59,0xb6,0xcc,0x65,0xd6,0x38,0x89,0xa5,0xce,0x38,0x89,0x6f, 0x95,0xac,0x57,0xb5,0xca,0x63,0xd5,0x38,0x8b,0xae,0xcc,0x38,0x86,0x6a,0x94,0xa3, 0x55,0xb4,0xcc,0x5f,0xd4,0x38,0x88,0xa5,0xce,0x38,0x8c,0x65,0x93,0xae,0x52,0xb3, 0xc4,0x5c,0xd3,0x38,0x8e,0xa0,0x53,0xc6,0x38,0x8a,0x61,0x92,0xad,0x50,0xb2,0xc3, 0x59,0xd2,0x38,0x8c,0xaf,0xc5,0x38,0x8c,0x5f,0x91,0xae,0x4f,0xb1,0xcc,0x57,0xd1, 0x38,0x8e,0xa0,0x50,0xce,0x39,0x8c,0xae,0x4f,0xcc,0x39,0x8a,0xac,0xca,0x38,0x92, 0xb2,0xd2,0x38,0x8c,0xae,0xcc,0x39,0x08,0x61,0x00,0x38,0x93,0xb3,0xd3,0x38,0x0d, 0x66,0x00,0x94,0xb4,0xd4,0x38,0x8c,0xae,0xcc,0x39,0x8e,0xa0,0x50,0xce,0x38,0x95, 0xb5,0xd5,0x38,0x8c,0xae,0x4f,0xcc,0x38,0x89,0x78,0x97,0xa4,0x5c,0xb7,0xc6,0x6a, 0xd7,0x37,0x0b,0x00,0x37,0x3e,0x00,0x0a,0x71,0x00,0x09,0x8a,0x00,0x08,0x7b,0x00, 0x0d,0x66,0x00,0x23,0x82,0x00,0x37,0x0b,0x00,0x37,0x3e,0x00,0x0a,0x71,0x00,0x09, 0x8a,0x00,0x08,0x7b,0x00,0x0d,0x66,0x00,0x23,0x82,0x00,0x37,0x0b,0x00,0x37,0x3e, 0x00,0x0a,0x71,0x00,0x09,0x8a,0x00,0x08,0x7b,0x00,0x0d,0x66,0x00,0x23,0x82,0x00, 0x37,0x0b,0x00,0x37,0x3e,0x00,0x0a,0x71,0x00,0x09,0x8a,0x00,0x08,0x7b,0x00,0x0d, 0x66,0x00,0x23,0x82,0x00,0x37,0x0b,0x00,0x37,0x3e,0x00,0x0a,0x71,0x00,0x09,0x8a, 0x00,0x08,0x7b,0x00,0x0d,0x66,0x00,0x19,0x82,0x00,0x09,0x6a,0x00,0x96,0xb6,0xd6, 0x0e,0x85,0x00,0x97,0xb7,0xd7,0x38,0x0d,0x66,0x00,0x98,0xb8,0xd8,0x0e,0x85,0x00, 0x99,0xb9,0xd9,0x38,0x0d,0x66,0x00,0x9a,0xba,0xda,0x0e,0x85,0x00,0x9b,0xbb,0xdb, 0x38,0x0d,0x66,0x00,0x9c,0xbc,0xdc,0x0e,0x85,0x00,0x9d,0xbd,0xdd,0x38,0x0d,0x66, 0x00,0x9e,0xbe,0xde,0x0e,0x85,0x00,0x9f,0xbf,0xdf,0x38,0x0c,0x66,0x00,0x39,0x0c, 0x86,0x00,0x0d,0x65,0x00,0x39,0x0c,0x86,0x00,0x0d,0x65,0x00,0x39,0x0c,0x86,0x00, 0x09,0x65,0x00,0x38,0x00}; const unsigned char stage1endboss_psgcompr[] = { 0x1e,0x00,0xa8,0xf0,0x00,0x03,0x03,0x43,0x67,0xe0,0x00,0x83,0xc7,0xe6,0xb6,0x9f, 0xfe,0x00,0x10,0xf8,0x00,0x07,0x0f,0x0f,0xdf,0x7f,0x3d,0xf1,0x07,0x0f,0x1b,0xdd, 0xff,0xfd,0x9f,0xfd,0xc8,0x00,0x04,0x02,0x82,0xe0,0x02,0xa8,0x1b,0xbd,0x00,0xc3, 0xe7,0xff,0x31,0x7e,0xc3,0xe7,0x5a,0xff,0x5a,0xe4,0x00,0x42,0x66,0x66,0x42,0xf8, 0x00,0xe0,0xf0,0xf0,0xfb,0xfe,0xbc,0x8f,0xe0,0xf0,0xd8,0xbb,0xff,0xbf,0xf9,0xbf, 0xc8,0x00,0x20,0x40,0x41,0x07,0x40,0xa8,0xf0,0x00,0xc0,0xc0,0xc2,0xe6,0xe0,0x00, 0xc1,0xe3,0x67,0x6d,0xf9,0xfe,0x00,0x08,0xfe,0x63,0x41,0x60,0x21,0x21,0x01,0x00, 0x0b,0x9e,0xbb,0x99,0x5d,0x5d,0x3a,0x89,0xcf,0x18,0x0c,0x16,0x1b,0x1b,0x0d,0x06, 0x03,0xe6,0x00,0x01,0x01,0x03,0xef,0x23,0xb3,0x61,0xa3,0xa3,0xc2,0x41,0xc1,0x38, 0xf3,0xb3,0xbf,0x6f,0xef,0xef,0xce,0x42,0x0c,0x8e,0x8e,0xd2,0x51,0xd1,0x02,0x02, 0x00,0x82,0x82,0x42,0x41,0xc1,0xea,0xe7,0xe7,0xc3,0x00,0x00,0x24,0x7e,0xff,0x9b, 0xff,0x7e,0x7e,0xc3,0xfb,0x00,0xff,0x02,0xef,0xc4,0xcd,0x86,0xc5,0xc5,0x43,0x82, 0x83,0x38,0xcf,0xcd,0xfd,0xf6,0xf7,0xf7,0x73,0x42,0x30,0x71,0x71,0x4b,0x8a,0x8b, 0x40,0x40,0x00,0x41,0x41,0x42,0x82,0x83,0xfe,0xc6,0x82,0x06,0x84,0x84,0x80,0x00, 0xd0,0x79,0xdd,0x99,0xba,0xba,0x5c,0x91,0xf3,0x18,0x30,0x68,0xd8,0xd8,0xb0,0x60, 0xc0,0xe6,0x00,0x80,0x80,0xc0,0xee,0x4c,0x2c,0x45,0x64,0x66,0x63,0x67,0x67,0x1b, 0x9e,0xab,0xde,0xbf,0x9f,0x00,0x03,0x02,0x13,0x11,0x18,0x15,0x15,0xfc,0x00,0x04, 0x04,0xfe,0x03,0xdf,0xff,0xf7,0xe7,0xce,0x1a,0x32,0xcf,0x7e,0xfc,0x79,0xff,0xdf, 0x1f,0x3f,0x32,0x9c,0x00,0x88,0x18,0x30,0xe0,0xc0,0x3f,0x00,0x02,0x1c,0xba,0x07, 0x00,0xe7,0x81,0x81,0x24,0x24,0xff,0xe7,0xff,0xc3,0xc3,0x18,0x7e,0x7e,0x41,0xe0, 0x7e,0x7e,0xff,0xe7,0xc3,0xa7,0x00,0x18,0x7e,0x7e,0xfe,0xc0,0xfb,0xff,0xef,0xe7, 0x73,0x58,0x4c,0xf3,0x7e,0x3f,0x9e,0xff,0xfb,0xf8,0xfc,0x4c,0x39,0x00,0x11,0x18, 0x0c,0x07,0x03,0x3f,0x00,0x40,0x38,0xee,0x32,0x34,0xa2,0x26,0x66,0xc6,0xe6,0xe6, 0x1b,0x79,0xd5,0x7b,0xfd,0xf9,0x00,0xc0,0x40,0xc8,0x88,0x18,0xa8,0xa8,0xfc,0x00, 0x20,0x20,0xbe,0x1a,0x38,0x27,0x43,0x31,0x7c,0x09,0x5e,0xfb,0x49,0x7c,0x7c,0xce, 0x45,0x75,0x1d,0x0e,0x37,0x03,0x03,0x31,0x3a,0x0b,0x1e,0x00,0x04,0x02,0x01,0x01, 0xff,0x4e,0xb2,0xcf,0xf6,0xfa,0xfc,0x76,0x96,0x7f,0xbf,0xcf,0x7e,0x7e,0x7c,0xfa, 0xfa,0x80,0x4c,0xb1,0xc1,0xc1,0xb3,0x6d,0x8d,0x00,0x00,0x81,0x40,0x40,0x30,0x60, 0x80,0xfa,0x00,0x00,0x24,0xa5,0x81,0xdb,0xdb,0xff,0x7e,0x18,0xc3,0xc3,0xff,0x3c, 0x3c,0x7e,0x86,0xe7,0xff,0x7e,0x7e,0x00,0x81,0xcf,0x00,0x7e,0x7e,0xff,0x72,0x4d, 0xf3,0x6f,0x5f,0x3f,0x6e,0x69,0xfe,0xfd,0xf3,0x7e,0x7e,0x3e,0x5f,0x5f,0x01,0x32, 0x8d,0x83,0x83,0xcd,0xb6,0xb1,0x00,0x00,0x81,0x02,0x02,0x0c,0x06,0x01,0xbe,0x1a, 0x1c,0xe4,0xc2,0x8c,0x3e,0x90,0x7a,0xdf,0x92,0x3e,0x3e,0x73,0xa2,0xae,0xb8,0x70, 0xec,0xc0,0xc0,0x8c,0x5c,0xd0,0x1e,0x00,0x20,0x40,0x80,0x80,0xfa,0x30,0x00,0x00, 0x40,0x40,0x70,0x30,0x10,0x7a,0x79,0x49,0xf9,0xf9,0xc8,0x78,0x38,0x1b,0x00,0x31, 0x30,0x30,0x30,0x7f,0x00,0x30,0xae,0x1f,0x15,0x77,0x5f,0x2e,0x34,0xff,0x7b,0xfb, 0x5f,0x7f,0x7f,0xed,0x44,0x20,0xb0,0xb0,0x10,0x30,0x10,0x1f,0x10,0x61,0x40,0x20, 0xa8,0x61,0x99,0xbd,0x5a,0xbd,0xdb,0xa5,0xc2,0x3c,0xa5,0xe7,0xe7,0x7e,0x24,0x41, 0x86,0xe7,0x66,0x24,0x00,0xe7,0xae,0x1f,0xa8,0xee,0xfa,0x74,0x34,0xff,0xde,0xdf, 0xfa,0xfe,0xfe,0xb7,0x22,0x04,0x0d,0x0d,0x08,0x0c,0x08,0x1f,0x08,0x86,0x02,0x04, 0xfa,0x0c,0x00,0x00,0x02,0x02,0x0e,0x0c,0x08,0x5e,0x9e,0x92,0x9f,0x9f,0x13,0x1e, 0x1c,0x1b,0x00,0x8c,0x0c,0x0c,0x0c,0x7f,0x00,0x0c,0x20,0x7f,0x00,0x10,0xaa,0x0f, 0x00,0x11,0x0f,0x03,0x01,0x07,0x00,0x7f,0x5f,0x23,0x1f,0x03,0x1f,0x00,0x30,0x3e, 0x1e,0x1f,0x00,0x10,0x0e,0x02,0xb8,0xf0,0x99,0xdb,0x7e,0x3c,0x00,0x3c,0x24,0x24, 0xa5,0xe7,0xe7,0x7e,0x3c,0x07,0x00,0xe7,0xe7,0xe7,0x66,0x24,0xaa,0x0f,0x00,0x88, 0xf0,0xc0,0x80,0x07,0x00,0xfe,0xfa,0xc4,0xf8,0xc0,0x1f,0x00,0x0c,0x7c,0x78,0x1f, 0x00,0x08,0x70,0x40,0x20,0x7f,0x00,0x08}; const unsigned char stage1middleboss_psgcompr[] = { 0x19,0x00,0xba,0x38,0x40,0x00,0x00,0x46,0x44,0x03,0x80,0xc0,0xa0,0xa0,0xbf,0xb0, 0xb3,0x66,0xf0,0x00,0x20,0x2f,0x2c,0x3b,0xfe,0x00,0x03,0xaa,0xf8,0x00,0x80,0xbd, 0x35,0xe0,0x00,0x01,0xc1,0xfd,0x7f,0xe7,0x20,0xfc,0x80,0x98,0x22,0xfe,0x80,0xa8, 0x70,0x18,0x00,0x99,0x99,0xff,0x66,0x5c,0x24,0x18,0xe7,0xff,0xff,0xc2,0x00,0x24, 0xe7,0xe7,0xe7,0x81,0xaa,0xf8,0x00,0x01,0xbd,0xac,0xe0,0x00,0x80,0x83,0xbf,0xfe, 0xe7,0x20,0xfc,0x01,0x19,0x22,0xfe,0x01,0xba,0x38,0x02,0x00,0x00,0x62,0x22,0xc0, 0x01,0x03,0x05,0x05,0xfd,0x0d,0xcd,0x66,0xf0,0x00,0x04,0xf4,0x34,0xdc,0xfe,0x00, 0xc0,0xfe,0x04,0x0f,0x0f,0x1f,0x06,0x03,0x1b,0x4f,0x23,0x1b,0x1b,0x3e,0x37,0x33, 0x79,0xb5,0x1c,0x04,0x04,0x01,0x18,0x1c,0x26,0x3a,0xfc,0x00,0x20,0x18,0xfa,0x39, 0xf6,0xf5,0x06,0x0b,0x0d,0x04,0x0d,0xfb,0xe7,0xe7,0xff,0x17,0xb7,0x87,0xb6,0x41, 0xf0,0xf8,0x5d,0x7c,0x5d,0xf0,0x00,0x18,0x1d,0x04,0x1d,0xaa,0xe0,0xe7,0xa5,0x5a, 0x00,0x5a,0xa5,0x1b,0xff,0xbd,0xbd,0xbd,0xa5,0xf1,0x00,0x5a,0x5a,0x5a,0x22,0xfb, 0x00,0xfa,0x9c,0x6f,0xaf,0x60,0xd0,0xb0,0x20,0xb0,0xdf,0xe7,0xe7,0xff,0xe8,0xed, 0xe1,0x6d,0x41,0xf0,0x1f,0xba,0x3e,0xba,0xf0,0x00,0x18,0xb8,0x20,0xb8,0xfe,0x20, 0xf0,0xf0,0xf8,0x60,0xc0,0xd8,0xf2,0xc4,0xd8,0xd8,0x7c,0xec,0xcc,0x9e,0xad,0x38, 0x20,0x20,0x80,0x18,0x38,0x64,0x5c,0xfc,0x00,0x04,0x18,0xaa,0x0f,0x08,0x4f,0x47, 0x57,0x55,0x0e,0x75,0xb5,0xbf,0xa7,0xa6,0x35,0x0e,0x38,0x3a,0x24,0x1e,0x3d,0x18, 0x8f,0x18,0x04,0x06,0x04,0xff,0x0d,0x01,0x85,0xc6,0xe6,0xf8,0xf8,0xe1,0xb2,0x8e, 0xc2,0x61,0x39,0xbf,0xbf,0x6e,0x5d,0x7d,0x3b,0x99,0xc1,0x40,0x40,0x97,0x1d,0x0d, 0x03,0x01,0x01,0x00,0x00,0x07,0xae,0x16,0x5a,0xa5,0xdb,0x99,0x3c,0xdb,0xce,0xff, 0xa5,0xe7,0x7e,0x00,0x24,0x66,0x24,0x00,0x42,0x42,0xc3,0xf8,0x00,0x42,0x42,0xc3, 0xff,0xb0,0x80,0xa1,0x63,0x67,0x1f,0x1f,0x87,0x4d,0x71,0x43,0x86,0x9c,0xfd,0xfd, 0x76,0xba,0xbe,0xdc,0x99,0x83,0x02,0x02,0xe9,0xb8,0xb0,0xc0,0x80,0x80,0x00,0x00, 0xe0,0xaa,0x0f,0x10,0xf2,0xe2,0xea,0xaa,0x0e,0xae,0xad,0xfd,0xe5,0x65,0xac,0x0e, 0x1c,0x5c,0x24,0x78,0xbc,0x18,0x8f,0x18,0x20,0x60,0x20,0xba,0x7f,0x00,0x08,0x35, 0x1d,0x1d,0x05,0x04,0x04,0x00,0x00,0x7f,0x00,0x18,0x02,0xa8,0x0f,0x00,0xa6,0xfa, 0xf0,0xe0,0x07,0x00,0x29,0xfc,0x3b,0xf0,0xe0,0x1f,0x00,0xd6,0x03,0xc0,0xfa,0xdb, 0xbd,0x7e,0x42,0x42,0x00,0x18,0x00,0x7e,0xe7,0xe7,0xc3,0xc3,0x7e,0x24,0x18,0x1c, 0x3c,0x42,0x99,0x18,0x00,0x00,0x3f,0x00,0x42,0x81,0xa8,0x0f,0x00,0x65,0x5f,0x0f, 0x07,0x07,0x00,0x94,0x3f,0xdc,0x0f,0x07,0x1f,0x00,0x6b,0xc0,0x03,0xba,0x7f,0x00, 0x10,0xac,0xb8,0xb8,0xa0,0x20,0x20,0x00,0x00,0x7f,0x00,0x18,0x02,0xea,0x00,0x00, 0x03,0x0f,0x1c,0x18,0x31,0x33,0x20,0xe0,0x0c,0x10,0x13,0x26,0x24,0xe0,0x00,0x03, 0x0f,0x0f,0x1e,0x1c,0xf0,0x00,0x03,0x04,0x08,0x08,0xea,0x00,0x00,0xc0,0xf0,0x38, 0x18,0x8c,0xcc,0x20,0xe0,0x30,0x08,0xc8,0x64,0x24,0xe0,0x00,0xc0,0xf0,0xf0,0x78, 0x38,0xf0,0x00,0xc0,0x20,0x10,0x10,0xea,0x33,0x31,0x18,0x1c,0x0f,0x03,0x00,0x00, 0x20,0x07,0x24,0x26,0x13,0x10,0x0c,0x07,0x00,0x1c,0x1e,0x0f,0x0f,0x03,0x0f,0x00, 0x08,0x08,0x04,0x03,0xea,0xcc,0x8c,0x18,0x38,0xf0,0xc0,0x00,0x00,0x20,0x07,0x24, 0x64,0xc8,0x08,0x30,0x07,0x00,0x38,0x78,0xf0,0xf0,0xc0,0x0f,0x00,0x10,0x10,0x20, 0xc0,0x00}; const unsigned char stage2endboss_psgcompr[] = { 0x24,0x00,0xba,0x0e,0x10,0x00,0x60,0x60,0x70,0x08,0xe0,0xd0,0xd0,0xc8,0x7e,0x3d, 0x3d,0x1c,0x70,0x40,0x00,0x18,0x1e,0x1e,0x0f,0x20,0x8f,0x40,0x40,0x40,0xba,0xf9, 0x00,0x05,0x05,0x00,0x00,0x0f,0x1f,0x1f,0x18,0x18,0x9f,0xf1,0x00,0x08,0x0f,0x0f, 0x02,0xba,0xfc,0x00,0x02,0x02,0x00,0x00,0x80,0xc0,0xc0,0xc3,0xc4,0xcc,0xf0,0x00, 0x80,0x80,0x83,0x07,0x02,0xba,0xfc,0x00,0x40,0x40,0x00,0x00,0x01,0x03,0x03,0xc3, 0x23,0x33,0xf0,0x00,0x01,0x01,0xc1,0xe0,0x02,0xba,0xf9,0x00,0xa0,0xa0,0x00,0x00, 0xf0,0xf8,0xf8,0x18,0x18,0xf9,0xf1,0x00,0x10,0xf0,0xf0,0x02,0xba,0x0e,0x08,0x00, 0x06,0x06,0x0e,0x10,0x07,0x0b,0x0b,0x13,0x7e,0xbc,0xbc,0x38,0x70,0x02,0x00,0x18, 0x78,0x78,0xf0,0x20,0x8f,0x02,0x02,0x02,0xba,0x0e,0x01,0x08,0x08,0x04,0x06,0x00, 0x1c,0x1c,0x0c,0x0e,0x07,0x03,0x03,0x01,0x20,0x0f,0x0f,0x0f,0x07,0x07,0x00,0xff, 0x85,0x85,0xe5,0xe5,0xe0,0xe0,0xe1,0xe1,0x78,0x78,0x38,0x38,0x3f,0x3f,0x29,0xa9, 0x8f,0x8f,0xef,0xef,0xe8,0xe8,0xf7,0xf7,0x0f,0x0f,0x2f,0x2f,0x28,0x28,0x31,0xb1, 0xaa,0xe0,0x02,0x10,0x62,0x42,0x00,0x1f,0xc4,0xcc,0xfc,0xff,0xec,0xff,0x80,0xe0, 0x87,0x90,0x77,0x77,0x00,0x7f,0x02,0xaa,0xe0,0x40,0x08,0x46,0x42,0x00,0xf8,0xc4, 0x33,0x3f,0xff,0x37,0xff,0x01,0xe0,0xe1,0x09,0xee,0xee,0x00,0xfe,0x02,0xff,0xa1, 0xa1,0xa7,0xa7,0x07,0x07,0x87,0x87,0x1e,0x1e,0x1c,0x1c,0xfc,0xfc,0x94,0x95,0xf1, 0xf1,0xf7,0xf7,0x17,0x17,0xef,0xef,0xf0,0xf0,0xf4,0xf4,0x14,0x14,0x8c,0x8d,0xba, 0x0e,0x80,0x10,0x10,0x20,0x60,0x00,0x38,0x38,0x30,0x70,0xe0,0xc0,0xc0,0x80,0x20, 0x0f,0xf0,0xf0,0xe0,0xe0,0x00,0xba,0xe1,0x00,0x08,0x0f,0x06,0x01,0x01,0x01,0x7f, 0x30,0x30,0x19,0x0e,0x07,0xe0,0x00,0x1f,0x1f,0x0e,0x07,0x01,0x02,0xee,0xe9,0xe9, 0x19,0x06,0xc6,0xf0,0x00,0x80,0x40,0x07,0xb7,0xf7,0xf9,0x1f,0x1f,0xe9,0xe9,0x1f, 0xe6,0xe6,0xf9,0x09,0x99,0x22,0x1f,0xa1,0xe1,0x19,0xff,0x30,0x30,0x65,0x88,0x8d, 0x0e,0x0c,0x69,0x8f,0x8a,0x98,0x7f,0x7a,0xf8,0x99,0x9a,0x78,0x7d,0x77,0xe8,0xed, 0x8f,0x6e,0x6c,0x78,0x78,0x70,0xe8,0xe8,0x88,0x08,0x08,0xff,0x0c,0x0c,0xa6,0x11, 0xb1,0x70,0x30,0x96,0xf1,0x51,0x19,0xfe,0x5e,0x1f,0x99,0x59,0x1e,0xbe,0xee,0x17, 0xb7,0xf1,0x76,0x36,0x1e,0x1e,0x0e,0x17,0x17,0x11,0x10,0x10,0xee,0x97,0x97,0x98, 0x60,0x63,0x0f,0x00,0x01,0x40,0x07,0xed,0xef,0x9f,0xf8,0xf8,0x97,0x97,0xf8,0x67, 0x67,0x9f,0x90,0x99,0x22,0x1f,0x85,0x87,0x98,0xba,0xe1,0x00,0x10,0xf0,0x60,0x80, 0x80,0x80,0xfe,0x0c,0x0c,0x98,0x70,0xe0,0xe0,0x00,0xf8,0xf8,0x70,0xe0,0x80,0x02, 0xaa,0x9c,0x00,0x02,0x01,0x06,0x06,0x23,0x09,0x07,0x0b,0x0e,0x0e,0x0f,0x47,0x06, 0x01,0x07,0x01,0x01,0x20,0x7b,0x01,0x06,0xee,0x80,0x00,0x00,0xde,0x4e,0x02,0x08, 0x08,0x70,0xff,0x7f,0x6f,0xe3,0x1f,0x1f,0xb9,0xf9,0x00,0xde,0xde,0x1e,0x09,0x09, 0x22,0xf3,0x4e,0x02,0xfe,0x0a,0x08,0x08,0x09,0x0c,0x66,0x10,0x13,0xfd,0xff,0xfc, 0xfa,0xf9,0x98,0xef,0xef,0x08,0xe8,0x0b,0xed,0xee,0x77,0x98,0x98,0x22,0x23,0x09, 0xeb,0xe9,0xe8,0x70,0xfe,0x50,0x10,0x10,0x90,0x30,0x66,0x08,0xc8,0xbf,0xff,0x3f, 0x5f,0x9f,0x19,0xf7,0xf7,0x10,0x17,0xd0,0xb7,0x77,0xee,0x19,0x19,0x22,0x23,0x90, 0xd7,0x97,0x17,0x0e,0xee,0x01,0x00,0x00,0x7b,0x72,0x40,0x10,0x10,0x70,0xff,0xfe, 0xf6,0xc7,0xf8,0xf8,0x9d,0x9f,0x00,0x7b,0x7b,0x78,0x90,0x90,0x22,0xf3,0x72,0x40, 0xaa,0x9c,0x00,0x40,0x80,0x60,0x60,0x23,0x90,0xe0,0xd0,0x70,0x70,0xf0,0x47,0x60, 0x80,0xe0,0x80,0x80,0x20,0x7b,0x80,0x60,0x2a,0x1f,0x00,0x09,0x07,0x01,0x7f,0x00, 0x06,0x02,0xaa,0x7f,0x00,0x07,0x0b,0x02,0x08,0x07,0x03,0x03,0x03,0x3b,0x01,0x07, 0x00,0x00,0x02,0xba,0x0d,0x80,0x07,0x68,0x08,0x01,0x83,0xf8,0x97,0x94,0x92,0x71, 0x68,0x64,0x63,0x41,0x68,0x67,0x6c,0xc7,0xc0,0xc0,0xf0,0x60,0x80,0xc0,0xc0,0xc0, 0xba,0x0d,0x01,0xe0,0x16,0x10,0x80,0xc1,0x1f,0xe9,0x29,0x49,0x8e,0x16,0x26,0xc6, 0x41,0x68,0xe6,0x36,0xe3,0x03,0x03,0xf0,0x06,0x01,0x03,0x03,0x03,0xaa,0x7f,0x00, 0xe0,0x0b,0x40,0x10,0xe0,0xc0,0xc0,0xc0,0x3b,0x80,0xe0,0x00,0x00,0x02,0x2a,0x1f, 0x00,0x90,0xe0,0x80,0x7f,0x00,0x60,0x02,0x00,0x2a,0x07,0x00,0x03,0x02,0x02,0x02, 0x01,0x8f,0x00,0x01,0x01,0x01,0x02,0xaa,0xf8,0x80,0x00,0x00,0x00,0xfa,0x60,0xe0, 0x20,0xf8,0xc0,0x40,0x00,0x00,0x02,0xaa,0xf8,0x01,0x00,0x00,0x00,0xfa,0x06,0x07, 0x04,0xf8,0x03,0x02,0x00,0x00,0x02,0x2a,0x07,0x00,0xc0,0x40,0x40,0x40,0x80,0x8f, 0x00,0x80,0x80,0x80,0x02,0x00}; const unsigned char stage7middleboss_psgcompr[] = { 0x30,0x00,0xaa,0x39,0x00,0x03,0x04,0x0f,0x10,0x20,0x1c,0x07,0x0f,0x07,0x38,0x7c, 0x20,0xbc,0x07,0x18,0x10,0x02,0xfe,0x30,0x06,0x02,0x01,0x41,0x81,0x01,0x03,0xfe, 0xb7,0x3e,0x3f,0x62,0xc3,0xc3,0x97,0xf0,0x3e,0x3b,0x3c,0x60,0xc1,0xc1,0x81,0x22, 0xee,0x3d,0x83,0xfa,0x11,0x08,0x00,0x00,0x04,0x80,0xc0,0xc1,0x11,0x09,0x89,0x89, 0x4d,0xc5,0x75,0xef,0x70,0x09,0x11,0x8d,0x05,0x05,0x86,0x22,0xf8,0x85,0x45,0xc7, 0xfa,0x84,0x18,0x00,0x00,0x20,0x01,0x03,0x83,0x84,0x98,0x99,0x99,0xb2,0xa3,0xa6, 0xf7,0x70,0x98,0x84,0xb1,0xa0,0xa0,0x61,0x22,0xf8,0xa1,0xa2,0xe3,0xbe,0x1c,0x80, 0x00,0x63,0x4c,0x82,0xc1,0x70,0xe3,0x7f,0xfd,0x4c,0xcc,0xc6,0xe3,0x00,0x73,0xdf, 0x3c,0x0c,0x8c,0x86,0x83,0x22,0xee,0xbc,0xc3,0xaa,0xce,0x00,0xc0,0x20,0xf0,0x20, 0xc7,0xe0,0xf0,0xe0,0x20,0xef,0xe0,0x02,0xba,0x1f,0x00,0x01,0x18,0x66,0x39,0x19, 0x67,0xf7,0xe6,0x05,0x06,0x05,0x07,0x04,0x01,0x19,0x67,0x46,0x06,0x02,0xfe,0x01, 0x07,0x05,0x02,0x00,0xf1,0x08,0x04,0xae,0xdf,0xaf,0x5f,0xa7,0xf3,0xfb,0xdd,0x80, 0x86,0x05,0x06,0x02,0xf1,0xf9,0x8c,0x22,0x07,0x82,0x87,0x07,0x07,0x03,0xef,0xc2, 0xe3,0xe4,0x60,0xb2,0x22,0xa4,0x1d,0x0e,0xff,0x96,0x4f,0xbf,0xdf,0xfe,0xa5,0x47, 0x27,0x04,0x90,0x03,0xe2,0xbc,0xa7,0x47,0xa7,0xc4,0xf2,0xe3,0xee,0xbc,0xef,0x43, 0xc7,0x27,0x06,0x4d,0x44,0x25,0xb8,0x0e,0xff,0x69,0xf2,0xfd,0xfb,0x7f,0xa5,0xe2, 0xe4,0x20,0x09,0xc0,0x47,0x3d,0xe5,0xe2,0xe5,0x23,0x4f,0xc7,0x77,0x3d,0xfe,0x80, 0xe0,0xa0,0x40,0x00,0x80,0x00,0x0f,0x63,0xf9,0xf5,0xf9,0xf4,0xea,0xd5,0xaf,0x03, 0x61,0xa1,0x61,0x40,0x80,0x80,0x0f,0x70,0xe1,0x43,0xc0,0x80,0x80,0x0f,0xba,0x47, 0x00,0x08,0x80,0x18,0x66,0x1c,0x3e,0x9c,0x98,0xe6,0x6f,0x67,0x20,0x21,0x19,0x18, 0x08,0x80,0x62,0x60,0x02,0xbe,0x17,0x00,0x09,0x10,0x62,0x04,0x0f,0x7d,0xfb,0xf3, 0x06,0x07,0x06,0x05,0x0d,0x19,0x73,0x03,0x06,0x06,0x04,0x04,0x02,0xbe,0x6b,0x00, 0x02,0x70,0x08,0xa6,0xdb,0xa4,0x71,0xf7,0x78,0xb3,0x53,0x86,0x83,0x00,0x70,0x70, 0x38,0x10,0x10,0x02,0xee,0x18,0x01,0x02,0x03,0x0b,0x04,0x02,0x03,0x40,0x70,0xff, 0x1c,0x57,0x8f,0xbf,0x1c,0x18,0x00,0x80,0x18,0x0c,0x12,0x13,0x22,0xe9,0x8c,0x0e, 0x17,0xee,0x18,0x80,0x40,0xc0,0xd0,0x20,0x40,0xc0,0x40,0x70,0xff,0x38,0xea,0xf1, 0xfd,0x38,0x18,0x00,0x01,0x18,0x30,0x48,0xc8,0x22,0xe9,0x31,0x70,0xe8,0xbe,0x7b, 0x00,0x70,0x1e,0x7f,0xf5,0xab,0xd5,0xea,0x5e,0x2e,0xdc,0x7f,0xf1,0x01,0x01,0x00, 0x1e,0x0e,0x0c,0x02,0xba,0xc5,0x00,0x90,0x08,0x46,0x20,0x20,0x20,0xb0,0x9e,0xdf, 0xcf,0x60,0x60,0x21,0xe3,0x98,0xce,0xc0,0x02,0xaa,0x1f,0x00,0x08,0x10,0x20,0x0f, 0x00,0x0a,0x7d,0xfe,0x7d,0x20,0x9f,0x18,0x38,0x02,0xba,0x33,0x00,0x08,0x04,0x10, 0x20,0xa9,0x4e,0xad,0x4e,0x79,0xfe,0x79,0x00,0x70,0x0c,0x08,0x18,0x30,0x00,0x00, 0x02,0xba,0x6f,0x00,0x01,0x03,0x9f,0x9f,0xcf,0xcf,0x67,0xa7,0x5d,0x0e,0x39,0x00, 0x0b,0x01,0x01,0x02,0x22,0xa7,0x07,0x03,0x03,0xba,0x6f,0x00,0x80,0xc0,0xf9,0xf9, 0xf3,0xf3,0xe6,0xe5,0xba,0x70,0x39,0x00,0xd0,0x80,0x80,0x40,0x22,0xa7,0xe0,0xc0, 0xc0,0xba,0xcc,0x00,0x10,0x20,0x08,0x04,0xa8,0xd8,0xb0,0x70,0xb0,0x70,0x98,0x0c, 0x1c,0x30,0x08,0x08,0x10,0x18,0x0c,0x02,0xaa,0xc7,0x00,0x10,0x08,0x04,0x20,0x23, 0x20,0x20,0x3e,0x7f,0x3e,0x21,0xe3,0x18,0x1c,0x00,0x02,0xaa,0xce,0x00,0x03,0x04, 0x0f,0x20,0xc7,0x07,0x0f,0x07,0x20,0xef,0x07,0x02,0xbe,0x1c,0x01,0x00,0xc6,0x32, 0x41,0x83,0x0e,0xc7,0xfe,0xbf,0x32,0x33,0x63,0xc7,0x00,0xce,0xfb,0x3c,0x30,0x31, 0x61,0xc1,0x22,0xee,0x3d,0xc3,0xfa,0x21,0x18,0x00,0x00,0x04,0x80,0xc0,0xc1,0x21, 0x19,0x99,0x99,0x4d,0xc5,0x65,0xef,0x70,0x19,0x21,0x8d,0x05,0x05,0x86,0x22,0xf8, 0x85,0x45,0xc7,0xfa,0x88,0x10,0x00,0x00,0x20,0x01,0x03,0x83,0x88,0x90,0x91,0x91, 0xb2,0xa3,0xae,0xf7,0x70,0x90,0x88,0xb1,0xa0,0xa0,0x61,0x22,0xf8,0xa1,0xa2,0xe3, 0xfe,0x0c,0x60,0x40,0x80,0x82,0x81,0x80,0xc0,0x7f,0xed,0x7c,0xfc,0x46,0xc3,0xc3, 0xe9,0x0f,0x7c,0xdc,0x3c,0x06,0x83,0x83,0x81,0x22,0xee,0xbc,0xc1,0xaa,0x39,0x00, 0xc0,0x20,0xf0,0x08,0x20,0x1c,0xe0,0xf0,0xe0,0x1c,0x3e,0x20,0xbc,0xe0,0x18,0x08, 0x02,0xba,0x47,0x00,0x10,0x01,0x18,0x66,0x38,0x7c,0x39,0x19,0x67,0xf6,0xe6,0x04, 0x21,0x19,0x18,0x10,0x01,0x46,0x06,0x02,0xfe,0x01,0x07,0x05,0x02,0x00,0x01,0x00, 0xf0,0xc6,0x9f,0xaf,0x9f,0x2f,0x57,0xab,0xf5,0xc0,0x86,0x85,0x86,0x02,0x01,0x01, 0xf0,0x70,0x87,0xc2,0x03,0x01,0x01,0xf0,0xef,0xc2,0xe3,0xe4,0x60,0xb2,0x22,0xa4, 0x1d,0x0e,0xff,0x96,0x4f,0xbf,0xdf,0xfe,0xa5,0x47,0x27,0x04,0x90,0x03,0xe2,0xbc, 0xa7,0x47,0xa7,0xc4,0xf2,0xe3,0xee,0xbc,0xef,0x43,0xc7,0x27,0x06,0x4d,0x44,0x25, 0xb8,0x0e,0xff,0x69,0xf2,0xfd,0xfb,0x7f,0xa5,0xe2,0xe4,0x20,0x09,0xc0,0x47,0x3d, 0xe5,0xe2,0xe5,0x23,0x4f,0xc7,0x77,0x3d,0xfe,0x80,0xe0,0xa0,0x40,0x00,0x8f,0x10, 0x20,0x75,0xfb,0xf5,0xfa,0xe5,0xcf,0xdf,0xbb,0x01,0x61,0xa0,0x60,0x40,0x8f,0x9f, 0x31,0x22,0x07,0x41,0xe1,0xe0,0xe0,0xc0,0xba,0x1f,0x00,0x80,0x18,0x66,0x9c,0x98, 0xe6,0xef,0x67,0xa0,0x60,0xa0,0x07,0x20,0x80,0x98,0xe6,0x62,0x60,0x02,0xba,0xc5, 0x00,0x09,0x10,0x62,0x04,0x04,0x04,0x0d,0x79,0xfb,0xf3,0x06,0x06,0x21,0xe3,0x19, 0x73,0x03,0x02,0xbe,0x7b,0x00,0x0e,0x78,0xfe,0xaf,0xd5,0xab,0x57,0x7a,0x74,0x3b, 0xfe,0x8f,0x80,0x80,0x00,0x78,0x70,0x30,0x02,0xee,0x18,0x01,0x02,0x03,0x0b,0x04, 0x02,0x03,0x40,0x70,0xff,0x1c,0x57,0x8f,0xbf,0x1c,0x18,0x00,0x80,0x18,0x0c,0x12, 0x13,0x22,0xe9,0x8c,0x0e,0x17,0xee,0x18,0x80,0x40,0xc0,0xd0,0x20,0x40,0xc0,0x40, 0x70,0xff,0x38,0xea,0xf1,0xfd,0x38,0x18,0x00,0x01,0x18,0x30,0x48,0xc8,0x22,0xe9, 0x31,0x70,0xe8,0xbe,0x6b,0x00,0x40,0x0e,0x10,0x65,0xdb,0x25,0x8e,0xef,0x1e,0xcd, 0xca,0x61,0xc1,0x00,0x0e,0x0e,0x1c,0x08,0x08,0x02,0xbe,0x17,0x00,0x90,0x08,0x46, 0x20,0xf0,0xbe,0xdf,0xcf,0x60,0xe0,0x60,0xa0,0xb0,0x98,0xce,0xc0,0x60,0x60,0x20, 0x20,0x02,0xaa,0xc7,0x00,0x08,0x10,0x20,0x20,0x23,0x04,0x04,0x7c,0xfe,0x7c,0x21, 0xe3,0x18,0x38,0x00,0x02,0xba,0xcc,0x00,0x08,0x04,0x10,0x20,0x15,0x1b,0x0d,0x0e, 0x0d,0x0e,0x19,0x30,0x1c,0x0c,0x10,0x10,0x08,0x18,0x30,0x02,0xba,0x6f,0x00,0x01, 0x03,0x9f,0x9f,0xcf,0xcf,0x67,0xa7,0x5d,0x0e,0x39,0x00,0x0b,0x01,0x01,0x02,0x22, 0xa7,0x07,0x03,0x03,0xba,0x6f,0x00,0x80,0xc0,0xf9,0xf9,0xf3,0xf3,0xe6,0xe5,0xba, 0x70,0x39,0x00,0xd0,0x80,0x80,0x40,0x22,0xa7,0xe0,0xc0,0xc0,0xba,0x33,0x00,0x10, 0x20,0x08,0x04,0x95,0x72,0xb5,0x72,0x9e,0x7f,0x9e,0x00,0x70,0x30,0x10,0x18,0x0c, 0x00,0x00,0x02,0xaa,0x1f,0x00,0x10,0x08,0x04,0x0f,0x00,0x50,0xbe,0x7f,0xbe,0x20, 0x9f,0x18,0x1c,0x02}; const unsigned char stage7palette_bin[] = { 0x00,0x3f,0x00,0x00,0x10,0x20,0x24,0x00,0x08,0x00,0x04,0x05,0x1f,0x2b,0x06,0x00}; const unsigned char stage7tilemap_l[] = { 0x00,0x01,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x03,0x04,0x05,0x06,0x07,0x06,0x07,0x06,0x07,0x08,0x09,0x08,0x09,0x08, 0x09,0x08,0x09,0x08,0x09,0x0a,0x0b,0x0a,0x0b,0x0a,0x0b,0x0c,0x0d,0x0c,0x0d,0x0e, 0x0f,0x10,0x11,0x12,0x13,0x14,0x0f,0x15,0x0d,0x0c,0x0d,0x15,0x0d,0x16,0x17,0x18, 0x19,0x1a,0x1b,0x1c,0x1d,0x18,0x1e,0x16,0x1f,0x16,0x1e,0x16,0x1f,0x16,0x20,0x21, 0x22,0x23,0x22,0x24,0x20,0x25,0x0d,0x0c,0x0d,0x15,0x0d,0x0c,0x0d,0x15,0x0d,0x0a, 0x0b,0x26,0x27,0x26,0x27,0x26,0x27,0x26,0x27,0x28,0x29,0x28,0x29,0x2a,0x2b,0x2c, 0x2b,0x2c,0x2b,0x2c,0x2b,0x0a,0x0b,0x16,0x1e,0x16,0x1f,0x16,0x2d,0x2e,0x12,0x11, 0x10,0x13,0x2f,0x2e,0x30,0x31,0x32,0x31,0x1e,0x16,0x1f,0x33,0x34,0x35,0x36,0x35, 0x37,0x33,0x38,0x31,0x30,0x31,0x32,0x31,0x30,0x31,0x32,0x31,0x30,0x31,0x32,0x39, 0x3a,0x3b,0x3c,0x3b,0x3c,0x3b,0x3d,0x3e,0x3f,0x3e,0x3f,0x3e,0x3f,0x40,0x3c,0x3b, 0x3c,0x3b,0x3c,0x3b,0x3d,0x3e,0x3f,0x3e,0x3f,0x3e,0x3f,0x3b,0x3d,0x39,0x3a,0x28, 0x29,0x28,0x29,0x28,0x41,0x2a,0x41,0x2a,0x41,0x2a,0x29,0x28,0x29,0x28,0x29,0x28, 0x29,0x28,0x29,0x26,0x27,0x26,0x27,0x26,0x27,0x26,0x29,0x28,0x42,0x43,0x44,0x45, 0x44,0x45,0x42,0x43,0x42,0x43,0x42,0x43,0x46,0x47,0x46,0x47,0x29,0x28,0x0b,0x0a, 0x0b,0x0a,0x0b,0x48,0x49,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x4e,0x50,0x51, 0x50,0x51,0x50,0x52,0x53,0x51,0x50,0x4e,0x4f,0x4e,0x4d,0x4c,0x4d,0x4c,0x53,0x52, 0x53,0x52,0x54,0x55,0x54,0x55,0x56,0x57,0x56,0x57,0x56,0x57,0x56,0x55,0x58,0x59, 0x58,0x5a,0x5b,0x5a,0x5b,0x5c,0x5d,0x5c,0x5e,0x5c,0x5d,0x5c,0x5e,0x5f,0x60,0x5f, 0x61,0x62,0x63,0x62,0x63,0x62,0x64,0x65,0x66,0x67,0x66,0x68,0x69,0x68,0x64,0x65, 0x63,0x62,0x60,0x5f,0x61,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x6f,0x6e,0x6f,0x6e,0x6f, 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7b,0x1f,0x7d, 0x32,0x7d,0x32,0x7d,0x32,0x7d,0x32,0x7d,0x7e,0x7f,0x80,0x81,0x80,0x81,0x80,0x81, 0x80,0x81,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x83,0x84,0x83,0x85,0x86,0x85, 0x86,0x85,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15, 0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x87,0x88,0x87,0x89,0x8a, 0x89,0x8a,0x89,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15, 0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15,0x82,0x15}; const unsigned char stage7tilemap_m[] = { 0x00,0x00,0x01,0x00,0x02,0x00,0x03,0x00,0x04,0x00,0x05,0x00,0x06,0x00,0x07,0x00, 0x08,0x00,0x09,0x00,0x0a,0x00,0x0b,0x00,0x0c,0x00,0x0c,0x02,0x0d,0x00,0x0e,0x00, 0x0f,0x00,0x10,0x00,0x10,0x02,0x0f,0x02,0x0e,0x02,0x0d,0x02,0x11,0x00,0x11,0x02, 0x12,0x00,0x13,0x00,0x14,0x00,0x15,0x00,0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00, 0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00, 0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00,0x17,0x00,0x18,0x00, 0x19,0x00,0x1a,0x00,0x1a,0x02,0x19,0x02,0x18,0x02,0x17,0x02,0x1b,0x00,0x1c,0x00, 0x12,0x00,0x13,0x00,0x1d,0x00,0x1d,0x00,0x16,0x00,0x16,0x00,0x16,0x00,0x16,0x00, 0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00, 0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00, 0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00, 0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00,0x13,0x00,0x12,0x00, 0x1b,0x00,0x1c,0x00,0x1b,0x00,0x1c,0x00,0x1b,0x00,0x1c,0x00,0x1b,0x00,0x1c,0x00, 0x1b,0x00,0x1c,0x00,0x1b,0x00,0x1c,0x00,0x1b,0x00,0x1b,0x00,0x1c,0x00,0x1b,0x00, 0x1c,0x00,0x1b,0x00,0x1c,0x00,0x1b,0x00,0x1c,0x00,0x1b,0x00,0x1c,0x00,0x1b,0x00, 0x1c,0x00,0x1b,0x00,0x1b,0x00,0x1c,0x00,0x1b,0x00,0x1c,0x00,0x1b,0x00,0x1c,0x00, 0x14,0x00,0x15,0x00,0x14,0x00,0x15,0x00,0x14,0x00,0x15,0x00,0x14,0x00,0x15,0x00, 0x14,0x00,0x15,0x00,0x14,0x00,0x15,0x00,0x14,0x00,0x14,0x00,0x15,0x00,0x14,0x00, 0x15,0x00,0x14,0x00,0x15,0x00,0x14,0x00,0x15,0x00,0x14,0x00,0x15,0x00,0x14,0x00, 0x15,0x00,0x14,0x00,0x14,0x00,0x15,0x00,0x14,0x00,0x15,0x00,0x14,0x00,0x15,0x00, 0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00, 0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00, 0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00, 0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00,0x1d,0x00, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00, 0x20,0x00,0x21,0x00,0x20,0x00,0x22,0x00,0x23,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00, 0x28,0x00,0x29,0x00,0x28,0x00,0x25,0x02,0x24,0x02,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00, 0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00, 0x1f,0x00,0x22,0x00,0x23,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00, 0x27,0x00,0x25,0x02,0x24,0x02,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02,0x1e,0x00,0x1f,0x00,0x25,0x02, 0x24,0x02,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02,0x26,0x00,0x27,0x00,0x22,0x00, 0x23,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02,0x1e,0x00,0x1f,0x00,0x25,0x02, 0x24,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02,0x26,0x00,0x27,0x00,0x25,0x02, 0x24,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02,0x1e,0x00,0x1f,0x00,0x25,0x02, 0x24,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02,0x26,0x00,0x27,0x00,0x22,0x00, 0x23,0x00,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02,0x1e,0x00,0x1f,0x00,0x25,0x02, 0x24,0x02,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x23,0x02, 0x22,0x02,0x1f,0x02,0x1e,0x02,0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x24,0x00, 0x25,0x00,0x27,0x02,0x26,0x02,0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x23,0x02, 0x22,0x02,0x1f,0x02,0x1e,0x02,0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00, 0x25,0x00,0x27,0x02,0x26,0x02,0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00, 0x25,0x00,0x27,0x02,0x26,0x02,0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x24,0x00, 0x25,0x00,0x27,0x02,0x26,0x02,0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x2a,0x00,0x2b,0x00,0x2a,0x00,0x2b,0x00,0x2a,0x00,0x2b,0x00, 0x2a,0x00,0x2b,0x00,0x2a,0x00,0x2b,0x00,0x10,0x02,0x0f,0x02,0x0e,0x02,0x0d,0x02, 0x0d,0x00,0x0e,0x00,0x0f,0x00,0x10,0x00,0x2a,0x00,0x2b,0x00,0x2a,0x00,0x2b,0x00, 0x2a,0x00,0x2b,0x00,0x2a,0x00,0x2b,0x00,0x2a,0x00,0x2b,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x2c,0x00,0x2d,0x00,0x2c,0x00,0x2d,0x00,0x2c,0x00,0x2d,0x00, 0x2c,0x00,0x2d,0x00,0x2c,0x00,0x2d,0x00,0x1a,0x02,0x19,0x02,0x18,0x02,0x17,0x02, 0x17,0x00,0x18,0x00,0x19,0x00,0x1a,0x00,0x2c,0x00,0x2d,0x00,0x2c,0x00,0x2d,0x00, 0x2c,0x00,0x2d,0x00,0x2c,0x00,0x2d,0x00,0x2c,0x00,0x2d,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x0d,0x00,0x0e,0x00,0x0f,0x00,0x10,0x00,0x16,0x00,0x10,0x02, 0x0f,0x02,0x0e,0x02,0x0d,0x02,0x16,0x00,0x10,0x02,0x0f,0x02,0x0e,0x02,0x0d,0x02, 0x0d,0x00,0x0e,0x00,0x0f,0x00,0x10,0x00,0x16,0x00,0x0d,0x00,0x0e,0x00,0x0f,0x00, 0x10,0x00,0x16,0x00,0x10,0x02,0x0f,0x02,0x0e,0x02,0x0d,0x02,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x17,0x00,0x18,0x00,0x19,0x00,0x1a,0x00,0x16,0x00,0x1a,0x02, 0x19,0x02,0x18,0x02,0x17,0x02,0x16,0x00,0x1a,0x02,0x19,0x02,0x18,0x02,0x17,0x02, 0x17,0x00,0x18,0x00,0x19,0x00,0x1a,0x00,0x16,0x00,0x17,0x00,0x18,0x00,0x19,0x00, 0x1a,0x00,0x16,0x00,0x1a,0x02,0x19,0x02,0x18,0x02,0x17,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x17,0x00,0x18,0x00,0x19,0x00,0x1a,0x00,0x16,0x00,0x1a,0x02, 0x19,0x02,0x18,0x02,0x17,0x02,0x16,0x00,0x1a,0x02,0x19,0x02,0x18,0x02,0x17,0x02, 0x17,0x00,0x18,0x00,0x19,0x00,0x1a,0x00,0x16,0x00,0x17,0x00,0x18,0x00,0x19,0x00, 0x1a,0x00,0x16,0x00,0x1a,0x02,0x19,0x02,0x18,0x02,0x17,0x02,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x0d,0x00,0x0e,0x00,0x0f,0x00,0x10,0x00,0x16,0x00,0x10,0x02, 0x0f,0x02,0x0e,0x02,0x0d,0x02,0x16,0x00,0x10,0x02,0x0f,0x02,0x0e,0x02,0x0d,0x02, 0x0d,0x00,0x0e,0x00,0x0f,0x00,0x10,0x00,0x16,0x00,0x0d,0x00,0x0e,0x00,0x0f,0x00, 0x10,0x00,0x16,0x00,0x10,0x02,0x0f,0x02,0x0e,0x02,0x0d,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x17,0x00,0x18,0x00,0x19,0x00,0x1a,0x00,0x16,0x00,0x1a,0x02, 0x19,0x02,0x18,0x02,0x17,0x02,0x16,0x00,0x1a,0x02,0x19,0x02,0x18,0x02,0x17,0x02, 0x17,0x00,0x18,0x00,0x19,0x00,0x1a,0x00,0x16,0x00,0x17,0x00,0x18,0x00,0x19,0x00, 0x1a,0x00,0x16,0x00,0x1a,0x02,0x19,0x02,0x18,0x02,0x17,0x02,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x0d,0x00,0x0e,0x00,0x0f,0x00,0x10,0x00,0x16,0x00,0x10,0x02, 0x0f,0x02,0x0e,0x02,0x0d,0x02,0x16,0x00,0x10,0x02,0x0f,0x02,0x0e,0x02,0x0d,0x02, 0x0d,0x00,0x0e,0x00,0x0f,0x00,0x10,0x00,0x16,0x00,0x0d,0x00,0x0e,0x00,0x0f,0x00, 0x10,0x00,0x16,0x00,0x10,0x02,0x0f,0x02,0x0e,0x02,0x0d,0x02,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1f,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00, 0x22,0x00,0x23,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x27,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00, 0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1f,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00, 0x22,0x00,0x23,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x27,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00, 0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x27,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00, 0x25,0x02,0x24,0x02,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x1f,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00, 0x22,0x00,0x23,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1f,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00, 0x22,0x00,0x23,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x27,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00, 0x25,0x02,0x24,0x02,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x27,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00, 0x25,0x02,0x24,0x02,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x1f,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00, 0x22,0x00,0x23,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x27,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00, 0x25,0x02,0x24,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x1f,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00, 0x22,0x00,0x23,0x00,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02, 0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x0c,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x27,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x28,0x00,0x29,0x00,0x28,0x00, 0x25,0x02,0x24,0x02,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1f,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x20,0x00,0x21,0x00,0x20,0x00, 0x22,0x00,0x23,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x22,0x00,0x23,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x25,0x02,0x24,0x02, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x20,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x24,0x00,0x25,0x00,0x20,0x00,0x28,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x20,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x28,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x28,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00, 0x20,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00, 0x28,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00, 0x28,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x22,0x00,0x23,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00,0x20,0x00, 0x20,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x28,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x20,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x20,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x28,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x20,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x28,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x20,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x24,0x00,0x25,0x00,0x20,0x00, 0x28,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x24,0x00,0x25,0x00, 0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00, 0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x23,0x02,0x22,0x02, 0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x23,0x02,0x22,0x02, 0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x28,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x23,0x02,0x22,0x02, 0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x20,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x23,0x02,0x22,0x02, 0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x26,0x00,0x27,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x24,0x00,0x25,0x00, 0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x23,0x02,0x22,0x02,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x28,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x23,0x02,0x22,0x02,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x20,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x28,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x23,0x02,0x22,0x02,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x23,0x02,0x22,0x02,0x20,0x00,0x21,0x00, 0x20,0x00,0x21,0x00,0x25,0x02,0x24,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x23,0x02,0x22,0x02,0x28,0x00,0x29,0x00, 0x28,0x00,0x29,0x00,0x25,0x02,0x24,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x23,0x02,0x22,0x02,0x20,0x00,0x21,0x00, 0x20,0x00,0x21,0x00,0x22,0x00,0x23,0x00,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x25,0x02,0x24,0x02,0x07,0x00,0x05,0x00,0x07,0x00,0x05,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x24,0x00,0x25,0x00,0x28,0x00,0x29,0x00, 0x28,0x00,0x29,0x00,0x25,0x02,0x24,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x05,0x02,0x07,0x02,0x05,0x02,0x07,0x02,0x24,0x00,0x25,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x22,0x00,0x23,0x00,0x06,0x00,0x04,0x00,0x06,0x00,0x04,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x04,0x02,0x06,0x02,0x04,0x02,0x06,0x02,0x23,0x02,0x22,0x02,0x1f,0x02,0x1e,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x22,0x00,0x23,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x25,0x02,0x24,0x02, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x23,0x02,0x22,0x02,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x22,0x00,0x23,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x23,0x02,0x22,0x02,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x25,0x02,0x24,0x02, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x22,0x00,0x23,0x00, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x25,0x02,0x24,0x02, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x23,0x02,0x22,0x02,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x27,0x02,0x26,0x02, 0x1e,0x00,0x1f,0x00,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x22,0x00,0x23,0x00, 0x06,0x00,0x04,0x00,0x06,0x00,0x08,0x00,0x0a,0x00,0x08,0x00,0x0a,0x00,0x00,0x00, 0x02,0x00,0x0a,0x02,0x08,0x02,0x0a,0x02,0x08,0x02,0x06,0x02,0x04,0x02,0x06,0x02, 0x23,0x02,0x22,0x02,0x28,0x00,0x29,0x00,0x28,0x00,0x29,0x00,0x1f,0x02,0x1e,0x02, 0x26,0x00,0x27,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x25,0x02,0x24,0x02, 0x07,0x00,0x05,0x00,0x07,0x00,0x09,0x00,0x0b,0x00,0x09,0x00,0x0b,0x00,0x01,0x00, 0x03,0x00,0x0b,0x02,0x09,0x02,0x0b,0x02,0x09,0x02,0x07,0x02,0x05,0x02,0x07,0x02, 0x24,0x00,0x25,0x00,0x20,0x00,0x21,0x00,0x20,0x00,0x21,0x00,0x27,0x02,0x26,0x02}; const unsigned char stage7tiles_psgcompr[] = { 0x2e,0x00,0xaa,0xee,0xff,0xfe,0xbe,0x40,0x8b,0x15,0x81,0x81,0x30,0x21,0xee,0x80, 0x00,0x42,0x9b,0xfe,0x7f,0xdf,0xa9,0x47,0xff,0xfe,0xee,0xfe,0xfe,0x9f,0x01,0x11, 0x91,0x21,0x4f,0x00,0x80,0x00,0xfa,0xdf,0x5f,0x1f,0x1f,0x3f,0xde,0x9f,0x1e,0xa0, 0xa0,0xa9,0xf0,0xf0,0x21,0x20,0x81,0x46,0x60,0xe0,0xe9,0xd0,0xf0,0xe0,0xc7,0xff, 0xfe,0xef,0xcf,0xed,0x4e,0x07,0x17,0x7f,0x3f,0x5f,0x1e,0x3f,0x40,0x15,0x99,0xb8, 0xf8,0x60,0xa1,0xf8,0xe0,0xd0,0x80,0xe0,0x60,0x60,0xc0,0xfe,0xff,0xdf,0xdb,0xfb, 0xd3,0xfd,0xf9,0x6e,0x80,0x70,0x2c,0x1e,0x6e,0x86,0x37,0x99,0x80,0x40,0x08,0x1c, 0x40,0x84,0x31,0x00,0x61,0xff,0x7f,0xef,0xbf,0xfb,0xdf,0xfe,0xff,0xfa,0xf7,0x4d, 0xef,0xef,0x1f,0xff,0x90,0x27,0x1e,0xbe,0x5e,0xbc,0xf8,0x18,0x90,0x22,0x16,0x00, 0x48,0xac,0x00,0x18,0x3b,0xff,0x7f,0xdf,0xf7,0xaa,0x7e,0xff,0xfe,0x5f,0x54,0x00, 0x03,0x60,0x01,0x80,0xe0,0x21,0x7e,0x02,0x00,0xd7,0xff,0x9f,0xfe,0xbb,0x1f,0xff, 0xdf,0x9f,0xef,0xe0,0xf1,0x71,0x10,0x9a,0x05,0x07,0x34,0x21,0x15,0x80,0x91,0x61, 0x8a,0x03,0xff,0x7e,0xbe,0xff,0x7d,0xfe,0xfc,0xdf,0xaa,0xef,0xff,0xbf,0x40,0xdd, 0x40,0x20,0x21,0xef,0x00,0x12,0xaa,0xcf,0xff,0xfe,0xf7,0x40,0x36,0x84,0x40,0x08, 0x08,0x21,0xcf,0x00,0x00,0x77,0xff,0x7f,0xf7,0xaa,0x23,0xff,0xe7,0xfe,0xbf,0xbf, 0xde,0x40,0xdd,0x21,0x21,0xdd,0x00,0x21,0x21,0x42,0xfd,0xfe,0xa9,0xfb,0xff,0xfe, 0x40,0xf7,0x20,0xf7,0x00,0x20,0xe8,0x00,0x10,0x30,0x7e,0x7e,0x30,0x10,0x00,0x10, 0x10,0xea,0x7f,0x4f,0xfc,0x93,0xff,0xe3,0xd8,0x9d,0x7b,0x7f,0xff,0xff,0x55,0x00, 0x48,0x50,0x40,0x50,0x9d,0xff,0x7f,0xbf,0xbf,0xe1,0x9f,0xf1,0xe6,0x5f,0x53,0xb3, 0xed,0x9e,0xce,0xff,0xf9,0xfe,0xfd,0xfa,0x3e,0x3f,0x67,0xd9,0x23,0x7a,0xfe,0x6f, 0xd8,0xfc,0xff,0xf7,0xc1,0x81,0xcc,0xfe,0x5d,0x00,0x18,0x01,0x0c,0x71,0xff,0xfe, 0xe3,0xfb,0xfe,0xfa,0xde,0xbc,0x76,0xed,0xdc,0x79,0x80,0xe0,0x04,0x3c,0x7c,0x3e, 0xbe,0xfc,0x78,0x60,0x07,0x00,0x04,0x20,0x40,0x08,0x10,0x20,0xc1,0x7e,0xff,0xfe, 0xfd,0xf8,0xba,0xc1,0x01,0x02,0x03,0x0f,0x02,0x02,0x91,0x62,0x92,0x84,0xa4,0xc4, 0x52,0x81,0x76,0xfc,0xfe,0xf8,0xfe,0xa3,0x00,0x01,0x03,0x03,0x02,0xfe,0x91,0x23, 0x05,0x09,0x0b,0x1d,0x0f,0x3a,0xa6,0x50,0x59,0xe4,0x77,0x64,0x0c,0x01,0x4f,0xef, 0xe2,0xf8,0xf8,0xfb,0x73,0x07,0x4e,0x00,0x10,0x04,0x01,0x38,0xff,0xc1,0xa1,0x22, 0xa1,0xca,0xf4,0x3f,0x20,0x5e,0x4f,0x2d,0xc5,0x32,0x08,0xca,0xd5,0xbe,0x9e,0xde, 0x1e,0xc4,0xf0,0xf0,0xe6,0x01,0x20,0x00,0x20,0x08,0x04,0x05,0x00,0xea,0x45,0x67, 0xba,0x44,0x11,0x40,0x04,0x00,0x1c,0xff,0x22,0xb0,0xc5,0x7f,0xd7,0x40,0x27,0x22, 0x90,0xbf,0xff,0x1f,0x00,0x45,0x47,0x3a,0xea,0x4d,0x67,0xba,0x44,0x11,0x40,0x04, 0x00,0x1c,0xff,0x22,0xb0,0xc5,0x7f,0xd7,0x40,0x27,0x22,0x90,0xbf,0xff,0x1f,0x00, 0x4d,0x47,0x3a,0x00,0xfa,0xa6,0x58,0xfc,0xef,0x93,0xfd,0xdd,0xfe,0xff,0xb7,0x7f, 0xff,0x7f,0xfb,0xbf,0x3f,0x4a,0x00,0x80,0x40,0x20,0x80,0x10,0x6f,0xff,0x7f,0xdf, 0xe9,0x5b,0xdb,0x6f,0x71,0xbf,0xde,0xe1,0xff,0x5c,0xff,0xf7,0xfd,0xfe,0xdf,0xb8, 0x00,0x01,0x80,0x40,0x12,0xba,0x54,0xff,0x9f,0xbf,0xfd,0xd7,0x14,0xff,0xbb,0x73, 0xf9,0xf9,0xcf,0x6f,0xc3,0x71,0x00,0x80,0x11,0x02,0x40,0x42,0xf2,0xfd,0xff,0xd7, 0xfa,0xd8,0x80,0xf8,0xfb,0xdf,0x9f,0x1f,0x00,0x60,0x70,0xf0,0xf8,0x4f,0xcf,0x86, 0x00,0xf7,0x00,0x06,0x20,0x39,0xf8,0xf0,0xdf,0x9f,0xfe,0x07,0x04,0x94,0x2f,0x75, 0xc9,0xea,0xbb,0xf2,0x74,0x23,0xcc,0x32,0xc9,0x86,0x51,0xf8,0xfb,0xfb,0x33,0x81, 0x24,0x71,0x20,0x54,0x00,0x05,0x04,0x44,0x08,0x8a,0xfe,0x8b,0x4f,0xd2,0x31,0xce, 0xc7,0xcb,0x77,0xb2,0x96,0x61,0x18,0x48,0x88,0x45,0x52,0x7d,0x79,0x18,0xc6,0x87, 0x07,0x32,0x20,0xc8,0x00,0x82,0x21,0x40,0x88,0x05,0xba,0xf0,0x00,0x10,0x10,0x7c, 0x9b,0xbd,0x62,0x12,0x45,0x00,0x38,0x46,0x81,0xf8,0xff,0xef,0x81,0x00,0xfc,0x00, 0x38,0x1a,0xfa,0x53,0x2c,0x04,0x62,0x2c,0x12,0x05,0x26,0x11,0x39,0x3c,0x40,0x6c, 0x1e,0x1b,0x0c,0x21,0xfd,0x1f,0x22,0x2e,0x53,0x3d,0x62,0x2e,0xfa,0x77,0x11,0x52, 0x39,0xcf,0x59,0xe2,0xcd,0xe8,0xfe,0xbd,0x77,0x9e,0xdf,0x3d,0x33,0x21,0x1c,0xef, 0xff,0xff,0x3f,0x3f,0xe3,0xff,0x7f,0xdf,0xdf,0xfa,0x94,0x19,0x7d,0xc4,0x16,0x39, 0xbe,0x49,0x77,0xf6,0xfa,0x7f,0x6e,0x47,0x41,0x37,0x16,0x7f,0xf7,0xf7,0xfb,0x7e, 0x3f,0x72,0xff,0xf7,0x7e,0x7f,0x7f,0xfa,0x97,0xdf,0xea,0xc9,0x16,0x59,0xae,0x3d, 0x78,0x30,0x1d,0x3f,0xf6,0x57,0xd1,0x43,0xb2,0xff,0xf7,0xf6,0x57,0x7f,0x22,0xbb, 0xff,0x5f,0xff,0xe9,0x4b,0x29,0xf5,0x96,0xc2,0x58,0x45,0x9f,0xb8,0xe9,0x2d,0x24, 0x02,0x98,0xc5,0xff,0xf8,0xe9,0x3d,0x34,0x82,0xd8,0xc5,0xff,0xfb,0xea,0xfc,0xb3, 0xc5,0xc7,0xda,0xea,0x45,0xee,0x02,0x57,0x9b,0x25,0xcf,0x16,0x25,0x00,0x41,0x20, 0x40,0x90,0x40,0x20,0xbf,0x6e,0x11,0xea,0x52,0xe1,0x28,0xf2,0xa4,0xf2,0x68,0xd1, 0xba,0x00,0x81,0x02,0x01,0x20,0xfe,0x51,0x41,0x7f,0x7f,0xfb,0x1d,0x27,0x87,0x3a, 0x55,0xe7,0x4c,0x76,0x16,0x21,0x84,0x2f,0x58,0x22,0x6f,0x7b,0x21,0xd3,0x85,0x5c, 0x23,0xef,0xd7,0x47,0xdf,0xbd,0xe7,0xef,0xff,0xfb,0xe3,0xd4,0x32,0x01,0x70,0x8f, 0xcd,0x64,0x03,0x47,0x67,0x06,0x31,0x38,0x88,0xcc,0x21,0xef,0x07,0xe3,0xd7,0x77, 0x07,0x71,0xbf,0xcd,0xec,0xfa,0xa3,0x96,0x73,0x91,0x3f,0xf0,0x22,0x81,0x1f,0x8d, 0xe0,0x73,0xef,0x5f,0x7d,0x9e,0x21,0xcc,0xe3,0xf3,0x7f,0x9f,0x22,0x13,0xbf,0x9f, 0xf3,0xff,0xff,0xfa,0xce,0x73,0x8f,0x77,0x91,0x1e,0xcb,0xc8,0x8c,0xdc,0x10,0x68, 0xfe,0xf5,0x3f,0x3f,0x0b,0xff,0x8c,0xdf,0x9f,0x6f,0xf5,0x4f,0xff,0xce,0x9f,0x7f, 0xfa,0xeb,0x26,0xbb,0xd5,0x1e,0x61,0xeb,0x23,0xd7,0xfd,0x60,0x33,0xfe,0xde,0xd4, 0xec,0x86,0xdf,0xfd,0xe3,0xf3,0xfe,0xef,0xc6,0xff,0xfb,0xf7,0xfe,0xef,0xfa,0x56, 0x3f,0xd8,0xb7,0xcc,0x59,0x75,0x13,0x40,0x40,0x3b,0x4f,0x3f,0x3e,0x6a,0x7c,0x19, 0x7f,0x40,0x6f,0x7b,0x3f,0x6f,0x47,0x7f,0x56,0xfb,0xff,0xff,0xfe,0x6b,0x9d,0xcf, 0xa6,0x92,0x5f,0xbb,0x26,0x02,0x03,0xd0,0x68,0x74,0xb4,0x7c,0xf8,0x02,0x9f,0xde, 0x6e,0xf6,0xf4,0xfe,0xfe,0x22,0x49,0x6b,0xdf,0xee,0xff,0xff,0xfa,0x38,0x0b,0x34, 0xd1,0x28,0x15,0x84,0x15,0x57,0x7b,0x27,0x76,0x5b,0x6d,0x3d,0x00,0x21,0x63,0x77, 0x77,0x7b,0x7d,0x22,0x4c,0x7f,0x37,0xf7,0xbd,0x15,0xfe,0x6e,0xe6,0x3b,0xce,0x9a, 0xf7,0xb1,0x00,0xd0,0xd8,0xf4,0x3c,0x7c,0x48,0x6f,0x00,0xde,0xde,0xf6,0xfc,0xfe, 0x4e,0xef,0x00,0xd8,0xfe,0xff,0xff,0xff,0x00};
the_stack_data/181394323.c
void ordr(double data[],int n,int out[]) /* --------------------------------------------- Function to find the order of one dimensional data Example: input: 3,16,39,5,-34 output:1,3,4,2,0 In case of the same number in data, the first one is the smaller number Algorithm: Find the minimum number for the remaining data, and rank the number Coded by Naotoshi Osaka < aordr.f (1980/5/23) 6/15/1994 ------------------------------------------------- */ { int i,jj,icont,in; double aminm; for(i=0;i<n;i++){out[i]= -1;} for(jj=0;jj<n;jj++){ icont=0; for(i=0;i<n;i++){ if(out[i]== -1){ if(icont==0){aminm=data[i]; in=i;} icont++; if(data[i]<aminm){aminm=data[i];in=i;} } } out[in]=jj; /* printf("jj=%d out= %d %d %d %d %d\n", jj,out[0],out[1],out[2],out[3],out[4]); */ } } /* ------------------------------------------------ */ /* main() { double data[5]; int j,out[5]; data[0]= 3.0; data[1]= 16.0; data[2]= 34.0; data[3]= 5.0; data[4]= -34.0; ordr(data,5,out); printf("Result: out= %5d %5d %5d %5d %5d\n", out[0],out[1],out[2],out[3],out[4]); } */
the_stack_data/132953463.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char **argv) { unsigned int sleep_seconds = 0; if (argc > 1) { sleep_seconds = atoi(argv[1]); } sleep(sleep_seconds); char *array = (char *) malloc(-1); array[0] = 'A'; *((int*) 0) = 69; return 0; }
the_stack_data/64200500.c
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 1997, 2013 Oracle and/or its affiliates. All rights reserved. * * $Id$ */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef _WIN32 extern int getopt(int, char * const *, const char *); #else #include <unistd.h> #endif #include <db.h> #define DATABASE "access.db" int main __P((int, char *[])); int usage __P((void)); int main(argc, argv) int argc; char *argv[]; { extern int optind; DB *dbp; DBC *dbcp; DBT key, data; size_t len; int ch, ret, rflag; char *database, *p, *t, buf[1024], rbuf[1024]; const char *progname = "ex_access"; /* Program name. */ rflag = 0; while ((ch = getopt(argc, argv, "r")) != EOF) switch (ch) { case 'r': rflag = 1; break; case '?': default: return (usage()); } argc -= optind; argv += optind; /* Accept optional database name. */ database = *argv == NULL ? DATABASE : argv[0]; /* Optionally discard the database. */ if (rflag) (void)remove(database); /* Create and initialize database object, open the database. */ if ((ret = db_create(&dbp, NULL, 0)) != 0) { fprintf(stderr, "%s: db_create: %s\n", progname, db_strerror(ret)); return (EXIT_FAILURE); } dbp->set_errfile(dbp, stderr); dbp->set_errpfx(dbp, progname); if ((ret = dbp->set_pagesize(dbp, 1024)) != 0) { dbp->err(dbp, ret, "set_pagesize"); goto err1; } if ((ret = dbp->set_cachesize(dbp, 0, 32 * 1024, 0)) != 0) { dbp->err(dbp, ret, "set_cachesize"); goto err1; } if ((ret = dbp->open(dbp, NULL, database, NULL, DB_BTREE, DB_CREATE, 0664)) != 0) { dbp->err(dbp, ret, "%s: open", database); goto err1; } /* * Insert records into the database, where the key is the user * input and the data is the user input in reverse order. */ memset(&key, 0, sizeof(DBT)); memset(&data, 0, sizeof(DBT)); for (;;) { printf("input> "); fflush(stdout); if (fgets(buf, sizeof(buf), stdin) == NULL) break; if (strcmp(buf, "exit\n") == 0 || strcmp(buf, "quit\n") == 0) break; if ((len = strlen(buf)) <= 1) continue; for (t = rbuf, p = buf + (len - 2); p >= buf;) *t++ = *p--; *t++ = '\0'; key.data = buf; data.data = rbuf; data.size = key.size = (u_int32_t)len - 1; switch (ret = dbp->put(dbp, NULL, &key, &data, DB_NOOVERWRITE)) { case 0: break; default: dbp->err(dbp, ret, "DB->put"); if (ret != DB_KEYEXIST) goto err1; break; } } printf("\n"); /* Acquire a cursor for the database. */ if ((ret = dbp->cursor(dbp, NULL, &dbcp, 0)) != 0) { dbp->err(dbp, ret, "DB->cursor"); goto err1; } /* Initialize the key/data pair so the flags aren't set. */ memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); /* Walk through the database and print out the key/data pairs. */ while ((ret = dbcp->get(dbcp, &key, &data, DB_NEXT)) == 0) printf("%.*s : %.*s\n", (int)key.size, (char *)key.data, (int)data.size, (char *)data.data); if (ret != DB_NOTFOUND) { dbp->err(dbp, ret, "DBcursor->get"); goto err2; } /* Close everything down. */ if ((ret = dbcp->close(dbcp)) != 0) { dbp->err(dbp, ret, "DBcursor->close"); goto err1; } if ((ret = dbp->close(dbp, 0)) != 0) { fprintf(stderr, "%s: DB->close: %s\n", progname, db_strerror(ret)); return (EXIT_FAILURE); } return (EXIT_SUCCESS); err2: (void)dbcp->close(dbcp); err1: (void)dbp->close(dbp, 0); return (EXIT_FAILURE); } int usage() { (void)fprintf(stderr, "usage: ex_access [-r] [database]\n"); return (EXIT_FAILURE); }
the_stack_data/40761623.c
/* LL raised several warnings, ignore them */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #ifdef STM32F0xx #include "stm32f0xx_ll_i2c.c" #elif STM32F1xx #include "stm32f1xx_ll_i2c.c" #elif STM32F2xx #include "stm32f2xx_ll_i2c.c" #elif STM32F3xx #include "stm32f3xx_ll_i2c.c" #elif STM32F4xx #include "stm32f4xx_ll_i2c.c" #elif STM32F7xx #include "stm32f7xx_ll_i2c.c" #elif STM32G0xx #include "stm32g0xx_ll_i2c.c" #elif STM32G4xx #include "stm32g4xx_ll_i2c.c" #elif STM32H7xx #include "stm32h7xx_ll_i2c.c" #elif STM32L0xx #include "stm32l0xx_ll_i2c.c" #elif STM32L1xx #include "stm32l1xx_ll_i2c.c" #elif STM32L4xx #include "stm32l4xx_ll_i2c.c" #elif STM32L5xx #include "stm32l5xx_ll_i2c.c" #elif STM32MP1xx #include "stm32mp1xx_ll_i2c.c" #elif STM32WBxx #include "stm32wbxx_ll_i2c.c" #elif STM32WLxx #include "stm32wlxx_ll_i2c.c" #endif #pragma GCC diagnostic pop
the_stack_data/200144005.c
#include <err.h> #include <pthread.h> #include <semaphore.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> /* * Εργαστήριο ΛΣ2 (Δ6) / Εργασία 2: Άσκηση 1.1 / 2020-2021 * Ονοματεπώνυμο: Χρήστος Μαργιώλης * ΑΜ: 19390133 * Τρόπος μεταγλώττισης: `cc ex1_1.c -lpthread -lrt -o ex1_1` */ /* Calculate an array's length. */ #define LEN(x) (sizeof(x) / sizeof(x[0])) struct foo { char *str; int tid; sem_t sem; }; /* Function declarations */ static void *thread_callback(void *); static void *emalloc(size_t); static void usage(void); /* Global variables */ static char *argv0; /* * Each thread will print one of these. Everything will adapt in case more * strings are added to the array. */ static const char *nums[] = { "<one>", "<two>", "<three>", }; static void * thread_callback(void *foo) { struct foo *f; f = (struct foo *)foo; /* Lock the semaphore (decrement by one). */ if (sem_wait(&f->sem) < 0) err(1, "sem_wait"); /* * Get appropriate string. `f->tid` has the thread's ID -- we'll use * it to give each thread a unique string. Thread 0 will get the first * string, thread 1 the second, and so on. */ if ((f->str = strdup(nums[f->tid++])) == NULL) err(1, "strdup"); fputs(f->str, stdout); free(f->str); /* Unlock the semaphore (increment by one). */ if (sem_post(&f->sem) < 0) err(1, "sem_post"); return NULL; } static void * emalloc(size_t nb) { void *p; if ((p = malloc(nb)) == NULL) err(1, "malloc"); return p; } static void usage(void) { fprintf(stderr, "usage: %s [-n times]\n", argv0); exit(1); } int main(int argc, char *argv[]) { struct foo *f; pthread_t *tds; int i, len, n = 5; char ch; argv0 = *argv; while ((ch = getopt(argc, argv, "n:")) != -1) { switch (ch) { case 'n': /* * Manually choose how many times the string sequence * is going to be printed. Obviously, we cannot allow * an N less than 1. By default `n` is 5 (see * declaration above). */ if ((n = atoi(optarg)) < 1) errx(1, "value must be greater than 1"); break; case '?': default: usage(); } } argc -= optind; argv += optind; len = LEN(nums); /* * Instead of hardcoding how many threads we want to have, the * number of threads is always equal to how many elements the * `nums` array has. That means in case we want to add/remove * entries from `nums`, everything will adapt automatically. */ tds = emalloc(len * sizeof(pthread_t)); f = emalloc(sizeof(struct foo)); /* * sem_init(3)'s second argument defines whether the semaphore * should be shared by multiple processes or not. This is done * by passing a non-zero value, but in this case we want the * semaphore to be shared only by this process. */ if (sem_init(&f->sem, 0, 1) < 0) err(1, "sem_init"); while (n--) { f->tid = 0; for (i = 0; i < len; i++) if (pthread_create(&tds[i], NULL, thread_callback, (void *)f) != 0) err(1, "pthread_create"); for (i = 0; i < len; i++) if (pthread_join(tds[i], NULL) != 0) err(1, "pthread_join"); } printf("\n"); (void)sem_destroy(&f->sem); pthread_exit(NULL); free(tds); free(f); return 0; }
the_stack_data/150141049.c
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <unistd.h> #include <sys/mman.h> #include <fcntl.h> int main() { int fd, i; int position, limit, offset; int16_t value[2]; void *cfg, *sts, *gpio_n, *gpio_p, *ram; char *name = "/dev/mem"; char buffer[32768]; if((fd = open(name, O_RDWR)) < 0) { perror("open"); return EXIT_FAILURE; } cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40000000); sts = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40001000); gpio_n = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40002000); gpio_p = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40003000); ram = mmap(NULL, 16*sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40010000); /* put oscilloscope and ram writer into reset mode */ *((uint16_t *)(cfg + 0)) &= ~3; /* configure trigger edge (0 for negative, 1 for positive) */ *((uint16_t *)(cfg + 2)) = 0; /* set trigger mask */ *((uint16_t *)(cfg + 4)) = 1; /* set trigger level */ *((uint16_t *)(cfg + 6)) = 1; /* set total number of samples */ *((uint16_t *)(cfg + 8)) = 8192 - 1; /* set decimation factor for CIC filter (from 5 to 125) */ /* combined (CIC and FIR) decimation factor is twice greater */ *((uint16_t *)(cfg + 10)) = 5; /* switch on LED 1 */ *((uint8_t *)(cfg + 12)) |= 1; /* set tri-state control register */ *((uint8_t *)(gpio_n + 4)) &= ~1; /* set pin DIO0_N to high */ *((uint8_t *)(gpio_n + 0)) |= 1; /* set tri-state control register */ *((uint8_t *)(gpio_p + 4)) &= ~1; /* set pin DIO0_P to high */ *((uint8_t *)(gpio_p + 0)) |= 1; /* enter normal operating mode */ *((uint16_t *)(cfg + 0)) |= 3; limit = 8192; while(1) { /* read ram writer position */ position = *((uint16_t *)(sts + 2)); /* process 8192 samples if ready, otherwise sleep */ if((limit > 0 && position > limit) || (limit == 0 && position < 8192)) { offset = limit > 0 ? 0 : 32768; limit = limit > 0 ? 0 : 8192; memcpy(buffer, ram + offset, 32768); /* process 8192 samples in buffer */ for(i = 0; i < 8192; ++i) { value[0] = *((int16_t *)(buffer + 4*i + 0)); value[1] = *((int16_t *)(buffer + 4*i + 2)); printf("%5d %5d\n", value[0], value[1]); } return EXIT_SUCCESS; } else { usleep(100); } } munmap(cfg, sysconf(_SC_PAGESIZE)); munmap(sts, sysconf(_SC_PAGESIZE)); munmap(gpio_n, sysconf(_SC_PAGESIZE)); munmap(gpio_p, sysconf(_SC_PAGESIZE)); munmap(ram, sysconf(_SC_PAGESIZE)); return EXIT_SUCCESS; }
the_stack_data/735424.c
/* MIT License Copyright (c) John Blaiklock 2019 miniwin Embedded Window Manager 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. */ #ifdef RASPBERRY_PI_PICO /*************** *** INCLUDES *** ***************/ #include <stdint.h> #include <string.h> #include "hardware/sync.h" #include "hardware/flash.h" #include "hal/hal_non_vol.h" /**************** *** CONSTANTS *** ****************/ #define FLASH_TARGET_OFFSET (PICO_FLASH_SIZE_BYTES - FLASH_SECTOR_SIZE) static const uint8_t *flash_target_contents = (const uint8_t *) (XIP_BASE + FLASH_TARGET_OFFSET); /************ *** TYPES *** ************/ /*********************** *** GLOBAL VARIABLES *** ***********************/ /********************** *** LOCAL VARIABLES *** **********************/ /******************************** *** LOCAL FUNCTION PROTOTYPES *** ********************************/ /********************** *** LOCAL FUNCTIONS *** **********************/ /*********************** *** GLOBAL FUNCTIONS *** ***********************/ void mw_hal_non_vol_init(void) { } void mw_hal_non_vol_load(uint8_t *data, uint16_t length) { (void)memcpy(data, flash_target_contents, (length)); } void mw_hal_non_vol_save(uint8_t *data, uint16_t length) { uint32_t interrupts; /* disable and dave all interrupts before doing flash things */ interrupts = save_and_disable_interrupts(); /* erase sector */ flash_range_erase(FLASH_TARGET_OFFSET, FLASH_SECTOR_SIZE); /* write data */ flash_range_program(FLASH_TARGET_OFFSET, data, length); /* restore all interrupts when flash stuff done */ restore_interrupts(interrupts); } #endif
the_stack_data/87637106.c
void ngx_process_get_status(void) { int status; __typeof(status) abc; }
the_stack_data/220454888.c
int arr[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; int main() { return arr[1][2]; }
the_stack_data/43887808.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern void signal(int sig , void *func ) ; extern float strtof(char const *str , char const *endptr ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned long input[1] , unsigned long output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; void RandomFunc(unsigned long input[1] , unsigned long output[1] ) { unsigned long state[1] ; unsigned long local1 ; unsigned int copy12 ; unsigned short copy13 ; { state[0UL] = (input[0UL] | 51238316UL) >> 3UL; local1 = 0UL; while (local1 < input[1UL]) { if (state[0UL] > local1) { if (state[0UL] > local1) { state[local1] = state[0UL] >> ((state[0UL] & 7UL) | 1UL); } } else if (state[0UL] == local1) { copy12 = *((unsigned int *)(& state[local1]) + 0); *((unsigned int *)(& state[local1]) + 0) = *((unsigned int *)(& state[local1]) + 1); *((unsigned int *)(& state[local1]) + 1) = copy12; } else { copy13 = *((unsigned short *)(& state[local1]) + 2); *((unsigned short *)(& state[local1]) + 2) = *((unsigned short *)(& state[local1]) + 3); *((unsigned short *)(& state[local1]) + 3) = copy13; } local1 += 2UL; } output[0UL] = (state[0UL] | 85060083UL) << 1UL; } } int main(int argc , char *argv[] ) { unsigned long input[1] ; unsigned long output[1] ; int randomFuns_i5 ; unsigned long randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == 4242424242UL) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%lu\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } } void megaInit(void) { { } }
the_stack_data/6388376.c
#include <stdio.h> #include <signal.h> #include <stdlib.h> void usage() { printf("Usage: ./test_divide <number1> <number2>\nPrints out number1 divided by number2\n"); } int divide(int a, int b) { return a/b; } void divByZeroError(int a) { printf("Error!\n"); exit(1); } int main(int argc, char ** argv) { struct sigaction divAction; sigemptyset(&divAction.sa_mask); divAction.sa_handler = divByZeroError; sigaction(SIGFPE, &divAction, NULL); sigaction(SIGTRAP, &divAction, NULL); printf("3/4 = %d\n9/2 = %d\n4/2 = %d\n10/0 = ", divide(3,4), divide(9,2), divide(4,2)); printf("%d\n", divide(10, 0)); return 0; }
the_stack_data/179831922.c
// REQUIRES: long_tests // Check that clang is able to process short response files // Since this is a short response file, clang must not use a response file // to pass its parameters to other tools. This is only necessary for a large // number of parameters. // RUN: echo "-DTEST" >> %t.0.txt // RUN: %clang -E @%t.0.txt %s -v 2>&1 | FileCheck %s -check-prefix=SHORT // SHORT-NOT: Arguments passed via response file // SHORT: extern int it_works; // Check that clang is able to process long response files, routing a long // sequence of arguments to other tools by using response files as well. // We generate a 2MB response file to be big enough to surpass any system // limit. // RUN: %clang -E %S/Inputs/gen-response.c | grep DTEST > %t.1.txt // RUN: %clang -E @%t.1.txt %s -v 2>&1 | FileCheck %s -check-prefix=LONG // LONG: Arguments passed via response file // LONG: extern int it_works; #ifdef TEST extern int it_works; #endif
the_stack_data/75867.c
/**************************************************************************** * libs/libc/math/lib_frexpf.c * * This file is a part of NuttX: * * Copyright (C) 2012 Gregory Nutt. All rights reserved. * Ported by: Darcy Gong * * It derives from the Rhombus OS math library by Nick Johnson which has * a compatibile, MIT-style license: * * Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <math.h> /**************************************************************************** * Public Functions ****************************************************************************/ float frexpf(float x, int *exponent) { float res; *exponent = (int)ceilf(log2f(fabsf(x))); res = x / ldexpf(1.0F, *exponent); if (res >= 1.0) { res -= 0.5; *exponent += 1; } if (res <= -1.0) { res += 0.5; *exponent += 1; } return res; }
the_stack_data/68888825.c
#include <stdio.h> int main() { printf("Hello World !\n"); return 0; }
the_stack_data/59512702.c
#include <limits.h> int reverse(int x) { long result = 0; while (x != 0) { result = result * 10 + x % 10; if (result > INT_MAX || result < INT_MIN) { return 0; } x /= 10; } return (int)result; }
the_stack_data/198579462.c
// This file is part of CPAchecker, // a tool for configurable software verification: // https://cpachecker.sosy-lab.org // // SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> // // SPDX-License-Identifier: Apache-2.0 typedef int bool; struct module; void *__VERIFIER_nondet_pointer(void); static inline bool try_module_get(struct module *module); static inline void module_put(struct module *module) { } static inline void __module_get(struct module *module) { } extern void module_put_and_exit(struct module *mod, long code); int module_refcount(struct module *mod); void ldv_check_final_state(void); const int N = 10; void main(void) { struct module *test_module_1; struct module *test_module_2; int i; i = try_module_get(test_module_1); i = try_module_get(test_module_2); module_put(test_module_2); module_put(test_module_1); ldv_check_final_state(); }
the_stack_data/23576169.c
#include<stdio.h> int main() { printf("%s","Hello World"); return 0; }
the_stack_data/64201688.c
#include <stdio.h> #include <stdlib.h> int main() { char *s; sprintf(s, "%d\0", 789); sprintf(s, "%d", 789); puts(s); //printf("s = %s\n", *s); //printf("s = %s\n", s); return 0; }
the_stack_data/161080963.c
//@ #include "auxiliary_definitions.gh" /*@ lemma void union_nil<t>(list<t> xs) requires true; ensures union(xs, nil) == xs && union(nil, xs) == xs; { switch (xs) { case cons(x0, xs0): union_nil(xs0); case nil: } } lemma void union_subset<t>(list<t> xs, list<t> ys) requires subset(xs, ys) == true; ensures union(xs, ys) == ys; { switch (xs) { case cons(x0, xs0): union_subset(xs0, ys); case nil: union_nil(ys); } } lemma void union_refl<t>(list<t> xs) requires true; ensures union(xs, xs) == xs; { subset_refl(xs); union_subset(xs, xs); } lemma void forall_union<t>(list<t> xs, list<t> ys, fixpoint(t, bool) p) requires forall(xs, p) && forall(ys, p); ensures true == forall(union(xs,ys), p); { switch (xs) { case cons(x0, xs0): forall_union(xs0, ys, p); case nil: union_nil(ys); } } lemma void forall_subset<t>(list<t> xs, list<t> ys, fixpoint(t, bool) p) requires forall(ys, p) && subset(xs, ys); ensures true == forall(xs, p); { switch (xs) { case cons(x0, xs0): forall_subset(xs0, ys, p); mem_subset(x0, xs, ys); forall_mem(x0, ys, p); case nil: } } lemma void dummy_foreach_extract<t>(t x, list<t> xs) requires [_]dummy_foreach(xs, ?p) &*& mem(x, xs) == true; ensures [_]p(x); { switch (xs) { case cons(x0, xs0): open [_]dummy_foreach(xs, p); if (x == x0) assert [_]p(x); else dummy_foreach_extract<t>(x, xs0); case nil: assert false; } } lemma void dummy_foreach_singleton<t>(predicate(t) p, t x) requires [_]p(x); ensures [_]dummy_foreach(cons(x, nil), p); { close dummy_foreach(nil, p); leak dummy_foreach(nil, p); close dummy_foreach(cons(x, nil), p); leak dummy_foreach(cons(x, nil), p); } lemma void dummy_foreach_union<t>(list<t> xs, list<t> ys) requires [_]dummy_foreach(xs, ?p) &*& [_]dummy_foreach(ys, p); ensures [_]dummy_foreach(union(xs, ys), p); { switch (xs) { case cons(x0, xs0): open [_]dummy_foreach(xs, p); dummy_foreach_union(xs0, ys); if (!mem(x0, ys)) { close dummy_foreach(union(xs, ys), p); leak dummy_foreach(union(xs, ys), p); } case nil: union_nil(ys); } } lemma void dummy_foreach_subset<t>(list<t> xs, list<t> ys) requires [_]dummy_foreach(ys, ?p) &*& true == subset(xs, ys); ensures [_]dummy_foreach(xs, p); { switch (xs) { case cons(x0, xs0): dummy_foreach_subset(xs0, ys); dummy_foreach_extract(x0, ys); close dummy_foreach(xs, p); leak dummy_foreach(xs, p); case nil: close dummy_foreach(xs, p); leak dummy_foreach(xs, p); } } lemma void drop_drop<T>(int i1, int i2, list<T> xs) requires i1 >= 0 &*& i2 >= 0 &*& i1 + i2 < length(xs); ensures drop(i1, drop(i2, xs)) == drop(i1 + i2, xs); { switch (xs) { case nil: case cons(x0, xs0): if (i2 > 0) { drop_n_plus_one(i2, xs); drop_drop(i1, i2 - 1, xs0); } } } lemma void equal_list_equal_prefix<T>(list<T> xs1, list<T> xs2, list<T> xs3) requires append(xs1, xs3) == append(xs2, xs3); ensures xs1 == xs2; { switch (xs1) { case nil: length_append(xs2, xs3); switch (xs2) { case nil: case cons(x2', xs2'): } case cons(x1', xs1'): length_append(xs1, xs3); switch (xs2) { case nil: case cons(x2, xs2'): equal_list_equal_prefix(xs1', xs2', xs3); } } } lemma void equal_append<T>(list<T> xs1, list<T> xs11, list<T> xs2, list<T> xs22) requires length(xs1) == length(xs2) &*& append(xs1, xs11) == append(xs2, xs22); ensures xs1 == xs2 && xs11 == xs22; { drop_append(length(xs1), xs1, xs11); drop_append(length(xs1), xs2, xs22); take_append(length(xs1), xs1, xs11); take_append(length(xs1), xs2, xs22); } lemma void equal_double_triple_append<T>(list<T> xs1, list<T> xs2, list<T> xs3, list<T> xs4, list<T> xs5, list<T> xs6) requires true; ensures append(xs1, append(xs2, append(xs3, append(xs4, append(xs5, xs6))))) == append(append(xs1, append(xs2, xs3)), append(xs4, append(xs5, xs6))); { append_assoc(xs1, append(xs2, xs3), append(xs4, append(xs5, xs6))); append_assoc(xs2, xs3, append(xs4, append(xs5, xs6))); } lemma void head_append<T>(list<T> xs, list<T> ys) requires length(xs) > 0; ensures head(xs) == head(append(xs, ys)); { switch(xs) { case cons(c, cs): case nil: } } lemma void head_mem<T>(list<T> l) requires length(l) > 0; ensures true == mem(head(l), l); { switch(l) { case cons(c, cs): case nil: } } lemma void take_1<T>(list<T> xs) requires length(xs) > 0; ensures take(1, xs) == cons(head(xs), nil); { switch(xs) { case cons(c, cs): case nil: } } lemma void prefix_length<T>(list<T> xs, list<T> ys) requires true == prefix(xs, ys); ensures length(xs) <= length(ys); { switch(ys) { case cons(y0, ys0): switch(xs) { case cons(x0, xs0): prefix_length(xs0, ys0); case nil: } case nil: } } lemma void prefix_append<T>(list<T> xs, list<T> ys) requires true; ensures true == prefix(xs, append(xs, ys)); { take_append(length(xs), xs, ys); } lemma void prefix_trans<T>(list<T> xs1, list<T> xs2, list<T> xs3) requires prefix(xs1, xs2) && prefix(xs2, xs3); ensures true == prefix(xs1, xs3); { switch(xs3) { case cons(x0, xs0): prefix_trans(drop(1, xs1), drop(1, xs2), xs0); case nil: } } lemma void sublist_refl<T>(list<T> xs) requires true; ensures true == sublist(xs, xs); { switch(xs) { case cons(x0, xs0): case nil: } } lemma void sublist_length<T>(list<T> xs, list<T> ys) requires true == sublist(xs, ys); ensures length(xs) <= length(ys); { switch(ys) { case cons(y0, ys0): if (prefix(xs, ys)) { prefix_length(xs, ys); } else { sublist_length(xs, ys0); } case nil: } } lemma void sublist_append<T>(list<T> xs1, list<T> xs, list<T> xs2) requires true; ensures true == sublist(xs, append(xs1, append(xs, xs2))); { switch(xs1) { case cons(x10, xs10): list<T> xs_total = append(xs1, append(xs, xs2)); if (false == prefix(xs, xs_total)) { sublist_append(xs10, xs, xs2); } case nil: list<T> xs_total = append(xs1, append(xs, xs2)); assert xs_total == append(xs, xs2); switch (xs_total) { case cons(x0, xs0): prefix_append(xs, xs2); case nil: switch (xs) {case cons(x0, xs0): case nil:} } } } lemma void sublist_trans<T>(list<T> xs1, list<T> xs2, list<T> xs3) requires sublist(xs1, xs2) && sublist(xs2, xs3); ensures true == sublist(xs1, xs3); { switch(xs3) { case cons(x30, xs30): switch(xs2) { case cons(x20, xs20): if (prefix(xs2, xs3)) { if (prefix(xs1, xs2)) { prefix_trans(xs1, xs2, xs3); } else { switch (xs30){case cons(x, xs): case nil:} sublist_trans(xs1, xs20, xs30); } } else { sublist_trans(xs1, xs2, xs30); } case nil: } case nil: } } lemma void take_length_bound<T>(int i, list<T> xs) requires i >= 0; ensures length(take(i, xs)) <= i && length(take(i, xs)) <= length(xs); { switch(xs) { case cons(x0, xs0): if (i > 0) take_length_bound<T>(i - 1, xs0); case nil: } } @*/
the_stack_data/115794.c
/* * Copyright (c) 2013, 2014 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * sys/socket/sendto.c * Send a message on a socket. */ #include <sys/socket.h> #include <string.h> ssize_t sendto(int fd, const void* buffer, size_t buffer_size, int flags, const struct sockaddr* addr, socklen_t addrsize) { struct msghdr msghdr; memset(&msghdr, 0, sizeof(msghdr)); struct iovec iovec; iovec.iov_base = (void*) buffer; iovec.iov_len = buffer_size; msghdr.msg_name = (void*) addr; msghdr.msg_namelen = addrsize; msghdr.msg_iov = &iovec; msghdr.msg_iovlen = 1; return sendmsg(fd, &msghdr, flags); }
the_stack_data/50272.c
/*实验4-2程序修改替换题程序*/ #include <stdio.h> //子函数声明 int maxx(int x, int y, int z); float summ(float x, float y); int main(void) { int a, b, c; float d, e; printf("Input three integers:"); scanf("%d%d%d", &a, &b, &c); printf("\nThe maximum of them is %d\n", maxx(a, b, c)); printf("Input two floating point numbers:"); scanf("%f%f", &d, &e); printf("\nThe sum of them is %f\n", summ(d, e)); return 0; } int maxx(int x, int y, int z) { int m = z; //if语句比较大小 if (x > m) m = x; if (y > m) m = y; return m; } float summ(float x, float y) { return x + y; //实现相加 }
the_stack_data/77534.c
/* { dg-do compile } */ /* { dg-options "-Winline -O2" } */ extern void *alloca (__SIZE_TYPE__); void big (void); inline void *q (void) { /* { dg-warning "(function not inlinable|alloca)" } */ return alloca (10); } inline void *t (void) { return q (); /* { dg-warning "called from here" } */ }
the_stack_data/62637509.c
/** * Author : BurningTiles * Created : 2020-11-22 15:59:19 * Link : BurningTiles.github.io * Program : Calculate the Nth term **/ #include <stdio.h> int find_nth_term(int n, int a, int b, int c){ if(n==1) return a; if(n==2) return b; if(n==3) return c; return find_nth_term(n-1, a, b, c) + find_nth_term(n-2, a, b, c) + find_nth_term(n-3, a, b, c); } int main(){ int n, a, b, c; scanf("%d %d %d %d", &n, &a, &b, &c); printf("%d", find_nth_term(n, a, b, c)); return 0; } /** Question : https://www.hackerrank.com/challenges/recursion-in-c/problem **/
the_stack_data/170453597.c
#define ALLOCSIZE 10000 /* size of available space */ static char allocbuf[ALLOCSIZE]; /* storage for alloc */ static char *allocp = allocbuf; /* next free position */ /* return pointer to n characters */ char *alloc(int n) { /* it fits */ if (allocbuf + ALLOCSIZE - allocp >= n) { allocp += n; /* old p */ return allocp - n; } else { /* not enough room */ return 0; } } /* free storage pointed to by p */ void afree(char *p) { if (p >= allocbuf && p < allocbuf + ALLOCSIZE) allocp = p; }
the_stack_data/8375.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> static inline int mystrlen(char *s) { int i = 0; while (s[i]) i++; return i; } void pass(void) { char s[] = "passed.\n"; write (1, s, sizeof (s) - 1); exit (0); } void _fail(char *reason) { char s[] = "\nfailed: "; int len = mystrlen(reason); write (1, s, sizeof (s) - 1); write (1, reason, len); write (1, "\n", 1); // exit (1); } void *memset (void *s, int c, size_t n) { char *p = s; int i; for (i = 0; i < n; i++) p[i] = c; return p; } void exit (int status) { register unsigned int callno asm ("r9") = 1; /* NR_exit */ asm volatile ("break 13\n" : : "r" (callno) : "memory" ); while(1) ; } ssize_t write (int fd, const void *buf, size_t count) { register unsigned int callno asm ("r9") = 4; /* NR_write */ register unsigned int r10 asm ("r10") = fd; register const void *r11 asm ("r11") = buf; register size_t r12 asm ("r12") = count; register unsigned int r asm ("r10"); asm volatile ("break 13\n" : "=r" (r) : "r" (callno), "0" (r10), "r" (r11), "r" (r12) : "memory"); return r; }
the_stack_data/318591.c
#include <math.h> double j1(double x) { return x; } /* XOPEN(4) LINK(m) */
the_stack_data/154827668.c
#include <stdio.h> double function_add(int a, float b) { return (double)a + (double)b; } int main(int argc, const char *argv[]) { unsigned i; double (*f)(int, float) = function_add; /* calling a function using function pointer */ printf("12 + 3.7 = %f\n", f(12, 3.7)); printf("\n"); /* print binary to compare it with the result of * objdump command */ printf("Binary of function_add:\n"); for (i = 0; i < 17; ++i) { printf("%02x ", ((unsigned char *)f)[i]); if (i == 7) printf("\n"); } printf("\n"); return 0; }
the_stack_data/132951930.c
/* servTCPIt.c - Exemplu de server TCP iterativ Asteapta un nume de la clienti; intoarce clientului sirul "Hello nume". Autor: Lenuta Alboaie <[email protected]> (c)2009 */ #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #include <unistd.h> #include <stdio.h> #include <string.h> #include <stdlib.h> /* portul folosit */ #define PORT 20213 /* codul de eroare returnat de anumite apeluri */ extern int errno; int main() { struct sockaddr_in server; // structura folosita de server struct sockaddr_in from; char msg[100]; //mesajul primit de la client char msgrasp[100] = " "; //mesaj de raspuns pentru client int sd; //descriptorul de socket /* crearea unui socket */ if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("[server]Eroare la socket().\n"); return errno; } /* pregatirea structurilor de date */ bzero(&server, sizeof(server)); bzero(&from, sizeof(from)); /* umplem structura folosita de server */ /* stabilirea familiei de socket-uri */ server.sin_family = AF_INET; /* acceptam orice adresa */ server.sin_addr.s_addr = htonl(INADDR_ANY); /* utilizam un port utilizator */ server.sin_port = htons(PORT); /* atasam socketul */ if (bind(sd, (struct sockaddr *)&server, sizeof(struct sockaddr)) == -1) { perror("[server]Eroare la bind().\n"); return errno; } /* punem serverul sa asculte daca vin clienti sa se conecteze */ if (listen(sd, 5) == -1) { perror("[server]Eroare la listen().\n"); return errno; } /* servim in mod iterativ clientii... */ while (1) { int client; int length = sizeof(from); printf("[server]Asteptam la portul %d...\n", PORT); fflush(stdout); /* acceptam un client (stare blocanta pina la realizarea conexiunii) */ client = accept(sd, (struct sockaddr *)&from, &length); /* eroare la acceptarea conexiunii de la un client */ if (client < 0) { perror("[server]Eroare la accept().\n"); continue; } /* s-a realizat conexiunea, se astepta mesajul */ bzero(msg, 100); printf("[server]Asteptam mesajul...\n"); fflush(stdout); /* citirea mesajului */ if (read(client, msg, 100) <= 0) { perror("[server]Eroare la read() de la client.\n"); close(client); /* inchidem conexiunea cu clientul */ continue; /* continuam sa ascultam */ } printf("[server]Mesajul a fost receptionat...%s\n", msg); /*pregatim mesajul de raspuns */ bzero(msgrasp, 100); strcat(msgrasp, "Hello "); strcat(msgrasp, msg); printf("[server]Trimitem mesajul inapoi...%s\n", msgrasp); /* returnam mesajul clientului */ if (write(client, msgrasp, 100) <= 0) { perror("[server]Eroare la write() catre client.\n"); continue; /* continuam sa ascultam */ } else printf("[server]Mesajul a fost trasmis cu succes.\n"); /* am terminat cu acest client, inchidem conexiunea */ close(client); } /* while */ } /* main */
the_stack_data/38830.c
// ============================================================== // Copyright (c) 1986 - 2021 Xilinx Inc. All rights reserved. // SPDX-License-Identifier: MIT // ============================================================== #ifndef __linux__ #include "xstatus.h" #include "xparameters.h" #include "xv_frmbufrd.h" extern XV_frmbufrd_Config XV_frmbufrd_ConfigTable[]; XV_frmbufrd_Config *XV_frmbufrd_LookupConfig(u16 DeviceId) { XV_frmbufrd_Config *ConfigPtr = NULL; int Index; for (Index = 0; Index < XPAR_XV_FRMBUFRD_NUM_INSTANCES; Index++) { if (XV_frmbufrd_ConfigTable[Index].DeviceId == DeviceId) { ConfigPtr = &XV_frmbufrd_ConfigTable[Index]; break; } } return ConfigPtr; } int XV_frmbufrd_Initialize(XV_frmbufrd *InstancePtr, u16 DeviceId) { XV_frmbufrd_Config *ConfigPtr; Xil_AssertNonvoid(InstancePtr != NULL); ConfigPtr = XV_frmbufrd_LookupConfig(DeviceId); if (ConfigPtr == NULL) { InstancePtr->IsReady = 0; return (XST_DEVICE_NOT_FOUND); } return XV_frmbufrd_CfgInitialize(InstancePtr, ConfigPtr, ConfigPtr->BaseAddress); } #endif
the_stack_data/97072.c
#include <stdio.h> struct employee{ char name[30]; int empId; float salary; }; int main() { struct employee emp; printf("\nEnter details :\n"); printf("Name ?:"); gets(emp.name); printf("ID ?:"); scanf("%d",&emp.empId); printf("Salary ?:"); scanf("%f",&emp.salary); printf("\nEntered detail is:"); printf("Name: %s" ,emp.name); printf("Id: %d" ,emp.empId); printf("Salary: %f\n",emp.salary); return 0; }
the_stack_data/62636681.c
/**/ #include<stdio.h> int main(void) { int a, b, c, median, temp; median = 0; temp = 0; printf("Please enter 3 numbers separated by spaces > "); scanf ("%d%d%d", &a, &b, &c); if (a>=b) { temp = b; b = a; a = temp; } if (a<c) median = b; else if (b>c) median = a; else median = c; printf("%d is the median\n", median); return(0); }
the_stack_data/357895.c
// KMSAN: uninit-value in sctp_rcv // https://syzkaller.appspot.com/bug?id=95632cde252ddaed5a8e // status:0 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <arpa/inet.h> #include <endian.h> #include <errno.h> #include <fcntl.h> #include <net/if.h> #include <net/if_arp.h> #include <netinet/in.h> #include <sched.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <sys/mount.h> #include <sys/prctl.h> #include <sys/resource.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> #include <unistd.h> #include <linux/capability.h> #include <linux/genetlink.h> #include <linux/if_addr.h> #include <linux/if_ether.h> #include <linux/if_link.h> #include <linux/if_tun.h> #include <linux/in6.h> #include <linux/ip.h> #include <linux/neighbour.h> #include <linux/net.h> #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <linux/tcp.h> #include <linux/veth.h> static unsigned long long procid; #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += (uint16_t)data[length - 1]; while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[1024]; }; static struct nlmsg nlmsg; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(struct nlmsg* nlmsg, int typ) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_type = typ; nlmsg->pos += sizeof(*attr); nlmsg->nested[nlmsg->nesting++] = attr; } static void netlink_done(struct nlmsg* nlmsg) { struct nlattr* attr = nlmsg->nested[--nlmsg->nesting]; attr->nla_len = nlmsg->pos - (char*)attr; } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; unsigned n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != hdr->nlmsg_len) exit(1); n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (hdr->nlmsg_type == NLMSG_DONE) { *reply_len = 0; return 0; } if (n < sizeof(struct nlmsghdr)) exit(1); if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr)) exit(1); if (hdr->nlmsg_type != NLMSG_ERROR) exit(1); return -((struct nlmsgerr*)(hdr + 1))->error; } static int netlink_send(struct nlmsg* nlmsg, int sock) { return netlink_send_ext(nlmsg, sock, 0, NULL); } static int netlink_next_msg(struct nlmsg* nlmsg, unsigned int offset, unsigned int total_len) { struct nlmsghdr* hdr = (struct nlmsghdr*)(nlmsg->buf + offset); if (offset == total_len || offset + hdr->nlmsg_len > total_len) return -1; return hdr->nlmsg_len; } static void netlink_add_device_impl(struct nlmsg* nlmsg, const char* type, const char* name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); netlink_init(nlmsg, RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(nlmsg, IFLA_IFNAME, name, strlen(name)); netlink_nest(nlmsg, IFLA_LINKINFO); netlink_attr(nlmsg, IFLA_INFO_KIND, type, strlen(type)); } static void netlink_add_device(struct nlmsg* nlmsg, int sock, const char* type, const char* name) { netlink_add_device_impl(nlmsg, type, name); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_veth(struct nlmsg* nlmsg, int sock, const char* name, const char* peer) { netlink_add_device_impl(nlmsg, "veth", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_nest(nlmsg, VETH_INFO_PEER); nlmsg->pos += sizeof(struct ifinfomsg); netlink_attr(nlmsg, IFLA_IFNAME, peer, strlen(peer)); netlink_done(nlmsg); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_hsr(struct nlmsg* nlmsg, int sock, const char* name, const char* slave1, const char* slave2) { netlink_add_device_impl(nlmsg, "hsr", name); netlink_nest(nlmsg, IFLA_INFO_DATA); int ifindex1 = if_nametoindex(slave1); netlink_attr(nlmsg, IFLA_HSR_SLAVE1, &ifindex1, sizeof(ifindex1)); int ifindex2 = if_nametoindex(slave2); netlink_attr(nlmsg, IFLA_HSR_SLAVE2, &ifindex2, sizeof(ifindex2)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_linked(struct nlmsg* nlmsg, int sock, const char* type, const char* name, const char* link) { netlink_add_device_impl(nlmsg, type, name); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_vlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t id, uint16_t proto) { netlink_add_device_impl(nlmsg, "vlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_VLAN_ID, &id, sizeof(id)); netlink_attr(nlmsg, IFLA_VLAN_PROTOCOL, &proto, sizeof(proto)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_macvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link) { netlink_add_device_impl(nlmsg, "macvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); uint32_t mode = MACVLAN_MODE_BRIDGE; netlink_attr(nlmsg, IFLA_MACVLAN_MODE, &mode, sizeof(mode)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_add_geneve(struct nlmsg* nlmsg, int sock, const char* name, uint32_t vni, struct in_addr* addr4, struct in6_addr* addr6) { netlink_add_device_impl(nlmsg, "geneve", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_GENEVE_ID, &vni, sizeof(vni)); if (addr4) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE, addr4, sizeof(*addr4)); if (addr6) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE6, addr6, sizeof(*addr6)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); (void)err; } #define IFLA_IPVLAN_FLAGS 2 #define IPVLAN_MODE_L3S 2 #undef IPVLAN_F_VEPA #define IPVLAN_F_VEPA 2 static void netlink_add_ipvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t mode, uint16_t flags) { netlink_add_device_impl(nlmsg, "ipvlan", name); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_IPVLAN_MODE, &mode, sizeof(mode)); netlink_attr(nlmsg, IFLA_IPVLAN_FLAGS, &flags, sizeof(flags)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); (void)err; } static void netlink_device_change(struct nlmsg* nlmsg, int sock, const char* name, bool up, const char* master, const void* mac, int macsize, const char* new_name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; hdr.ifi_index = if_nametoindex(name); netlink_init(nlmsg, RTM_NEWLINK, 0, &hdr, sizeof(hdr)); if (new_name) netlink_attr(nlmsg, IFLA_IFNAME, new_name, strlen(new_name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(nlmsg, IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(nlmsg, IFLA_ADDRESS, mac, macsize); int err = netlink_send(nlmsg, sock); (void)err; } static int netlink_add_addr(struct nlmsg* nlmsg, int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(nlmsg, RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, IFA_LOCAL, addr, addrsize); netlink_attr(nlmsg, IFA_ADDRESS, addr, addrsize); return netlink_send(nlmsg, sock); } static void netlink_add_addr4(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in_addr, sizeof(in_addr)); (void)err; } static void netlink_add_addr6(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in6_addr, sizeof(in6_addr)); (void)err; } #define DEVLINK_FAMILY_NAME "devlink" #define DEVLINK_CMD_PORT_GET 5 #define DEVLINK_ATTR_BUS_NAME 1 #define DEVLINK_ATTR_DEV_NAME 2 #define DEVLINK_ATTR_NETDEV_NAME 7 static int netlink_devlink_id_get(struct nlmsg* nlmsg, int sock) { struct genlmsghdr genlhdr; struct nlattr* attr; int err, n; uint16_t id = 0; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, DEVLINK_FAMILY_NAME, strlen(DEVLINK_FAMILY_NAME) + 1); err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n); if (err) { return -1; } attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); /* recv ack */ return id; } static struct nlmsg nlmsg2; static void initialize_devlink_ports(const char* bus_name, const char* dev_name, const char* netdev_prefix) { struct genlmsghdr genlhdr; int len, total_len, id, err, offset; uint16_t netdev_index; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) exit(1); int rtsock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rtsock == -1) exit(1); id = netlink_devlink_id_get(&nlmsg, sock); if (id == -1) goto error; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = DEVLINK_CMD_PORT_GET; netlink_init(&nlmsg, id, NLM_F_DUMP, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, DEVLINK_ATTR_BUS_NAME, bus_name, strlen(bus_name) + 1); netlink_attr(&nlmsg, DEVLINK_ATTR_DEV_NAME, dev_name, strlen(dev_name) + 1); err = netlink_send_ext(&nlmsg, sock, id, &total_len); if (err) { goto error; } offset = 0; netdev_index = 0; while ((len = netlink_next_msg(&nlmsg, offset, total_len)) != -1) { struct nlattr* attr = (struct nlattr*)(nlmsg.buf + offset + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg.buf + offset + len; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == DEVLINK_ATTR_NETDEV_NAME) { char* port_name; char netdev_name[IFNAMSIZ]; port_name = (char*)(attr + 1); snprintf(netdev_name, sizeof(netdev_name), "%s%d", netdev_prefix, netdev_index); netlink_device_change(&nlmsg2, rtsock, port_name, true, 0, 0, 0, netdev_name); break; } } offset += len; netdev_index++; } error: close(rtsock); close(sock); } #define DEV_IPV4 "172.20.20.%d" #define DEV_IPV6 "fe80::%02x" #define DEV_MAC 0x00aaaaaaaaaa static void netdevsim_add(unsigned int addr, unsigned int port_count) { char buf[16]; sprintf(buf, "%u %u", addr, port_count); if (write_file("/sys/bus/netdevsim/new_device", buf)) { snprintf(buf, sizeof(buf), "netdevsim%d", addr); initialize_devlink_ports("netdevsim", buf, "netdevsim"); } } #define WG_GENL_NAME "wireguard" enum wg_cmd { WG_CMD_GET_DEVICE, WG_CMD_SET_DEVICE, }; enum wgdevice_attribute { WGDEVICE_A_UNSPEC, WGDEVICE_A_IFINDEX, WGDEVICE_A_IFNAME, WGDEVICE_A_PRIVATE_KEY, WGDEVICE_A_PUBLIC_KEY, WGDEVICE_A_FLAGS, WGDEVICE_A_LISTEN_PORT, WGDEVICE_A_FWMARK, WGDEVICE_A_PEERS, }; enum wgpeer_attribute { WGPEER_A_UNSPEC, WGPEER_A_PUBLIC_KEY, WGPEER_A_PRESHARED_KEY, WGPEER_A_FLAGS, WGPEER_A_ENDPOINT, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, WGPEER_A_LAST_HANDSHAKE_TIME, WGPEER_A_RX_BYTES, WGPEER_A_TX_BYTES, WGPEER_A_ALLOWEDIPS, WGPEER_A_PROTOCOL_VERSION, }; enum wgallowedip_attribute { WGALLOWEDIP_A_UNSPEC, WGALLOWEDIP_A_FAMILY, WGALLOWEDIP_A_IPADDR, WGALLOWEDIP_A_CIDR_MASK, }; static int netlink_wireguard_id_get(struct nlmsg* nlmsg, int sock) { struct genlmsghdr genlhdr; struct nlattr* attr; int err, n; uint16_t id = 0; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, WG_GENL_NAME, strlen(WG_GENL_NAME) + 1); err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n); if (err) { return -1; } attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); /* recv ack */ return id; } static void netlink_wireguard_setup(void) { const char ifname_a[] = "wg0"; const char ifname_b[] = "wg1"; const char ifname_c[] = "wg2"; const char private_a[] = "\xa0\x5c\xa8\x4f\x6c\x9c\x8e\x38\x53\xe2\xfd\x7a" "\x70\xae\x0f\xb2\x0f\xa1\x52\x60\x0c\xb0\x08\x45" "\x17\x4f\x08\x07\x6f\x8d\x78\x43"; const char private_b[] = "\xb0\x80\x73\xe8\xd4\x4e\x91\xe3\xda\x92\x2c\x22" "\x43\x82\x44\xbb\x88\x5c\x69\xe2\x69\xc8\xe9\xd8" "\x35\xb1\x14\x29\x3a\x4d\xdc\x6e"; const char private_c[] = "\xa0\xcb\x87\x9a\x47\xf5\xbc\x64\x4c\x0e\x69\x3f" "\xa6\xd0\x31\xc7\x4a\x15\x53\xb6\xe9\x01\xb9\xff" "\x2f\x51\x8c\x78\x04\x2f\xb5\x42"; const char public_a[] = "\x97\x5c\x9d\x81\xc9\x83\xc8\x20\x9e\xe7\x81\x25\x4b" "\x89\x9f\x8e\xd9\x25\xae\x9f\x09\x23\xc2\x3c\x62\xf5" "\x3c\x57\xcd\xbf\x69\x1c"; const char public_b[] = "\xd1\x73\x28\x99\xf6\x11\xcd\x89\x94\x03\x4d\x7f\x41" "\x3d\xc9\x57\x63\x0e\x54\x93\xc2\x85\xac\xa4\x00\x65" "\xcb\x63\x11\xbe\x69\x6b"; const char public_c[] = "\xf4\x4d\xa3\x67\xa8\x8e\xe6\x56\x4f\x02\x02\x11\x45" "\x67\x27\x08\x2f\x5c\xeb\xee\x8b\x1b\xf5\xeb\x73\x37" "\x34\x1b\x45\x9b\x39\x22"; const uint16_t listen_a = 20001; const uint16_t listen_b = 20002; const uint16_t listen_c = 20003; const uint16_t af_inet = AF_INET; const uint16_t af_inet6 = AF_INET6; /* Unused, but useful in case we change this: const struct sockaddr_in endpoint_a_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_a), .sin_addr = {htonl(INADDR_LOOPBACK)}};*/ const struct sockaddr_in endpoint_b_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_b), .sin_addr = {htonl(INADDR_LOOPBACK)}}; const struct sockaddr_in endpoint_c_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_c), .sin_addr = {htonl(INADDR_LOOPBACK)}}; struct sockaddr_in6 endpoint_a_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_a)}; endpoint_a_v6.sin6_addr = in6addr_loopback; /* Unused, but useful in case we change this: const struct sockaddr_in6 endpoint_b_v6 = { .sin6_family = AF_INET6, .sin6_port = htons(listen_b)}; endpoint_b_v6.sin6_addr = in6addr_loopback; */ struct sockaddr_in6 endpoint_c_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_c)}; endpoint_c_v6.sin6_addr = in6addr_loopback; const struct in_addr first_half_v4 = {0}; const struct in_addr second_half_v4 = {htonl(128 << 24)}; const struct in6_addr first_half_v6 = {{{0}}}; const struct in6_addr second_half_v6 = {{{0x80}}}; const uint8_t half_cidr = 1; const uint16_t persistent_keepalives[] = {1, 3, 7, 9, 14, 19}; struct genlmsghdr genlhdr = {.cmd = WG_CMD_SET_DEVICE, .version = 1}; int sock; int id, err; sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) { return; } id = netlink_wireguard_id_get(&nlmsg, sock); if (id == -1) goto error; netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_a, strlen(ifname_a) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_a, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_a, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[0], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v6, sizeof(endpoint_c_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[1], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_b, strlen(ifname_b) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_b, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_b, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[2], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v4, sizeof(endpoint_c_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[3], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_c, strlen(ifname_c) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_c, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_c, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[4], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[5], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err) { } error: close(sock); } static void initialize_netdevices(void) { char netdevsim[16]; sprintf(netdevsim, "netdevsim%d", (int)procid); struct { const char* type; const char* dev; } devtypes[] = { {"ip6gretap", "ip6gretap0"}, {"bridge", "bridge0"}, {"vcan", "vcan0"}, {"bond", "bond0"}, {"team", "team0"}, {"dummy", "dummy0"}, {"nlmon", "nlmon0"}, {"caif", "caif0"}, {"batadv", "batadv0"}, {"vxcan", "vxcan1"}, {"netdevsim", netdevsim}, {"veth", 0}, {"xfrm", "xfrm0"}, {"wireguard", "wg0"}, {"wireguard", "wg1"}, {"wireguard", "wg2"}, }; const char* devmasters[] = {"bridge", "bond", "team", "batadv"}; struct { const char* name; int macsize; bool noipv6; } devices[] = { {"lo", ETH_ALEN}, {"sit0", 0}, {"bridge0", ETH_ALEN}, {"vcan0", 0, true}, {"tunl0", 0}, {"gre0", 0}, {"gretap0", ETH_ALEN}, {"ip_vti0", 0}, {"ip6_vti0", 0}, {"ip6tnl0", 0}, {"ip6gre0", 0}, {"ip6gretap0", ETH_ALEN}, {"erspan0", ETH_ALEN}, {"bond0", ETH_ALEN}, {"veth0", ETH_ALEN}, {"veth1", ETH_ALEN}, {"team0", ETH_ALEN}, {"veth0_to_bridge", ETH_ALEN}, {"veth1_to_bridge", ETH_ALEN}, {"veth0_to_bond", ETH_ALEN}, {"veth1_to_bond", ETH_ALEN}, {"veth0_to_team", ETH_ALEN}, {"veth1_to_team", ETH_ALEN}, {"veth0_to_hsr", ETH_ALEN}, {"veth1_to_hsr", ETH_ALEN}, {"hsr0", 0}, {"dummy0", ETH_ALEN}, {"nlmon0", 0}, {"vxcan0", 0, true}, {"vxcan1", 0, true}, {"caif0", ETH_ALEN}, {"batadv0", ETH_ALEN}, {netdevsim, ETH_ALEN}, {"xfrm0", ETH_ALEN}, {"veth0_virt_wifi", ETH_ALEN}, {"veth1_virt_wifi", ETH_ALEN}, {"virt_wifi0", ETH_ALEN}, {"veth0_vlan", ETH_ALEN}, {"veth1_vlan", ETH_ALEN}, {"vlan0", ETH_ALEN}, {"vlan1", ETH_ALEN}, {"macvlan0", ETH_ALEN}, {"macvlan1", ETH_ALEN}, {"ipvlan0", ETH_ALEN}, {"ipvlan1", ETH_ALEN}, {"veth0_macvtap", ETH_ALEN}, {"veth1_macvtap", ETH_ALEN}, {"macvtap0", ETH_ALEN}, {"macsec0", ETH_ALEN}, {"veth0_to_batadv", ETH_ALEN}, {"veth1_to_batadv", ETH_ALEN}, {"batadv_slave_0", ETH_ALEN}, {"batadv_slave_1", ETH_ALEN}, {"geneve0", ETH_ALEN}, {"geneve1", ETH_ALEN}, {"wg0", 0}, {"wg1", 0}, {"wg2", 0}, }; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) netlink_add_device(&nlmsg, sock, devtypes[i].type, devtypes[i].dev); for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) { char master[32], slave0[32], veth0[32], slave1[32], veth1[32]; sprintf(slave0, "%s_slave_0", devmasters[i]); sprintf(veth0, "veth0_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave0, veth0); sprintf(slave1, "%s_slave_1", devmasters[i]); sprintf(veth1, "veth1_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave1, veth1); sprintf(master, "%s0", devmasters[i]); netlink_device_change(&nlmsg, sock, slave0, false, master, 0, 0, NULL); netlink_device_change(&nlmsg, sock, slave1, false, master, 0, 0, NULL); } netlink_device_change(&nlmsg, sock, "bridge_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "bridge_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "hsr_slave_0", "veth0_to_hsr"); netlink_add_veth(&nlmsg, sock, "hsr_slave_1", "veth1_to_hsr"); netlink_add_hsr(&nlmsg, sock, "hsr0", "hsr_slave_0", "hsr_slave_1"); netlink_device_change(&nlmsg, sock, "hsr_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "hsr_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "veth0_virt_wifi", "veth1_virt_wifi"); netlink_add_linked(&nlmsg, sock, "virt_wifi", "virt_wifi0", "veth1_virt_wifi"); netlink_add_veth(&nlmsg, sock, "veth0_vlan", "veth1_vlan"); netlink_add_vlan(&nlmsg, sock, "vlan0", "veth0_vlan", 0, htons(ETH_P_8021Q)); netlink_add_vlan(&nlmsg, sock, "vlan1", "veth0_vlan", 1, htons(ETH_P_8021AD)); netlink_add_macvlan(&nlmsg, sock, "macvlan0", "veth1_vlan"); netlink_add_macvlan(&nlmsg, sock, "macvlan1", "veth1_vlan"); netlink_add_ipvlan(&nlmsg, sock, "ipvlan0", "veth0_vlan", IPVLAN_MODE_L2, 0); netlink_add_ipvlan(&nlmsg, sock, "ipvlan1", "veth0_vlan", IPVLAN_MODE_L3S, IPVLAN_F_VEPA); netlink_add_veth(&nlmsg, sock, "veth0_macvtap", "veth1_macvtap"); netlink_add_linked(&nlmsg, sock, "macvtap", "macvtap0", "veth0_macvtap"); netlink_add_linked(&nlmsg, sock, "macsec", "macsec0", "veth1_macvtap"); char addr[32]; sprintf(addr, DEV_IPV4, 14 + 10); struct in_addr geneve_addr4; if (inet_pton(AF_INET, addr, &geneve_addr4) <= 0) exit(1); struct in6_addr geneve_addr6; if (inet_pton(AF_INET6, "fc00::01", &geneve_addr6) <= 0) exit(1); netlink_add_geneve(&nlmsg, sock, "geneve0", 0, &geneve_addr4, 0); netlink_add_geneve(&nlmsg, sock, "geneve1", 1, 0, &geneve_addr6); netdevsim_add((int)procid, 4); netlink_wireguard_setup(); for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { char addr[32]; sprintf(addr, DEV_IPV4, i + 10); netlink_add_addr4(&nlmsg, sock, devices[i].name, addr); if (!devices[i].noipv6) { sprintf(addr, DEV_IPV6, i + 10); netlink_add_addr6(&nlmsg, sock, devices[i].name, addr); } uint64_t macaddr = DEV_MAC + ((i + 10ull) << 40); netlink_device_change(&nlmsg, sock, devices[i].name, true, 0, &macaddr, devices[i].macsize, NULL); } close(sock); } static void initialize_netdevices_init(void) { int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); struct { const char* type; int macsize; bool noipv6; bool noup; } devtypes[] = { {"nr", 7, true}, {"rose", 5, true, true}, }; unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) { char dev[32], addr[32]; sprintf(dev, "%s%d", devtypes[i].type, (int)procid); sprintf(addr, "172.30.%d.%d", i, (int)procid + 1); netlink_add_addr4(&nlmsg, sock, dev, addr); if (!devtypes[i].noipv6) { sprintf(addr, "fe88::%02x:%02x", i, (int)procid + 1); netlink_add_addr6(&nlmsg, sock, dev, addr); } int macsize = devtypes[i].macsize; uint64_t macaddr = 0xbbbbbb + ((unsigned long long)i << (8 * (macsize - 2))) + (procid << (8 * (macsize - 1))); netlink_device_change(&nlmsg, sock, dev, !devtypes[i].noup, 0, &macaddr, macsize, NULL); } close(sock); } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); sandbox_common(); drop_caps(); initialize_netdevices_init(); if (unshare(CLONE_NEWNET)) { } initialize_netdevices(); loop(); exit(1); } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void loop(void) { intptr_t res = 0; memcpy((void*)0x20000080, "/dev/net/tun\000", 13); res = syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000080ul, 0x88002ul, 0ul); if (res != -1) r[0] = res; memcpy((void*)0x20000040, "syzkaller1\000\000\000\000\000\000", 16); *(uint16_t*)0x20000050 = 0x5001; syscall(__NR_ioctl, r[0], 0x400454ca, 0x20000040ul); res = syscall(__NR_socket, 0xaul, 3ul, 0x3a); if (res != -1) r[1] = res; memcpy((void*)0x20000140, "syzkaller1\000\000\000\000\000\000", 16); *(uint16_t*)0x20000150 = 7; *(uint16_t*)0x20000152 = htobe16(0); *(uint8_t*)0x20000154 = 0xac; *(uint8_t*)0x20000155 = 0x14; *(uint8_t*)0x20000156 = 0x14; *(uint8_t*)0x20000157 = 0xaa; syscall(__NR_ioctl, r[1], 0x8914, 0x20000140ul); *(uint8_t*)0x20000240 = 0x11; *(uint8_t*)0x20000241 = 0; *(uint16_t*)0x20000242 = 0; *(uint16_t*)0x20000244 = 0; *(uint16_t*)0x20000246 = 0x15; *(uint16_t*)0x20000248 = 0; STORE_BY_BITMASK(uint8_t, , 0x2000024a, 5, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x2000024a, 4, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x2000024b, 0, 0, 2); STORE_BY_BITMASK(uint8_t, , 0x2000024b, 0, 2, 6); *(uint16_t*)0x2000024c = htobe16(0x29); *(uint16_t*)0x2000024e = htobe16(0); *(uint16_t*)0x20000250 = htobe16(0); *(uint8_t*)0x20000252 = 0; *(uint8_t*)0x20000253 = 0x84; *(uint16_t*)0x20000254 = htobe16(0); *(uint8_t*)0x20000256 = 0xac; *(uint8_t*)0x20000257 = 0x14; *(uint8_t*)0x20000258 = 0x14; *(uint8_t*)0x20000259 = 0xbb; *(uint8_t*)0x2000025a = 0xac; *(uint8_t*)0x2000025b = 0x14; *(uint8_t*)0x2000025c = 0x14; *(uint8_t*)0x2000025d = 0xaa; *(uint16_t*)0x2000025e = htobe16(0); *(uint16_t*)0x20000260 = htobe16(0); *(uint8_t*)0x20000262 = 6; STORE_BY_BITMASK(uint8_t, , 0x20000263, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x20000263, 0, 4, 4); *(uint16_t*)0x20000264 = htobe16(0); STORE_BY_BITMASK(uint8_t, , 0x20000266, 0, 0, 1); STORE_BY_BITMASK(uint8_t, , 0x20000266, 0, 1, 4); STORE_BY_BITMASK(uint8_t, , 0x20000266, 0, 5, 3); memcpy((void*)0x20000267, "\xf4\x26\xe6", 3); *(uint8_t*)0x2000026a = 4; memcpy((void*)0x2000026b, "\xc8\x00\x05", 3); memcpy((void*)0x2000026e, "\x2b\x7c\x55\x42\xb5", 5); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000256, 4); csum_inet_update(&csum_1, (const uint8_t*)0x2000025a, 4); uint16_t csum_1_chunk_2 = 0x2100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x1000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x2000025e, 16); *(uint16_t*)0x20000264 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x2000024a, 20); *(uint16_t*)0x20000254 = csum_inet_digest(&csum_2); syscall(__NR_write, r[0], 0x20000240ul, 0xfdeful); } int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); do_sandbox_none(); return 0; }
the_stack_data/167330165.c
// // Created by zing on 5/17/2020. // /* * show-bytes.c */ #include <stdio.h> typedef unsigned char *byte_pointer; void show_bytes(byte_pointer start, size_t len) { size_t i; for (i = 0; i < len; i++) { printf(" %.2x", start[i]); } printf("\n"); } void show_int(int x) { show_bytes((byte_pointer) &x, sizeof(int)); } void show_float(float x) { show_bytes((byte_pointer) &x, sizeof(float)); } void show_pointer(void *x) { show_bytes((byte_pointer) &x, sizeof(void *)); } //============= // 2.57 changes //============= void show_short(short x) { show_bytes((byte_pointer) &x, sizeof(short)); } void show_long(long x) { show_bytes((byte_pointer) &x, sizeof(long)); } void show_double(double x) { show_bytes((byte_pointer) &x, sizeof(double)); } //================== // 2.57 changes end //================== void test_show_bytes(int val) { int ival = val; float fval = (float) ival; int *pval = &ival; show_int(ival); show_float(fval); show_pointer(pval); //============= // 2.57 changes //============= short sval = (short) ival; long lval = (long) ival; double dval = (double) ival; show_short(sval); show_long(lval); show_double(dval); //================== // 2.57 changes end //================== } int main(int argc, char *argv[]) { int test_num = 328; test_show_bytes(test_num); return 0; } //48 01 00 00 //00 00 a4 43 //f8 0b 25 f5 ff 7f 00 00 //48 01 //48 01 00 00 00 00 00 00 //00 00 00 00 00 80 74 40
the_stack_data/648184.c
void dladdr() {} ; void dlclose() {} ; void dlerror() {} ; void dlopen() {} ; void dlsym() {} ;
the_stack_data/68478.c
//Generates filter coefficients for Apply Spencer's 15-point MA filter. //B = [-3, -6, -5, 3, 21, 46, 67, 74, 67, 46, 21, 3, -5, -6, -3] / 320; //These can be used with fir. //This is a symmetric filter that is designed to allow all //linear, quadratic and cubic functions to pass through unaltered. #include <stdio.h> #ifdef __cplusplus namespace codee { extern "C" { #endif int spencer_s (float *Y); int spencer_d (double *Y); int spencer_s (float *Y) { *Y++ = -3.0f / 320.0f; *Y++ = -6.0f / 320.0f; *Y++ = -5.0f / 320.0f; *Y++ = 3.0f / 320.0f; *Y++ = 21.0f / 320.0f; *Y++ = 46.0f / 320.0f; *Y++ = 67.0f / 320.0f; *Y++ = 74.0f / 320.0f; *Y++ = 67.0f / 320.0f; *Y++ = 46.0f / 320.0f; *Y++ = 21.0f / 320.0f; *Y++ = 3.0f / 320.0f; *Y++ = -5.0f / 320.0f; *Y++ = -6.0f / 320.0f; *Y = -3.0f / 320.0f; return 0; } int spencer_d (double *Y) { *Y++ = -3.0 / 320.0; *Y++ = -6.0 / 320.0; *Y++ = -5.0 / 320.0; *Y++ = 3.0 / 320.0; *Y++ = 21.0 / 320.0; *Y++ = 46.0 / 320.0; *Y++ = 67.0 / 320.0; *Y++ = 74.0 / 320.0; *Y++ = 67.0 / 320.0; *Y++ = 46.0 / 320.0; *Y++ = 21.0 / 320.0; *Y++ = 3.0 / 320.0; *Y++ = -5.0 / 320.0; *Y++ = -6.0 / 320.0; *Y = -3.0 / 320.0; return 0; } #ifdef __cplusplus } } #endif
the_stack_data/109803.c
#include <stdio.h> int main() { int a, b; a = 077; b = a & 3; printf("a & b (decimal) is %d \n", b); b &= 7; printf("a & b (decimal) is %d \n", b); return 0; }
the_stack_data/86074874.c
/* =========================================================================== Doom 3 GPL Source Code Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?). Doom 3 Source Code 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. Doom 3 Source Code 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 Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. =========================================================================== */ #include <stdio.h> #include <sys/time.h> #include <sched.h> #include <errno.h> /* ================ Sys_Milliseconds ================ */ /* base time in seconds, that's our origin timeval:tv_sec is an int: assuming this wraps every 0x7fffffff - ~68 years since the Epoch (1970) - we're safe till 2038 using unsigned long data type to work right with Sys_XTimeToSysTime */ unsigned long sys_timeBase = 0; /* current time in ms, using sys_timeBase as origin NOTE: sys_timeBase*1000 + curtime -> ms since the Epoch 0x7fffffff ms - ~24 days or is it 48 days? the specs say int, but maybe it's casted from unsigned int? */ int Sys_Milliseconds(void) { int curtime; struct timeval tp; gettimeofday(&tp, NULL); if (!sys_timeBase) { sys_timeBase = tp.tv_sec; return tp.tv_usec / 1000; } curtime = (tp.tv_sec - sys_timeBase) * 1000 + tp.tv_usec / 1000; return curtime; } #define STAT_BUF 100 int main(int argc, void *argv[]) { int start = 30; // start waiting with 30 ms int dec = 2; // decrement by 2 ms int min = 4; // min wait test int i, j, now, next; int stats[STAT_BUF]; struct sched_param parm; Sys_Milliseconds(); // init // set schedule policy to see if that affects usleep // (root rights required for that) parm.sched_priority = 99; if ( sched_setscheduler(0, SCHED_RR, &parm) != 0 ) { printf("sched_setscheduler SCHED_RR failed: %s\n", strerror(errno) ); } else { printf("sched_setscheduler SCHED_RR ok\n"); } // now run the test for( i = start ; i >= min ; i -= dec ) { printf( "sleep %d ms", i ); for( j = 0 ; j < STAT_BUF ; j++ ) { now = Sys_Milliseconds(); usleep(i*1000); stats[j] = Sys_Milliseconds() - now; } for( j = 0; j < STAT_BUF; j++) { if ( ! (j & 0xf) ) { printf("\n"); } printf( "%d ", stats[j] ); } printf("\n"); } return 0; }
the_stack_data/306755.c
/* iscntrl.c - ctype character class ncc standard library Copyright (c) 1987, 1997, 2001 Prentice Hall. All rights reserved. Copyright (c) 1987 Vrije Universiteit, Amsterdam, The Netherlands. Copyright (c) 2021 Charles E. Youse ([email protected]). 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 Prentice Hall nor the names of the software authors or contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <ctype.h> int (iscntrl)(int c) { return iscntrl(c); } /* vi: set ts=4 expandtab: */
the_stack_data/61075178.c
#include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #define MSQKEY 34858 #define MSQSIZE 32 struct msgbuf { long mtype; char mtext[MSQSIZE]; }; int main(int argc, char *argv[]) { key_t key; int n, msqid; struct msgbuf mbuf; //Get a message queue. The server must have created it. key = MSQKEY; if ((msqid = msgget(key, 0666)) < 0) { perror("client: msgget"); exit(1); } /* * YOUR TASK: * Read data from the standard input and send as messages of type 1. */ while((n = read(0, mbuf.mtext, sizeof(mbuf))) > 0) { mbuf.mtype = 1; msgsnd(msqid, &mbuf, n, 0); } //Send a message of type 2 to indicate no more data. mbuf.mtype = 2; memset(mbuf.mtext, 0, MSQSIZE); if (msgsnd(msqid, &mbuf, MSQSIZE, 0) < 0) { perror("client: msgsnd"); exit(1); } exit(0); }
the_stack_data/111078071.c
#include <stdio.h> #define bool int #define true 1 bool isBadVersion(int version) { return version >= 1702766719;//7; } int firstBadVersion(int n) { int r = n; int l = 1; int m; while(l < r) { m = l + (r - l) / 2; if (isBadVersion(m)) { r = m; } else { l = m + 1; } } return l; } void test(int n) { int i = firstBadVersion(n); printf("First: %d", i); } int main(void) { // test(8); test(2126753390); }
the_stack_data/146507.c
//===--- Adi.c ---- Alternating Direction Implicit ---------------*- C -*-===// // // This file implements the Alternating Direction Implicit(ADI) method which is // an iterative method used to solve partial differential equations. // //===----------------------------------------------------------------------===// #include <math.h> #include <stdio.h> #include <stdlib.h> #define MAX(A, b) ((A) > (b) ? (A) : (b)) #define NX 384 #define NY 384 #define NZ 384 double A[NX][NY][NZ]; void init(); double iter(); int main(int Argc, char *Argv[]) { double MaxEps, Eps; int It, ItMax, I, J, K; MaxEps = 0.01; ItMax = 100; init(); for (It = 1; It <= ItMax; It++) { Eps = iter(); printf(" IT = %4i EPS = %14.7E\n", It, Eps); if (Eps < MaxEps) break; } printf(" ADI Benchmark Completed.\n"); printf(" Size = %4d x %4d x %4d\n", NX, NY, NZ); printf(" Iterations = %12d\n", ItMax); printf(" Operation type = double precision\n"); printf(" Verification = %12s\n", (fabs(Eps - 0.07249074) < 1e-6 ? "SUCCESSFUL" : "UNSUCCESSFUL")); printf(" END OF ADI Benchmark\n"); return 0; } void init() { int I, J, K; for (I = 0; I < NX; I++) for (J = 0; J < NY; J++) for (K = 0; K < NZ; K++) if (K == 0 || K == NZ - 1 || J == 0 || J == NY - 1 || I == 0 || I == NX - 1) A[I][J][K] = 10.0 * I / (NX - 1) + 10.0 * J / (NY - 1) + 10.0 * K / (NZ - 1); else A[I][J][K] = 0; } double iter() { int I, J, K; double Eps = 0; for (I = 1; I < NX - 1; I++) for (J = 1; J < NY - 1; J++) for (K = 1; K < NZ - 1; K++) A[I][J][K] = (A[I - 1][J][K] + A[I + 1][J][K]) / 2; for (I = 1; I < NX - 1; I++) for (J = 1; J < NY - 1; J++) for (K = 1; K < NZ - 1; K++) A[I][J][K] = (A[I][J - 1][K] + A[I][J + 1][K]) / 2; for (I = 1; I < NX - 1; I++) for (J = 1; J < NY - 1; J++) for (K = 1; K < NZ - 1; K++) { double Tmp1 = (A[I][J][K - 1] + A[I][J][K + 1]) / 2; double Tmp2 = fabs(A[I][J][K] - Tmp1); Eps = MAX(Eps, Tmp2); A[I][J][K] = Tmp1; } return Eps; } //CHECK: Adi.global.c:69:3: remark: parallel execution of loop is possible //CHECK: for (I = 1; I < NX - 1; I++) //CHECK: ^ //CHECK: Adi.global.c:65:3: remark: parallel execution of loop is possible //CHECK: for (I = 1; I < NX - 1; I++) //CHECK: ^ //CHECK: Adi.global.c:61:3: remark: parallel execution of loop is possible //CHECK: for (I = 1; I < NX - 1; I++) //CHECK: ^ //CHECK: Adi.global.c:62:5: remark: parallel execution of loop is possible //CHECK: for (J = 1; J < NY - 1; J++) //CHECK: ^ //CHECK: Adi.global.c:47:3: remark: parallel execution of loop is possible //CHECK: for (I = 0; I < NX; I++) //CHECK: ^
the_stack_data/20451502.c
#include <stdio.h> int main( ) { int num1 = 10; int num2 = 10; printf( "Equal Operand - %i\n", num1 == num2 ); printf( "Not Equal Operand - %i\n", num1 != num2 ); printf( "Greater Than Operand - %i\n", num1 > num2 ); printf( "Greater Than Or Equal To Operand - %i\n", num1 >= num2 ); printf( "Less Than Operand - %i\n", num1 < num2 ); printf( "Less Than Or Equal To Operand - %i\n", num1 <= num2 ); return 0; }
the_stack_data/228066.c
// 12. // 修改第8章的编程题14,读取句子时把单词存储在一个二维的char类型数组中,每行存储一个单词。 // 假定句子中的单词数不超过30,且每个单词的长度都不超过20个字符。 // 注意,要在每个单词的后面存储一个空字符,使其可以作为字符串处理。 // 编写程序颠倒句子中单词的顺序: // Enter a sentence: you can cage a swallow can't you? // Reversal of sentence: you can't swallow a cage can you? // 提示:用循环逐个读取字符,然后将它们存储在一个一维字符数组中。 // 当遇到句号、问号或者感叹号(称为“终止字符”)时,终止循环并把终止字符存储在一个char类型变量中。 // 然后再用一个循环反向搜索数组,找到最后一个单词的起始位置。 // 显示最后一个单词,然后反向搜索倒数第二个单词。 // 重复这一过程,直至到达数组的起始位置。最后显示出终止字符。 #include <stdio.h> #include <string.h> #define MAX_WORD_NUMS 30 #define MAX_WORD_LENS 20 int main() { // 读取 printf("Enter a sentence: "); char str_arr[MAX_WORD_NUMS][MAX_WORD_LENS + 1]; char str_read[MAX_WORD_NUMS * MAX_WORD_LENS]; gets(str_read); char* p0 = str_read; int i = 0; int j = 0; while (*p0 != '\0' && i < MAX_WORD_NUMS) { if (*p0 != ' ') { str_arr[i][j] = *p0; ++j; } else { str_arr[i][j] = '\0'; ++i; j = 0; } ++p0; } str_arr[i][j] = '\0'; // 反向输出,最后一个单词单独处理 // 寻找末尾的字符 char* p = &str_arr[i][0]; while (*p != '.' && *p != '?' && *p != '!') { printf("%c", *p); ++p; } printf(" "); char end_symbol = *p; // 反向输出其它单词 for (int t = i - 1; t >= 0; --t) { p = &str_arr[t][0]; while (*p != '\0') { printf("%c", *p); ++p; } if (t != 0) printf(" "); } printf("%c\n", end_symbol); return 0; }
the_stack_data/1116421.c
#include <stdio.h> #include <stdlib.h> int main (int argc, char * argv[]) { printf ("I am awesome!\n"); return EXIT_SUCCESS; }
the_stack_data/80707.c
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <pthread.h> #include <arpa/inet.h> #include <sys/socket.h> #include <netinet/in.h> /* 스레드 처리를 위한 함수 */ static void *clnt_connection(void *arg); int sendData(FILE* fp, char *ct, char *filename); void sendOk(FILE* fp); void sendError(FILE* fp); int main(int argc, char **argv) { int ssock; pthread_t thread; struct sockaddr_in servaddr, cliaddr; unsigned int len; /* 프로그램을 시작할 때 서버를 위한 포트 번호를 입력받는다. */ if(argc!=2) { printf("usage: %s <port>\n", argv[0]); return -1; } /* 서버를 위한 소켓을 생성한다. */ ssock = socket(AF_INET, SOCK_STREAM, 0); if(ssock == -1) { perror("socket()"); return -1; } /* 입력받는 포트 번호를 이용해서 서비스를 운영체제에 등록한다. */ memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); servaddr.sin_port = (argc != 2)?htons(8000):htons(atoi(argv[1])); if(bind(ssock, (struct sockaddr *)&servaddr, sizeof(servaddr))==-1) { perror("bind()"); return -1; } /* 최대 10대의 클라이언트의 동시 접속을 처리할 수 있도록 큐를 생성한다. */ if(listen(ssock, 10) == -1) { perror("listen()"); return -1; } while(1) { char mesg[BUFSIZ]; int csock; /* 클라이언트의 요청을 기다린다. */ len = sizeof(cliaddr); csock = accept(ssock, (struct sockaddr*)&cliaddr, &len); /* 네트워크 주소를 문자열로 변경 */ inet_ntop(AF_INET, &cliaddr.sin_addr, mesg, BUFSIZ); printf("Client IP : %s:%d\n", mesg, ntohs(cliaddr.sin_port)); /* 클라이언트의 요청이 들어오면 스레드를 생성하고 클라이언트의 요청을 처리한다. */ pthread_create(&thread, NULL, clnt_connection, &csock); pthread_join(thread, NULL); } return 0; } void *clnt_connection(void *arg) { /* 스레드를 통해서 넘어온 arg를 int 형의 파일 디스크립터로 변환한다. */ int csock = *((int*)arg); FILE *clnt_read, *clnt_write; char reg_line[BUFSIZ], reg_buf[BUFSIZ]; char method[BUFSIZ], type[BUFSIZ]; char filename[BUFSIZ], *ret; /* 파일 디스크립터를 FILE 스트림으로 변환한다. */ clnt_read = fdopen(csock, "r"); clnt_write = fdopen(dup(csock), "w"); /* 한 줄의 문자열을 읽어서 reg_line 변수에 저장한다. */ fgets(reg_line, BUFSIZ, clnt_read); /* reg_line 변수에 문자열을 화면에 출력한다. */ fputs(reg_line, stdout); /* ' ' 문자로 reg_line을 구분해서 요청 라인의 내용(메소드)를 분리한다. */ ret = strtok(reg_line, "/ "); strcpy(method, (ret != NULL)?ret:""); if(strcmp(method, "POST") == 0) { /* POST 메소드일 경우를 처리한다. */ sendOk(clnt_write); /* 단순히 OK 메시지를 클라이언트로 보낸다. */ goto END; } else if(strcmp(method, "GET") != 0) { /* GET 메소드가 아닐 경우를 처리한다. */ sendError(clnt_write); /* 에러 메시지를 클라이언트로 보낸다. */ goto END; } ret = strtok(NULL, " "); /* 요청 라인에서 경로(path)를 가져온다. */ strcpy(filename, (ret != NULL)?ret:""); if(filename[0] == '/') { /* 경로가 '/'로 시작될 경우 /를 제거한다. */ for(int i = 0, j = 0; i < BUFSIZ; i++, j++) { if(filename[0] == '/') j++; filename[i] = filename[j]; if(filename[j] == '\0') break; } } /* 메시지 헤더를 읽어서 화면에 출력하고 나머지는 무시한다. */ do { fgets(reg_line, BUFSIZ, clnt_read); fputs(reg_line, stdout); strcpy(reg_buf, reg_line); char* buf = strchr(reg_buf, ':'); } while(strncmp(reg_line, "\r\n", 2)); /* 요청 헤더는 ‘\r\n’으로 끝난다. */ /* 파일의 이름을 이용해서 클라이언트로 파일의 내용을 보낸다. */ sendData(clnt_write, type, filename); END: fclose(clnt_read); /* 파일의 스트림을 닫는다. */ fclose(clnt_write); pthread_exit(0); /* 스레드를 종료시킨다. */ return (void*)NULL; } int sendData(FILE* fp, char *ct, char *filename) { /* 클라이언트로 보낼 성공에 대한 응답 메시지 */ char protocol[ ] = "HTTP/1.1 200 OK\r\n"; char server[ ] = "Server:Netscape-Enterprise/6.0\r\n"; char cnt_type[ ] = "Content-Type:text/html\r\n"; char end[ ] = "\r\n"; /* 응답 헤더의 끝은 항상 \r\n */ char buf[BUFSIZ]; int fd, len; fputs(protocol, fp); fputs(server, fp); fputs(cnt_type, fp); fputs(end, fp); fd = open(filename, O_RDWR); /* 파일을 연다. */ do { len = read(fd, buf, BUFSIZ); /* 파일을 읽어서 클라이언트로 보낸다. */ fputs(buf, fp); } while(len == BUFSIZ); close(fd); /* 파일을 닫는다. */ return 0; } void sendOk(FILE* fp) { /* 클라이언트에 보낼 성공에 대한 HTTP 응답 메시지 */ char protocol[ ] = "HTTP/1.1 200 OK\r\n"; char server[ ] = "Server: Netscape-Enterprise/6.0\r\n\r\n"; fputs(protocol, fp); fputs(server, fp); fflush(fp); } void sendError(FILE* fp) { /* 클라이언트로 보낼 실패에 대한 HTTP 응답 메시지 */ char protocol[ ] = "HTTP/1.1 400 Bad Request\r\n"; char server[ ] = "Server: Netscape-Enterprise/6.0\r\n"; char cnt_len[ ] = "Content-Length:1024\r\n"; char cnt_type[ ] = "Content-Type:text/html\r\n\r\n"; /* 화면에 표시될 HTML의 내용 */ char content1[ ] = "<html><head><title>BAD Connection</title></head>"; char content2[ ] = "<body><font size=+5>Bad Request</font></body></html>"; printf("send_error\n"); fputs(protocol, fp); fputs(server, fp); fputs(cnt_len, fp); fputs(cnt_type, fp); fputs(content1, fp); fputs(content2, fp); fflush(fp); }
the_stack_data/1131367.c
/* CSD 331 Computer Networks Lab, Fall 2019 Server Code Team: Devshree Patel(075), Muskan Matwani(027), Ratnam Parikh(036), Yesha Shastri(035) */ //Commands for compilation and running //gcc server.c //./a.out 127.0.0.1 /* Including all the header files required for socket programming */ #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <dirent.h> #include <string.h> #include <pthread.h> #include <stdio.h> #include <sys/wait.h> #include <sys/stat.h> #include <fcntl.h> /*Defining all the variables used recurrently in the program*/ #define MAX_BUFFER_SIZE 256 #define MULTI_SERVER_IP "239.192.1.10" #define BUFFER_SIZE 4096 #define SERVER_PORT 5432 #define BUFFER_SIZE_SMALL 1024 #define NO_OF_STATIONS 3 //Defining structure for station info request typedef struct station_info_request_t { uint8_t type; } station_info_request; //Init Function for station_info_request_t station_info_request initStationInfoRequest(station_info_request *sir){ sir->type = 1; return *sir; } //Defining structure for station info typedef struct station_info_t { uint8_t station_number; uint8_t station_name_size; char station_name[MAX_BUFFER_SIZE]; uint32_t multicast_address; uint16_t data_port; uint16_t info_port; uint32_t bit_rate; } station_info; //Defining structure for site info typedef struct site_info_t { uint8_t type;// = 10; uint8_t site_name_size; char site_name[MAX_BUFFER_SIZE]; uint8_t site_desc_size; char site_desc[MAX_BUFFER_SIZE]; uint8_t station_count; station_info station_list[MAX_BUFFER_SIZE]; } site_info; //Init Function for station_info site_info initSiteInfo(site_info *si){ si->type = 10; return *si; } //Defining structure for station not found typedef struct station_not_found_t{ uint8_t type;// = 11; uint8_t station_number; } station_not_found; //Init Function for station_not_found station_not_found initStationNotFound(station_not_found *snf){ snf->type = 11; return *snf; } //Defining structure for song info typedef struct song_info_t { uint8_t type;// = 12; uint8_t song_name_size; char song_name[MAX_BUFFER_SIZE]; uint16_t remaining_time_in_sec; uint8_t next_song_name_size; char next_song_name[MAX_BUFFER_SIZE]; } song_info; //Init Function for song_info song_info initSongInfo(song_info *si){ si->type = 12; return *si; } //Defining structure for station id path typedef struct station_id_path_t { int id; char path[BUFFER_SIZE_SMALL]; int port; } station_id_path; //Creating array of objects of structures station_info stations[NO_OF_STATIONS]; station_id_path stationIDPaths[NO_OF_STATIONS]; //Declaring threads for stations pthread_t stationThreads[NO_OF_STATIONS]; //Declaring sleep variable long idealSleep; //Declaring variables for storing command line arguments int argC; char **argV; //Function for getting the bit rate int getBitRate(char *fName){ int pid = 0; char *cmd1 = "mediainfo "; //Fetching all the media properties char *redirect = " | grep 'Overall bit rate : ' > info.txt";//Writing down the output (bit rate) into a file char cmd[256]; strcpy(cmd, cmd1); strcat(cmd, fName); strcat(cmd, redirect); system(cmd); // execl(params[0], params[1], params[2],params[3],NULL); wait(NULL); FILE* fp = fopen("info.txt", "r"); char *str = "Overall bit rate : "; char buf[256]; memset(buf, '\0', sizeof(buf));//setting buffer to 0 char *s; fgets(buf, sizeof(buf), fp); char* p = strstr(buf,"Kbps\n");//string representing bit rate memset(p, '\0', strlen(p));//setting string to 0 s = strstr(buf,str); s = s+strlen(str); char buf1[256]; memset(buf1, '\0', 256); int i=0,j=0; for(i=0;i<strlen(s)+1;i++){ if(s[i] == ' ') continue; buf1[j++] = s[i]; } int br = atoi(buf1);//char array to int conversion return br; } //defining the function for calculation of bit rate void BR_calc(char names[][BUFFER_SIZE_SMALL], int bitRate[], int sCount) { for (int i = 0; i < sCount; i++) { bitRate[i] = getBitRate(names[i]); } } //Defining function for sending structures to stations void *startStationListServer(void *arg) { //Structure object initialised struct sockaddr_in sin; int len; int socket1, new_socket; char str[INET_ADDRSTRLEN]; //Server IP initialised and declared char *serverIP; if (argC > 1) serverIP = argV[1]; /* build address data structure */ bzero((char *)&sin, sizeof(sin)); sin.sin_family = AF_INET; //assigning family sin.sin_addr.s_addr = inet_addr(serverIP);//assigning server address sin.sin_port = htons(SERVER_PORT);//assigning server port /* setup passive open */ if ((socket1 = socket(PF_INET, SOCK_STREAM, 0)) < 0) { perror("Socket creation failed!!");//generating error on failure of socket exit(1);//program is terminated if socket is not created } inet_ntop(AF_INET, &(sin.sin_addr), str, INET_ADDRSTRLEN);//converting address from network format to presentation format printf("Server is using address %s and port %d.\n", str, SERVER_PORT); //Binding server to the address if ((bind(socket1, (struct sockaddr *)&sin, sizeof(sin))) < 0) { perror("Bind failed");//generating error if bind not done exit(1);//termination on failure of bind } else printf("Bind done successfully\n"); listen(socket1, 5);//call for listen where pending request can be atmost 5 //Sending structures infinitely to client while (1) { //Accepting the connection request from client if ((new_socket = accept(socket1, (struct sockaddr *)&sin, (unsigned int *)&len)) < 0) { perror("Accept failed");//Generating error if accept command fails exit(1);//terminating on failure of accept call } printf("Client and server connected! Starting to send structures\n"); uint32_t nos = 3;//initialising no of stations nos = htonl(nos);//sending int requires this conversion send(new_socket, &nos, sizeof(uint32_t), 0);//no of stations(int) is sent for (int i = 0; i < NO_OF_STATIONS; i++)//sending the station info for all the stations specified { send(new_socket, &stations[i], sizeof(station_info), 0); } } } //Defining function fill stations void StationDetails() { station_info stat_info1; station_id_path stat_id_path; //Initialising station1 info into structure variables stat_info1.station_number = 1; stat_info1.station_name_size = htonl(strlen("Station 1")); strcpy(stat_info1.station_name, "Station 1"); stat_info1.data_port = htons(8200); stat_id_path.port = 8200; stat_id_path.id = 1; strcpy(stat_id_path.path, "./Station_1/"); //Copying station1 info and path memcpy(&stations[0], &stat_info1, sizeof(station_info)); memcpy(&stationIDPaths[0], &stat_id_path, sizeof(station_id_path)); //Clearing out station1 info and path bzero(&stat_info1, sizeof(station_info)); bzero(&stat_id_path, sizeof(station_id_path)); //Initialising station2 info into structure variables stat_info1.station_number = 2; stat_info1.station_name_size = htonl(strlen("Station 2")); strcpy(stat_info1.station_name, "Station 2"); stat_info1.data_port = htons(8201); stat_id_path.port = 8201; stat_id_path.id = 2; strcpy(stat_id_path.path, "./Station_2/"); //Copying station2 info and path memcpy(&stations[1], &stat_info1, sizeof(station_info)); memcpy(&stationIDPaths[1], &stat_id_path, sizeof(station_id_path)); //Clearing out station2 info and path bzero(&stat_info1, sizeof(station_info)); bzero(&stat_id_path, sizeof(station_id_path)); //Initialising station3 info into structure variables stat_info1.station_number = 3; stat_info1.station_name_size = htonl(strlen("Station 3")); strcpy(stat_info1.station_name, "Station 3"); stat_info1.data_port = htons(8202); stat_id_path.port = 8202; stat_id_path.id = 3; strcpy(stat_id_path.path, "./Station_3/"); //Copying station3 info and path memcpy(&stations[2], &stat_info1, sizeof(station_info)); memcpy(&stationIDPaths[2], &stat_id_path, sizeof(station_id_path)); } //Function for starting / setting up station void *startStation(void *arg) { //Parsing directory and opening songs station_id_path *stat_id_path = (station_id_path *)arg; DIR *dir; struct dirent *entry; int sCount = 0; //path for song file printf("Path:-- %s\n", stat_id_path->path); //searching in the directory and then reading all the songs if ((dir = opendir(stat_id_path->path)) != NULL) { //Reading all the files with extension mp3 and then collecting them while ((entry = readdir(dir)) != NULL) { if (strstr(entry->d_name, ".mp3") != NULL) ++sCount;//counter for songs with mp3 extension } closedir(dir);//closing directory } else { /* could not open file in the directory */ perror("Could not find file in the directory"); return 0; } char songs[sCount][BUFFER_SIZE_SMALL]; //Declaring 2D array for path of the songs and their size char sNames[sCount][BUFFER_SIZE_SMALL]; //Declaring 2D array for names of the songs and their size FILE *songFiles[sCount]; int bitRates[sCount]; for (int i = 0; i < sCount; i++) { memset(songs[i], '\0', BUFFER_SIZE_SMALL); strcpy(songs[i], stat_id_path->path); //storing path of the songs } int cur = 0; if ((dir = opendir(stat_id_path->path)) != NULL) //Checks for station directory is not empty { while ((entry = readdir(dir)) != NULL) //proceeds to read the songs if directory is not null { if (strstr(entry->d_name, ".mp3") != NULL) { memcpy(&(songs[cur][strlen(stat_id_path->path)]), entry->d_name, strlen(entry->d_name) + 1); strcpy((sNames[cur]), entry->d_name); //stores names of the available songs songFiles[cur] = fopen(songs[cur], "rb"); //Opening the file if (songFiles[cur] == NULL) { perror("No song file present in the directory"); //Displaying error for no song files exit(1); } cur++; //incrementing value to check for all the files in the directory } } closedir(dir); //closing the current directory } //Creating Song_Info Structures song_info sInfo[sCount]; for (int i = 0; i < sCount; i++) bzero(&sInfo[i], sizeof(song_info)); //zeros out the struct for information of songs for (int i = 0; i <= sCount; i++) { initSongInfo(&sInfo[i]); //calling initSongInfo for the number of songs printf("song info : %hu p = %p\n", (unsigned short)sInfo[i].type, &sInfo[i].type); } for (int i = 0; i < sCount; i++) { //Fetching size and name of the song for the current song sInfo[i].song_name_size = (uint8_t)strlen(sNames[i]) + 1; printf("%d", sInfo[i].song_name_size); strcpy((sInfo[i].song_name), sNames[i]); //Fetching size and name of the next song sInfo[i].next_song_name_size = (uint8_t)strlen(sNames[(i + 1) % sCount]) + 1; strcpy((sInfo[i].next_song_name), sNames[(i + 1) % sCount]); } //Displaying information about songs for (int i = 0; i < sCount; i++) { printf("%s\n", songs[i]); printf("Song info : %hu p = %p\n", (unsigned short)sInfo[i].type, &sInfo[i].type); } int socket1; //socket variable struct sockaddr_in sin; //object that refers to sockaddr structure int len; char buf[BUFFER_SIZE_SMALL]; char *mcast_addr; /* multicast address */ struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 20000000L; //Multicast address initialisation mcast_addr = "239.192.1.10"; //socket creation for UDP multicase if ((socket1 = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { perror("Socket creation failed!!");//Error if socket is not created exit(1); } //build address data structure memset((char *)&sin, 0, sizeof(sin));//setting address variable to 0 using memset sin.sin_family = AF_INET;//assigning family sin.sin_addr.s_addr = inet_addr(mcast_addr);//assigning multicast address sin.sin_port = htons(stat_id_path->port);//assigning port number printf("\nStarting station ID : %d!\n\n", stat_id_path->id); /* Send multicast messages */ memset(buf, 0, sizeof(buf)); int curSong = -1; while (1) { //Choosing songs one by one curSong = (curSong + 1) % sCount; //Pointer for song FILE *song = songFiles[curSong]; //In case when song is not found if (song == NULL) printf("Song not found!!\n"); //Printing song number and song name printf("Curent Song number = %d current Song name= %p\n", curSong, song); rewind(song);//Setting pointer to the beginning of file int size = BUFFER_SIZE_SMALL; int counter = 0; //Printing structure which is sent printf("Sending Structure : current Song number= %d. Song_Info->type = %hu p = %p\n", curSong, (unsigned short)sInfo[curSong].type, &sInfo[curSong].type); if ((len = sendto(socket1, &sInfo[curSong], sizeof(song_info), 0, (struct sockaddr *)&sin, sizeof(sin))) == -1) { perror("Server sending failed"); exit(1); } // calculating sleep time in accordance with bit rate float bitrate = bitRates[curSong]; idealSleep = ((BUFFER_SIZE_SMALL * 8) / bitrate) * 500000000; // if sleep time is less than zero, assigning it to the default value specified if (idealSleep < 0) idealSleep = ts.tv_nsec; // if sleep time is greater than zero, assigning it to the idealSleep if (ts.tv_nsec > idealSleep) ts.tv_nsec = idealSleep; while (!(size < BUFFER_SIZE_SMALL)) { // Sending the contents of song size = fread(buf, 1, sizeof(buf), song); if ((len = sendto(socket1, buf, size, 0, (struct sockaddr *)&sin, sizeof(sin))) == -1) { perror("server: sendto"); exit(1); } if (len != size) { printf("ERROR!!"); exit(0); } // Delaying the in between packet time in order to reduce packet loss at the client side // Delaying it with the time assigned to idealSleep nanosleep(&ts, NULL); memset(buf, 0, sizeof(buf)); //Setting buffer to 0 } } //closing the socket close(socket1); } int main(int argc, char *argv[]) { //Assigning command line arguments to variables argC = argc; argV = argv; //Initializing Stations StationDetails(); // Starting TCP Server //Declaring and creating pthread for starting TCP connection pthread_t tTCPid; pthread_create(&tTCPid, NULL, startStationListServer, NULL); //Starting all stations for (int i = 0; i < NO_OF_STATIONS; i++) { //creating thread for each station pthread_create(&stationThreads[i], NULL, startStation, &stationIDPaths[i]); } //waits for the thread tTCPid to terminate pthread_join(tTCPid, NULL); return 0; }
the_stack_data/154831295.c
/* Simple Hello World example */ #include <err.h> #include <errno.h> #include <stdio.h> #include <string.h> #include <sys/types.h> #include <pwd.h> int main(int argc, char *argv[]) { puts("Hello world!"); errno = 0; if (argc > 1) { char buf[256]; struct passwd pwd; struct passwd *pw = NULL; memset(&pwd, 0, sizeof(pwd)); getpwnam_r(argv[1], &pwd, buf, sizeof(buf), &pw); if (!pw) errx(1, "Failed getting user %s", argv[1]); printf("Found user %s with UID %d\n", pw->pw_name, pw->pw_uid); } return 0; }
the_stack_data/122014705.c
#include <stdio.h> int main() { //Variable for the loop int i; //Variable for the inner loop int j; //Variable for the printing spaces in the loop int space; //Variable for the number of rows int rows; printf("Enter number of rows: "); scanf("%d", &rows); for (i = 1; i <= rows; i++) { for (space = 1; space <= rows - i; space++) { printf(" "); } for (j = 1; j <= 2 * i - 1; j++) { printf("*"); } printf("\n"); } }
the_stack_data/145452851.c
//src-test/pints-test.c
the_stack_data/211081051.c
// general protection fault in __btf_resolve_helper_id // https://syzkaller.appspot.com/bug?id=ee09bda7017345f1fbe6 // status:6 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include <endian.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/syscall.h> #include <sys/types.h> #include <unistd.h> #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) #ifndef __NR_bpf #define __NR_bpf 321 #endif int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); *(uint32_t*)0x20000080 = 5; *(uint32_t*)0x20000084 = 3; *(uint64_t*)0x20000088 = 0x20000280; *(uint8_t*)0x20000280 = 0x85; STORE_BY_BITMASK(uint8_t, , 0x20000281, 0, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x20000281, 0, 4, 4); *(uint16_t*)0x20000282 = 0; *(uint32_t*)0x20000284 = 0x8d; *(uint8_t*)0x20000288 = 0x36; *(uint8_t*)0x20000289 = 0; *(uint16_t*)0x2000028a = 0; *(uint32_t*)0x2000028c = 0x80000000; *(uint8_t*)0x20000290 = 0x95; *(uint8_t*)0x20000291 = 0; *(uint16_t*)0x20000292 = 0; *(uint32_t*)0x20000294 = 0; *(uint64_t*)0x20000090 = 0x20000140; memcpy((void*)0x20000140, "GPL\000", 4); *(uint32_t*)0x20000098 = 1; *(uint32_t*)0x2000009c = 0xfc76; *(uint64_t*)0x200000a0 = 0x20000180; *(uint32_t*)0x200000a8 = 0; *(uint32_t*)0x200000ac = 0; *(uint8_t*)0x200000b0 = 0; *(uint8_t*)0x200000b1 = 0; *(uint8_t*)0x200000b2 = 0; *(uint8_t*)0x200000b3 = 0; *(uint8_t*)0x200000b4 = 0; *(uint8_t*)0x200000b5 = 0; *(uint8_t*)0x200000b6 = 0; *(uint8_t*)0x200000b7 = 0; *(uint8_t*)0x200000b8 = 0; *(uint8_t*)0x200000b9 = 0; *(uint8_t*)0x200000ba = 0; *(uint8_t*)0x200000bb = 0; *(uint8_t*)0x200000bc = 0; *(uint8_t*)0x200000bd = 0; *(uint8_t*)0x200000be = 0; *(uint8_t*)0x200000bf = 0; *(uint32_t*)0x200000c0 = 0; *(uint32_t*)0x200000c4 = 0; *(uint32_t*)0x200000c8 = -1; *(uint32_t*)0x200000cc = 8; *(uint64_t*)0x200000d0 = 0x20000040; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint32_t*)0x200000d8 = 0; *(uint32_t*)0x200000dc = 0x10; *(uint64_t*)0x200000e0 = 0x20000000; *(uint32_t*)0x20000000 = 0; *(uint32_t*)0x20000004 = 0; *(uint32_t*)0x20000008 = 0; *(uint32_t*)0x2000000c = 0; *(uint32_t*)0x200000e8 = 0xfffffe77; *(uint32_t*)0x200000ec = 0; *(uint32_t*)0x200000f0 = -1; syscall(__NR_bpf, 5ul, 0x20000080ul, 0x48ul); return 0; }
the_stack_data/234517923.c
/* pe16-3.c -- 极坐标转换直角坐标 */ #include <stdio.h> #include <math.h> #define DEG_TO_RAD (4 * atan(1) / 180) typedef struct { double magnitude; double angle; } POLAR_V; typedef struct { double x; double y; } RECT_V; RECT_V polar2rect(POLAR_V polar); int main(void) { POLAR_V polar = {sqrt(2), 45}; RECT_V rect; rect = polar2rect(polar); printf("rect: %.2f, %.2f\n", rect.x, rect.y); printf("\n---------------------------------------------\n"); return 0; } RECT_V polar2rect(POLAR_V polar) { RECT_V rect; rect.x = polar.magnitude * cos(polar.angle * DEG_TO_RAD); rect.y = polar.magnitude * sin(polar.angle * DEG_TO_RAD); return rect; }
the_stack_data/995197.c
/* man 2.4 - display online manual pages Author: Kees J. Bot * 17 Mar 1993 */ #define nil NULL #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <string.h> #include <errno.h> #include <unistd.h> #include <stdarg.h> #include <fcntl.h> #include <signal.h> #include <sys/stat.h> #include <sys/wait.h> /* Defaults: */ char MANPATH[]= "/usr/local/man:/usr/man:/usr/gnu/man"; char PAGER[]= "more"; /* Comment at the start to let tbl(1) be run before n/troff. */ char TBL_MAGIC[] = ".\\\"t\n"; #define arraysize(a) (sizeof(a) / sizeof((a)[0])) #define arraylimit(a) ((a) + arraysize(a)) #define between(a, c, z) ((unsigned) ((c) - (a)) <= (unsigned) ((z) - (a))) /* Section 9 uses special macros under Minix. */ #if __minix #define SEC9SPECIAL 1 #else #define SEC9SPECIAL 0 #endif int searchwhatis(FILE *wf, char *title, char **ppage, char **psection) /* Search a whatis file for the next occurence of "title". Return the basename * of the page to read and the section it is in. Return 0 on failure, 1 on * success, -1 on EOF or error. */ { static char page[256], section[32]; char alias[256]; int found= 0; int c; /* Each whatis line should have the format: * page, title, title (section) - descriptive text */ /* Search the file for a line with the title. */ do { int first= 1; char *pc= section; c= fgetc(wf); /* Search the line for the title. */ do { char *pa= alias; while (c == ' ' || c == '\t' || c == ',') c= fgetc(wf); while (c != ' ' && c != '\t' && c != ',' && c != '(' && c != '\n' && c != EOF ) { if (pa < arraylimit(alias)-1) *pa++= c; c= getc(wf); } *pa= 0; if (first) { strcpy(page, alias); first= 0; } if (strcmp(alias, title) == 0) found= 1; } while (c != '(' && c != '\n' && c != EOF); if (c != '(') { found= 0; } else { while ((c= fgetc(wf)) != ')' && c != '\n' && c != EOF) { if ('A' <= c && c <= 'Z') c= c - 'A' + 'a'; if (pc < arraylimit(section)-1) *pc++= c; } *pc= 0; if (c != ')' || pc == section) found= 0; } while (c != EOF && c != '\n') c= getc(wf); } while (!found && c != EOF); if (found) { *ppage= page; *psection= section; } return c == EOF ? -1 : found; } int searchwindex(FILE *wf, char *title, char **ppage, char **psection) /* Search a windex file for the next occurence of "title". Return the basename * of the page to read and the section it is in. Return 0 on failure, 1 on * success, -1 on EOF or error. */ { static char page[256], section[32]; static long low, high; long mid0, mid1; int c; unsigned char *pt; char *pc; /* Each windex line should have the format: * title page (section) - descriptive text * The file is sorted. */ if (ftell(wf) == 0) { /* First read of this file, initialize. */ low= 0; fseek(wf, (off_t) 0, SEEK_END); high= ftell(wf); } /* Binary search for the title. */ while (low <= high) { pt= (unsigned char *) title; mid0= mid1= (low + high) >> 1; if (mid0 == 0) { if (fseek(wf, (off_t) 0, SEEK_SET) != 0) return -1; } else { if (fseek(wf, (off_t) mid0 - 1, SEEK_SET) != 0) return -1; /* Find the start of a line. */ while ((c= getc(wf)) != EOF && c != '\n') mid1++; if (ferror(wf)) return -1; } /* See if the line has the title we seek. */ for (;;) { if ((c= getc(wf)) == ' ' || c == '\t') c= 0; if (c == 0 || c != *pt) break; pt++; } /* Halve the search range. */ if (c == EOF || *pt <= c) { high= mid0 - 1; } else { low= mid1 + 1; } } /* Look for the title from 'low' onwards. */ if (fseek(wf, (off_t) low, SEEK_SET) != 0) return -1; do { if (low != 0) { /* Find the start of a line. */ while ((c= getc(wf)) != EOF && c != '\n') low++; if (ferror(wf)) return -1; } /* See if the line has the title we seek. */ pt= (unsigned char *) title; for (;;) { if ((c= getc(wf)) == EOF) return 0; low++; if (c == ' ' || c == '\t') c= 0; if (c == 0 || c != *pt) break; pt++; } } while (c < *pt); if (*pt != c) return 0; /* Not found. */ /* Get page and section. */ while ((c= fgetc(wf)) == ' ' || c == '\t') {} pc= page; while (c != ' ' && c != '\t' && c != '(' && c != '\n' && c != EOF) { if (pc < arraylimit(page)-1) *pc++= c; c= getc(wf); } if (pc == page) return 0; *pc= 0; while (c == ' ' || c == '\t') c= fgetc(wf); if (c != '(') return 0; pc= section; while ((c= fgetc(wf)) != ')' && c != '\n' && c != EOF) { if ('A' <= c && c <= 'Z') c= c - 'A' + 'a'; if (pc < arraylimit(section)-1) *pc++= c; } *pc= 0; if (c != ')' || pc == section) return 0; while (c != EOF && c != '\n') c= getc(wf); if (c != '\n') return 0; *ppage= page; *psection= section; return 1; } char ALL[]= ""; /* Magic sequence of all sections. */ int all= 0; /* Show all pages with a given title. */ int whatis= 0; /* man -f word == whatis word. */ int apropos= 0; /* man -k word == apropos word. */ int quiet= 0; /* man -q == quietly check. */ enum ROFF { NROFF, TROFF } rofftype= NROFF; char *roff[] = { "nroff", "troff" }; int shown; /* True if something has been shown. */ int tty; /* True if displaying on a terminal. */ char *manpath; /* The manual directory path. */ char *pager; /* The pager to use. */ char *pipeline[8][8]; /* An 8 command pipeline of 7 arguments each. */ char *(*plast)[8] = pipeline; void putinline(char *arg1, ...) /* Add a command to the pipeline. */ { va_list ap; char **argv; argv= *plast++; *argv++= arg1; va_start(ap, arg1); while ((*argv++= va_arg(ap, char *)) != nil) {} va_end(ap); } void execute(int set_mp, char *file) /* Execute the pipeline build with putinline(). (This is a lot of work to * avoid a call to system(), but it so much fun to do it right!) */ { char *(*plp)[8], **argv; char *mp; int fd0, pfd[2], err[2]; pid_t pid; int r, status; int last; void (*isav)(int sig), (*qsav)(int sig), (*tsav)(int sig); if (tty) { /* Must run this through a pager. */ putinline(pager, (char *) nil); } if (plast == pipeline) { /* No commands at all? */ putinline("cat", (char *) nil); } /* Add the file as argument to the first command. */ argv= pipeline[0]; while (*argv != nil) argv++; *argv++= file; *argv= nil; /* Start the commands. */ fd0= 0; for (plp= pipeline; plp < plast; plp++) { argv= *plp; last= (plp+1 == plast); /* Create an error pipe and pipe between this command and the next. */ if (pipe(err) < 0 || (!last && pipe(pfd) < 0)) { fprintf(stderr, "man: can't create a pipe: %s\n", strerror(errno)); exit(1); } (void) fcntl(err[1], F_SETFD, fcntl(err[1], F_GETFD) | FD_CLOEXEC); if ((pid = fork()) < 0) { fprintf(stderr, "man: cannot fork: %s\n", strerror(errno)); exit(1); } if (pid == 0) { /* Child. */ if (set_mp) { mp= malloc((8 + strlen(manpath) + 1) * sizeof(*mp)); if (mp != nil) { strcpy(mp, "MANPATH="); strcat(mp, manpath); (void) putenv(mp); } } if (fd0 != 0) { dup2(fd0, 0); close(fd0); } if (!last) { close(pfd[0]); if (pfd[1] != 1) { dup2(pfd[1], 1); close(pfd[1]); } } close(err[0]); execvp(argv[0], argv); (void) write(err[1], &errno, sizeof(errno)); _exit(1); } close(err[1]); if (read(err[0], &errno, sizeof(errno)) != 0) { fprintf(stderr, "man: %s: %s\n", argv[0], strerror(errno)); exit(1); } close(err[0]); if (!last) { close(pfd[1]); fd0= pfd[0]; } set_mp= 0; } /* Wait for the last command to finish. */ isav= signal(SIGINT, SIG_IGN); qsav= signal(SIGQUIT, SIG_IGN); tsav= signal(SIGTERM, SIG_IGN); while ((r= wait(&status)) != pid) { if (r < 0) { fprintf(stderr, "man: wait(): %s\n", strerror(errno)); exit(1); } } (void) signal(SIGINT, isav); (void) signal(SIGQUIT, qsav); (void) signal(SIGTERM, tsav); if (status != 0) exit(1); plast= pipeline; } void keyword(char *keyword) /* Make an apropos(1) or whatis(1) call. */ { putinline(apropos ? "apropos" : "whatis", all ? "-a" : (char *) nil, (char *) nil); if (tty) { printf("Looking for keyword '%s'\n", keyword); fflush(stdout); } execute(1, keyword); } enum pagetype { CAT, CATZ, MAN, MANZ, SMAN, SMANZ }; int showpage(char *page, enum pagetype ptype, char *macros) /* Show a manual page if it exists using the proper decompression and * formatting tools. */ { struct stat st; /* We want a normal file without X bits if not a full path. */ if (stat(page, &st) < 0) return 0; if (!S_ISREG(st.st_mode)) return 0; if ((st.st_mode & 0111) && page[0] != '/') return 0; /* Do we only care if it exists? */ if (quiet) { shown= 1; return 1; } if (ptype == CATZ || ptype == MANZ || ptype == SMANZ) { putinline("zcat", (char *) nil); } if (ptype == SMAN || ptype == SMANZ) { /* Change SGML into regular *roff. */ putinline("/usr/lib/sgml/sgml2roff", (char *) nil); putinline("tbl", (char *) nil); putinline("eqn", (char *) nil); } if (ptype == MAN) { /* Do we need tbl? */ FILE *fp; int c; char *tp = TBL_MAGIC; if ((fp = fopen(page, "r")) == nil) { fprintf(stderr, "man: %s: %s\n", page, strerror(errno)); exit(1); } c= fgetc(fp); for (;;) { if (c == *tp || (c == '\'' && *tp == '.')) { if (*++tp == 0) { /* A match, add tbl. */ putinline("tbl", (char *) nil); break; } } else { /* No match. */ break; } while ((c = fgetc(fp)) == ' ' || c == '\t') {} } fclose(fp); } if (ptype == MAN || ptype == MANZ || ptype == SMAN || ptype == SMANZ) { putinline(roff[rofftype], macros, (char *) nil); } if (tty) { printf("%s %s\n", ptype == CAT || ptype == CATZ ? "Showing" : "Formatting", page); fflush(stdout); } execute(0, page); shown= 1; return 1; } int member(char *word, char *list) /* True if word is a member of a comma separated list. */ { size_t len= strlen(word); if (list == ALL) return 1; while (*list != 0) { if (strncmp(word, list, len) == 0 && (list[len] == 0 || list[len] == ',')) return 1; while (*list != 0 && *list != ',') list++; if (*list == ',') list++; } return 0; } int trymandir(char *mandir, char *title, char *section) /* Search the whatis file of the manual directory for a page of the given * section and display it. */ { FILE *wf; char whatis[1024], pagename[1024], *wpage, *wsection; int rsw, rsp; int ntries; int (*searchidx)(FILE *, char *, char **, char **); struct searchnames { enum pagetype ptype; char *pathfmt; } *sp; static struct searchnames searchN[] = { { CAT, "%s/cat%s/%s.%s" }, /* SysV */ { CATZ, "%s/cat%s/%s.%s.Z" }, { MAN, "%s/man%s/%s.%s" }, { MANZ, "%s/man%s/%s.%s.Z" }, { SMAN, "%s/sman%s/%s.%s" }, /* Solaris */ { SMANZ,"%s/sman%s/%s.%s.Z" }, { CAT, "%s/cat%.1s/%s.%s" }, /* BSD */ { CATZ, "%s/cat%.1s/%s.%s.Z" }, { MAN, "%s/man%.1s/%s.%s" }, { MANZ, "%s/man%.1s/%s.%s.Z" }, }; if (strlen(mandir) + 1 + 6 + 1 > arraysize(whatis)) return 0; /* Prefer a fast windex database if available. */ sprintf(whatis, "%s/windex", mandir); if ((wf= fopen(whatis, "r")) != nil) { searchidx= searchwindex; } else { /* Use a classic whatis database. */ sprintf(whatis, "%s/whatis", mandir); if ((wf= fopen(whatis, "r")) == nil) return 0; searchidx= searchwhatis; } rsp= 0; while (!rsp && (rsw= (*searchidx)(wf, title, &wpage, &wsection)) == 1) { if (!member(wsection, section)) continue; /* When looking for getc(1S) we try: * cat1s/getc.1s * cat1s/getc.1s.Z * man1s/getc.1s * man1s/getc.1s.Z * sman1s/getc.1s * sman1s/getc.1s.Z * cat1/getc.1s * cat1/getc.1s.Z * man1/getc.1s * man1/getc.1s.Z */ if (strlen(mandir) + 2 * strlen(wsection) + strlen(wpage) + 10 > arraysize(pagename)) continue; sp= searchN; ntries= arraysize(searchN); do { if (sp->ptype <= CATZ && rofftype != NROFF) continue; sprintf(pagename, sp->pathfmt, mandir, wsection, wpage, wsection); rsp= showpage(pagename, sp->ptype, (SEC9SPECIAL && strcmp(wsection, "9") == 0) ? "-mnx" : "-man"); } while (sp++, !rsp && --ntries != 0); if (all) rsp= 0; } if (rsw < 0 && ferror(wf)) { fprintf(stderr, "man: %s: %s\n", whatis, strerror(errno)); exit(1); } fclose(wf); return rsp; } int trysubmandir(char *mandir, char *title, char *section) /* Search the subdirectories of this manual directory for whatis files, they * may have manual pages that override the ones in the major directory. */ { char submandir[1024]; DIR *md; struct dirent *entry; if ((md= opendir(mandir)) == nil) return 0; while ((entry= readdir(md)) != nil) { if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue; if ((strncmp(entry->d_name, "man", 3) == 0 || strncmp(entry->d_name, "cat", 3) == 0) && between('0', entry->d_name[3], '9')) continue; if (strlen(mandir) + 1 + strlen(entry->d_name) + 1 > arraysize(submandir)) continue; sprintf(submandir, "%s/%s", mandir, entry->d_name); if (trymandir(submandir, title, section) && !all) { closedir(md); return 1; } } closedir(md); return 0; } void searchmanpath(char *title, char *section) /* Search the manual path for a manual page describing "title." */ { char mandir[1024]; char *pp= manpath, *pd; for (;;) { while (*pp != 0 && *pp == ':') pp++; if (*pp == 0) break; pd= mandir; while (*pp != 0 && *pp != ':') { if (pd < arraylimit(mandir)) *pd++= *pp; pp++; } if (pd == arraylimit(mandir)) continue; /* forget it */ *pd= 0; if (trysubmandir(mandir, title, section) && !all) break; if (trymandir(mandir, title, section) && !all) break; } } void usage(void) { fprintf(stderr, "Usage: man -[antfkq] [-M path] [-s section] title ...\n"); exit(1); } int main(int argc, char **argv) { char *title, *section= ALL; int i; int nomoreopt= 0; char *opt; if ((pager= getenv("PAGER")) == nil) pager= PAGER; if ((manpath= getenv("MANPATH")) == nil) manpath= MANPATH; tty= isatty(1); i= 1; do { while (i < argc && argv[i][0] == '-' && !nomoreopt) { opt= argv[i++]+1; if (opt[0] == '-' && opt[1] == 0) { nomoreopt= 1; break; } while (*opt != 0) { switch (*opt++) { case 'a': all= 1; break; case 'f': whatis= 1; break; case 'k': apropos= 1; break; case 'q': quiet= 1; break; case 'n': rofftype= NROFF; apropos= whatis= 0; break; case 't': rofftype= TROFF; apropos= whatis= 0; break; case 's': if (*opt == 0) { if (i == argc) usage(); section= argv[i++]; } else { section= opt; opt= ""; } break; case 'M': if (*opt == 0) { if (i == argc) usage(); manpath= argv[i++]; } else { manpath= opt; opt= ""; } break; default: usage(); } } } if (i >= argc) usage(); if (between('0', argv[i][0], '9') && argv[i][1] == 0) { /* Allow single digit section designations. */ section= argv[i++]; } if (i == argc) usage(); title= argv[i++]; if (whatis || apropos) { keyword(title); } else { shown= 0; searchmanpath(title, section); if (!shown) (void) showpage(title, MAN, "-man"); if (!shown) { if (!quiet) { fprintf(stderr, "man: no manual on %s\n", title); } exit(1); } } } while (i < argc); return 0; }
the_stack_data/60241.c
/* * Copyright (C) 2010 - 2018 Xilinx, 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: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR 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. * */ /* * platform_mb.c * * MicroBlaze platform specific functions. */ #ifdef __MICROBLAZE__ #include "platform.h" #include "platform_config.h" #include "mb_interface.h" #include "xparameters.h" #include "xintc.h" #include "xtmrctr_l.h" void xadapter_timer_handler(void *p) { timer_callback(); /* Load timer, clear interrupt bit */ XTmrCtr_SetControlStatusReg(PLATFORM_TIMER_BASEADDR, 0, XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK); XTmrCtr_SetControlStatusReg(PLATFORM_TIMER_BASEADDR, 0, XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK); XIntc_AckIntr(XPAR_INTC_0_BASEADDR, PLATFORM_TIMER_INTERRUPT_MASK); } #define MHZ (66) #define TIMER_TLR (25000000*((float)MHZ/100)) void platform_setup_timer() { /* set the number of cycles the timer counts before interrupting */ /* 100 Mhz clock => .01us for 1 clk tick. For 100ms, 10000000 clk ticks need to elapse */ XTmrCtr_SetLoadReg(PLATFORM_TIMER_BASEADDR, 0, TIMER_TLR); /* reset the timers, and clear interrupts */ XTmrCtr_SetControlStatusReg(PLATFORM_TIMER_BASEADDR, 0, XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK ); /* start the timers */ XTmrCtr_SetControlStatusReg(PLATFORM_TIMER_BASEADDR, 0, XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK); /* Register Timer handler */ XIntc_RegisterHandler(XPAR_INTC_0_BASEADDR, PLATFORM_TIMER_INTERRUPT_INTR, (XInterruptHandler)xadapter_timer_handler, 0); } void platform_enable_interrupts() { #ifdef MICROBLAZE_EXCEPTIONS_ENABLED microblaze_enable_exceptions(); #endif microblaze_enable_interrupts(); } void platform_disable_interrupts() { microblaze_disable_interrupts(); } #endif
the_stack_data/47507.c
/* FredHappyface 2020 */ #include <stdio.h> int* swap(int ab[]); int main(){ int ab[] = {1, 2}; int* arr_pointer; arr_pointer = swap(ab); if (arr_pointer == 2){ printf("Swap worked"); } } int* swap(int ab[]){ int swapped[] = {ab[1], ab[0]}; return *swapped; }
the_stack_data/187642020.c
#include <stdio.h> #include <math.h> int main(void) { double a, b, c, radical, root1, root2; printf("For ax^2 + bx + c = 0, enter a: "); scanf("%lf", &a); printf("Enter b: "); scanf("%lf", &b); printf("Enter c: "); scanf("%lf", &c); radical = b * b - (4 * a * c); if (radical < 0) printf("The roots to the given quadratic are complex.\n"); else { radical = sqrt(radical); root1 = (-b + radical) / (2 * a); root2 = (-b - radical) / (2 * a); if (root1 == root2) printf("1 root: x = %lf\n", root1); else printf("2 roots: x = %lf or %lf\n", root1, root2); } return 0; }
the_stack_data/93887249.c
typedef enum {false, true} bool; extern int __VERIFIER_nondet_int(void); int main() { int c; int x, y; x = __VERIFIER_nondet_int(); y = __VERIFIER_nondet_int(); c = 0; while (!(x == y)) { if (x > y) { y = y + 1; } else { x = x + 1; } c = c + 1; } return 0; }
the_stack_data/707944.c
/* * POK header * * The following file is a part of the POK project. Any modification should * made according to the POK licence. You CANNOT use this file or a part of * this file is this part of a file for your own project * * For more information on the POK licence, please see our LICENCE FILE * * Please follow the coding guidelines described in doc/CODING_GUIDELINES * * Copyright (c) 2007-2009 POK team * * Created by julien on Fri Jan 30 14:41:34 2009 */ /* $NetBSD: s_signgam.c,v 1.4 1998/01/09 03:15:46 perry Exp $ */ #ifdef POK_NEEDS_LIBMATH #include <libm.h> #include "math_private.h" int signgam = 0; #endif
the_stack_data/151272.c
typedef unsigned int size_t; typedef long __time_t; struct buf_mem_st { int length ; char *data ; int max ; }; typedef struct buf_mem_st BUF_MEM; typedef __time_t time_t; struct stack_st { int num ; char **data ; int sorted ; int num_alloc ; int (*comp)(char const * const * , char const * const * ) ; }; typedef struct stack_st STACK; struct bio_st; struct crypto_ex_data_st { STACK *sk ; int dummy ; }; typedef struct crypto_ex_data_st CRYPTO_EX_DATA; typedef struct bio_st BIO; typedef void bio_info_cb(struct bio_st * , int , char const * , int , long , long );struct bio_method_st { int type ; char const *name ; int (*bwrite)(BIO * , char const * , int ) ; int (*bread)(BIO * , char * , int ) ; int (*bputs)(BIO * , char const * ) ; int (*bgets)(BIO * , char * , int ) ; long (*ctrl)(BIO * , int , long , void * ) ; int (*create)(BIO * ) ; int (*destroy)(BIO * ) ; long (*callback_ctrl)(BIO * , int , bio_info_cb * ) ; }; typedef struct bio_method_st BIO_METHOD; struct bio_st { BIO_METHOD *method ; long (*callback)(struct bio_st * , int , char const * , int , long , long ) ; char *cb_arg ; int init ; int shutdown ; int flags ; int retry_reason ; int num ; void *ptr ; struct bio_st *next_bio ; struct bio_st *prev_bio ; int references ; unsigned long num_read ; unsigned long num_write ; CRYPTO_EX_DATA ex_data ; }; struct bignum_st { unsigned long *d ; int top ; int dmax ; int neg ; int flags ; }; typedef struct bignum_st BIGNUM; struct bignum_ctx { int tos ; BIGNUM bn[16] ; int flags ; int depth ; int pos[12] ; int too_many ; }; typedef struct bignum_ctx BN_CTX; struct bn_blinding_st { int init ; BIGNUM *A ; BIGNUM *Ai ; BIGNUM *mod ; }; typedef struct bn_blinding_st BN_BLINDING; struct bn_mont_ctx_st { int ri ; BIGNUM RR ; BIGNUM N ; BIGNUM Ni ; unsigned long n0 ; int flags ; }; typedef struct bn_mont_ctx_st BN_MONT_CTX; struct X509_algor_st;struct X509_algor_st; struct asn1_object_st { char const *sn ; char const *ln ; int nid ; int length ; unsigned char *data ; int flags ; }; typedef struct asn1_object_st ASN1_OBJECT; struct asn1_string_st { int length ; int type ; unsigned char *data ; long flags ; }; typedef struct asn1_string_st ASN1_STRING; typedef struct asn1_string_st ASN1_INTEGER; typedef struct asn1_string_st ASN1_ENUMERATED; typedef struct asn1_string_st ASN1_BIT_STRING; typedef struct asn1_string_st ASN1_OCTET_STRING; typedef struct asn1_string_st ASN1_PRINTABLESTRING; typedef struct asn1_string_st ASN1_T61STRING; typedef struct asn1_string_st ASN1_IA5STRING; typedef struct asn1_string_st ASN1_GENERALSTRING; typedef struct asn1_string_st ASN1_UNIVERSALSTRING; typedef struct asn1_string_st ASN1_BMPSTRING; typedef struct asn1_string_st ASN1_UTCTIME; typedef struct asn1_string_st ASN1_TIME; typedef struct asn1_string_st ASN1_GENERALIZEDTIME; typedef struct asn1_string_st ASN1_VISIBLESTRING; typedef struct asn1_string_st ASN1_UTF8STRING; typedef int ASN1_BOOLEAN; union __anonunion_value_19 { char *ptr ; ASN1_BOOLEAN boolean ; ASN1_STRING *asn1_string ; ASN1_OBJECT *object ; ASN1_INTEGER *integer ; ASN1_ENUMERATED *enumerated ; ASN1_BIT_STRING *bit_string ; ASN1_OCTET_STRING *octet_string ; ASN1_PRINTABLESTRING *printablestring ; ASN1_T61STRING *t61string ; ASN1_IA5STRING *ia5string ; ASN1_GENERALSTRING *generalstring ; ASN1_BMPSTRING *bmpstring ; ASN1_UNIVERSALSTRING *universalstring ; ASN1_UTCTIME *utctime ; ASN1_GENERALIZEDTIME *generalizedtime ; ASN1_VISIBLESTRING *visiblestring ; ASN1_UTF8STRING *utf8string ; ASN1_STRING *set ; ASN1_STRING *sequence ; }; struct asn1_type_st { int type ; union __anonunion_value_19 value ; }; typedef struct asn1_type_st ASN1_TYPE; struct MD5state_st { unsigned int A ; unsigned int B ; unsigned int C ; unsigned int D ; unsigned int Nl ; unsigned int Nh ; unsigned int data[16] ; int num ; }; typedef struct MD5state_st MD5_CTX; struct SHAstate_st { unsigned int h0 ; unsigned int h1 ; unsigned int h2 ; unsigned int h3 ; unsigned int h4 ; unsigned int Nl ; unsigned int Nh ; unsigned int data[16] ; int num ; }; typedef struct SHAstate_st SHA_CTX; struct MD2state_st { int num ; unsigned char data[16] ; unsigned int cksm[16] ; unsigned int state[16] ; }; typedef struct MD2state_st MD2_CTX; struct MD4state_st { unsigned int A ; unsigned int B ; unsigned int C ; unsigned int D ; unsigned int Nl ; unsigned int Nh ; unsigned int data[16] ; int num ; }; typedef struct MD4state_st MD4_CTX; struct RIPEMD160state_st { unsigned int A ; unsigned int B ; unsigned int C ; unsigned int D ; unsigned int E ; unsigned int Nl ; unsigned int Nh ; unsigned int data[16] ; int num ; }; typedef struct RIPEMD160state_st RIPEMD160_CTX; typedef unsigned char des_cblock[8]; union __anonunion_ks_20 { des_cblock cblock ; unsigned long deslong[2] ; }; struct des_ks_struct { union __anonunion_ks_20 ks ; int weak_key ; }; typedef struct des_ks_struct des_key_schedule[16]; struct rc4_key_st { unsigned int x ; unsigned int y ; unsigned int data[256] ; }; typedef struct rc4_key_st RC4_KEY; struct rc2_key_st { unsigned int data[64] ; }; typedef struct rc2_key_st RC2_KEY; struct rc5_key_st { int rounds ; unsigned long data[34] ; }; typedef struct rc5_key_st RC5_32_KEY; struct bf_key_st { unsigned int P[18] ; unsigned int S[1024] ; }; typedef struct bf_key_st BF_KEY; struct cast_key_st { unsigned long data[32] ; int short_key ; }; typedef struct cast_key_st CAST_KEY; struct idea_key_st { unsigned int data[9][6] ; }; typedef struct idea_key_st IDEA_KEY_SCHEDULE; struct mdc2_ctx_st { int num ; unsigned char data[8] ; des_cblock h ; des_cblock hh ; int pad_type ; }; typedef struct mdc2_ctx_st MDC2_CTX; struct rsa_st;typedef struct rsa_st RSA; struct rsa_meth_st { char const *name ; int (*rsa_pub_enc)(int flen , unsigned char *from , unsigned char *to , RSA *rsa , int padding ) ; int (*rsa_pub_dec)(int flen , unsigned char *from , unsigned char *to , RSA *rsa , int padding ) ; int (*rsa_priv_enc)(int flen , unsigned char *from , unsigned char *to , RSA *rsa , int padding ) ; int (*rsa_priv_dec)(int flen , unsigned char *from , unsigned char *to , RSA *rsa , int padding ) ; int (*rsa_mod_exp)(BIGNUM *r0 , BIGNUM *I , RSA *rsa ) ; int (*bn_mod_exp)(BIGNUM *r , BIGNUM *a , BIGNUM const *p , BIGNUM const *m , BN_CTX *ctx , BN_MONT_CTX *m_ctx ) ; int (*init)(RSA *rsa ) ; int (*finish)(RSA *rsa ) ; int flags ; char *app_data ; int (*rsa_sign)(int type , unsigned char *m , unsigned int m_len , unsigned char *sigret , unsigned int *siglen , RSA *rsa ) ; int (*rsa_verify)(int dtype , unsigned char *m , unsigned int m_len , unsigned char *sigbuf , unsigned int siglen , RSA *rsa ) ; }; typedef struct rsa_meth_st RSA_METHOD; struct rsa_st { int pad ; int version ; RSA_METHOD *meth ; BIGNUM *n ; BIGNUM *e ; BIGNUM *d ; BIGNUM *p ; BIGNUM *q ; BIGNUM *dmp1 ; BIGNUM *dmq1 ; BIGNUM *iqmp ; CRYPTO_EX_DATA ex_data ; int references ; int flags ; BN_MONT_CTX *_method_mod_n ; BN_MONT_CTX *_method_mod_p ; BN_MONT_CTX *_method_mod_q ; char *bignum_data ; BN_BLINDING *blinding ; }; struct dh_st;typedef struct dh_st DH; struct dh_method { char const *name ; int (*generate_key)(DH *dh ) ; int (*compute_key)(unsigned char *key , BIGNUM *pub_key , DH *dh ) ; int (*bn_mod_exp)(DH *dh , BIGNUM *r , BIGNUM *a , BIGNUM const *p , BIGNUM const *m , BN_CTX *ctx , BN_MONT_CTX *m_ctx ) ; int (*init)(DH *dh ) ; int (*finish)(DH *dh ) ; int flags ; char *app_data ; }; typedef struct dh_method DH_METHOD; struct dh_st { int pad ; int version ; BIGNUM *p ; BIGNUM *g ; int length ; BIGNUM *pub_key ; BIGNUM *priv_key ; int flags ; char *method_mont_p ; BIGNUM *q ; BIGNUM *j ; unsigned char *seed ; int seedlen ; BIGNUM *counter ; int references ; CRYPTO_EX_DATA ex_data ; DH_METHOD *meth ; }; struct dsa_st;typedef struct dsa_st DSA; struct DSA_SIG_st { BIGNUM *r ; BIGNUM *s ; }; typedef struct DSA_SIG_st DSA_SIG; struct dsa_method { char const *name ; DSA_SIG *(*dsa_do_sign)(unsigned char const *dgst , int dlen , DSA *dsa ) ; int (*dsa_sign_setup)(DSA *dsa , BN_CTX *ctx_in , BIGNUM **kinvp , BIGNUM **rp ) ; int (*dsa_do_verify)(unsigned char const *dgst , int dgst_len , DSA_SIG *sig , DSA *dsa ) ; int (*dsa_mod_exp)(DSA *dsa , BIGNUM *rr , BIGNUM *a1 , BIGNUM *p1 , BIGNUM *a2 , BIGNUM *p2 , BIGNUM *m , BN_CTX *ctx , BN_MONT_CTX *in_mont ) ; int (*bn_mod_exp)(DSA *dsa , BIGNUM *r , BIGNUM *a , BIGNUM const *p , BIGNUM const *m , BN_CTX *ctx , BN_MONT_CTX *m_ctx ) ; int (*init)(DSA *dsa ) ; int (*finish)(DSA *dsa ) ; int flags ; char *app_data ; }; typedef struct dsa_method DSA_METHOD; struct dsa_st { int pad ; int version ; int write_params ; BIGNUM *p ; BIGNUM *q ; BIGNUM *g ; BIGNUM *pub_key ; BIGNUM *priv_key ; BIGNUM *kinv ; BIGNUM *r ; int flags ; char *method_mont_p ; int references ; CRYPTO_EX_DATA ex_data ; DSA_METHOD *meth ; }; union __anonunion_pkey_21 { char *ptr ; struct rsa_st *rsa ; struct dsa_st *dsa ; struct dh_st *dh ; }; struct evp_pkey_st { int type ; int save_type ; int references ; union __anonunion_pkey_21 pkey ; int save_parameters ; STACK *attributes ; }; typedef struct evp_pkey_st EVP_PKEY; struct env_md_st { int type ; int pkey_type ; int md_size ; void (*init)() ; void (*update)() ; void (*final)() ; int (*sign)() ; int (*verify)() ; int required_pkey_type[5] ; int block_size ; int ctx_size ; }; typedef struct env_md_st EVP_MD; union __anonunion_md_22 { unsigned char base[4] ; MD2_CTX md2 ; MD5_CTX md5 ; MD4_CTX md4 ; RIPEMD160_CTX ripemd160 ; SHA_CTX sha ; MDC2_CTX mdc2 ; }; struct env_md_ctx_st { EVP_MD const *digest ; union __anonunion_md_22 md ; }; typedef struct env_md_ctx_st EVP_MD_CTX; struct evp_cipher_st;typedef struct evp_cipher_st EVP_CIPHER; struct evp_cipher_ctx_st;typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; struct evp_cipher_st { int nid ; int block_size ; int key_len ; int iv_len ; unsigned long flags ; int (*init)(EVP_CIPHER_CTX *ctx , unsigned char const *key , unsigned char const *iv , int enc ) ; int (*do_cipher)(EVP_CIPHER_CTX *ctx , unsigned char *out , unsigned char const *in , unsigned int inl ) ; int (*cleanup)(EVP_CIPHER_CTX * ) ; int ctx_size ; int (*set_asn1_parameters)(EVP_CIPHER_CTX * , ASN1_TYPE * ) ; int (*get_asn1_parameters)(EVP_CIPHER_CTX * , ASN1_TYPE * ) ; int (*ctrl)(EVP_CIPHER_CTX * , int type , int arg , void *ptr ) ; void *app_data ; }; struct __anonstruct_rc4_24 { unsigned char key[16] ; RC4_KEY ks ; }; struct __anonstruct_desx_cbc_25 { des_key_schedule ks ; des_cblock inw ; des_cblock outw ; }; struct __anonstruct_des_ede_26 { des_key_schedule ks1 ; des_key_schedule ks2 ; des_key_schedule ks3 ; }; struct __anonstruct_rc2_27 { int key_bits ; RC2_KEY ks ; }; struct __anonstruct_rc5_28 { int rounds ; RC5_32_KEY ks ; }; union __anonunion_c_23 { struct __anonstruct_rc4_24 rc4 ; des_key_schedule des_ks ; struct __anonstruct_desx_cbc_25 desx_cbc ; struct __anonstruct_des_ede_26 des_ede ; IDEA_KEY_SCHEDULE idea_ks ; struct __anonstruct_rc2_27 rc2 ; struct __anonstruct_rc5_28 rc5 ; BF_KEY bf_ks ; CAST_KEY cast_ks ; }; struct evp_cipher_ctx_st { EVP_CIPHER const *cipher ; int encrypt ; int buf_len ; unsigned char oiv[8] ; unsigned char iv[8] ; unsigned char buf[8] ; int num ; void *app_data ; int key_len ; union __anonunion_c_23 c ; }; struct X509_algor_st { ASN1_OBJECT *algorithm ; ASN1_TYPE *parameter ; }; typedef struct X509_algor_st X509_ALGOR; struct X509_val_st { ASN1_TIME *notBefore ; ASN1_TIME *notAfter ; }; typedef struct X509_val_st X509_VAL; struct X509_pubkey_st { X509_ALGOR *algor ; ASN1_BIT_STRING *public_key ; EVP_PKEY *pkey ; }; typedef struct X509_pubkey_st X509_PUBKEY; struct X509_name_st { STACK *entries ; int modified ; BUF_MEM *bytes ; unsigned long hash ; }; typedef struct X509_name_st X509_NAME; struct x509_cinf_st { ASN1_INTEGER *version ; ASN1_INTEGER *serialNumber ; X509_ALGOR *signature ; X509_NAME *issuer ; X509_VAL *validity ; X509_NAME *subject ; X509_PUBKEY *key ; ASN1_BIT_STRING *issuerUID ; ASN1_BIT_STRING *subjectUID ; STACK *extensions ; }; typedef struct x509_cinf_st X509_CINF; struct x509_cert_aux_st { STACK *trust ; STACK *reject ; ASN1_UTF8STRING *alias ; ASN1_OCTET_STRING *keyid ; STACK *other ; }; typedef struct x509_cert_aux_st X509_CERT_AUX; struct AUTHORITY_KEYID_st;struct x509_st { X509_CINF *cert_info ; X509_ALGOR *sig_alg ; ASN1_BIT_STRING *signature ; int valid ; int references ; char *name ; CRYPTO_EX_DATA ex_data ; long ex_pathlen ; unsigned long ex_flags ; unsigned long ex_kusage ; unsigned long ex_xkusage ; unsigned long ex_nscert ; ASN1_OCTET_STRING *skid ; struct AUTHORITY_KEYID_st *akid ; unsigned char sha1_hash[20] ; X509_CERT_AUX *aux ; }; typedef struct x509_st X509; struct lhash_node_st { void *data ; struct lhash_node_st *next ; unsigned long hash ; }; typedef struct lhash_node_st LHASH_NODE; struct lhash_st { LHASH_NODE **b ; int (*comp)() ; unsigned long (*hash)() ; unsigned int num_nodes ; unsigned int num_alloc_nodes ; unsigned int p ; unsigned int pmax ; unsigned long up_load ; unsigned long down_load ; unsigned long num_items ; unsigned long num_expands ; unsigned long num_expand_reallocs ; unsigned long num_contracts ; unsigned long num_contract_reallocs ; unsigned long num_hash_calls ; unsigned long num_comp_calls ; unsigned long num_insert ; unsigned long num_replace ; unsigned long num_delete ; unsigned long num_no_delete ; unsigned long num_retrieve ; unsigned long num_retrieve_miss ; unsigned long num_hash_comps ; int error ; }; struct x509_store_ctx_st;typedef struct x509_store_ctx_st X509_STORE_CTX; struct x509_store_st { int cache ; STACK *objs ; STACK *get_cert_methods ; int (*verify)(X509_STORE_CTX *ctx ) ; int (*verify_cb)(int ok , X509_STORE_CTX *ctx ) ; CRYPTO_EX_DATA ex_data ; int references ; int depth ; }; typedef struct x509_store_st X509_STORE; struct x509_store_ctx_st { X509_STORE *ctx ; int current_method ; X509 *cert ; STACK *untrusted ; int purpose ; int trust ; time_t check_time ; unsigned long flags ; void *other_ctx ; int (*verify)(X509_STORE_CTX *ctx ) ; int (*verify_cb)(int ok , X509_STORE_CTX *ctx ) ; int (*get_issuer)(X509 **issuer , X509_STORE_CTX *ctx , X509 *x ) ; int (*check_issued)(X509_STORE_CTX *ctx , X509 *x , X509 *issuer ) ; int (*cleanup)(X509_STORE_CTX *ctx ) ; int depth ; int valid ; int last_untrusted ; STACK *chain ; int error_depth ; int error ; X509 *current_cert ; X509 *current_issuer ; CRYPTO_EX_DATA ex_data ; }; struct comp_method_st { int type ; char const *name ; int (*init)() ; void (*finish)() ; int (*compress)() ; int (*expand)() ; long (*ctrl)() ; long (*callback_ctrl)() ; }; typedef struct comp_method_st COMP_METHOD; struct comp_ctx_st { COMP_METHOD *meth ; unsigned long compress_in ; unsigned long compress_out ; unsigned long expand_in ; unsigned long expand_out ; CRYPTO_EX_DATA ex_data ; }; typedef struct comp_ctx_st COMP_CTX; typedef int pem_password_cb(char *buf , int size , int rwflag , void *userdata ); struct ssl_st; struct ssl_cipher_st { int valid ; char const *name ; unsigned long id ; unsigned long algorithms ; unsigned long algo_strength ; unsigned long algorithm2 ; int strength_bits ; int alg_bits ; unsigned long mask ; unsigned long mask_strength ; }; typedef struct ssl_cipher_st SSL_CIPHER; typedef struct ssl_st SSL; struct ssl_ctx_st;typedef struct ssl_ctx_st SSL_CTX; struct ssl3_enc_method;struct ssl_method_st { int version ; int (*ssl_new)(SSL *s ) ; void (*ssl_clear)(SSL *s ) ; void (*ssl_free)(SSL *s ) ; int (*ssl_accept)(SSL *s ) ; int (*ssl_connect)(SSL *s ) ; int (*ssl_read)(SSL *s , void *buf , int len ) ; int (*ssl_peek)(SSL *s , void *buf , int len ) ; int (*ssl_write)(SSL *s , void const *buf , int len ) ; int (*ssl_shutdown)(SSL *s ) ; int (*ssl_renegotiate)(SSL *s ) ; int (*ssl_renegotiate_check)(SSL *s ) ; long (*ssl_ctrl)(SSL *s , int cmd , long larg , char *parg ) ; long (*ssl_ctx_ctrl)(SSL_CTX *ctx , int cmd , long larg , char *parg ) ; SSL_CIPHER *(*get_cipher_by_char)(unsigned char const *ptr ) ; int (*put_cipher_by_char)(SSL_CIPHER const *cipher , unsigned char *ptr ) ; int (*ssl_pending)(SSL *s ) ; int (*num_ciphers)(void) ; SSL_CIPHER *(*get_cipher)(unsigned int ncipher ) ; struct ssl_method_st *(*get_ssl_method)(int version ) ; long (*get_timeout)(void) ; struct ssl3_enc_method *ssl3_enc ; int (*ssl_version)() ; long (*ssl_callback_ctrl)(SSL *s , int cb_id , void (*fp)() ) ; long (*ssl_ctx_callback_ctrl)(SSL_CTX *s , int cb_id , void (*fp)() ) ; }; typedef struct ssl_method_st SSL_METHOD; struct sess_cert_st;struct ssl_session_st { int ssl_version ; unsigned int key_arg_length ; unsigned char key_arg[8] ; int master_key_length ; unsigned char master_key[48] ; unsigned int session_id_length ; unsigned char session_id[32] ; unsigned int sid_ctx_length ; unsigned char sid_ctx[32] ; int not_resumable ; struct sess_cert_st *sess_cert ; X509 *peer ; long verify_result ; int references ; long timeout ; long time ; int compress_meth ; SSL_CIPHER *cipher ; unsigned long cipher_id ; STACK *ciphers ; CRYPTO_EX_DATA ex_data ; struct ssl_session_st *prev ; struct ssl_session_st *next ; }; typedef struct ssl_session_st SSL_SESSION; struct ssl_comp_st { int id ; char *name ; COMP_METHOD *method ; }; typedef struct ssl_comp_st SSL_COMP; struct __anonstruct_stats_37 { int sess_connect ; int sess_connect_renegotiate ; int sess_connect_good ; int sess_accept ; int sess_accept_renegotiate ; int sess_accept_good ; int sess_miss ; int sess_timeout ; int sess_cache_full ; int sess_hit ; int sess_cb_hit ; }; struct cert_st;struct ssl_ctx_st { SSL_METHOD *method ; unsigned long options ; unsigned long mode ; STACK *cipher_list ; STACK *cipher_list_by_id ; struct x509_store_st *cert_store ; struct lhash_st *sessions ; unsigned long session_cache_size ; struct ssl_session_st *session_cache_head ; struct ssl_session_st *session_cache_tail ; int session_cache_mode ; long session_timeout ; int (*new_session_cb)(struct ssl_st *ssl , SSL_SESSION *sess ) ; void (*remove_session_cb)(struct ssl_ctx_st *ctx , SSL_SESSION *sess ) ; SSL_SESSION *(*get_session_cb)(struct ssl_st *ssl , unsigned char *data , int len , int *copy ) ; struct __anonstruct_stats_37 stats ; int references ; void (*info_callback)() ; int (*app_verify_callback)() ; char *app_verify_arg ; struct cert_st *cert ; int read_ahead ; int verify_mode ; int verify_depth ; unsigned int sid_ctx_length ; unsigned char sid_ctx[32] ; int (*default_verify_callback)(int ok , X509_STORE_CTX *ctx ) ; int purpose ; int trust ; pem_password_cb *default_passwd_callback ; void *default_passwd_callback_userdata ; int (*client_cert_cb)() ; STACK *client_CA ; int quiet_shutdown ; CRYPTO_EX_DATA ex_data ; EVP_MD const *rsa_md5 ; EVP_MD const *md5 ; EVP_MD const *sha1 ; STACK *extra_certs ; STACK *comp_methods ; }; struct ssl2_state_st;struct ssl3_state_st;struct ssl_st { int version ; int type ; SSL_METHOD *method ; BIO *rbio ; BIO *wbio ; BIO *bbio ; int rwstate ; int in_handshake ; int (*handshake_func)() ; int server ; int new_session ; int quiet_shutdown ; int shutdown ; int state ; int rstate ; BUF_MEM *init_buf ; int init_num ; int init_off ; unsigned char *packet ; unsigned int packet_length ; struct ssl2_state_st *s2 ; struct ssl3_state_st *s3 ; int read_ahead ; int hit ; int purpose ; int trust ; STACK *cipher_list ; STACK *cipher_list_by_id ; EVP_CIPHER_CTX *enc_read_ctx ; EVP_MD const *read_hash ; COMP_CTX *expand ; EVP_CIPHER_CTX *enc_write_ctx ; EVP_MD const *write_hash ; COMP_CTX *compress ; struct cert_st *cert ; unsigned int sid_ctx_length ; unsigned char sid_ctx[32] ; SSL_SESSION *session ; int verify_mode ; int verify_depth ; int (*verify_callback)(int ok , X509_STORE_CTX *ctx ) ; void (*info_callback)() ; int error ; int error_code ; SSL_CTX *ctx ; int debug ; long verify_result ; CRYPTO_EX_DATA ex_data ; STACK *client_CA ; int references ; unsigned long options ; unsigned long mode ; int first_packet ; int client_version ; }; struct __anonstruct_tmp_38 { unsigned int conn_id_length ; unsigned int cert_type ; unsigned int cert_length ; unsigned int csl ; unsigned int clear ; unsigned int enc ; unsigned char ccl[32] ; unsigned int cipher_spec_length ; unsigned int session_id_length ; unsigned int clen ; unsigned int rlen ; }; struct ssl2_state_st { int three_byte_header ; int clear_text ; int escape ; int ssl2_rollback ; unsigned int wnum ; int wpend_tot ; unsigned char const *wpend_buf ; int wpend_off ; int wpend_len ; int wpend_ret ; int rbuf_left ; int rbuf_offs ; unsigned char *rbuf ; unsigned char *wbuf ; unsigned char *write_ptr ; unsigned int padding ; unsigned int rlength ; int ract_data_length ; unsigned int wlength ; int wact_data_length ; unsigned char *ract_data ; unsigned char *wact_data ; unsigned char *mac_data ; unsigned char *pad_data_UNUSED ; unsigned char *read_key ; unsigned char *write_key ; unsigned int challenge_length ; unsigned char challenge[32] ; unsigned int conn_id_length ; unsigned char conn_id[16] ; unsigned int key_material_length ; unsigned char key_material[48] ; unsigned long read_sequence ; unsigned long write_sequence ; struct __anonstruct_tmp_38 tmp ; }; struct ssl3_record_st { int type ; unsigned int length ; unsigned int off ; unsigned char *data ; unsigned char *input ; unsigned char *comp ; }; typedef struct ssl3_record_st SSL3_RECORD; struct ssl3_buffer_st { unsigned char *buf ; int offset ; int left ; }; typedef struct ssl3_buffer_st SSL3_BUFFER; struct __anonstruct_tmp_39 { unsigned char cert_verify_md[72] ; unsigned char finish_md[72] ; int finish_md_len ; unsigned char peer_finish_md[72] ; int peer_finish_md_len ; unsigned long message_size ; int message_type ; SSL_CIPHER *new_cipher ; DH *dh ; int next_state ; int reuse_message ; int cert_req ; int ctype_num ; char ctype[7] ; STACK *ca_names ; int use_rsa_tmp ; int key_block_length ; unsigned char *key_block ; EVP_CIPHER const *new_sym_enc ; EVP_MD const *new_hash ; SSL_COMP const *new_compression ; int cert_request ; }; struct ssl3_state_st { long flags ; int delay_buf_pop_ret ; unsigned char read_sequence[8] ; unsigned char read_mac_secret[36] ; unsigned char write_sequence[8] ; unsigned char write_mac_secret[36] ; unsigned char server_random[32] ; unsigned char client_random[32] ; SSL3_BUFFER rbuf ; SSL3_BUFFER wbuf ; SSL3_RECORD rrec ; SSL3_RECORD wrec ; unsigned char alert_fragment[2] ; unsigned int alert_fragment_len ; unsigned char handshake_fragment[4] ; unsigned int handshake_fragment_len ; unsigned int wnum ; int wpend_tot ; int wpend_type ; int wpend_ret ; unsigned char const *wpend_buf ; EVP_MD_CTX finish_dgst1 ; EVP_MD_CTX finish_dgst2 ; int change_cipher_spec ; int warn_alert ; int fatal_alert ; int alert_dispatch ; unsigned char send_alert[2] ; int renegotiate ; int total_renegotiations ; int num_renegotiations ; int in_read_app_data ; struct __anonstruct_tmp_39 tmp ; }; struct cert_pkey_st { X509 *x509 ; EVP_PKEY *privatekey ; }; typedef struct cert_pkey_st CERT_PKEY; struct cert_st { CERT_PKEY *key ; int valid ; unsigned long mask ; unsigned long export_mask ; RSA *rsa_tmp ; RSA *(*rsa_tmp_cb)(SSL *ssl , int is_export , int keysize ) ; DH *dh_tmp ; DH *(*dh_tmp_cb)(SSL *ssl , int is_export , int keysize ) ; CERT_PKEY pkeys[5] ; int references ; }; typedef struct cert_st CERT; struct sess_cert_st { STACK *cert_chain ; int peer_cert_type ; CERT_PKEY *peer_key ; CERT_PKEY peer_pkeys[5] ; RSA *peer_rsa_tmp ; DH *peer_dh_tmp ; int references ; }; typedef struct sess_cert_st SESS_CERT; struct ssl3_enc_method { int (*enc)(SSL * , int ) ; int (*mac)(SSL * , unsigned char * , int ) ; int (*setup_key_block)(SSL * ) ; int (*generate_master_secret)(SSL * , unsigned char * , unsigned char * , int ) ; int (*change_cipher_state)(SSL * , int ) ; int (*final_finish_mac)(SSL * , EVP_MD_CTX * , EVP_MD_CTX * , char const * , int , unsigned char * ) ; int finish_mac_length ; int (*cert_verify_mac)(SSL * , EVP_MD_CTX * , unsigned char * ) ; char const *client_finished_label ; int client_finished_label_len ; char const *server_finished_label ; int server_finished_label_len ; int (*alert_value)(int ) ; }; extern BUF_MEM *BUF_MEM_new(void) ; extern void BUF_MEM_free(BUF_MEM *a ) ; extern int BUF_MEM_grow(BUF_MEM *str , int len ) ; extern int RAND_pseudo_bytes(unsigned char *buf , int num ) ; extern void RAND_add(void const *buf , int num , double entropy ) ; extern int sk_num(STACK const * ) ; extern char *sk_value(STACK const * , int ) ; extern STACK *sk_new_null(void) ; extern void sk_free(STACK * ) ; extern void sk_pop_free(STACK *st , void (*func)(void * ) ) ; extern int sk_push(STACK *st , char *data ) ; extern char *sk_shift(STACK *st ) ; extern int CRYPTO_add_lock(int *pointer , int amount , int type , char const *file , int line ) ; extern long BIO_ctrl(BIO *bp , int cmd , long larg , void *parg ) ; extern time_t time(time_t *__timer ) ; extern int BN_num_bits(BIGNUM const *a ) ; extern void BN_clear_free(BIGNUM *a ) ; extern BIGNUM *BN_bin2bn(unsigned char const *s , int len , BIGNUM *ret ) ; extern int BN_bn2bin(BIGNUM const *a , unsigned char *to ) ; extern BIGNUM *BN_dup(BIGNUM const *a ) ; extern char *ASN1_dup(int (*i2d)() , char *(*d2i)() , char *x ) ; extern int RSA_private_decrypt(int flen , unsigned char *from , unsigned char *to , RSA *rsa , int padding ) ; extern int RSA_sign(int type , unsigned char *m , unsigned int m_len , unsigned char *sigret , unsigned int *siglen , RSA *rsa ) ; extern int RSA_verify(int type , unsigned char *m , unsigned int m_len , unsigned char *sigbuf , unsigned int siglen , RSA *rsa ) ; extern void DH_free(DH *dh ) ; extern int DH_generate_key(DH *dh ) ; extern int DH_compute_key(unsigned char *key , BIGNUM *pub_key , DH *dh ) ; DH *d2i_DHparams(DH **a , unsigned char **pp , long length ) {} int i2d_DHparams(DH *a , unsigned char **pp ) {} extern int DSA_verify(int type , unsigned char const *dgst , int dgst_len , unsigned char *sigbuf , int siglen , DSA *dsa ) ; extern void EVP_DigestInit(EVP_MD_CTX *ctx , EVP_MD const *type ) ; extern void EVP_DigestUpdate(EVP_MD_CTX *ctx , void const *d , unsigned int cnt ) ; extern void EVP_DigestFinal(EVP_MD_CTX *ctx , unsigned char *md , unsigned int *s ) ; extern int EVP_SignFinal(EVP_MD_CTX *ctx , unsigned char *md , unsigned int *s , EVP_PKEY *pkey ) ; extern EVP_MD *EVP_dss1(void) ; extern int EVP_PKEY_size(EVP_PKEY *pkey ) ; extern void EVP_PKEY_free(EVP_PKEY *pkey ) ; extern int i2d_X509_NAME(X509_NAME *a , unsigned char **pp ) ; void X509_free(X509 *a ) {} extern X509 *d2i_X509(X509 **a , unsigned char **pp , long length ) ; extern EVP_PKEY *X509_get_pubkey(X509 *x ) ; extern int X509_certificate_type(X509 *x , EVP_PKEY *pubkey ) ; extern void *memcpy(void * /* __restrict */ __dest , void const * /* __restrict */ __src , size_t __n ) ; extern void *memset(void *__s , int __c , size_t __n ) ; extern int *__errno_location(void) /* __attribute__((__const__)) */ ; extern void ERR_put_error(int lib , int func , int reason , char const *file , int line ) ; extern void ERR_clear_error(void) ; extern int SSL_clear(SSL *s ) ; SSL_METHOD *SSLv3_server_method(void) ; extern STACK *SSL_get_client_CA_list(SSL *s ) ; extern int SSL_state(SSL *ssl ) ; extern SSL_METHOD *sslv3_base_method(void) ; extern SESS_CERT *ssl_sess_cert_new(void) ; extern int ssl_get_new_session(SSL *s , int session ) ; extern int ssl_get_prev_session(SSL *s , unsigned char *session , int len ) ; extern STACK *ssl_bytes_to_cipher_list(SSL *s , unsigned char *p , int num , STACK **skp ) ; extern void ssl_update_cache(SSL *s , int mode ) ; extern int ssl_verify_cert_chain(SSL *s , STACK *sk ) ; extern X509 *ssl_get_server_send_cert(SSL * ) ; extern EVP_PKEY *ssl_get_sign_pkey(SSL * , SSL_CIPHER * ) ; extern STACK *ssl_get_ciphers_by_id(SSL *s ) ; extern int ssl_verify_alarm_type(long type ) ; extern int ssl3_put_cipher_by_char(SSL_CIPHER const *c , unsigned char *p ) ; extern void ssl3_init_finished_mac(SSL *s ) ; int ssl3_send_server_certificate(SSL *s ) ; extern int ssl3_get_finished(SSL *s , int state_a , int state_b ) ; extern int ssl3_send_change_cipher_spec(SSL *s , int state_a , int state_b ) ; extern void ssl3_cleanup_key_block(SSL *s ) ; extern int ssl3_do_write(SSL *s , int type ) ; extern void ssl3_send_alert(SSL *s , int level , int desc ) ; extern int ssl3_get_req_cert_type(SSL *s , unsigned char *p ) ; extern long ssl3_get_message(SSL *s , int st1 , int stn , int mt , long max , int *ok ) ; extern int ssl3_send_finished(SSL *s , int a , int b , char const *sender , int slen ) ; extern unsigned long ssl3_output_cert_chain(SSL *s , X509 *x ) ; extern SSL_CIPHER *ssl3_choose_cipher(SSL *ssl , STACK *have , STACK *pref ) ; extern int ssl3_setup_buffers(SSL *s ) ; int ssl3_accept(SSL *s ) ; extern int ssl_init_wbio_buffer(SSL *s , int push ) ; extern void ssl_free_wbio_buffer(SSL *s ) ; static SSL_METHOD *ssl3_get_server_method(int ver ) ; static int ssl3_get_client_hello(SSL *s ) ; static int ssl3_check_client_hello(SSL *s ) ; static int ssl3_send_server_hello(SSL *s ) ; static int ssl3_send_server_key_exchange(SSL *s ) ; static int ssl3_send_certificate_request(SSL *s ) ; static int ssl3_send_server_done(SSL *s ) ; static int ssl3_get_client_key_exchange(SSL *s ) ; static int ssl3_get_client_certificate(SSL *s ) ; static int ssl3_get_cert_verify(SSL *s ) ; static int ssl3_send_hello_request(SSL *s ) ; static SSL_METHOD *ssl3_get_server_method(int ver ) { SSL_METHOD *tmp ; { if (ver == 768) { tmp = SSLv3_server_method(); return (tmp); } else { return ((SSL_METHOD *)((void *)0)); } } } SSL_METHOD *SSLv3_server_method(void) ;static int init = 1; static SSL_METHOD SSLv3_server_data ; SSL_METHOD *SSLv3_server_method(void) { char *tmp ; { if (init) { tmp = (char *)sslv3_base_method(); memcpy((void * )((char *)(& SSLv3_server_data)), (void const * )tmp, sizeof(SSL_METHOD )); SSLv3_server_data.ssl_accept = & ssl3_accept; SSLv3_server_data.get_ssl_method = & ssl3_get_server_method; init = 0; } return (& SSLv3_server_data); } } // TRACER: to shadow s->state int myState; // TRACER: to shadow (s->s3)->tmp.next_state int myStateNext; extern int unknown(); int main() { SSL *s = 0; return ssl3_accept(s); } int ssl3_accept(SSL *s ) { BUF_MEM *buf ; unsigned long l ; unsigned long Time ; unsigned long tmp ; void (*cb)() ; //long num1 ; int ret ; int new_state ; int state ; int skip ; int got_new_session ; int tmp___7 ; int TRACER_NONDET; int blastFlag; { myState /*s->state*/ = 8464; blastFlag = 0; //tmp = (unsigned long )time((time_t *)((void *)0)); tmp = unknown(); Time = tmp; cb = (void (*)())((void *)0); ret = -1; skip = 0; got_new_session = 0; //RAND_add((void const *)(& Time), (int )sizeof(Time), (double )0); //ERR_clear_error(); //tmp___0 = __errno_location(); (*tmp___0) = 0; if ((unsigned long )s->info_callback != (unsigned long )((void *)0)) { cb = s->info_callback; } else { if ((unsigned long )(s->ctx)->info_callback != (unsigned long )((void *)0)) { cb = (s->ctx)->info_callback; } } s->in_handshake ++; //tmp___1 = SSL_state(s); if (TRACER_NONDET & 12288) { //tmp___2 = SSL_state(s); if (TRACER_NONDET & 16384) { //SSL_clear(s); } } else { //SSL_clear(s); } if ((unsigned long )s->cert == (unsigned long )((void *)0)) { //ERR_put_error(20, 128, 179, (char const *)"s3_srvr.c", 187); return (-1); } while (1) { state = myState /*s->state*/; switch (myState /*s->state*/) { case 12292: s->new_session = 1; case 16384: ; case 8192: ; case 24576: ; case 8195: s->server = 1; if (/*(unsigned long )cb != (unsigned long )((void *)0)*/ TRACER_NONDET) { //((*cb))(s, 16, 1); } if (s->version >> 8 != 3) { //ERR_put_error(20, 128, 157, (char const *)"s3_srvr.c", 211); return (-1); } s->type = 8192; if ((unsigned long )s->init_buf == (unsigned long )((void *)0)) { //buf = BUF_MEM_new(); buf = unknown(); if ((unsigned long )buf == (unsigned long )((void *)0)) { ret = -1; goto end; } //tmp___3 = BUF_MEM_grow(buf, 16384); if (! TRACER_NONDET) { ret = -1; goto end; } s->init_buf = buf; } //tmp___4 = ssl3_setup_buffers(s); if (! TRACER_NONDET) { ret = -1; goto end; } s->init_num = 0; if (myState /*s->state*/ != 12292) { //tmp___5 = ssl_init_wbio_buffer(s, 1); if (! TRACER_NONDET) { ret = -1; goto end; } //ssl3_init_finished_mac(s); myState /*s->state*/ = 8464; (s->ctx)->stats.sess_accept ++; } else { (s->ctx)->stats.sess_accept_renegotiate ++; myState /*s->state*/ = 8480; } break; case 8480: ; case 8481: s->shutdown = 0; //ret = ssl3_send_hello_request(s); ret = unknown(); if (ret <= 0) { goto end; } myStateNext /*(s->s3)->tmp.next_state*/ = 8482; myState /*s->state*/ = 8448; s->init_num = 0; //ssl3_init_finished_mac(s); break; case 8482: myState /*s->state*/ = 3; break; case 8464: ; case 8465: ; case 8466: s->shutdown = 0; //ret = ssl3_get_client_hello(s); ret = unknown(); if(blastFlag == 0) blastFlag = 1; if (ret <= 0) { goto end; } got_new_session = 1; myState /*s->state*/ = 8496; s->init_num = 0; break; case 8496: ; case 8497: //ret = ssl3_send_server_hello(s); ret = unknown(); if(blastFlag == 1) blastFlag = 2; if (ret <= 0) { goto end; } if (s->hit) { myState /*s->state*/ = 8656; } else { myState /*s->state*/ = 8512; } s->init_num = 0; break; case 8512: ; case 8513: ; if (((s->s3)->tmp.new_cipher)->algorithms & 256UL) { skip = 1; } else { //ret = ssl3_send_server_certificate(s); ret = unknown(); if(blastFlag == 2) blastFlag = 6; if (ret <= 0) { goto end; } } myState /*s->state*/ = 8528; s->init_num = 0; break; case 8528: ; case 8529: l = ((s->s3)->tmp.new_cipher)->algorithms; if (s->options & 2097152UL) { (s->s3)->tmp.use_rsa_tmp = 1; } else { (s->s3)->tmp.use_rsa_tmp = 0; } if ((s->s3)->tmp.use_rsa_tmp) { goto _L___0; } else { if (l & 30UL) { goto _L___0; } else { if (l & 1UL) { if ((unsigned long )(s->cert)->pkeys[0].privatekey == (unsigned long )((void *)0)) { goto _L___0; } else { if (((s->s3)->tmp.new_cipher)->algo_strength & 2UL) { //tmp___6 = EVP_PKEY_size((s->cert)->pkeys[0].privatekey); if (((s->s3)->tmp.new_cipher)->algo_strength & 4UL) { tmp___7 = 512; } else { tmp___7 = 1024; } if (TRACER_NONDET * 8 > tmp___7) { _L___0: _L: //ret = ssl3_send_server_key_exchange(s); ret = unknown(); if(blastFlag == 6) blastFlag = 7; if (ret <= 0) { goto end; } } else { skip = 1; } } else { skip = 1; } } } else { skip = 1; } } } myState /*s->state*/ = 8544; s->init_num = 0; break; case 8544: ; case 8545: ; if (s->verify_mode & 1) { if ((unsigned long )(s->session)->peer != (unsigned long )((void *)0)) { if (s->verify_mode & 4) { skip = 1; (s->s3)->tmp.cert_request = 0; myState /*s->state*/ = 8560; } else { goto _L___2; } } else { _L___2: if (((s->s3)->tmp.new_cipher)->algorithms & 256UL) { if (s->verify_mode & 2) { goto _L___1; } else { skip = 1; (s->s3)->tmp.cert_request = 0; myState /*s->state*/ = 8560; } } else { _L___1: (s->s3)->tmp.cert_request = 1; //ret = ssl3_send_certificate_request(s); ret = unknown(); _TRACER_abort(blastFlag == 8); //if(blastFlag == 8) goto ERROR; if (ret <= 0) { goto end; } myState /*s->state*/ = 8448; myStateNext /*(s->s3)->tmp.next_state*/ = 8576; s->init_num = 0; } } } else { skip = 1; (s->s3)->tmp.cert_request = 0; myState /*s->state*/ = 8560; } break; case 8560: ; case 8561: //ret = ssl3_send_server_done(s); ret = unknown(); if (ret <= 0) { goto end; } myStateNext /*(s->s3)->tmp.next_state*/ = 8576; myState /*s->state*/ = 8448; s->init_num = 0; break; case 8448: //num1 = BIO_ctrl(s->wbio, 3, 0L, (void *)0); //if (num1 > 0L) { if(TRACER_NONDET) { s->rwstate = 2; //tmp___8 = BIO_ctrl(s->wbio, 11, 0L, (void *)0); //num1 = (long )((int )TRACER_NONDET); //if (num1 <= 0L) { if(TRACER_NONDET) { ret = -1; goto end; } s->rwstate = 1; } myState /*s->state*/ = myStateNext /*(s->s3)->tmp.next_state*/; break; case 8576: ; case 8577: //ret = ssl3_check_client_hello(s); ret = unknown(); if (ret <= 0) { goto end; } if (ret == 2) { myState /*s->state*/ = 8466; } else { //ret = ssl3_get_client_certificate(s); ret = unknown(); if (ret <= 0) { goto end; } s->init_num = 0; myState /*s->state*/ = 8592; } break; case 8592: ; case 8593: //ret = ssl3_get_client_key_exchange(s); ret = unknown(); if (ret <= 0) { goto end; } myState /*s->state*/ = 8608; s->init_num = 0; //((*(((s->method)->ssl3_enc)->cert_verify_mac)))(s, & (s->s3)->finish_dgst1, & (s->s3)->tmp.cert_verify_md[0]); //((*(((s->method)->ssl3_enc)->cert_verify_mac)))(s, & (s->s3)->finish_dgst2, & (s->s3)->tmp.cert_verify_md[16]); break; case 8608: ; case 8609: //ret = ssl3_get_cert_verify(s); ret = unknown(); if (ret <= 0) { goto end; } myState /*s->state*/ = 8640; s->init_num = 0; break; case 8640: ; case 8641: //ret = ssl3_get_finished(s, 8640, 8641); ret = unknown(); _TRACER_abort(blastFlag == 5); //if(blastFlag == 5) goto ERROR; if (ret <= 0) { goto end; } if (s->hit) { myState /*s->state*/ = 3; } else { myState /*s->state*/ = 8656; } s->init_num = 0; break; case 8656: ; case 8657: (s->session)->cipher = (s->s3)->tmp.new_cipher; //tmp___9 = ((*(((s->method)->ssl3_enc)->setup_key_block)))(s); if (! TRACER_NONDET) { ret = -1; goto end; } //ret = ssl3_send_change_cipher_spec(s, 8656, 8657); ret = unknown(); if(blastFlag == 2) blastFlag = 3; else if(blastFlag == 4) blastFlag = 5; else if(blastFlag == 7) blastFlag = 8; if (ret <= 0) { goto end; } myState /*s->state*/ = 8672; s->init_num = 0; //tmp___10 = ((*(((s->method)->ssl3_enc)->change_cipher_state)))(s, 34); if (! TRACER_NONDET) { ret = -1; goto end; } break; case 8672: ; case 8673: //ret = ssl3_send_finished(s, 8672, 8673, ((s->method)->ssl3_enc)->server_finished_label,((s->method)->ssl3_enc)->server_finished_label_len); ret = unknown(); if(blastFlag == 3) blastFlag = 4; if (ret <= 0) { goto end; } myState /*s->state*/ = 8448; if (s->hit) { myStateNext /*(s->s3)->tmp.next_state*/ = 8640; } else { myStateNext /*(s->s3)->tmp.next_state*/ = 3; } s->init_num = 0; break; case 3: //ssl3_cleanup_key_block(s); //BUF_MEM_free(s->init_buf); s->init_buf = (BUF_MEM *)((void *)0); //ssl_free_wbio_buffer(s); s->init_num = 0; if (/*got_new_session*/ TRACER_NONDET) { s->new_session = 0; //ssl_update_cache(s, 2); (s->ctx)->stats.sess_accept_good ++; s->handshake_func = (int (*)())(& ssl3_accept); if (/*(unsigned long )cb != (unsigned long )((void *)0)*/ TRACER_NONDET) { //((*cb))(s, 32, 1); } } ret = 1; goto end; default: //ERR_put_error(20, 128, 255, (char const *)"s3_srvr.c", 536); ret = -1; goto end; } if (! (s->s3)->tmp.reuse_message) { if (/*! skip*/ TRACER_NONDET) { if (s->debug) { //ret = (int )BIO_ctrl(s->wbio, 11, 0L, (void *)0); ret = unknown(); if (ret <= 0) { goto end; } } if (/*(unsigned long )cb != (unsigned long )((void *)0)*/ TRACER_NONDET) { if (myState /*s->state*/ != state) { new_state = myState /*s->state*/; myState /*s->state*/ = state; //((*cb))(s, 8193, 1); myState /*s->state*/ = new_state; } } } } skip = 0; } end: s->in_handshake --; if (/*(unsigned long )cb != (unsigned long )((void *)0)*/TRACER_NONDET) { //((*cb))(s, 8194, ret); } return (ret); // ERROR: goto ERROR; } } static int ssl3_send_hello_request(SSL *s ) { unsigned char *p ; unsigned char *tmp ; unsigned char *tmp___0 ; unsigned char *tmp___1 ; unsigned char *tmp___2 ; int tmp___3 ; { if (s->state == 8480) { p = (unsigned char *)(s->init_buf)->data; tmp = p; p ++; (*tmp) = 0; tmp___0 = p; p ++; (*tmp___0) = 0; tmp___1 = p; p ++; (*tmp___1) = 0; tmp___2 = p; p ++; (*tmp___2) = 0; s->state = 8481; s->init_num = 4; s->init_off = 0; } tmp___3 = ssl3_do_write(s, 22); return (tmp___3); } }static int ssl3_check_client_hello(SSL *s ) { int ok ; long n ; { n = ssl3_get_message(s, 8576, 8577, -1, 102400L, & ok); if (! ok) { return ((int )n); } (s->s3)->tmp.reuse_message = 1; if ((s->s3)->tmp.message_type == 1) { if ((unsigned long )(s->s3)->tmp.dh != (unsigned long )((void *)0)) { DH_free((s->s3)->tmp.dh); (s->s3)->tmp.dh = (DH *)((void *)0); } return (2); } return (1); } }static int ssl3_get_client_hello(SSL *s ) { int i ; int j ; int ok ; int al ; int ret ; long n ; unsigned long id ; unsigned char *p ; unsigned char *d ; unsigned char *q ; SSL_CIPHER *c ; SSL_COMP *comp ; STACK *ciphers ; unsigned char *tmp ; int tmp___0 ; int tmp___1 ; STACK *tmp___2 ; int tmp___4 ; int tmp___6 ; unsigned char *tmp___7 ; int m ; int nn ; int o ; int v ; int done ; STACK *tmp___9 ; STACK *sk ; SSL_CIPHER *nc ; SSL_CIPHER *ec ; int tmp___11 ; { ret = -1; comp = (SSL_COMP *)((void *)0); ciphers = (STACK *)((void *)0); if (s->state == 8464) { s->first_packet = 1; s->state = 8465; } n = ssl3_get_message(s, 8465, 8466, 1, 16384L, & ok); if (! ok) { return ((int )n); } p = (unsigned char *)(s->init_buf)->data; d = p; s->client_version = ((int )(*(p + 0)) << 8) | (int )(*(p + 1)); p += 2; if (s->client_version < s->version) { ERR_put_error(20, 138, 267, (char const *)"s3_srvr.c", 667); if (s->client_version >> 8 == 3) { s->version = s->client_version; } al = 70; goto f_err; } memcpy((void * )((s->s3)->client_random), (void const * )p, 32U); p += 32; tmp = p; p ++; j = (int )(*tmp); s->hit = 0; if (j == 0) { tmp___0 = ssl_get_new_session(s, 1); if (! tmp___0) { goto err; } } else { i = ssl_get_prev_session(s, p, j); if (i == 1) { s->hit = 1; } else { if (i == -1) { goto err; } else { tmp___1 = ssl_get_new_session(s, 1); if (! tmp___1) { goto err; } } } } p += j; i = (int )(((unsigned int )(*(p + 0)) << 8) | (unsigned int )(*(p + 1))); p += 2; if (i == 0) { if (j != 0) { al = 47; ERR_put_error(20, 138, 183, (char const *)"s3_srvr.c", 712); goto f_err; } } if ((unsigned long )(p + i) > (unsigned long )(d + n)) { al = 50; ERR_put_error(20, 138, 159, (char const *)"s3_srvr.c", 719); goto f_err; } if (i > 0) { tmp___2 = ssl_bytes_to_cipher_list(s, p, i, & ciphers); if ((unsigned long )tmp___2 == (unsigned long )((void *)0)) { goto err; } } p += i; if (s->hit) { if (i > 0) { j = 0; id = ((s->session)->cipher)->id; i = 0; while (1) { tmp___4 = sk_num((STACK const *)ciphers); if (! (i < tmp___4)) { break; } c = (SSL_CIPHER *)sk_value((STACK const *)ciphers, i); if (c->id == id) { j = 1; break; } i ++; } if (j == 0) { if (s->options & 8UL) { tmp___6 = sk_num((STACK const *)ciphers); if (tmp___6 == 1) { (s->session)->cipher = (SSL_CIPHER *)sk_value((STACK const *)ciphers, 0); } else { al = 47; ERR_put_error(20, 138, 215, (char const *)"s3_srvr.c", 764); goto f_err; } } else { al = 47; ERR_put_error(20, 138, 215, (char const *)"s3_srvr.c", 764); goto f_err; } } } } tmp___7 = p; p ++; i = (int )(*tmp___7); q = p; j = 0; while (j < i) { if ((int )(*(p + j)) == 0) { break; } j ++; } p += i; if (j >= i) { al = 50; ERR_put_error(20, 138, 187, (char const *)"s3_srvr.c", 783); goto f_err; } (s->s3)->tmp.new_compression = (SSL_COMP const *)((void *)0); if ((unsigned long )(s->ctx)->comp_methods != (unsigned long )((void *)0)) { done = 0; nn = sk_num((STACK const *)(s->ctx)->comp_methods); m = 0; while (m < nn) { comp = (SSL_COMP *)sk_value((STACK const *)(s->ctx)->comp_methods, m); v = comp->id; o = 0; while (o < i) { if (v == (int )(*(q + o))) { done = 1; break; } o ++; } if (done) { break; } m ++; } if (done) { (s->s3)->tmp.new_compression = (SSL_COMP const *)comp; } else { comp = (SSL_COMP *)((void *)0); } } if (s->version == 768) { if ((unsigned long )p > (unsigned long )(d + n)) { al = 50; ERR_put_error(20, 138, 159, (char const *)"s3_srvr.c", 824); goto f_err; } } if (s->hit) { nc = (SSL_CIPHER *)((void *)0); ec = (SSL_CIPHER *)((void *)0); if (s->options & 2147483648UL) { sk = (s->session)->ciphers; i = 0; while (1) { tmp___11 = sk_num((STACK const *)sk); if (! (i < tmp___11)) { break; } c = (SSL_CIPHER *)sk_value((STACK const *)sk, i); if (c->algorithms & 65536UL) { nc = c; } if (c->algo_strength & 2UL) { ec = c; } i ++; } if ((unsigned long )nc != (unsigned long )((void *)0)) { (s->s3)->tmp.new_cipher = nc; } else { if ((unsigned long )ec != (unsigned long )((void *)0)) { (s->s3)->tmp.new_cipher = ec; } else { (s->s3)->tmp.new_cipher = (s->session)->cipher; } } } else { (s->s3)->tmp.new_cipher = (s->session)->cipher; } } else { if ((unsigned long )comp == (unsigned long )((void *)0)) { (s->session)->compress_meth = 0; } else { (s->session)->compress_meth = comp->id; } if ((unsigned long )(s->session)->ciphers != (unsigned long )((void *)0)) { sk_free((s->session)->ciphers); } (s->session)->ciphers = ciphers; if ((unsigned long )ciphers == (unsigned long )((void *)0)) { al = 47; ERR_put_error(20, 138, 182, (char const *)"s3_srvr.c", 841); goto f_err; } ciphers = (STACK *)((void *)0); tmp___9 = ssl_get_ciphers_by_id(s); c = ssl3_choose_cipher(s, (s->session)->ciphers, tmp___9); if ((unsigned long )c == (unsigned long )((void *)0)) { al = 40; ERR_put_error(20, 138, 193, (char const *)"s3_srvr.c", 851); goto f_err; } (s->s3)->tmp.new_cipher = c; } ret = 1; if (0) { f_err: ssl3_send_alert(s, 2, al); } err: if ((unsigned long )ciphers != (unsigned long )((void *)0)) { sk_free(ciphers); } return (ret); } }static int ssl3_send_server_hello(SSL *s ) { unsigned char *buf ; unsigned char *p ; unsigned char *d ; int i ; int sl ; unsigned long l ; unsigned long Time ; unsigned char *tmp ; unsigned char *tmp___0 ; unsigned char *tmp___1 ; unsigned char *tmp___2 ; unsigned char *tmp___3 ; unsigned char *tmp___4 ; unsigned char *tmp___5 ; unsigned char *tmp___6 ; unsigned char *tmp___7 ; unsigned char *tmp___8 ; int tmp___9 ; { if (s->state == 8496) { buf = (unsigned char *)(s->init_buf)->data; p = (s->s3)->server_random; Time = (unsigned long )time((time_t *)((void *)0)); tmp = p; p ++; (*tmp) = (unsigned char )((Time >> 24) & 255UL); tmp___0 = p; p ++; (*tmp___0) = (unsigned char )((Time >> 16) & 255UL); tmp___1 = p; p ++; (*tmp___1) = (unsigned char )((Time >> 8) & 255UL); tmp___2 = p; p ++; (*tmp___2) = (unsigned char )(Time & 255UL); RAND_pseudo_bytes(p, (int )(32U - sizeof(Time))); p = buf + 4; d = p; tmp___3 = p; p ++; (*tmp___3) = (unsigned char )(s->version >> 8); tmp___4 = p; p ++; (*tmp___4) = (unsigned char )(s->version & 255); memcpy((void * )p, (void const * )((s->s3)->server_random), 32U); p += 32; if (! ((s->ctx)->session_cache_mode & 2)) { (s->session)->session_id_length = 0U; } sl = (int )(s->session)->session_id_length; tmp___5 = p; p ++; (*tmp___5) = (unsigned char )sl; memcpy((void * )p, (void const * )((s->session)->session_id), (unsigned int )sl); p += sl; i = ssl3_put_cipher_by_char((SSL_CIPHER const *)(s->s3)->tmp.new_cipher, p); p += i; if ((unsigned long )(s->s3)->tmp.new_compression == (unsigned long )((void *)0)) { tmp___6 = p; p ++; (*tmp___6) = 0; } else { tmp___7 = p; p ++; (*tmp___7) = (unsigned char )((s->s3)->tmp.new_compression)->id; } l = (unsigned long )(p - d); d = buf; tmp___8 = d; d ++; (*tmp___8) = 2; (*(d + 0)) = (unsigned char )((l >> 16) & 255UL); (*(d + 1)) = (unsigned char )((l >> 8) & 255UL); (*(d + 2)) = (unsigned char )(l & 255UL); d += 3; s->state = 4369; s->init_num = p - buf; s->init_off = 0; } tmp___9 = ssl3_do_write(s, 22); return (tmp___9); } }static int ssl3_send_server_done(SSL *s ) { unsigned char *p ; unsigned char *tmp ; unsigned char *tmp___0 ; unsigned char *tmp___1 ; unsigned char *tmp___2 ; int tmp___3 ; { if (s->state == 8560) { p = (unsigned char *)(s->init_buf)->data; tmp = p; p ++; (*tmp) = 14; tmp___0 = p; p ++; (*tmp___0) = 0; tmp___1 = p; p ++; (*tmp___1) = 0; tmp___2 = p; p ++; (*tmp___2) = 0; s->state = 8561; s->init_num = 4; s->init_off = 0; } tmp___3 = ssl3_do_write(s, 22); return (tmp___3); } }static int ssl3_send_server_key_exchange(SSL *s ) { unsigned char *q ; int j ; int num ; RSA *rsa ; unsigned char md_buf[36] ; unsigned int u ; DH *dh ; DH *dhp ; EVP_PKEY *pkey ; unsigned char *p ; unsigned char *d ; int al ; int i ; unsigned long type ; int n ; CERT *cert ; BIGNUM *r[4] ; int nr[4] ; int kn ; BUF_MEM *buf ; EVP_MD_CTX md_ctx ; int tmp ; int tmp___0 ; int tmp___2 ; int tmp___3 ; int tmp___4 ; EVP_MD const *tmp___5 ; int tmp___6 ; EVP_MD const *tmp___7 ; int tmp___8 ; unsigned char *tmp___9 ; int tmp___10 ; { dh = (DH *)((void *)0); if (s->state == 8528) { type = ((s->s3)->tmp.new_cipher)->algorithms & 31UL; cert = s->cert; buf = s->init_buf; r[3] = (BIGNUM *)((void *)0); r[2] = r[3]; r[1] = r[2]; r[0] = r[1]; n = 0; if (type & 1UL) { rsa = cert->rsa_tmp; if ((unsigned long )rsa == (unsigned long )((void *)0)) { if ((unsigned long )(s->cert)->rsa_tmp_cb != (unsigned long )((void *)0)) { if (((s->s3)->tmp.new_cipher)->algo_strength & 4UL) { tmp = 512; } else { tmp = 1024; } rsa = ((*((s->cert)->rsa_tmp_cb)))(s, (int )(((s->s3)->tmp.new_cipher)->algo_strength & 2UL), tmp); if ((unsigned long )rsa == (unsigned long )((void *)0)) { al = 40; ERR_put_error(20, 155, 1092, (char const *)"s3_srvr.c", 1043); goto f_err; } CRYPTO_add_lock(& rsa->references, 1, 9, (char const *)"s3_srvr.c", 1046); cert->rsa_tmp = rsa; } } if ((unsigned long )rsa == (unsigned long )((void *)0)) { al = 40; ERR_put_error(20, 155, 172, (char const *)"s3_srvr.c", 1052); goto f_err; } r[0] = rsa->n; r[1] = rsa->e; (s->s3)->tmp.use_rsa_tmp = 1; } else { if (type & 16UL) { dhp = cert->dh_tmp; if ((unsigned long )dhp == (unsigned long )((void *)0)) { if ((unsigned long )(s->cert)->dh_tmp_cb != (unsigned long )((void *)0)) { if (((s->s3)->tmp.new_cipher)->algo_strength & 4UL) { tmp___0 = 512; } else { tmp___0 = 1024; } dhp = ((*((s->cert)->dh_tmp_cb)))(s, (int )(((s->s3)->tmp.new_cipher)->algo_strength & 2UL), tmp___0); } } if ((unsigned long )dhp == (unsigned long )((void *)0)) { al = 40; ERR_put_error(20, 155, 171, (char const *)"s3_srvr.c", 1072); goto f_err; } if ((unsigned long )(s->s3)->tmp.dh != (unsigned long )((void *)0)) { DH_free(dh); ERR_put_error(20, 155, 157, (char const *)"s3_srvr.c", 1079); goto err; } dh = (DH *)ASN1_dup((int (*)())(& i2d_DHparams), (char *(*)())(& d2i_DHparams), (char *)dhp); if ((unsigned long )dh == (unsigned long )((void *)0)) { ERR_put_error(20, 155, 5, (char const *)"s3_srvr.c", 1085); goto err; } (s->s3)->tmp.dh = dh; if ((unsigned long )dhp->pub_key == (unsigned long )((void *)0)) { goto _L; } else { if ((unsigned long )dhp->priv_key == (unsigned long )((void *)0)) { goto _L; } else { if (s->options & 1048576UL) { _L: tmp___2 = DH_generate_key(dh); if (! tmp___2) { ERR_put_error(20, 155, 5, (char const *)"s3_srvr.c", 1096); goto err; } } else { dh->pub_key = BN_dup((BIGNUM const *)dhp->pub_key); dh->priv_key = BN_dup((BIGNUM const *)dhp->priv_key); if ((unsigned long )dh->pub_key == (unsigned long )((void *)0)) { ERR_put_error(20, 155, 5, (char const *)"s3_srvr.c", 1108); goto err; } else { if ((unsigned long )dh->priv_key == (unsigned long )((void *)0)) { ERR_put_error(20, 155, 5, (char const *)"s3_srvr.c", 1108); goto err; } } } } } r[0] = dh->p; r[1] = dh->g; r[2] = dh->pub_key; } else { al = 40; ERR_put_error(20, 155, 250, (char const *)"s3_srvr.c", 1120); goto f_err; } } i = 0; while ((unsigned long )r[i] != (unsigned long )((void *)0)) { tmp___3 = BN_num_bits((BIGNUM const *)r[i]); nr[i] = (tmp___3 + 7) / 8; n += 2 + nr[i]; i ++; } if (((s->s3)->tmp.new_cipher)->algorithms & 256UL) { pkey = (EVP_PKEY *)((void *)0); kn = 0; } else { pkey = ssl_get_sign_pkey(s, (s->s3)->tmp.new_cipher); if ((unsigned long )pkey == (unsigned long )((void *)0)) { al = 50; goto f_err; } kn = EVP_PKEY_size(pkey); } tmp___4 = BUF_MEM_grow(buf, (n + 4) + kn); if (! tmp___4) { ERR_put_error(20, 155, 7, (char const *)"s3_srvr.c", 1147); goto err; } d = (unsigned char *)(s->init_buf)->data; p = d + 4; i = 0; while ((unsigned long )r[i] != (unsigned long )((void *)0)) { (*(p + 0)) = (unsigned char )((nr[i] >> 8) & 255); (*(p + 1)) = (unsigned char )(nr[i] & 255); p += 2; BN_bn2bin((BIGNUM const *)r[i], p); p += nr[i]; i ++; } if ((unsigned long )pkey != (unsigned long )((void *)0)) { if (pkey->type == 6) { q = md_buf; j = 0; num = 2; while (num > 0) { if (num == 2) { tmp___5 = (s->ctx)->md5; } else { tmp___5 = (s->ctx)->sha1; } EVP_DigestInit(& md_ctx, tmp___5); EVP_DigestUpdate(& md_ctx, (void const *)(& (s->s3)->client_random[0]), 32U); EVP_DigestUpdate(& md_ctx, (void const *)(& (s->s3)->server_random[0]), 32U); EVP_DigestUpdate(& md_ctx, (void const *)(d + 4), (unsigned int )n); EVP_DigestFinal(& md_ctx, q, (unsigned int *)(& i)); q += i; j += i; num --; } tmp___6 = RSA_sign(114, md_buf, (unsigned int )j, p + 2, & u, pkey->pkey.rsa); if (tmp___6 <= 0) { ERR_put_error(20, 155, 4, (char const *)"s3_srvr.c", 1185); goto err; } (*(p + 0)) = (unsigned char )((u >> 8) & 255U); (*(p + 1)) = (unsigned char )(u & 255U); p += 2; n = (int )((unsigned int )n + (u + 2U)); } else { if (pkey->type == 116) { tmp___7 = (EVP_MD const *)EVP_dss1(); EVP_DigestInit(& md_ctx, tmp___7); EVP_DigestUpdate(& md_ctx, (void const *)(& (s->s3)->client_random[0]), 32U); EVP_DigestUpdate(& md_ctx, (void const *)(& (s->s3)->server_random[0]), 32U); EVP_DigestUpdate(& md_ctx, (void const *)(d + 4), (unsigned int )n); tmp___8 = EVP_SignFinal(& md_ctx, p + 2, (unsigned int *)(& i), pkey); if (! tmp___8) { ERR_put_error(20, 155, 10, (char const *)"s3_srvr.c", 1204); goto err; } (*(p + 0)) = (unsigned char )((i >> 8) & 255); (*(p + 1)) = (unsigned char )(i & 255); p += 2; n += i + 2; } else { al = 40; ERR_put_error(20, 155, 251, (char const *)"s3_srvr.c", 1215); goto f_err; } } } tmp___9 = d; d ++; (*tmp___9) = 12; (*(d + 0)) = (unsigned char )((n >> 16) & 255); (*(d + 1)) = (unsigned char )((n >> 8) & 255); (*(d + 2)) = (unsigned char )(n & 255); d += 3; s->init_num = n + 4; s->init_off = 0; } s->state = 8529; tmp___10 = ssl3_do_write(s, 22); return (tmp___10); f_err: ssl3_send_alert(s, 2, al); err: return (-1); } }static int ssl3_send_certificate_request(SSL *s ) { unsigned char *p ; unsigned char *d ; int i ; int j ; int nl ; int off ; int n ; STACK *sk ; X509_NAME *name ; BUF_MEM *buf ; int tmp___0 ; int tmp___1 ; unsigned char *tmp___2 ; unsigned char *tmp___3 ; unsigned char *tmp___4 ; unsigned char *tmp___5 ; unsigned char *tmp___6 ; int tmp___7 ; { sk = (STACK *)((void *)0); if (s->state == 8544) { buf = s->init_buf; p = (unsigned char *)(buf->data + 4); d = p; p ++; n = ssl3_get_req_cert_type(s, p); (*(d + 0)) = (unsigned char )n; p += n; n ++; off = n; p += 2; n += 2; sk = SSL_get_client_CA_list(s); nl = 0; if ((unsigned long )sk != (unsigned long )((void *)0)) { i = 0; while (1) { tmp___1 = sk_num((STACK const *)sk); if (! (i < tmp___1)) { break; } name = (X509_NAME *)sk_value((STACK const *)sk, i); j = i2d_X509_NAME(name, (unsigned char **)((void *)0)); tmp___0 = BUF_MEM_grow(buf, ((4 + n) + j) + 2); if (! tmp___0) { ERR_put_error(20, 150, 7, (char const *)"s3_srvr.c", 1272); goto err; } p = (unsigned char *)(buf->data + (4 + n)); if (s->options & 536870912UL) { d = p; i2d_X509_NAME(name, & p); j -= 2; (*(d + 0)) = (unsigned char )((j >> 8) & 255); (*(d + 1)) = (unsigned char )(j & 255); d += 2; j += 2; n += j; nl += j; } else { (*(p + 0)) = (unsigned char )((j >> 8) & 255); (*(p + 1)) = (unsigned char )(j & 255); p += 2; i2d_X509_NAME(name, & p); n += 2 + j; nl += 2 + j; } i ++; } } p = (unsigned char *)(buf->data + (4 + off)); (*(p + 0)) = (unsigned char )((nl >> 8) & 255); (*(p + 1)) = (unsigned char )(nl & 255); p += 2; d = (unsigned char *)buf->data; tmp___2 = d; d ++; (*tmp___2) = 13; (*(d + 0)) = (unsigned char )((n >> 16) & 255); (*(d + 1)) = (unsigned char )((n >> 8) & 255); (*(d + 2)) = (unsigned char )(n & 255); d += 3; s->init_num = n + 4; s->init_off = 0; p = (unsigned char *)(s->init_buf)->data + s->init_num; tmp___3 = p; p ++; (*tmp___3) = 14; tmp___4 = p; p ++; (*tmp___4) = 0; tmp___5 = p; p ++; (*tmp___5) = 0; tmp___6 = p; p ++; (*tmp___6) = 0; s->init_num += 4; } tmp___7 = ssl3_do_write(s, 22); return (tmp___7); err: return (-1); } }static int ssl3_get_client_key_exchange(SSL *s ) { int i ; int al ; int ok ; long n ; unsigned long l ; unsigned char *p ; RSA *rsa ; EVP_PKEY *pkey ; BIGNUM *pub ; DH *dh_srvr ; { rsa = (RSA *)((void *)0); pkey = (EVP_PKEY *)((void *)0); pub = (BIGNUM *)((void *)0); n = ssl3_get_message(s, 8592, 8593, 16, 2048L, & ok); if (! ok) { return ((int )n); } p = (unsigned char *)(s->init_buf)->data; l = ((s->s3)->tmp.new_cipher)->algorithms; if (l & 1UL) { if ((s->s3)->tmp.use_rsa_tmp) { if ((unsigned long )s->cert != (unsigned long )((void *)0)) { if ((unsigned long )(s->cert)->rsa_tmp != (unsigned long )((void *)0)) { rsa = (s->cert)->rsa_tmp; } } if ((unsigned long )rsa == (unsigned long )((void *)0)) { al = 40; ERR_put_error(20, 139, 173, (char const *)"s3_srvr.c", 1365); goto f_err; } } else { pkey = (s->cert)->pkeys[0].privatekey; if ((unsigned long )pkey == (unsigned long )((void *)0)) { al = 40; ERR_put_error(20, 139, 168, (char const *)"s3_srvr.c", 1378); goto f_err; } else { if (pkey->type != 6) { al = 40; ERR_put_error(20, 139, 168, (char const *)"s3_srvr.c", 1378); goto f_err; } else { if ((unsigned long )pkey->pkey.rsa == (unsigned long )((void *)0)) { al = 40; ERR_put_error(20, 139, 168, (char const *)"s3_srvr.c", 1378); goto f_err; } } } rsa = pkey->pkey.rsa; } if (s->version > 768) { i = (int )(((unsigned int )(*(p + 0)) << 8) | (unsigned int )(*(p + 1))); p += 2; if (n != (long )(i + 2)) { if (s->options & 256UL) { p -= 2; } else { ERR_put_error(20, 139, 234, (char const *)"s3_srvr.c", 1392); goto err; } } else { n = (long )i; } } i = RSA_private_decrypt((int )n, p, p, rsa, 1); al = -1; if (i != 48) { al = 50; ERR_put_error(20, 139, 118, (char const *)"s3_srvr.c", 1409); } if (al == -1) { if ((int )(*(p + 0)) == s->client_version >> 8) { if (! ((int )(*(p + 1)) == (s->client_version & 255))) { goto _L; } } else { _L: if (s->options & 1024UL) { if ((int )(*(p + 0)) == s->version >> 8) { if (! ((int )(*(p + 1)) == (s->version & 255))) { al = 50; ERR_put_error(20, 139, 116, (char const *)"s3_srvr.c", 1425); goto f_err; } } else { al = 50; ERR_put_error(20, 139, 116, (char const *)"s3_srvr.c", 1425); goto f_err; } } else { al = 50; ERR_put_error(20, 139, 116, (char const *)"s3_srvr.c", 1425); goto f_err; } } } if (al != -1) { ERR_clear_error(); i = 48; (*(p + 0)) = (unsigned char )(s->client_version >> 8); (*(p + 1)) = (unsigned char )(s->client_version & 255); RAND_pseudo_bytes(p + 2, i - 2); } (s->session)->master_key_length = ((*(((s->method)->ssl3_enc)->generate_master_secret)))(s, (s->session)->master_key, p, i); memset((void *)p, 0, (unsigned int )i); } else { if (l & 22UL) { i = (int )(((unsigned int )(*(p + 0)) << 8) | (unsigned int )(*(p + 1))); p += 2; if (n != (long )(i + 2)) { if (s->options & 128UL) { p -= 2; i = (int )n; } else { ERR_put_error(20, 139, 148, (char const *)"s3_srvr.c", 1467); goto err; } } if (n == 0L) { al = 40; ERR_put_error(20, 139, 236, (char const *)"s3_srvr.c", 1480); goto f_err; } else { if ((unsigned long )(s->s3)->tmp.dh == (unsigned long )((void *)0)) { al = 40; ERR_put_error(20, 139, 171, (char const *)"s3_srvr.c", 1488); goto f_err; } else { dh_srvr = (s->s3)->tmp.dh; } } pub = BN_bin2bn((unsigned char const *)p, i, (BIGNUM *)((void *)0)); if ((unsigned long )pub == (unsigned long )((void *)0)) { ERR_put_error(20, 139, 130, (char const *)"s3_srvr.c", 1498); goto err; } i = DH_compute_key(p, pub, dh_srvr); if (i <= 0) { ERR_put_error(20, 139, 5, (char const *)"s3_srvr.c", 1506); goto err; } DH_free((s->s3)->tmp.dh); (s->s3)->tmp.dh = (DH *)((void *)0); BN_clear_free(pub); pub = (BIGNUM *)((void *)0); (s->session)->master_key_length = ((*(((s->method)->ssl3_enc)->generate_master_secret)))(s, (s->session)->master_key, p, i); memset((void *)p, 0, (unsigned int )i); } else { al = 40; ERR_put_error(20, 139, 249, (char const *)"s3_srvr.c", 1524); goto f_err; } } return (1); f_err: ssl3_send_alert(s, 2, al); err: return (-1); } }static int ssl3_get_cert_verify(SSL *s ) { EVP_PKEY *pkey ; unsigned char *p ; int al ; int ok ; int ret ; long n ; int type ; int i ; int j ; X509 *peer ; { pkey = (EVP_PKEY *)((void *)0); ret = 0; type = 0; n = ssl3_get_message(s, 8608, 8609, -1, 512L, & ok); if (! ok) { return ((int )n); } if ((unsigned long )(s->session)->peer != (unsigned long )((void *)0)) { peer = (s->session)->peer; pkey = X509_get_pubkey(peer); type = X509_certificate_type(peer, pkey); } else { peer = (X509 *)((void *)0); pkey = (EVP_PKEY *)((void *)0); } if ((s->s3)->tmp.message_type != 15) { (s->s3)->tmp.reuse_message = 1; if ((unsigned long )peer != (unsigned long )((void *)0)) { if (type | 16) { al = 10; ERR_put_error(20, 136, 174, (char const *)"s3_srvr.c", 1573); goto f_err; } } ret = 1; goto end; } if ((unsigned long )peer == (unsigned long )((void *)0)) { ERR_put_error(20, 136, 186, (char const *)"s3_srvr.c", 1582); al = 10; goto f_err; } if (! (type & 16)) { ERR_put_error(20, 136, 220, (char const *)"s3_srvr.c", 1589); al = 47; goto f_err; } if ((s->s3)->change_cipher_spec) { ERR_put_error(20, 136, 133, (char const *)"s3_srvr.c", 1596); al = 10; goto f_err; } p = (unsigned char *)(s->init_buf)->data; i = (int )(((unsigned int )(*(p + 0)) << 8) | (unsigned int )(*(p + 1))); p += 2; n -= 2L; if ((long )i > n) { ERR_put_error(20, 136, 159, (char const *)"s3_srvr.c", 1607); al = 50; goto f_err; } j = EVP_PKEY_size(pkey); if (i > j) { ERR_put_error(20, 136, 265, (char const *)"s3_srvr.c", 1615); al = 50; goto f_err; } else { if (n > (long )j) { ERR_put_error(20, 136, 265, (char const *)"s3_srvr.c", 1615); al = 50; goto f_err; } else { if (n <= 0L) { ERR_put_error(20, 136, 265, (char const *)"s3_srvr.c", 1615); al = 50; goto f_err; } } } if (pkey->type == 6) { i = RSA_verify(114, (s->s3)->tmp.cert_verify_md, 36U, p, (unsigned int )i, pkey->pkey.rsa); if (i < 0) { al = 51; ERR_put_error(20, 136, 118, (char const *)"s3_srvr.c", 1629); goto f_err; } if (i == 0) { al = 51; ERR_put_error(20, 136, 122, (char const *)"s3_srvr.c", 1635); goto f_err; } } else { if (pkey->type == 116) { j = DSA_verify(pkey->save_type, (unsigned char const *)(& (s->s3)->tmp.cert_verify_md[16]), 20, p, i, pkey->pkey.dsa); if (j <= 0) { al = 51; ERR_put_error(20, 136, 112, (char const *)"s3_srvr.c", 1651); goto f_err; } } else { ERR_put_error(20, 136, 157, (char const *)"s3_srvr.c", 1658); al = 43; goto f_err; } } ret = 1; if (0) { f_err: ssl3_send_alert(s, 2, al); } end: EVP_PKEY_free(pkey); return (ret); } }static int ssl3_get_client_certificate(SSL *s ) { int i ; int ok ; int al ; int ret ; X509 *x ; unsigned long l ; unsigned long nc ; unsigned long llen ; unsigned long n ; unsigned char *p ; unsigned char *d ; unsigned char *q ; STACK *sk ; int tmp ; int tmp___0 ; { ret = -1; x = (X509 *)((void *)0); sk = (STACK *)((void *)0); n = (unsigned long )ssl3_get_message(s, 8576, 8577, -1, 102400L, & ok); if (! ok) { return ((int )n); } if ((s->s3)->tmp.message_type == 16) { if (s->verify_mode & 1) { if (s->verify_mode & 2) { ERR_put_error(20, 137, 199, (char const *)"s3_srvr.c", 1701); al = 40; goto f_err; } } if (s->version > 768) { if ((s->s3)->tmp.cert_request) { ERR_put_error(20, 137, 233, (char const *)"s3_srvr.c", 1708); al = 10; goto f_err; } } (s->s3)->tmp.reuse_message = 1; return (1); } if ((s->s3)->tmp.message_type != 11) { al = 10; ERR_put_error(20, 137, 262, (char const *)"s3_srvr.c", 1719); goto f_err; } p = (unsigned char *)(s->init_buf)->data; d = p; sk = sk_new_null(); if ((unsigned long )sk == (unsigned long )((void *)0)) { ERR_put_error(20, 137, 33, (char const *)"s3_srvr.c", 1726); goto err; } llen = (((unsigned long )(*(p + 0)) << 16) | ((unsigned long )(*(p + 1)) << 8)) | (unsigned long )(*(p + 2)); p += 3; if (llen + 3UL != n) { al = 50; ERR_put_error(20, 137, 159, (char const *)"s3_srvr.c", 1734); goto f_err; } nc = 0UL; while (nc < llen) { l = (((unsigned long )(*(p + 0)) << 16) | ((unsigned long )(*(p + 1)) << 8)) | (unsigned long )(*(p + 2)); p += 3; if ((l + nc) + 3UL > llen) { al = 50; ERR_put_error(20, 137, 135, (char const *)"s3_srvr.c", 1743); goto f_err; } q = p; x = d2i_X509((X509 **)((void *)0), & p, (long )l); if ((unsigned long )x == (unsigned long )((void *)0)) { ERR_put_error(20, 137, 13, (char const *)"s3_srvr.c", 1751); goto err; } if ((unsigned long )p != (unsigned long )(q + l)) { al = 50; ERR_put_error(20, 137, 135, (char const *)"s3_srvr.c", 1757); goto f_err; } tmp = sk_push(sk, (char *)x); if (! tmp) { ERR_put_error(20, 137, 33, (char const *)"s3_srvr.c", 1762); goto err; } x = (X509 *)((void *)0); nc += l + 3UL; } tmp___0 = sk_num((STACK const *)sk); if (tmp___0 <= 0) { if (s->version == 768) { al = 40; ERR_put_error(20, 137, 176, (char const *)"s3_srvr.c", 1775); goto f_err; } else { if (s->verify_mode & 1) { if (s->verify_mode & 2) { ERR_put_error(20, 137, 199, (char const *)"s3_srvr.c", 1782); al = 40; goto f_err; } } } } else { i = ssl_verify_cert_chain(s, sk); if (! i) { al = ssl_verify_alarm_type(s->verify_result); ERR_put_error(20, 137, 178, (char const *)"s3_srvr.c", 1793); goto f_err; } } if ((unsigned long )(s->session)->peer != (unsigned long )((void *)0)) { X509_free((s->session)->peer); } (s->session)->peer = (X509 *)sk_shift(sk); (s->session)->verify_result = s->verify_result; if ((unsigned long )(s->session)->sess_cert == (unsigned long )((void *)0)) { (s->session)->sess_cert = ssl_sess_cert_new(); if ((unsigned long )(s->session)->sess_cert == (unsigned long )((void *)0)) { ERR_put_error(20, 137, 33, (char const *)"s3_srvr.c", 1810); goto err; } } if ((unsigned long )((s->session)->sess_cert)->cert_chain != (unsigned long )((void *)0)) { sk_pop_free(((s->session)->sess_cert)->cert_chain, (void (*)(void * ))(& X509_free)); } ((s->session)->sess_cert)->cert_chain = sk; sk = (STACK *)((void *)0); ret = 1; if (0) { f_err: ssl3_send_alert(s, 2, al); } err: if ((unsigned long )x != (unsigned long )((void *)0)) { X509_free(x); } if ((unsigned long )sk != (unsigned long )((void *)0)) { sk_pop_free(sk, (void (*)(void * ))(& X509_free)); } return (ret); } }int ssl3_send_server_certificate(SSL *s ) { unsigned long l ; X509 *x ; int tmp ; { if (s->state == 8512) { x = ssl_get_server_send_cert(s); if ((unsigned long )x == (unsigned long )((void *)0)) { ERR_put_error(20, 154, 157, (char const *)"s3_srvr.c", 1844); return (0); } l = ssl3_output_cert_chain(s, x); s->state = 8513; s->init_num = (int )l; s->init_off = 0; } tmp = ssl3_do_write(s, 22); return (tmp); } }
the_stack_data/125140593.c
/*** *NMKtoBAT.C - convert NMAKE.EXE output into a Windows 9x batch file * * Copyright (c) Microsoft Corporation. All rights reserved. * *Purpose: * The makefiles provided with the Microsoft Visual C++ (C/C++) Run-Time * Library Sources generate commands with multiple commands per line, * separated by ampersands (&). This program will convert such a * text file into a batch file which can be executed by the Windows 9x * command interpreter (COMMAND.COM) which does not recognize multiple * commands on a single line. * *******************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char **argv); #define MAXLINE 4096 char InBuf [ MAXLINE ] ; int main(int argc, char **argv) { /* * If any arguments are given, print a usage message and exit */ if ( argc != 1 || argv [ 1 ] ) { fprintf ( stderr , "Usage: nmk2bat < input > output\n" "This program takes no arguments\n" ) ; exit ( 1 ) ; } /* * Batch file should be terse */ printf ( "@echo off\n" ) ; /* * Process each input line */ while ( fgets ( InBuf , sizeof ( InBuf ) , stdin ) ) { char * pStart ; char * pFinish ; char * pNextPart ; pStart = InBuf ; pFinish = pStart + strlen ( pStart ) ; /* * Remove the trailing newline character from the * input buffer. This simplifies the line processing. */ if ( pFinish > pStart && pFinish [ -1 ] == '\n' ) pFinish [ -1 ] = '\0' ; /* * Process each part of the line. Parts are delimited * by ampersand characters with optional whitespace. */ do { /* * Skip initial whitespace */ while ( * pStart == ' ' || * pStart == '\t' ) ++ pStart ; /* * Find the next command separator or * the end of line, whichever comes first */ pNextPart = strchr ( pStart , '&' ) ; if ( ! pNextPart ) pNextPart = pStart + strlen ( pStart ) ; pFinish = pNextPart ; /* * Skip blank lines and blank parts of lines */ if ( pStart == pNextPart ) break ; /* * Skip the trailing whitespace */ while ( pFinish > pStart && ( pFinish [ -1 ] == ' ' || pFinish [ -1 ] == '\t' ) ) -- pFinish ; /* * Copy to stdout the characters between * the skipped initial whitespace and * the skipped trailing whitespace */ while ( pStart < pFinish ) putchar ( * pStart ++ ) ; putchar ( '\n' ) ; /* * We are done with this line when pNextPart * points to a null character (rather than a '&'). */ pStart = pNextPart ; } while ( * pStart ++ ) ; } return 0 ; }
the_stack_data/76700177.c
/* * fbtestXIVb.c * * compile with 'gcc -O2 -o fbtestXIVb fbtestXIVb.c' * run with './fbtestXIVb' * * http://raspberrycompote.blogspot.com/2015/01/low-level-graphics-on-raspberry-pi-part.html * http://raspberrycompote.blogspot.com/2015/01/low-level-graphics-on-raspberry-pi-part_27.html * * Original work by J-P Rosti (a.k.a -rst- and 'Raspberry Compote') * * Licensed under the Creative Commons Attribution 3.0 Unported License * (http://creativecommons.org/licenses/by/3.0/deed.en_US) * * Distributed in the hope that this will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <sys/mman.h> #include <linux/fb.h> #include <linux/kd.h> #include <linux/ioctl.h> // 'global' variables to store screen info int fbfd = 0; char *fbp = 0; struct fb_var_screeninfo vinfo; struct fb_fix_screeninfo finfo; int page_size = 0; int cur_page = 0; #define NUM_ELEMS 200 int xs[NUM_ELEMS]; int ys[NUM_ELEMS]; int dxs[NUM_ELEMS]; int dys[NUM_ELEMS]; // helper function to 'plot' a pixel in given color void put_pixel(int x, int y, int c) { // calculate the pixel's byte offset inside the buffer unsigned int pix_offset = x + y * finfo.line_length; // offset by the current buffer start pix_offset += cur_page * page_size; // now this is about the same as 'fbp[pix_offset] = value' *((char*)(fbp + pix_offset)) = c; } // helper function to draw a rectangle in given color void fill_rect(int x, int y, int w, int h, int c) { int cx, cy; for (cy = 0; cy < h; cy++) { for (cx = 0; cx < w; cx++) { put_pixel(x + cx, y + cy, c); } } } // helper to clear (fill with given color) the screen void clear_screen(int c) { memset(fbp + cur_page * page_size, c, page_size); } // helper function for drawing - no more need to go mess with // the main function when just want to change what to draw... void draw() { int i, x, y, w, h, dx, dy; // rectangle dimensions w = vinfo.yres / 10; h = w; // start position (upper left) x = 0; y = 0; int n; for (n = 0; n < NUM_ELEMS; n++) { int ex = rand() % (vinfo.xres - w); int ey = rand() % (vinfo.yres - h); xs[n] = ex; ys[n] = ey; int edx = (rand() % 10) + 1; int edy = (rand() % 10) + 1; dxs[n] = edx; dys[n] = edy; } // move step 'size' dx = 1; dy = 1; int fps = 60; int secs = 10; int vx, vy; // loop for a while for (i = 0; i < (fps * secs); i++) { // change page to draw to (between 0 and 1) cur_page = (cur_page + 1) % 2; // clear the previous image (= fill entire screen) clear_screen(0); for (n = 0; n < NUM_ELEMS; n++) { x = xs[n]; y = ys[n]; dx = dxs[n]; dy = dys[n]; // draw the bouncing rectangle fill_rect(x, y, w, h, (n % 15) + 1); // move the rectangle x = x + dx; y = y + dy; // check for display sides if ((x < 0) || (x > (vinfo.xres - w))) { dx = -dx; // reverse direction x = x + 2 * dx; // counteract the move already done above } // same for vertical dir if ((y < 0) || (y > (vinfo.yres - h))) { dy = -dy; y = y + 2 * dy; } xs[n] = x; ys[n] = y; dxs[n] = dx; dys[n] = dy; } // switch page vinfo.yoffset = cur_page * vinfo.yres; __u32 dummy = 0; ioctl(fbfd, FBIO_WAITFORVSYNC, &dummy); // would expect this order to work but tearing occurs... ioctl(fbfd, FBIOPAN_DISPLAY, &vinfo); } } // application entry point int main(int argc, char* argv[]) { struct fb_var_screeninfo orig_vinfo; long int screensize = 0; // Open the framebuffer file for reading and writing fbfd = open("/dev/fb0", O_RDWR); if (fbfd == -1) { printf("Error: cannot open framebuffer device.\n"); return(1); } // Get variable screen information if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { printf("Error reading variable information.\n"); } // Store for reset (copy vinfo to vinfo_orig) memcpy(&orig_vinfo, &vinfo, sizeof(struct fb_var_screeninfo)); // Change variable info vinfo.bits_per_pixel = 8; vinfo.xres = 960; vinfo.yres = 540; vinfo.xres_virtual = vinfo.xres; vinfo.yres_virtual = vinfo.yres * 2; if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &vinfo)) { printf("Error setting variable information.\n"); } // hide cursor char *kbfds = "/dev/tty"; int kbfd = open(kbfds, O_WRONLY); if (kbfd >= 0) { ioctl(kbfd, KDSETMODE, KD_GRAPHICS); } else { printf("Could not open %s.\n", kbfds); } // Get fixed screen information if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { printf("Error reading fixed information.\n"); } page_size = finfo.line_length * vinfo.yres; // map fb to user mem screensize = finfo.smem_len; fbp = (char*)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if ((int)fbp == -1) { printf("Failed to mmap\n"); } else { // draw... draw(); //sleep(5); } // unmap fb file from memory munmap(fbp, screensize); // reset cursor if (kbfd >= 0) { ioctl(kbfd, KDSETMODE, KD_TEXT); // close kb file close(kbfd); } // reset the display mode if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_vinfo)) { printf("Error re-setting variable information.\n"); } // close fb file close(fbfd); return 0; }
the_stack_data/1000518.c
// REQUIRES: clang-driver // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fblocks -fbuiltin -fmath-errno -fcommon -fpascal-strings -fsplit-stack %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s // RUN: %clang -### -S -fasm -fblocks -fbuiltin -fno-math-errno -fcommon -fpascal-strings -fno-asm -fno-blocks -fno-builtin -fmath-errno -fno-common -fno-pascal-strings -fno-show-source-location -fshort-enums %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s // CHECK-OPTIONS1: -split-stacks // CHECK-OPTIONS1: -fgnu-keywords // CHECK-OPTIONS1: -fblocks // CHECK-OPTIONS1: -fpascal-strings // CHECK-OPTIONS2: -fmath-errno // CHECK-OPTIONS2: -fno-gnu-keywords // CHECK-OPTIONS2: -fno-builtin // CHECK-OPTIONS2: -fshort-enums // CHECK-OPTIONS2: -fno-common // CHECK-OPTIONS2: -fno-show-source-location // RUN: %clang -### -S -Wwrite-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS1 %s // WRITE-STRINGS1: -fconst-strings // RUN: %clang -### -S -Wwrite-strings -Wno-write-strings %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS2 %s // WRITE-STRINGS2-NOT: -fconst-strings // RUN: %clang -### -S -Wwrite-strings -w %s 2>&1 | FileCheck -check-prefix=WRITE-STRINGS3 %s // WRITE-STRINGS3-NOT: -fconst-strings // RUN: %clang -### -x c++ -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s // RUN: %clang -### -x c++ -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s // RUN: %clang -### -x c++ -c -Wno-deprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s // RUN: %clang -### -x c++ -c -Wno-deprecated -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s // RUN: %clang -### -x c++ -c -w %s 2>&1 | FileCheck -check-prefix=DEPRECATED-ON-CHECK %s // RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s // RUN: %clang -### -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s // DEPRECATED-ON-CHECK: -fdeprecated-macro // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro // RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s // RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s // RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s // FP-CONTRACT-FAST-CHECK: -ffp-contract=fast // FP-CONTRACT-OFF-CHECK: -ffp-contract=off // RUN: %clang -### -S -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s // RUN: %clang -### -S -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s // RUN: %clang -### -S -fno-unroll-loops -funroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-UNROLL-LOOPS %s // RUN: %clang -### -S -funroll-loops -fno-unroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-UNROLL-LOOPS %s // CHECK-UNROLL-LOOPS: "-funroll-loops" // CHECK-NO-UNROLL-LOOPS: "-fno-unroll-loops" // RUN: %clang -### -S -freroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-REROLL-LOOPS %s // RUN: %clang -### -S -fno-reroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-REROLL-LOOPS %s // RUN: %clang -### -S -fno-reroll-loops -freroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-REROLL-LOOPS %s // RUN: %clang -### -S -freroll-loops -fno-reroll-loops %s 2>&1 | FileCheck -check-prefix=CHECK-NO-REROLL-LOOPS %s // CHECK-REROLL-LOOPS: "-freroll-loops" // CHECK-NO-REROLL-LOOPS-NOT: "-freroll-loops" // RUN: %clang -### -S -fprofile-sample-accurate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-SAMPLE-ACCURATE %s // CHECK-PROFILE-SAMPLE-ACCURATE: "-fprofile-sample-accurate" // RUN: %clang -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s // CHECK-SAMPLE-PROFILE: "-fprofile-sample-use={{.*}}/file.prof" // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s // CHECK-AUTO-PROFILE: "-fprofile-sample-use={{.*}}/file.prof" // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-profile-sample-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE %s // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-auto-profile %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AUTO-PROFILE %s // CHECK-NO-AUTO-PROFILE-NOT: "-fprofile-sample-use={{.*}}/file.prof" // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-profile-sample-use -fauto-profile %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s // RUN: %clang -### -S -fauto-profile=%S/Inputs/file.prof -fno-auto-profile -fprofile-sample-use %s 2>&1 | FileCheck -check-prefix=CHECK-AUTO-PROFILE %s // RUN: %clang -### -S -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-ARCS %s // RUN: %clang -### -S -fno-profile-arcs -fprofile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-ARCS %s // RUN: %clang -### -S -fno-profile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-ARCS %s // RUN: %clang -### -S -fprofile-arcs -fno-profile-arcs %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-ARCS %s // CHECK-PROFILE-ARCS: "-femit-coverage-data" // CHECK-NO-PROFILE-ARCS-NOT: "-femit-coverage-data" // RUN: %clang -### -S -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR-UNUSED %s // RUN: %clang -### -S -ftest-coverage -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR-UNUSED %s // RUN: %clang -### -S -fprofile-arcs -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR %s // RUN: %clang -### -S --coverage -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR %s // RUN: %clang -### -S -fprofile-arcs -fno-profile-arcs -fprofile-dir=abc %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DIR-NEITHER %s // CHECK-PROFILE-DIR: "-coverage-data-file" "abc // CHECK-PROFILE-DIR-UNUSED: argument unused // CHECK-PROFILE-DIR-UNUSED-NOT: "-coverage-data-file" "abc // CHECK-PROFILE-DIR-NEITHER-NOT: argument unused // RUN: %clang_cl -### /c --coverage /Fo/foo/bar.obj -- %s 2>&1 | FileCheck -check-prefix=CHECK-GCNO-LOCATION %s // CHECK-GCNO-LOCATION: "-coverage-notes-file" "{{.*}}/foo/bar.gcno" // RUN: %clang -### -fprofile-arcs -ftest-coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s // RUN: %clang -### --coverage %s 2>&1 | FileCheck -check-prefix=CHECK-u %s // CHECK-u-NOT: "-u{{.*}}" // RUN: %clang -### -S -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-LLVM %s // RUN: %clang -### -S -fprofile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s // RUN: %clang -### -S -fprofile-generate=/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-DIR %s // RUN: %clang -### -S -fprofile-instr-generate=/tmp/somefile.profraw %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s // RUN: %clang -### -S -fprofile-generate -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate -fprofile-use=dir %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-use=dir %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fprofile-use=dir %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate=dir -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate=dir -fprofile-use=dir %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate=dir -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-generate=dir -fprofile-instr-use=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s // RUN: %clang -### -S -fprofile-instr-generate=file -fno-profile-instr-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GENERATE %s // RUN: %clang -### -S -fprofile-instr-generate -fprofile-generate=file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GENERATE %s // RUN: %clang -### -S -fprofile-generate=dir -fno-profile-generate %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-GEN %s // RUN: %clang -### -S -fprofile-instr-use=file -fno-profile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s // RUN: %clang -### -S -fprofile-instr-use=file -fno-profile-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s // RUN: %clang -### -S -fprofile-use=file -fno-profile-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s // RUN: %clang -### -S -fprofile-use=file -fno-profile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-USE %s // RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s // RUN: %clang -### -S -fprofile-remapping-file foo/bar.txt %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-REMAP %s // RUN: %clang -### -S -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR %s // RUN: %clang -### -flto -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR-LTO %s // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" // CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm" // CHECK-PROFILE-GENERATE-DIR: "-fprofile-instrument-path=/some/dir{{/|\\\\}}{{.*}}" // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw" // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}' // CHECK-NO-MIX-GENERATE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}' // CHECK-DISABLE-GEN-NOT: "-fprofile-instrument=clang" // CHECK-DISABLE-USE-NOT: "-fprofile-instr-use" // CHECK-COVERAGE-AND-GEN: '-fcoverage-mapping' only allowed with '-fprofile-instr-generate' // CHECK-DISABLE-COVERAGE-NOT: "-fcoverage-mapping" // CHECK-PROFILE-REMAP: "-fprofile-remapping-file=foo/bar.txt" // CHECK-ORDERFILE-INSTR: "-forder-file-instrumentation" // CHECK-ORDERFILE-INSTR: "-enable-order-file-instrumentation" // CHECK-ORDERFILE-INSTR-LTO: "-forder-file-instrumentation" // CHECK-ORDERFILE-INSTR-LTO-NOT: "-enable-order-file-instrumentation" // RUN: %clang -### -S -fprofile-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s // RUN: %clang -### -S -fprofile-instr-use %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s // RUN: mkdir -p %t.d/some/dir // RUN: %clang -### -S -fprofile-use=%t.d/some/dir %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-DIR %s // RUN: %clang -### -S -fprofile-instr-use=/tmp/somefile.prof %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s // CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata" // CHECK-PROFILE-USE-DIR: "-fprofile-instrument-use-path={{.*}}.d/some/dir{{/|\\\\}}default.profdata" // CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof" // RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -fvectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -ftree-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-tree-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-tree-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -ftree-vectorize -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -fno-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -O1 -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S -Ofast %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // RUN: %clang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s // CHECK-VECTORIZE: "-vectorize-loops" // CHECK-NO-VECTORIZE-NOT: "-vectorize-loops" // RUN: %clang -### -S -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -fslp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -ftree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-tree-slp-vectorize -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-tree-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -ftree-slp-vectorize -fno-slp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -Oz %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -fno-slp-vectorize -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -O1 -fslp-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S -Ofast %s 2>&1 | FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // RUN: %clang -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s // CHECK-SLP-VECTORIZE: "-vectorize-slp" // CHECK-NO-SLP-VECTORIZE-NOT: "-vectorize-slp" // RUN: %clang -### -S -fextended-identifiers %s 2>&1 | FileCheck -check-prefix=CHECK-EXTENDED-IDENTIFIERS %s // RUN: not %clang -### -S -fno-extended-identifiers %s 2>&1 | FileCheck -check-prefix=CHECK-NO-EXTENDED-IDENTIFIERS %s // CHECK-EXTENDED-IDENTIFIERS: "-cc1" // CHECK-EXTENDED-IDENTIFIERS-NOT: "-fextended-identifiers" // CHECK-NO-EXTENDED-IDENTIFIERS: error: unsupported option '-fno-extended-identifiers' // RUN: %clang -### -S -frounding-math %s 2>&1 | FileCheck -check-prefix=CHECK-ROUNDING-MATH %s // CHECK-ROUNDING-MATH: "-cc1" // CHECK-ROUNDING-MATH: "-frounding-math" // CHECK-ROUNDING-MATH-NOT: "-fno-rounding-math" // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-ROUNDING-MATH-NOT %s // RUN: %clang -### -S -ffp-model=imprecise %s 2>&1 | FileCheck -check-prefix=CHECK-FPMODEL %s // CHECK-FPMODEL: unsupported argument 'imprecise' to option 'ffp-model=' // RUN: %clang -### -S -ffp-model=precise %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-model=strict %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-model=fast %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-exception-behavior=trap %s 2>&1 | FileCheck -check-prefix=CHECK-FPEB %s // CHECK-FPEB: unsupported argument 'trap' to option 'ffp-exception-behavior=' // RUN: %clang -### -S -ffp-exception-behavior=maytrap %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-exception-behavior=ignore %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -ffp-exception-behavior=strict %s 2>&1 | FileCheck -check-prefix=IGNORE %s // RUN: %clang -### -S -fno-pascal-strings -mpascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-M-PASCAL-STRINGS %s // CHECK-M-PASCAL-STRINGS: "-fpascal-strings" // RUN: %clang -### -S -fpascal-strings -mno-pascal-strings %s 2>&1 | FileCheck -check-prefix=CHECK-NO-M-PASCAL-STRINGS %s // CHECK-NO-M-PASCAL-STRINGS-NOT: "-fpascal-strings" // RUN: %clang -### -S -O4 %s 2>&1 | FileCheck -check-prefix=CHECK-MAX-O %s // CHECK-MAX-O: warning: -O4 is equivalent to -O3 // CHECK-MAX-O: -O3 // RUN: %clang -S -O20 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-O %s // CHECK-INVALID-O: warning: optimization level '-O20' is not supported; using '-O3' instead // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1' // RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s // CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1' // Test that we don't error on these. // RUN: %clang -### -S -Werror \ // RUN: -falign-functions -falign-functions=2 -fno-align-functions \ // RUN: -fasynchronous-unwind-tables -fno-asynchronous-unwind-tables \ // RUN: -fbuiltin -fno-builtin \ // RUN: -fdiagnostics-show-location=once \ // RUN: -ffloat-store -fno-float-store \ // RUN: -feliminate-unused-debug-types -fno-eliminate-unused-debug-types \ // RUN: -fgcse -fno-gcse \ // RUN: -fident -fno-ident \ // RUN: -fimplicit-templates -fno-implicit-templates \ // RUN: -finput-charset=UTF-8 \ // RUN: -fexec-charset=UTF-8 \ // RUN: -fivopts -fno-ivopts \ // RUN: -fnon-call-exceptions -fno-non-call-exceptions \ // RUN: -fno-semantic-interposition \ // RUN: -fpermissive -fno-permissive \ // RUN: -fdefer-pop -fno-defer-pop \ // RUN: -fprefetch-loop-arrays -fno-prefetch-loop-arrays \ // RUN: -fprofile-correction -fno-profile-correction \ // RUN: -fprofile-values -fno-profile-values \ // RUN: -frounding-math -fno-rounding-math \ // RUN: -fsee -fno-see \ // RUN: -ftracer -fno-tracer \ // RUN: -funroll-all-loops -fno-unroll-all-loops \ // RUN: -fuse-ld=gold \ // RUN: -fno-builtin-foobar \ // RUN: -fno-builtin-strcat -fno-builtin-strcpy \ // RUN: -fno-var-tracking \ // RUN: -fno-unsigned-char \ // RUN: -fno-signed-char \ // RUN: -fstrength-reduce -fno-strength-reduce \ // RUN: -finline-limit=1000 \ // RUN: -finline-limit \ // RUN: -flto=1 \ // RUN: -falign-labels \ // RUN: -falign-labels=100 \ // RUN: -falign-loops \ // RUN: -falign-loops=100 \ // RUN: -falign-jumps \ // RUN: -falign-jumps=100 \ // RUN: -fexcess-precision=100 \ // RUN: -fbranch-count-reg \ // RUN: -fcaller-saves \ // RUN: -fno-default-inline -fdefault-inline \ // RUN: -fgcse-after-reload \ // RUN: -fgcse-las \ // RUN: -fgcse-sm \ // RUN: -fipa-cp \ // RUN: -finline-functions-called-once \ // RUN: -fmodulo-sched \ // RUN: -fmodulo-sched-allow-regmoves \ // RUN: -fpeel-loops \ // RUN: -frename-registers \ // RUN: -fschedule-insns2 \ // RUN: -fsingle-precision-constant \ // RUN: -ftree_loop_im \ // RUN: -ftree_loop_ivcanon \ // RUN: -ftree_loop_linear \ // RUN: -funsafe-loop-optimizations \ // RUN: -fuse-linker-plugin \ // RUN: -fvect-cost-model \ // RUN: -fvariable-expansion-in-unroller \ // RUN: -fweb \ // RUN: -fwhole-program \ // RUN: -fno-tree-dce -ftree-dce \ // RUN: -fno-tree-ter -ftree-ter \ // RUN: -fno-tree-vrp -ftree-vrp \ // RUN: -fno-delete-null-pointer-checks -fdelete-null-pointer-checks \ // RUN: -fno-inline-small-functions -finline-small-functions \ // RUN: -fno-fat-lto-objects -ffat-lto-objects \ // RUN: -fno-merge-constants -fmerge-constants \ // RUN: -fno-merge-all-constants -fmerge-all-constants \ // RUN: -fno-caller-saves -fcaller-saves \ // RUN: -fno-reorder-blocks -freorder-blocks \ // RUN: -fno-schedule-insns2 -fschedule-insns2 \ // RUN: -fno-stack-check \ // RUN: -fno-check-new -fcheck-new \ // RUN: -ffriend-injection \ // RUN: -fno-implement-inlines -fimplement-inlines \ // RUN: -fstack-check \ // RUN: -fforce-addr \ // RUN: -malign-functions=100 \ // RUN: -malign-loops=100 \ // RUN: -malign-jumps=100 \ // RUN: %s 2>&1 | FileCheck --check-prefix=IGNORE %s // IGNORE-NOT: error: unknown argument // Test that the warning is displayed on these. // RUN: %clang -### \ // RUN: -finline-limit=1000 \ // RUN: -finline-limit \ // RUN: -fexpensive-optimizations \ // RUN: -fno-expensive-optimizations \ // RUN: -fno-defer-pop \ // RUN: -fkeep-inline-functions \ // RUN: -fno-keep-inline-functions \ // RUN: -freorder-blocks \ // RUN: -ffloat-store \ // RUN: -fgcse \ // RUN: -fivopts \ // RUN: -fprefetch-loop-arrays \ // RUN: -fprofile-correction \ // RUN: -fprofile-values \ // RUN: -fschedule-insns \ // RUN: -fsignaling-nans \ // RUN: -fstrength-reduce \ // RUN: -ftracer \ // RUN: -funroll-all-loops \ // RUN: -funswitch-loops \ // RUN: -flto=1 \ // RUN: -falign-labels \ // RUN: -falign-labels=100 \ // RUN: -falign-loops \ // RUN: -falign-loops=100 \ // RUN: -falign-jumps \ // RUN: -falign-jumps=100 \ // RUN: -fexcess-precision=100 \ // RUN: -fbranch-count-reg \ // RUN: -fcaller-saves \ // RUN: -fno-default-inline \ // RUN: -fgcse-after-reload \ // RUN: -fgcse-las \ // RUN: -fgcse-sm \ // RUN: -fipa-cp \ // RUN: -finline-functions-called-once \ // RUN: -fmodulo-sched \ // RUN: -fmodulo-sched-allow-regmoves \ // RUN: -fpeel-loops \ // RUN: -frename-registers \ // RUN: -fschedule-insns2 \ // RUN: -fsingle-precision-constant \ // RUN: -ftree_loop_im \ // RUN: -ftree_loop_ivcanon \ // RUN: -ftree_loop_linear \ // RUN: -funsafe-loop-optimizations \ // RUN: -fuse-linker-plugin \ // RUN: -fvect-cost-model \ // RUN: -fvariable-expansion-in-unroller \ // RUN: -fweb \ // RUN: -fwhole-program \ // RUN: -fcaller-saves \ // RUN: -freorder-blocks \ // RUN: -ffat-lto-objects \ // RUN: -fmerge-constants \ // RUN: -finline-small-functions \ // RUN: -ftree-dce \ // RUN: -ftree-ter \ // RUN: -ftree-vrp \ // RUN: -fno-devirtualize \ // RUN: -fno-devirtualize-speculatively \ // RUN: -fslp-vectorize-aggressive \ // RUN: -fno-slp-vectorize-aggressive \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-WARNING %s // CHECK-WARNING-DAG: optimization flag '-finline-limit=1000' is not supported // CHECK-WARNING-DAG: optimization flag '-finline-limit' is not supported // CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported // CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported // CHECK-WARNING-DAG: optimization flag '-ffloat-store' is not supported // CHECK-WARNING-DAG: optimization flag '-fgcse' is not supported // CHECK-WARNING-DAG: optimization flag '-fivopts' is not supported // CHECK-WARNING-DAG: optimization flag '-fprefetch-loop-arrays' is not supported // CHECK-WARNING-DAG: optimization flag '-fprofile-correction' is not supported // CHECK-WARNING-DAG: optimization flag '-fprofile-values' is not supported // CHECK-WARNING-DAG: optimization flag '-fschedule-insns' is not supported // CHECK-WARNING-DAG: optimization flag '-fsignaling-nans' is not supported // CHECK-WARNING-DAG: optimization flag '-fstrength-reduce' is not supported // CHECK-WARNING-DAG: optimization flag '-ftracer' is not supported // CHECK-WARNING-DAG: optimization flag '-funroll-all-loops' is not supported // CHECK-WARNING-DAG: optimization flag '-funswitch-loops' is not supported // CHECK-WARNING-DAG: unsupported argument '1' to option 'flto=' // CHECK-WARNING-DAG: optimization flag '-falign-labels' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-labels=100' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-loops' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-loops=100' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-jumps' is not supported // CHECK-WARNING-DAG: optimization flag '-falign-jumps=100' is not supported // CHECK-WARNING-DAG: optimization flag '-fexcess-precision=100' is not supported // CHECK-WARNING-DAG: optimization flag '-fbranch-count-reg' is not supported // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-default-inline' is not supported // CHECK-WARNING-DAG: optimization flag '-fgcse-after-reload' is not supported // CHECK-WARNING-DAG: optimization flag '-fgcse-las' is not supported // CHECK-WARNING-DAG: optimization flag '-fgcse-sm' is not supported // CHECK-WARNING-DAG: optimization flag '-fipa-cp' is not supported // CHECK-WARNING-DAG: optimization flag '-finline-functions-called-once' is not supported // CHECK-WARNING-DAG: optimization flag '-fmodulo-sched' is not supported // CHECK-WARNING-DAG: optimization flag '-fmodulo-sched-allow-regmoves' is not supported // CHECK-WARNING-DAG: optimization flag '-fpeel-loops' is not supported // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not supported // CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported // CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported // CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not supported // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported // CHECK-WARNING-DAG: optimization flag '-fvariable-expansion-in-unroller' is not supported // CHECK-WARNING-DAG: optimization flag '-fweb' is not supported // CHECK-WARNING-DAG: optimization flag '-fwhole-program' is not supported // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported // CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported // CHECK-WARNING-DAG: optimization flag '-ffat-lto-objects' is not supported // CHECK-WARNING-DAG: optimization flag '-fmerge-constants' is not supported // CHECK-WARNING-DAG: optimization flag '-finline-small-functions' is not supported // CHECK-WARNING-DAG: optimization flag '-ftree-dce' is not supported // CHECK-WARNING-DAG: optimization flag '-ftree-ter' is not supported // CHECK-WARNING-DAG: optimization flag '-ftree-vrp' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-devirtualize' is not supported // CHECK-WARNING-DAG: optimization flag '-fno-devirtualize-speculatively' is not supported // CHECK-WARNING-DAG: the flag '-fslp-vectorize-aggressive' has been deprecated and will be ignored // CHECK-WARNING-DAG: the flag '-fno-slp-vectorize-aggressive' has been deprecated and will be ignored // Test that we mute the warning on these // RUN: %clang -### -finline-limit=1000 -Wno-invalid-command-line-argument \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-WARNING1 %s // RUN: %clang -### -finline-limit -Wno-invalid-command-line-argument \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-WARNING2 %s // RUN: %clang -### -finline-limit \ // RUN: -Winvalid-command-line-argument -Wno-ignored-optimization-argument \ // RUN: %s 2>&1 | FileCheck --check-prefix=CHECK-NO-WARNING2 %s // CHECK-NO-WARNING1-NOT: optimization flag '-finline-limit=1000' is not supported // CHECK-NO-WARNING2-NOT: optimization flag '-finline-limit' is not supported // Test that an ignored optimization argument only prints 1 warning, // not both a warning about not claiming the arg, *and* about not supporting // the arg; and that adding -Wno-ignored-optimization silences the warning. // // RUN: %clang -### -fprofile-correction %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-WARNING3 %s // CHECK-NO-WARNING3: optimization flag '-fprofile-correction' is not supported // CHECK-NO-WARNING3-NOT: argument unused // RUN: %clang -### -fprofile-correction -Wno-ignored-optimization-argument %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-WARNING4 %s // CHECK-NO-WARNING4-NOT: not supported // CHECK-NO-WARNING4-NOT: argument unused // RUN: %clang -### -S -fsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN1 %s // CHAR-SIGN1-NOT: -fno-signed-char // RUN: %clang -### -S -funsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN2 %s // CHAR-SIGN2: -fno-signed-char // RUN: %clang -### -S -fno-signed-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN3 %s // CHAR-SIGN3: -fno-signed-char // RUN: %clang -### -S -fno-unsigned-char %s 2>&1 | FileCheck -check-prefix=CHAR-SIGN4 %s // CHAR-SIGN4-NOT: -fno-signed-char // RUN: %clang -target x86_64-unknown-none-none -### -fshort-wchar -fno-short-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR1 -check-prefix=DELIMITERS %s // RUN: %clang -target x86_64-unknown-none-none -### -fno-short-wchar -fshort-wchar %s 2>&1 | FileCheck -check-prefix=CHECK-WCHAR2 -check-prefix=DELIMITERS %s // Make sure we don't match the -NOT lines with the linker invocation. // Delimiters match the start of the cc1 and the start of the linker lines // DELIMITERS: {{^ (\(in-process\)|")}} // CHECK-WCHAR1: -fwchar-type=int // CHECK-WCHAR1-NOT: -fwchar-type=short // CHECK-WCHAR2: -fwchar-type=short // CHECK-WCHAR2-NOT: -fwchar-type=int // DELIMITERS: {{^ *"}} // RUN: %clang -### -fno-experimental-new-pass-manager -fexperimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM --check-prefix=CHECK-NEW-PM %s // RUN: %clang -### -fexperimental-new-pass-manager -fno-experimental-new-pass-manager %s 2>&1 | FileCheck --check-prefix=CHECK-PM --check-prefix=CHECK-NO-NEW-PM %s // CHECK-PM-NOT: argument unused // CHECK-NEW-PM: -fexperimental-new-pass-manager // CHECK-NEW-PM-NOT: -fno-experimental-new-pass-manager // CHECK-NO-NEW-PM: -fno-experimental-new-pass-manager // CHECK-NO-NEW-PM-NOT: -fexperimental-new-pass-manager // RUN: %clang -### -S -fstrict-return %s 2>&1 | FileCheck -check-prefix=CHECK-STRICT-RETURN %s // RUN: %clang -### -S -fno-strict-return %s 2>&1 | FileCheck -check-prefix=CHECK-NO-STRICT-RETURN %s // CHECK-STRICT-RETURN-NOT: "-fno-strict-return" // CHECK-NO-STRICT-RETURN: "-fno-strict-return" // RUN: %clang -### -S -fno-debug-info-for-profiling -fdebug-info-for-profiling %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-DEBUG %s // RUN: %clang -### -S -fdebug-info-for-profiling -fno-debug-info-for-profiling %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PROFILE-DEBUG %s // CHECK-PROFILE-DEBUG: -fdebug-info-for-profiling // CHECK-NO-PROFILE-DEBUG-NOT: -fdebug-info-for-profiling // RUN: %clang -### -S -fallow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-ALLOW-PLACEHOLDERS %s // RUN: %clang -### -S -fno-allow-editor-placeholders %s 2>&1 | FileCheck -check-prefix=CHECK-NO-ALLOW-PLACEHOLDERS %s // CHECK-ALLOW-PLACEHOLDERS: -fallow-editor-placeholders // CHECK-NO-ALLOW-PLACEHOLDERS-NOT: -fallow-editor-placeholders // RUN: %clang -### -target x86_64-unknown-windows-msvc -fno-short-wchar %s 2>&1 | FileCheck -check-prefix CHECK-WINDOWS-ISO10646 %s // CHECK-WINDOWS-ISO10646: "-fwchar-type=int" // CHECK-WINDOWS-ISO10646: "-fsigned-wchar" // RUN: %clang -### -S -fcf-protection %s 2>&1 | FileCheck -check-prefix=CHECK-CF-PROTECTION-FULL %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-FULL %s // RUN: %clang -### -S -fcf-protection=full %s 2>&1 | FileCheck -check-prefix=CHECK-CF-PROTECTION-FULL %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-FULL %s // CHECK-CF-PROTECTION-FULL: -fcf-protection=full // CHECK-NO-CF-PROTECTION-FULL-NOT: -fcf-protection=full // RUN: %clang -### -S -fcf-protection=return %s 2>&1 | FileCheck -check-prefix=CHECK-CF-PROTECTION-RETURN %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-RETURN %s // CHECK-CF-PROTECTION-RETURN: -fcf-protection=return // CHECK-NO-CF-PROTECTION-RETURN-NOT: -fcf-protection=return // RUN: %clang -### -S -fcf-protection=branch %s 2>&1 | FileCheck -check-prefix=CHECK-CF-PROTECTION-BRANCH %s // RUN: %clang -### -S %s 2>&1 | FileCheck -check-prefix=CHECK-NO-CF-PROTECTION-BRANCH %s // CHECK-CF-PROTECTION-BRANCH: -fcf-protection=branch // CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch // RUN: %clang -### -S -fdebug-compilation-dir . %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // RUN: %clang -### -S -fdebug-compilation-dir=. %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // RUN: %clang -### -fdebug-compilation-dir . -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // RUN: %clang -### -fdebug-compilation-dir=. -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // CHECK-DEBUG-COMPILATION-DIR: "-fdebug-compilation-dir" "." // RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s // RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-NO-DISCARD-NAMES %s // CHECK-DISCARD-NAMES: "-discard-value-names" // CHECK-NO-DISCARD-NAMES-NOT: "-discard-value-names" // RUN: %clang -### -S -fmerge-all-constants %s 2>&1 | FileCheck -check-prefix=CHECK-MERGE-ALL-CONSTANTS %s // RUN: %clang -### -S -fno-merge-all-constants %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MERGE-ALL-CONSTANTS %s // RUN: %clang -### -S -fmerge-all-constants -fno-merge-all-constants %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MERGE-ALL-CONSTANTS %s // RUN: %clang -### -S -fno-merge-all-constants -fmerge-all-constants %s 2>&1 | FileCheck -check-prefix=CHECK-MERGE-ALL-CONSTANTS %s // CHECK-NO-MERGE-ALL-CONSTANTS-NOT: "-fmerge-all-constants" // CHECK-MERGE-ALL-CONSTANTS: "-fmerge-all-constants" // RUN: %clang -### -S -fdelete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NULL-POINTER-CHECKS %s // RUN: %clang -### -S -fno-delete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NO-NULL-POINTER-CHECKS %s // RUN: %clang -### -S -fdelete-null-pointer-checks -fno-delete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NO-NULL-POINTER-CHECKS %s // RUN: %clang -### -S -fno-delete-null-pointer-checks -fdelete-null-pointer-checks %s 2>&1 | FileCheck -check-prefix=CHECK-NULL-POINTER-CHECKS %s // CHECK-NO-NULL-POINTER-CHECKS: "-fno-delete-null-pointer-checks" // CHECK-NULL-POINTER-CHECKS-NOT: "-fno-delete-null-pointer-checks" // RUN: %clang -### -S -target x86_64-unknown-linux -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-gcc-switches -frecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -frecord-gcc-switches -fno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -fno-record-command-line -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES %s // RUN: %clang -### -S -target x86_64-unknown-linux -frecord-command-line -fno-record-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RECORD-GCC-SWITCHES %s // Test with a couple examples of non-ELF object file formats // RUN: %clang -### -S -target x86_64-unknown-macosx -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ERROR %s // RUN: %clang -### -S -target x86_64-unknown-windows -frecord-command-line %s 2>&1 | FileCheck -check-prefix=CHECK-RECORD-GCC-SWITCHES-ERROR %s // CHECK-RECORD-GCC-SWITCHES: "-record-command-line" // CHECK-NO-RECORD-GCC-SWITCHES-NOT: "-record-command-line" // CHECK-RECORD-GCC-SWITCHES-ERROR: error: unsupported option '-frecord-command-line' for target // RUN: %clang -### -S -ftrivial-auto-var-init=uninitialized %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-UNINIT %s // RUN: %clang -### -S -ftrivial-auto-var-init=pattern %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-PATTERN %s // RUN: %clang -### -S -ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-GOOD %s // RUN: %clang -### -S -ftrivial-auto-var-init=zero %s 2>&1 | FileCheck -check-prefix=CHECK-TRIVIAL-ZERO-BAD %s // CHECK-TRIVIAL-UNINIT-NOT: hasn't been enabled // CHECK-TRIVIAL-PATTERN-NOT: hasn't been enabled // CHECK-TRIVIAL-ZERO-GOOD-NOT: hasn't been enabled // CHECK-TRIVIAL-ZERO-BAD: hasn't been enabled // RUN: %clang -### -S -fno-temp-file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-TEMP-FILE %s // CHECK-NO-TEMP-FILE: "-fno-temp-file"
the_stack_data/29826391.c
int main() { int a = 5; int b = 2; int c = 6; a += b-c; return a; }
the_stack_data/82948977.c
/* * Write a program that reads from the console a sequence of n integer numbers * and returns the minimal, the maximal number, the sum and the average of all * numbers (displayed with 2 digits after the decimal point). The input starts * by the number n (alone in a line) followed by n lines, each holding an integer * number. The output is like in the examples below. Examples: input output input output 3 min = 1.00 2 min = -1.00 2 max = 5.00 -1 max = 4.00 5 sum = 8.00222 4 sum = 3.00 1 avg = 2.67 avg = 1.50 */ #include <stdio.h> int main() { int n; printf("Please enter positive integer: "); scanf("%d", &n); int i; double min, max, sum = 0, avg = 0; for (i = 1; i <= n; i++) { double currentNum; printf("num%d = ", i); scanf("%lf", &currentNum); if (i == 1) { min = currentNum; max = currentNum; } sum += currentNum; if (currentNum >= max) { max = currentNum; } if (currentNum <= min) { min = currentNum; } } avg = sum / n; printf("min = %.2f\n", min); printf("max = %.2f\n", max); printf("sum = %.2f\n", sum); printf("avg = %.2f\n", avg); return 0; }
the_stack_data/215769134.c
#ifndef TH_GENERIC_FILE #define TH_GENERIC_FILE "generic/SpatialReSampling.c" #else #ifndef MAX #define MAX(a,b) ( ((a)>(b)) ? (a) : (b) ) #endif #ifndef MIN #define MIN(a,b) ( ((a)<(b)) ? (a) : (b) ) #endif static int nn_(SpatialReSampling_updateOutput)(lua_State *L) { // get all params THTensor *input = luaT_checkudata(L, 2, torch_Tensor); int owidth = luaT_getfieldcheckint(L, 1, "owidth"); int oheight = luaT_getfieldcheckint(L, 1, "oheight"); THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); // check dims luaL_argcheck(L, input->nDimension == 3, 2, "3D tensor expected"); // dims int iwidth = input->size[2]; int iheight = input->size[1]; int ochannels = input->size[0]; // resize output THTensor_(resize3d)(output, ochannels, oheight, owidth); // select planes THTensor *outputPlane = THTensor_(new)(); THTensor *inputPlane = THTensor_(new)(); // mapping ratios float wratio = (float)(iwidth-1) / (owidth-1); float hratio = (float)(iheight-1) / (oheight-1); // resample each plane int k; for (k=0; k<ochannels; k++) { // get planes THTensor_(select)(inputPlane, input, 0, k); THTensor_(select)(outputPlane, output, 0, k); // for each plane, resample int x,y; for (y=0; y<oheight; y++) { for (x=0; x<owidth; x++) { // subpixel position: float ix = wratio*x; float iy = hratio*y; // 4 nearest neighbors: float ix_nw = floor(ix); float iy_nw = floor(iy); float ix_ne = ix_nw + 1; float iy_ne = iy_nw; float ix_sw = ix_nw; float iy_sw = iy_nw + 1; float ix_se = ix_nw + 1; float iy_se = iy_nw + 1; // get surfaces to each neighbor: float se = (ix-ix_nw)*(iy-iy_nw); float sw = (ix_ne-ix)*(iy-iy_ne); float ne = (ix-ix_sw)*(iy_sw-iy); float nw = (ix_se-ix)*(iy_se-iy); // weighted sum of neighbors: double sum = THTensor_(get2d)(inputPlane, iy_nw, ix_nw) * nw + THTensor_(get2d)(inputPlane, iy_ne, MIN(ix_ne,iwidth-1)) * ne + THTensor_(get2d)(inputPlane, MIN(iy_sw,iheight-1), ix_sw) * sw + THTensor_(get2d)(inputPlane, MIN(iy_se,iheight-1), MIN(ix_se,iwidth-1)) * se; // set output THTensor_(set2d)(outputPlane, y, x, sum); } } } // cleanup THTensor_(free)(inputPlane); THTensor_(free)(outputPlane); return 1; } static int nn_(SpatialReSampling_updateGradInput)(lua_State *L) { // get all params THTensor *input = luaT_checkudata(L, 2, torch_Tensor); THTensor *gradOutput = luaT_checkudata(L, 3, torch_Tensor); THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_Tensor); // dims int iwidth = input->size[2]; int iheight = input->size[1]; int ichannels = input->size[0]; int owidth = gradOutput->size[2]; int oheight = gradOutput->size[1]; int ochannels = gradOutput->size[0]; // resize gradInput THTensor_(resize3d)(gradInput, ichannels, iheight, iwidth); THTensor_(zero)(gradInput); // select planes THTensor *gradOutputPlane = THTensor_(new)(); THTensor *gradInputPlane = THTensor_(new)(); // mapping ratios float wratio = (float)(iwidth-1) / (owidth-1); float hratio = (float)(iheight-1) / (oheight-1); // compute gradients for each plane int k; for (k=0; k<ochannels; k++) { // get planes THTensor_(select)(gradInputPlane, gradInput, 0, k); THTensor_(select)(gradOutputPlane, gradOutput, 0, k); // for each plane, resample int x,y; for (y=0; y<oheight; y++) { for (x=0; x<owidth; x++) { // subpixel position: float ix = wratio*x; float iy = hratio*y; // 4 nearest neighbors: float ix_nw = floor(ix); float iy_nw = floor(iy); float ix_ne = ix_nw + 1; float iy_ne = iy_nw; float ix_sw = ix_nw; float iy_sw = iy_nw + 1; float ix_se = ix_nw + 1; float iy_se = iy_nw + 1; // get surfaces to each neighbor: float se = (ix-ix_nw)*(iy-iy_nw); float sw = (ix_ne-ix)*(iy-iy_ne); float ne = (ix-ix_sw)*(iy_sw-iy); float nw = (ix_se-ix)*(iy_se-iy); // output gradient double ograd = THTensor_(get2d)(gradOutputPlane, y, x); // accumulate gradient THTensor_(set2d)(gradInputPlane, iy_nw, ix_nw, THTensor_(get2d)(gradInputPlane, iy_nw, ix_nw) + nw * ograd); THTensor_(set2d)(gradInputPlane, iy_ne, MIN(ix_ne,iwidth-1), THTensor_(get2d)(gradInputPlane, iy_ne, MIN(ix_ne,iwidth-1)) + ne * ograd); THTensor_(set2d)(gradInputPlane, MIN(iy_sw,iheight-1), ix_sw, THTensor_(get2d)(gradInputPlane, MIN(iy_sw,iheight-1), ix_sw) + sw * ograd); THTensor_(set2d)(gradInputPlane, MIN(iy_se,iheight-1), MIN(ix_se,iwidth-1), THTensor_(get2d)(gradInputPlane, MIN(iy_se,iheight-1), MIN(ix_se,iwidth-1)) + se * ograd); } } } // cleanup THTensor_(free)(gradInputPlane); THTensor_(free)(gradOutputPlane); return 1; } static const struct luaL_Reg nn_(SpatialReSampling__) [] = { {"SpatialReSampling_updateOutput", nn_(SpatialReSampling_updateOutput)}, {"SpatialReSampling_updateGradInput", nn_(SpatialReSampling_updateGradInput)}, {NULL, NULL} }; static void nn_(SpatialReSampling_init)(lua_State *L) { luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialReSampling__), "nn"); lua_pop(L,1); } #endif