/*
 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#ifndef HEADER_PEM_H
# define HEADER_PEM_H

# include <openssl/e_os2.h>
# include <openssl/bio.h>
# include <openssl/safestack.h>
# include <openssl/evp.h>
# include <openssl/x509.h>
# include <openssl/pemerr.h>

#ifdef  __cplusplus
extern "C" {
#endif

# define PEM_BUFSIZE             1024

# define PEM_STRING_X509_OLD     "X509 CERTIFICATE"
# define PEM_STRING_X509         "CERTIFICATE"
# define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE"
# define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST"
# define PEM_STRING_X509_REQ     "CERTIFICATE REQUEST"
# define PEM_STRING_X509_CRL     "X509 CRL"
# define PEM_STRING_EVP_PKEY     "ANY PRIVATE KEY"
# define PEM_STRING_PUBLIC       "PUBLIC KEY"
# define PEM_STRING_RSA          "RSA PRIVATE KEY"
# define PEM_STRING_RSA_PUBLIC   "RSA PUBLIC KEY"
# define PEM_STRING_DSA          "DSA PRIVATE KEY"
# define PEM_STRING_DSA_PUBLIC   "DSA PUBLIC KEY"
# define PEM_STRING_PKCS7        "PKCS7"
# define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA"
# define PEM_STRING_PKCS8        "ENCRYPTED PRIVATE KEY"
# define PEM_STRING_PKCS8INF     "PRIVATE KEY"
# define PEM_STRING_DHPARAMS     "DH PARAMETERS"
# define PEM_STRING_DHXPARAMS    "X9.42 DH PARAMETERS"
# define PEM_STRING_SSL_SESSION  "SSL SESSION PARAMETERS"
# define PEM_STRING_DSAPARAMS    "DSA PARAMETERS"
# define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY"
# define PEM_STRING_ECPARAMETERS "EC PARAMETERS"
# define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY"
# define PEM_STRING_PARAMETERS   "PARAMETERS"
# define PEM_STRING_CMS          "CMS"

# define PEM_TYPE_ENCRYPTED      10
# define PEM_TYPE_MIC_ONLY       20
# define PEM_TYPE_MIC_CLEAR      30
# define PEM_TYPE_CLEAR          40

/*
 * These macros make the PEM_read/PEM_write functions easier to maintain and
 * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or
 * IMPLEMENT_PEM_rw_cb(...)
 */

# ifdef OPENSSL_NO_STDIO

#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/
#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/
#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/
#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/
#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/
# else

#  define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
{ \
return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \
}

#  define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
int PEM_write_##name(FILE *fp, type *x) \
{ \
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \
}

#  define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
int PEM_write_##name(FILE *fp, const type *x) \
{ \
return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \
}

#  define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
             unsigned char *kstr, int klen, pem_password_cb *cb, \
                  void *u) \
        { \
        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
        }

#  define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
             unsigned char *kstr, int klen, pem_password_cb *cb, \
                  void *u) \
        { \
        return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \
        }

# endif

# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
{ \
return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \
}

# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, type *x) \
{ \
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \
}

# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, const type *x) \
{ \
return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \
}

# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
        { \
        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \
        }

# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
             unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
        { \
        return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \
        }

# define IMPLEMENT_PEM_write(name, type, str, asn1) \
        IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
        IMPLEMENT_PEM_write_fp(name, type, str, asn1)

# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \
        IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
        IMPLEMENT_PEM_write_fp_const(name, type, str, asn1)

# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \
        IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
        IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1)

# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \
        IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
        IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1)

# define IMPLEMENT_PEM_read(name, type, str, asn1) \
        IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
        IMPLEMENT_PEM_read_fp(name, type, str, asn1)

# define IMPLEMENT_PEM_rw(name, type, str, asn1) \
        IMPLEMENT_PEM_read(name, type, str, asn1) \
        IMPLEMENT_PEM_write(name, type, str, asn1)

# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \
        IMPLEMENT_PEM_read(name, type, str, asn1) \
        IMPLEMENT_PEM_write_const(name, type, str, asn1)

# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \
        IMPLEMENT_PEM_read(name, type, str, asn1) \
        IMPLEMENT_PEM_write_cb(name, type, str, asn1)

/* These are the same except they are for the declarations */

# if defined(OPENSSL_NO_STDIO)

#  define DECLARE_PEM_read_fp(name, type) /**/
#  define DECLARE_PEM_write_fp(name, type) /**/
#  define DECLARE_PEM_write_fp_const(name, type) /**/
#  define DECLARE_PEM_write_cb_fp(name, type) /**/
# else

#  define DECLARE_PEM_read_fp(name, type) \
        type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u);

#  define DECLARE_PEM_write_fp(name, type) \
        int PEM_write_##name(FILE *fp, type *x);

#  define DECLARE_PEM_write_fp_const(name, type) \
        int PEM_write_##name(FILE *fp, const type *x);

#  define DECLARE_PEM_write_cb_fp(name, type) \
        int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \
             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);

# endif

#  define DECLARE_PEM_read_bio(name, type) \
        type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u);

#  define DECLARE_PEM_write_bio(name, type) \
        int PEM_write_bio_##name(BIO *bp, type *x);

#  define DECLARE_PEM_write_bio_const(name, type) \
        int PEM_write_bio_##name(BIO *bp, const type *x);

#  define DECLARE_PEM_write_cb_bio(name, type) \
        int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
             unsigned char *kstr, int klen, pem_password_cb *cb, void *u);

# define DECLARE_PEM_write(name, type) \
        DECLARE_PEM_write_bio(name, type) \
        DECLARE_PEM_write_fp(name, type)
# define DECLARE_PEM_write_const(name, type) \
        DECLARE_PEM_write_bio_const(name, type) \
        DECLARE_PEM_write_fp_const(name, type)
# define DECLARE_PEM_write_cb(name, type) \
        DECLARE_PEM_write_cb_bio(name, type) \
        DECLARE_PEM_write_cb_fp(name, type)
# define DECLARE_PEM_read(name, type) \
        DECLARE_PEM_read_bio(name, type) \
        DECLARE_PEM_read_fp(name, type)
# define DECLARE_PEM_rw(name, type) \
        DECLARE_PEM_read(name, type) \
        DECLARE_PEM_write(name, type)
# define DECLARE_PEM_rw_const(name, type) \
        DECLARE_PEM_read(name, type) \
        DECLARE_PEM_write_const(name, type)
# define DECLARE_PEM_rw_cb(name, type) \
        DECLARE_PEM_read(name, type) \
        DECLARE_PEM_write_cb(name, type)
typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata);

int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher);
int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len,
                  pem_password_cb *callback, void *u);

int PEM_read_bio(BIO *bp, char **name, char **header,
                 unsigned char **data, long *len);
#   define PEM_FLAG_SECURE             0x1
#   define PEM_FLAG_EAY_COMPATIBLE     0x2
#   define PEM_FLAG_ONLY_B64           0x4
int PEM_read_bio_ex(BIO *bp, char **name, char **header,
                    unsigned char **data, long *len, unsigned int flags);
int PEM_bytes_read_bio_secmem(unsigned char **pdata, long *plen, char **pnm,
                              const char *name, BIO *bp, pem_password_cb *cb,
                              void *u);
int PEM_write_bio(BIO *bp, const char *name, const char *hdr,
                  const unsigned char *data, long len);
int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm,
                       const char *name, BIO *bp, pem_password_cb *cb,
                       void *u);
void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x,
                        pem_password_cb *cb, void *u);
int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x,
                       const EVP_CIPHER *enc, unsigned char *kstr, int klen,
                       pem_password_cb *cb, void *u);

STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk,
                                            pem_password_cb *cb, void *u);
int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc,
                            unsigned char *kstr, int klen,
                            pem_password_cb *cd, void *u);

#ifndef OPENSSL_NO_STDIO
int PEM_read(FILE *fp, char **name, char **header,
             unsigned char **data, long *len);
int PEM_write(FILE *fp, const char *name, const char *hdr,
              const unsigned char *data, long len);
void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x,
                    pem_password_cb *cb, void *u);
int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,
                   void *x, const EVP_CIPHER *enc, unsigned char *kstr,
                   int klen, pem_password_cb *callback, void *u);
STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk,
                                        pem_password_cb *cb, void *u);
#endif

int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type);
int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt);
int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
                  unsigned int *siglen, EVP_PKEY *pkey);

/* The default pem_password_cb that's used internally */
int PEM_def_callback(char *buf, int num, int rwflag, void *userdata);
void PEM_proc_type(char *buf, int type);
void PEM_dek_info(char *buf, const char *type, int len, char *str);

# include <openssl/symhacks.h>

DECLARE_PEM_rw(X509, X509)
DECLARE_PEM_rw(X509_AUX, X509)
DECLARE_PEM_rw(X509_REQ, X509_REQ)
DECLARE_PEM_write(X509_REQ_NEW, X509_REQ)
DECLARE_PEM_rw(X509_CRL, X509_CRL)
DECLARE_PEM_rw(PKCS7, PKCS7)
DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE)
DECLARE_PEM_rw(PKCS8, X509_SIG)
DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO)
# ifndef OPENSSL_NO_RSA
DECLARE_PEM_rw_cb(RSAPrivateKey, RSA)
DECLARE_PEM_rw_const(RSAPublicKey, RSA)
DECLARE_PEM_rw(RSA_PUBKEY, RSA)
# endif
# ifndef OPENSSL_NO_DSA
DECLARE_PEM_rw_cb(DSAPrivateKey, DSA)
DECLARE_PEM_rw(DSA_PUBKEY, DSA)
DECLARE_PEM_rw_const(DSAparams, DSA)
# endif
# ifndef OPENSSL_NO_EC
DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP)
DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY)
DECLARE_PEM_rw(EC_PUBKEY, EC_KEY)
# endif
# ifndef OPENSSL_NO_DH
DECLARE_PEM_rw_const(DHparams, DH)
DECLARE_PEM_write_const(DHxparams, DH)
# endif
DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY)
DECLARE_PEM_rw(PUBKEY, EVP_PKEY)

int PEM_write_bio_PrivateKey_traditional(BIO *bp, EVP_PKEY *x,
                                         const EVP_CIPHER *enc,
                                         unsigned char *kstr, int klen,
                                         pem_password_cb *cb, void *u);

int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
                                      char *kstr, int klen,
                                      pem_password_cb *cb, void *u);
int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *,
                                  char *, int, pem_password_cb *, void *);
int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
                            char *kstr, int klen,
                            pem_password_cb *cb, void *u);
int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid,
                                char *kstr, int klen,
                                pem_password_cb *cb, void *u);
EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb,
                                  void *u);

# ifndef OPENSSL_NO_STDIO
int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
                           char *kstr, int klen,
                           pem_password_cb *cb, void *u);
int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid,
                               char *kstr, int klen,
                               pem_password_cb *cb, void *u);
int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
                                  char *kstr, int klen,
                                  pem_password_cb *cb, void *u);

EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb,
                                 void *u);

int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
                              char *kstr, int klen, pem_password_cb *cd,
                              void *u);
# endif
EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x);
int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x);

# ifndef OPENSSL_NO_DSA
EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length);
EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length);
EVP_PKEY *b2i_PrivateKey_bio(BIO *in);
EVP_PKEY *b2i_PublicKey_bio(BIO *in);
int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk);
int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk);
#  ifndef OPENSSL_NO_RC4
EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u);
int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel,
                pem_password_cb *cb, void *u);
#  endif
# endif

# ifdef  __cplusplus
}
# endif
#endif


/* void Main()
{
   (new int [] {}).Permutations().Dump("Permutations of empty collection");
   (new [] {1}).Permutations().Dump("Permutations of singleton collection");
   (new [] {1,2}).Permutations().Dump("Permutations of doubleton collection");
   (new [] {1,2,3}).Permutations().Dump("Permutations of tripleton
collection");

   Pluck<int>(2)(new [] {1,2,3}).Dump("Pluck second element from a
collection");
   CoPluck<int>(2)(new [] {1,2,3}).Dump("A new collection with all
but the second element");

   (new [] {new [] {1,2,3}, new [] {4,5,6}})
       .Select(Pluck<int>(2))
       .Dump("Map Pluck(2)");

   (new [] {1,2,3}).PluckPair(2).Dump("The plucked element and its residual");
   (new [] {1,2,3}).PluckPairs().Dump("All pluck pairs of a collection");

   (new int [] {}).Permutations2().Dump("Permutations of empty collection");
   (new [] {1}).Permutations2().Dump("Permutations of singleton collection");
   (new [] {1,2}).Permutations2().Dump("Permutations of doubleton collection");
   (new [] {1,2,3}).Permutations2().Dump("Permutations of tripleton
collection");

   (new int [] {}).Riffles(new int [] {}).Dump("All riffles of two
empty collections");
   (new [] {1}).Riffles(new int [] {}).Dump("All riffles of a
singleton and an empty");
   (new int [] {}).Riffles(new [] {4}).Dump("All riffles of an empty
and a singleton");
   (new [] {1}).Riffles(new [] {4}).Dump("All riffles of two singletons");
   (new [] {1,2}).Riffles(new [] {4}).Dump("All riffles of a
doubleton and a singletons");
   (new [] {1}).Riffles(new [] {4,5}).Dump("All riffles of a
singleton and a doubleton");
   (new [] {1,2}).Riffles(new [] {4,5}).Dump("All riffles of two doubletons");
   (new [] {1,2,3}).Riffles(new [] {4,5}).Dump("All riffles of a
tripleton and a doubleton");
   (new [] {1,2}).Riffles(new [] {4,5,6}).Dump("All riffles of a
doubleton and a tripleton");
   (new [] {1,2,3}).Riffles(new [] {4,5,6}).Dump("All riffles of two
tripletons");
}

// Pluck returns a function so it can be mapped over other collections.
public static Func<IEnumerable<T>, T> Pluck<T>(int n)
{   return xs =>
   {   if (n <= 0 || n > xs.Count())
           throw new ArgumentOutOfRangeException("n",
               String.Format("argument must have value between 1 and
{0} inclusive",
                   xs.Count()));
       return xs.ElementAt(n - 1);
   };
}

// CoPluck returns a function so it can be mapped over other collections
public static Func<IEnumerable<T>, IEnumerable<T>> CoPluck<T>(int n)
{   return xs =>
   {   var c = xs.Count();
       if (n <= 0 || n > c)
           throw new ArgumentOutOfRangeException("n",
               String.Format("argument must have value between 1 and
{0} inclusive", c));
        var ys = new List<T>();
        var i = 1;
        foreach (var x in xs)
        {  if (i != n)
               ys.Add(x);
           i++;
       }
       return ys;
   };
}
public static class Extensions
{
public static IEnumerable<IEnumerable<T>> Riffles<T>(this
IEnumerable<T> left, IEnumerable<T> right)
   {   if (left.Count() == 0)
       {   yield return right;
           yield break;
       }
       if (right.Count() == 0)
       {   yield return left;
           yield break;
       }
       foreach (var r in right.Splits().Skip(1).Take(1))
       {   foreach (var l in left.Splits())
           {   foreach (var f in Riffles(l.Second(), r.Second()))
               {   yield return l.First().Concat(r.First()).Concat(f);
               }
           }
       }
   }
   public static T Second<T> (this IEnumerable<T> these)
   {   return these.Skip(1).First();
   }
   public static IEnumerable<IEnumerable<IEnumerable<T>>>
Splits<T>(this IEnumerable<T> these)
   {   var c = these.Count();
       for (var i = 0; i <= c; i++)
           yield return new IEnumerable<T> [2] {these.Take(i), these.Skip(i)};
   }

   public static IEnumerable<T> Append<T>(this IEnumerable<T> these, T that)
   {   foreach (var t in these)
           yield return t;
       yield return that;
   }
   public static IEnumerable<T> Prepend<T>(this IEnumerable<T> these, T that)
   {   yield return that;
       foreach (var t in these)
           yield return t;
   }
   public static IEnumerable<Tuple<T, IEnumerable<T>>>
PluckPairs<T>(this IEnumerable<T> xs)
   {   var c = xs.Count();
       var result = new List<Tuple<T, IEnumerable<T>>>();
       for (var n = 1; n <= c; n++)
       {   var ys = new List<T>();
           var y = default(T);
           var i = 1;
           foreach (var x in xs)
           {  if (i != n)
                   ys.Add(x);
               else
                   y = x;
               i++;
           }
           result.Add(Tuple.Create(y, (IEnumerable<T>)ys));
       }
       return result;
   }
   public static Tuple<T, IEnumerable<T>> PluckPair<T>(this
IEnumerable<T> xs, int n)
   {   var c = xs.Count();
       if (n <= 0 || n > c)
           throw new ArgumentOutOfRangeException("n",
               String.Format("argument must have value between 1 and
{0} inclusive", c));
       var ys = new List<T>();
       var y = default(T);
       var i = 1;
       foreach (var x in xs)
       {  if (i != n)
               ys.Add(x);
           else
               y = x;
           i++;
       }
       return Tuple.Create(y, (IEnumerable<T>)ys);
   }

   // Slow but understandable "reference implementation" of Permutations
   public static IEnumerable<IEnumerable<T>> Permutations2<T>(this
IEnumerable<T> these)
   {   Debug.Assert(these != null);
       // Inherently combinatorial-time algorithm!
       var len = these.Count();
       if (len == 1)
       {   yield return these;
           yield break;
       }
       foreach (var pluckPair in these.PluckPairs())
       {   foreach (var permutation in pluckPair.Item2.Permutations2())
           {   yield return permutation.Prepend(pluckPair.Item1);
           }
       }
   }
   // Faster but more difficult index-based implementation of Permutations
   public static IEnumerable<IEnumerable<T>> Permutations<T>(this
IEnumerable<T> these)
   {   Debug.Assert(these != null);
       // Inherently combinatorial-time algorithm!
       var len = these.Count();
       if (len == 1)
       {   yield return these;
           yield break;
       }
       var source = these.ToArray();
       var result = new T [len];
       for (var i = 0; i < len; i++)
       {   result[0] = source[i];
           var rs = new T [len - 1];
           for (var j = 0; j < len - 1; j++)
           {   if (j < i)
               {   rs[j] = source[j];
               }
               else if (j >= i)
               {   rs[j] = source[j + 1];
               }
           }
           var perms = rs.Permutations();
           foreach (var perm in perms)
           {   var ps = perm.ToArray();
               for(var j = 0; j < len - 1; j++)
                   result[j + 1] = ps[j];
               yield return result;
           }
       }
   }
}
*/


// Copyright 2019 tree xie
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// brotli compress

package util

import (
	"bytes"
	"io/ioutil"

	"github.com/andybalholm/brotli"
)

const (
	defaultBrQuality = 8
)

func brotliEncode(buf []byte, level int) (*bytes.Buffer, error) {
	buffer := new(bytes.Buffer)
	if level <= 0 || level > 11 {
		level = defaultBrQuality
	}
	w := brotli.NewWriterLevel(buffer, level)
	defer w.Close()
	_, err := w.Write(buf)
	if err != nil {
		return nil, err
	}
	return buffer, nil
}

// Brotli brotli compress
func Brotli(buf []byte, level int) ([]byte, error) {
	buffer, err := brotliEncode(buf, level)
	if err != nil {
		return nil, err
	}
	return buffer.Bytes(), nil
}

// BrotliDecode brotli decode
func BrotliDecode(buf []byte) ([]byte, error) {
	if len(buf) == 0 {
		return nil, nil
	}
	r := brotli.NewReader(bytes.NewBuffer(buf))
	return ioutil.ReadAll(r)
}


block includes
  include ../_util-fns
:marked
  This page describes Angular's built-in
  protections against common web-application vulnerabilities and attacks such as cross-site
  scripting attacks. It doesn't cover application-level security, such as authentication (_Who is
  this user?_) and authorization (_What can this user do?_).

  For more information about the attacks and mitigations described below, see [OWASP Guide Project](https://www.owasp.org/index.php/Category:OWASP_Guide_Project).

.l-main-section
:marked
  # Contents

  * [Reporting vulnerabilities](#report-issues).
  * [Best practices](#best-practices).
  * [Preventing cross-site scripting (XSS)](#xss).
  * [Trusting safe values](#bypass-security-apis).
  * [HTTP-Level vulnerabilities](#http).
  * [Auditing Angular applications](#code-review).

:marked
  You can run the <live-example></live-example> in Plunker and download the code from there.

.l-main-section
h2#report-issues Reporting vulnerabilities
:marked
  To report vulnerabilities in Angular itself, email us at [security@angular.io](mailto:security@angular.io).

  For more information about how Google handles security issues, see [Google's security
  philosophy](https://www.google.com/about/appsecurity/).

.l-main-section
h2#best-practices Best practices
:marked
  * **Keep current with the latest Angular library releases.**
  We regularly update the Angular libraries, and these updates may fix security defects discovered in
  previous versions. Check the Angular [change
  log](https://github.com/angular/angular/blob/master/CHANGELOG.md) for security-related updates.

  * **Don't modify your copy of Angular.**
  Private, customized versions of Angular tend to fall behind the current version and may not include
  important security fixes and enhancements. Instead, share your Angular improvements with the
  community and make a pull request.

  * **Avoid Angular APIs marked in the documentation as “_Security Risk_.”**
  For more information, see the [Trusting safe values](#bypass-security-apis) section of this page.

.l-main-section
h2#xss Preventing cross-site scripting (XSS)
:marked
  [Cross-site scripting (XSS)](https://en.wikipedia.org/wiki/Cross-site_scripting) enables attackers
  to inject malicious code into web pages. Such code can then, for example, steal user data (in
  particular, login data) or perform actions to impersonate the user. This is one of the most
  common attacks on the web.

  To block XSS attacks, you must prevent malicious code from entering the DOM (Document Object Model). For example, if
  attackers can trick you into inserting a `<script>` tag in the DOM, they can run arbitrary code on
  your website. The attack isn't limited to `<script>` tags—many elements and properties in the
  DOM allow code execution, for example, `<img onerror="...">` and `<a href="javascript:...">`. If
  attacker-controlled data enters the DOM, expect security vulnerabilities.

  ### Angular’s cross-site scripting security model

  To systematically block XSS bugs, Angular treats all values as untrusted by default. When a value
  is inserted into the DOM from a template, via property, attribute, style, class binding, or interpolation,
  Angular sanitizes and escapes untrusted values.

  _Angular templates are the same as executable code_: HTML, attributes, and binding expressions
  (but not the values bound) in templates are trusted to be safe. This means that applications must
  prevent values that an attacker can control from ever making it into the source code of a
  template. Never generate template source code by concatenating user input and templates.
  To prevent these vulnerabilities, use
  the [offline template compiler](#offline-template-compiler), also known as _template injection_.

  ### Sanitization and security contexts

  _Sanitization_ is the inspection of an untrusted value, turning it into a value that's safe to insert into
  the DOM. In many cases, sanitization doesn't change a value at all. Sanitization depends on context:
  a value that's harmless in CSS is potentially dangerous in a URL.

  Angular defines the following security contexts:

  * **HTML** is used when interpreting a value as HTML, for example, when binding to `innerHtml`.
  * **Style** is used when binding CSS into the `style` property.
  * **URL** is used for URL properties, such as `<a href>`.
  * **Resource URL** is a URL that will be loaded and executed as code, for example, in `<script src>`.

  Angular sanitizes untrusted values for HTML, styles, and URLs; sanitizing resource URLs isn't
  possible because they contain arbitrary code. In development mode, Angular prints a console warning
  when it has to change a value during sanitization.

  ### Sanitization example

  The following template binds the value of `htmlSnippet`, once by interpolating it into an element's
  content, and once by binding it to the `innerHTML` property of an element:

+makeExample('src/app/inner-html-binding.component.html')

:marked
  Interpolated content is always escaped—the HTML isn't interpreted and the browser displays
  angle brackets in the element's text content.

  For the HTML to be interpreted, bind it to an HTML property such as `innerHTML`. But binding
  a value that an attacker might control into `innerHTML` normally causes an XSS
  vulnerability. For example, code contained in a `<script>` tag is executed:

+makeExcerpt('src/app/inner-html-binding.component.ts', 'class')

:marked
  Angular recognizes the value as unsafe and automatically sanitizes it, which removes the `<script>`
  tag but keeps safe content such as the text content of the `<script>` tag and the `<b>` element.

figure.image-display
    img(src='/resources/images/devguide/security/binding-inner-html.png'
        alt='A screenshot showing interpolated and bound HTML values')

:marked
  ### Avoid direct use of the DOM APIs

  The built-in browser DOM APIs don't automatically protect you from security vulnerabilities.
  For example, `document`, the node available through `ElementRef`, and many third-party APIs
  contain unsafe methods. Avoid directly interacting with the DOM and instead use Angular
  templates where possible.

  ### Content security policy

  Content Security Policy (CSP) is a defense-in-depth
  technique to prevent XSS. To enable CSP, configure your web server to return an appropriate
  `Content-Security-Policy` HTTP header. Read more about content security policy at
  [An Introduction to Content Security Policy](http://www.html5rocks.com/en/tutorials/security/content-security-policy/)
  on the HTML5Rocks website.

a#offline-template-compiler
:marked
  ### Use the offline template compiler

  The offline template compiler prevents a whole class of vulnerabilities called template injection,
  and greatly improves application performance. Use the offline template compiler in production
  deployments; don't dynamically generate templates. Angular trusts template code, so generating
  templates, in particular templates containing user data, circumvents Angular's built-in protections.
  For information about dynamically constructing forms in a safe way, see the
  [Dynamic Forms](../cookbook/dynamic-form.html) cookbook page.

  ### Server-side XSS protection

  HTML constructed on the server is vulnerable to injection attacks. Injecting template code into an
  Angular application is the same as injecting executable code into the
  application: it gives the attacker full control over the application. To prevent this,
  use a templating language that automatically escapes values to prevent XSS vulnerabilities on
  the server. Don't generate Angular templates on the server side using a templating language; doing this
  carries a high risk of introducing template-injection vulnerabilities.

.l-main-section
h2#bypass-security-apis Trusting safe values
:marked
  Sometimes applications genuinely need to include executable code, display an `<iframe>` from some
  URL, or construct potentially dangerous URLs. To prevent automatic sanitization in any of these
  situations, you can tell Angular that you inspected a value, checked how it was generated, and made
  sure it will always be secure. But *be careful*. If you trust a value that might be malicious, you
  are introducing a security vulnerability into your application. If in doubt, find a professional
  security reviewer.

  To mark a value as trusted, inject `DomSanitizer` and call one of the
  following methods:

  * `bypassSecurityTrustHtml`
  * `bypassSecurityTrustScript`
  * `bypassSecurityTrustStyle`
  * `bypassSecurityTrustUrl`
  * `bypassSecurityTrustResourceUrl`

  Remember, whether a value is safe depends on context, so choose the right context for
  your intended use of the value. Imagine that the following template needs to bind a URL to a
  `javascript:alert(...)` call:

+makeExcerpt('src/app/bypass-security.component.html', 'URL')

:marked
  Normally, Angular automatically sanitizes the URL, disables the dangerous code, and
  in development mode, logs this action to the console. To prevent
  this, mark the URL value as a trusted URL using the `bypassSecurityTrustUrl` call:

+makeExcerpt('src/app/bypass-security.component.ts ()', 'trust-url')

figure.image-display
    img(src='/resources/images/devguide/security/bypass-security-component.png'
        alt='A screenshot showing an alert box created from a trusted URL')

:marked
  If you need to convert user input into a trusted value, use a
  controller method. The following template allows users to enter a YouTube video ID and load the
  corresponding video in an `<iframe>`. The `<iframe src>` attribute is a resource URL security
  context, because an untrusted source can, for example, smuggle in file downloads that unsuspecting users
  could execute. So call a method on the controller to construct a trusted video URL, which causes
  Angular to allow binding into `<iframe src>`:

+makeExcerpt('src/app/bypass-security.component.html', 'iframe')
+makeExcerpt('src/app/bypass-security.component.ts ()', 'trust-video-url')

.l-main-section
h2#http HTTP-level vulnerabilities
:marked
  Angular has built-in support to help prevent two common HTTP vulnerabilities, cross-site request
  forgery (CSRF or XSRF) and cross-site script inclusion (XSSI). Both of these must be mitigated primarily
  on the server side, but Angular provides helpers to make integration on the client side easier.

h3#xsrf Cross-site request forgery
:marked
  In a cross-site request forgery (CSRF or XSRF), an attacker tricks the user into visiting
  a different web page (such as `evil.com`) with malignant code that secretly sends a malicious request
  to the application's web server (such as `example-bank.com`).

  Assume the user is logged into the application at `example-bank.com`.
  The user opens an email and clicks a link to `evil.com`, which opens in a new tab.

  The `evil.com` page immediately sends a malicious request to `example-bank.com`.
  Perhaps it's a request to transfer money from the user's account to the attacker's account.
  The browser automatically sends the `example-bank.com` cookies (including the authentication cookie) with this request.

  If the `example-bank.com` server lacks XSRF protection, it can't tell the difference between a legitimate
  request from the application and the forged request from `evil.com`.

  To prevent this, the application must ensure that a user request originates from the real
  application, not from a different site.
  The server and client must cooperate to thwart this attack.

  In a common anti-XSRF technique, the application server sends a randomly
  generated authentication token in a cookie.
  The client code reads the cookie and adds a custom request header with the token in all subsequent requests.
  The server compares the received cookie value to the request header value and rejects the request if the values are missing or don't match.

  This technique is effective because all browsers implement the _same origin policy_. Only code from the website
  on which cookies are set can read the cookies from that site and set custom headers on requests to that site.
  That means only your application can read this cookie token and set the custom header. The malicious code on `evil.com` can't.

  Angular's `http` has built-in support for the client-side half of this technique in its `XSRFStrategy`.
  The default `CookieXSRFStrategy` is turned on automatically.
  Before sending an HTTP request, the `CookieXSRFStrategy` looks for a cookie called `XSRF-TOKEN` and
  sets a header named `X-XSRF-TOKEN` with the value of that cookie.

  The server must do its part by setting the
  initial `XSRF-TOKEN` cookie and confirming that each subsequent state-modifying request
  includes a matching `XSRF-TOKEN` cookie and `X-XSRF-TOKEN` header.

  XSRF/CSRF tokens should be unique per user and session, have a large random value generated by a
  cryptographically secure random number generator, and expire in a day or two.

  Your server may use a different cookie or header name for this purpose.
  An Angular application can customize cookie and header names by providing its own `CookieXSRFStrategy` values.
code-example(language="typescript").
  { provide: XSRFStrategy, useValue: new CookieXSRFStrategy('myCookieName', 'My-Header-Name') }
:marked
  Or you can implement and provide an entirely custom `XSRFStrategy`:

code-example(language="typescript").
  { provide: XSRFStrategy, useClass: MyXSRFStrategy }

:marked
  For information about CSRF at the Open Web Application Security Project (OWASP), see
  Cross-Site Request Forgery (CSRF) and
  Cross-Site Request Forgery (CSRF) Prevention Cheat Sheet.
  The Stanford University paper
  Robust Defenses for Cross-Site Request Forgery is a rich source of detail.

  See also Dave Smith's easy-to-understand
  talk on XSRF at AngularConnect 2016.

h3#xssi Cross-site script inclusion (XSSI)
:marked
  Cross-site script inclusion, also known as JSON vulnerability, can allow an attacker's website to
  read data from a JSON API. The attack works on older browsers by overriding native JavaScript
  object constructors, and then including an API URL using a `<script>` tag.

  This attack is only successful if the returned JSON is executable as JavaScript. Servers can
  prevent an attack by prefixing all JSON responses to make them non-executable, by convention, using the
  well-known string `")]}',\n"`.

  Angular's `Http` library recognizes this convention and automatically strips the string
  `")]}',\n"` from all responses before further parsing.

  For more information, see the XSSI section of this [Google web security blog
  post](https://security.googleblog.com/2011/05/website-security-for-webmasters.html).

.l-main-section
h2#code-review Auditing Angular applications
:marked
  Angular applications must follow the same security principles as regular web applications, and
  must be audited as such. Angular-specific APIs that should be audited in a security review,
  such as the [_bypassSecurityTrust_](#bypass-security-apis) methods, are marked in the documentation
  as security sensitive.


UPDATE kalturadw_ds.files
SET process_id = 3
WHERE file_name like 'akamai_%'
AND process_id = 1


# -*- coding: utf-8 -*-
# @Author  : LG

from Model import RetainNet, Evaler
from Data import vocdataset
from Configs import _C as cfg
from Data import transfrom,targettransform

# 训练数据集,VOC格式数据集, 训练数据取自 ImageSets/Main/train.txt'
train_dataset=vocdataset(cfg, is_train=True, transform=transfrom(cfg,is_train=True),
                         target_transform=targettransform(cfg))

# 测试数据集,VOC格式数据集, 测试数据取自 ImageSets/Main/eval.txt'
test_dataset = vocdataset(cfg=cfg, is_train=False,
                          transform=transfrom(cfg=cfg, is_train=False),
                          target_transform=targettransform(cfg))

if __name__ == '__main__':
    # 模型测试只支持GPU单卡或多卡,不支持cpu
    net = RetainNet(cfg)
    # 将模型移动到gpu上,cfg.DEVICE.MAINDEVICE定义了模型所使用的主GPU
    net.to(cfg.DEVICE.MAINDEVICE)
    # 模型从权重文件中加载权重
    net.load_pretrained_weight('XXX.pkl')
    # 初始化验证器,验证器参数通过cfg进行配置;也可传入参数进行配置,但不建议
    evaler = Evaler(cfg, eval_devices=None)
    # 验证器开始在数据集上验证模型
    ap, map = evaler(model=net,
                     test_dataset=test_dataset)
    print(ap)
    print(map)


msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Language: \n"

msgid "en"
msgstr "अङ्ग्रेजी"

msgid "en_US"
msgstr "अमेरिकी अङ्ग्रेजी"

msgid "af"
msgstr "अफ्रिकान्स"

msgid "ak"
msgstr "आकान"

msgid "sq"
msgstr "अल्बानियाली"

msgid "arq"
msgstr "अल्जेरियाली अरबी"

msgid "am"
msgstr "अम्हारिक"

msgid "ar"
msgstr "अरबी"

msgid "hy"
msgstr "आर्मेनियाली"

msgid "rup_MK"
msgstr "अरोमानीयाली"

msgid "frp"
msgstr "अर्पितान"

msgid "as"
msgstr "आसामी"

msgid "az"
msgstr "अजरबैजानी"

msgid "az_TR"
msgstr ""

msgid "bcc"
msgstr ""

msgid "ba"
msgstr "बास्किर"

msgid "eu"
msgstr "बास्क"

msgid "bel"
msgstr ""

msgid "bn_BD"
msgstr "बंगाली"

msgid "bs_BA"
msgstr "बोस्नियाली"

msgid "bre"
msgstr "ब्रेटन"

msgid "bg_BG"
msgstr "बुल्गेरियाली"

msgid "ca"
msgstr "क्याटालन"

msgid "bal"
msgstr "बालुची"

msgid "zh_CN"
msgstr ""

msgid "zh_HK"
msgstr ""

msgid "zh_TW"
msgstr ""

msgid "co"
msgstr "कोर्सिकन"

msgid "hr"
msgstr "क्रोयसियाली"

msgid "cs_CZ"
msgstr "चेक"

msgid "da_DK"
msgstr "डेनिस"

msgid "dv"
msgstr "दिबेही"

msgid "nl_NL"
msgstr "डच"

msgid "nl_BE"
msgstr "फ्लेमिस"

msgid "dzo"
msgstr ""

msgid "en_AU"
msgstr "अस्ट्रेलियाली अङ्ग्रेजी"

msgid "en_CA"
msgstr "क्यानाडेली अङ्ग्रेजी"

msgid "en_NZ"
msgstr ""

msgid "en_ZA"
msgstr ""

msgid "en_GB"
msgstr "बेलायती अङ्ग्रेजी"

msgid "eo"
msgstr "एस्पेरान्तो"

msgid "et"
msgstr "इस्टोनियाली"

msgid "fo"
msgstr "फारोज"

msgid "fi"
msgstr "फिनिस"

msgid "fr_BE"
msgstr ""

msgid "fr_CA"
msgstr "क्यानेडाली फ्रान्सेली"

msgid "fr_FR"
msgstr "फ्रान्सेली"

msgid "fy"
msgstr "फ्रिजीयन"

msgid "fur"
msgstr "फ्रिउलियाली"

msgid "fuc"
msgstr ""

msgid "gl_ES"
msgstr "गलिसियाली"

msgid "ka_GE"
msgstr "जर्जियाली"

msgid "de_DE"
msgstr "जर्मन"

msgid "de_CH"
msgstr "स्वीस हाई जर्मन"

msgid "el"
msgstr "ग्रीक"

msgid "gn"
msgstr "गुवारानी"

msgid "gu"
msgstr "गुजराती"

msgid "haw_US"
msgstr "हवाइयन"

msgid "haz"
msgstr ""

msgid "he_IL"
msgstr "हिब्रु"

msgid "hi_IN"
msgstr "हिन्दी"

msgid "hu_HU"
msgstr "हङ्गेरियाली"

msgid "is_IS"
msgstr "आइसल्यान्डियाली"

msgid "ido"
msgstr ""

msgid "id_ID"
msgstr "इन्डोनेसियाली"

msgid "ga"
msgstr "आयरिस"

msgid "it_IT"
msgstr "इटालेली"

msgid "ja"
msgstr "जापानी"

msgid "jv_ID"
msgstr "जाभानी"

msgid "kab"
msgstr "काबिल"

msgid "kn"
msgstr "कन्नाडा"

msgid "kk"
msgstr "काजाख"

msgid "km"
msgstr "खमेर"

msgid "kin"
msgstr ""

msgid "ky_KY"
msgstr "किर्गिज"

msgid "ko_KR"
msgstr "कोरियाली"

msgid "ckb"
msgstr "केन्द्रीय कुर्दी"

msgid "lo"
msgstr "लाओ"

msgid "lv"
msgstr "लात्भियाली"

msgid "li"
msgstr "लिम्बुर्गी"

msgid "lin"
msgstr ""

msgid "lt_LT"
msgstr "लिथुआनियाली"

msgid "lb_LU"
msgstr "लक्जेम्बर्गी"

msgid "mk_MK"
msgstr "म्यासेडोनियाली"

msgid "mg_MG"
msgstr "मलागासी"

msgid "ms_MY"
msgstr "मलाय"

msgid "ml_IN"
msgstr "मलयालम"

msgid "mri"
msgstr ""

msgid "mr"
msgstr "मराठी"

msgid "xmf"
msgstr "मिनग्रेलियाली"

msgid "mn"
msgstr "मङ्गोलियाली"

msgid "me_ME"
msgstr ""

msgid "ary"
msgstr "मोरोक्कोली अरबी"

msgid "my_MM"
msgstr ""

msgid "ne_NP"
msgstr "नेपाली"

msgid "nb_NO"
msgstr "नर्वेली बोकमाल"

msgid "nn_NO"
msgstr "नर्वेली नाइनोर्स्क"

msgid "oci"
msgstr ""

msgid "ory"
msgstr ""

msgid "os"
msgstr "अोस्सेटिक"

msgid "ps"
msgstr "पास्तो"

msgid "fa_IR"
msgstr "फारसी"

msgid "fa_AF"
msgstr ""

msgid "pl_PL"
msgstr "पोलिस"

msgid "pt_BR"
msgstr "ब्राजिली पोर्तुगी"

msgid "pt_PT"
msgstr "युरोपेली पोर्तुगी"

msgid "pa_IN"
msgstr "पंजाबी"

msgid "rhg"
msgstr ""

msgid "ro_RO"
msgstr "रोमानियाली"

msgid "roh"
msgstr ""

msgid "ru_RU"
msgstr "रूसी"

msgid "ru_UA"
msgstr ""

msgid "rue"
msgstr ""

msgid "sah"
msgstr ""

msgid "sa_IN"
msgstr ""

msgid "srd"
msgstr ""

msgid "gd"
msgstr "स्कटिस गाएलिक"

msgid "sr_RS"
msgstr "सर्बियाली"

msgid "szl"
msgstr ""

msgid "sd_PK"
msgstr "सिन्धी"

msgid "si_LK"
msgstr "सिन्हाली"

msgid "sk_SK"
msgstr "स्लोभाकियाली"

msgid "sl_SI"
msgstr "स्लोभेनियाली"

msgid "so_SO"
msgstr "सोमाली"

msgid "azb"
msgstr ""

msgid "es_AR"
msgstr ""

msgid "es_CL"
msgstr ""

msgid "es_CO"
msgstr ""

msgid "es_MX"
msgstr "मेक्सिकन स्पेनी"

msgid "es_PE"
msgstr ""

msgid "es_PR"
msgstr ""

msgid "es_ES"
msgstr "युरोपेली स्पेनी"

msgid "es_VE"
msgstr ""

msgid "su_ID"
msgstr ""

msgid "sw"
msgstr "स्वाहिली"

msgid "sv_SE"
msgstr "स्विडिस"

msgid "gsw"
msgstr "स्वीस जर्मन"

msgid "tl"
msgstr ""

msgid "tg"
msgstr "ताजिक"

msgid "tzm"
msgstr "केन्द्रीय एट्लास टामाजिघट"

msgid "ta_IN"
msgstr "तामिल"

msgid "ta_LK"
msgstr ""

msgid "tt_RU"
msgstr "तातार"

msgid "te"
msgstr "तेलुगु"

msgid "th"
msgstr "थाई"

msgid "bo"
msgstr "तिब्बती"

msgid "tir"
msgstr ""

msgid "tr_TR"
msgstr "टर्किश"

msgid "tuk"
msgstr ""

msgid "ug_CN"
msgstr "उइघुर"

msgid "uk"
msgstr "युक्रेनी"

msgid "ur"
msgstr "उर्दु"

msgid "uz_UZ"
msgstr "उज्बेकी"

msgid "vi"
msgstr "भियतनामी"

msgid "wa"
msgstr ""

msgid "cy"
msgstr "वेल्श"

msgid "yor"
msgstr ""


/*******************************************************************************
 *  @file      BkgroundUI.cpp 2015\5\5 16:07:13 $
 *  @author    доки<nansong@mogujie.com>
 *  @brief
 ******************************************************************************/

#include "stdafx.h"
#include "BkgroundUI.h"
#include "../ScreenSnapshot.h"

class CCustomPaintDC
{
public:
	CCustomPaintDC(){}
	~CCustomPaintDC()
	{
		SelectObject(m_hDC, m_hPrevBrush);
		HPEN hDrawPen = (HPEN)SelectObject(m_hDC, (HGDIOBJ)m_hPrevPen);

		DeleteObject(hDrawPen);
		ReleaseDC(m_hWnd, m_hDC);
	}

	CCustomPaintDC(__in HWND hWnd, __in COLORREF iPenColor, __in int iPenWidth)
	{
		m_hWnd = hWnd;
		HPEN hDrawPen = CreatePen(PS_SOLID, iPenWidth, iPenColor);

		m_hDC = GetDC(hWnd);
		m_hPrevBrush = (HBRUSH)SelectObject(m_hDC, GetStockObject(NULL_BRUSH));
		m_hPrevPen = (HPEN)SelectObject(m_hDC, (HGDIOBJ)hDrawPen);

	}

	HDC getDC(){ return m_hDC; }

private:
	HWND m_hWnd;
	HDC m_hDC;
	HPEN m_hPrevPen;
	HBRUSH m_hPrevBrush;
};
IMP_DIALOG_PROC(BkgroundUI)

BkgroundUI::BkgroundUI()
{
	memset(&m_sDrawRect, 0, sizeof(RECT));
    memset(&m_sSelectRect, 0, sizeof(RECT));
}

LPDLGTEMPLATE BkgroundUI::makeDlgTemplate(__in LPVOID lpBuf)
{
	if (!lpBuf)
	{
		return NULL;
	}

	LPDLGTEMPLATE dlgTemplate = (LPDLGTEMPLATE)ScreenCommon::makeWORDAlign((LPWORD)lpBuf);

	dlgTemplate->style = WS_POPUP | WS_CHILD;
	dlgTemplate->dwExtendedStyle = 0;
	dlgTemplate->cdit = 0;

	//х╚фа╢╟©з
	RECT rc = {0};
	GetWindowRect(GetDesktopWindow(), &rc);
	dlgTemplate->x = 0;
	dlgTemplate->y = 0;
	dlgTemplate->cx = (short)(rc.right - rc.left);
	dlgTemplate->cy = (short)(rc.bottom - rc.top);

	return (LPDLGTEMPLATE)dlgTemplate;
}

HWND BkgroundUI::createWindow()
{
	BYTE *lpTemplateBuf = new BYTE[1024];
	memset(lpTemplateBuf, 0, 1024);
	HWND hWnd = CreateDialogXIndirect(makeDlgTemplate(lpTemplateBuf), GetDesktopWindow(), &BkgroundUI::DialogProc);

	DWORD dwErr = GetLastError();
	delete[]lpTemplateBuf;

	return hWnd;
}

void BkgroundUI::onInitDialog(__in HWND hWnd, __in WPARAM wParam, __in LPARAM lParam)
{
}

void BkgroundUI::InitMsgMap()
{
	CDlgBase::InitMsgMap();
	RegisterMsg(WM_INITDIALOG, (MSG_HANDLER)&BkgroundUI::onInitDialog);
    RegisterMsg(WM_KEYDOWN, (MSG_HANDLER)&BkgroundUI::onKeyDown);
	RegisterMsg(WM_PAINT, (MSG_HANDLER)&BkgroundUI::onPaint);
    RegisterMsg(WM_SNAPSHOT_MOUSE_WINDOW_CHANGE, (MSG_HANDLER)&BkgroundUI::onSnapshotWindowChange);
    RegisterMsg(WM_SNAPSHOT_TEST_SELECT_RECT, (MSG_HANDLER)&BkgroundUI::onSnapshotTestSelectRect);
	RegisterMsg(WM_SNAPSHOT_DRAW_RECT, (MSG_HANDLER)&BkgroundUI::onDrawRect);
	RegisterMsg(WM_SNAPSHOT_DRAW_POLY_REGION, (MSG_HANDLER)&BkgroundUI::onDrawPolyRegion);
	RegisterMsg(WM_SNAPSHOT_ADD_RECT_ITEM, (MSG_HANDLER)&BkgroundUI::onAddRectItem);
	RegisterMsg(WM_SNAPSHOT_ADD_POLY_REGION_ITEM, (MSG_HANDLER)&BkgroundUI::onAddPolyRegionItem);
}

void BkgroundUI::onKeyDown(__in HWND hWnd, __in WPARAM wParam, __in LPARAM lParam)
{
    if (VK_ESCAPE == wParam)
    {
        ScreenCommon::postNotifyMessage(WM_SNAPSHOT_CANCEL_CPATURE, 0, 0);
    }
}

void BkgroundUI::onSnapshotTestSelectRect(__in HWND hWnd, __in WPARAM wParam, __in LPARAM lParam)
{
    LPRECT lpRect = (LPRECT)wParam;
    if (!lpRect)
    {
        return;
    }
    memcpy(lpRect, &m_sSelectRect, sizeof(RECT));
}
void BkgroundUI::onSnapshotWindowChange(__in HWND hWnd, __in WPARAM wParam, __in LPARAM lParam)
{
    LPRECT lpRect = (LPRECT)lParam;
    if (ScreenCommon::isRectEqual(lpRect, &m_sSelectRect))
    {
        return;
    }
    memcpy(&m_sSelectRect, lpRect, sizeof(RECT));
    ScreenSnapshot::Instance()->paintWndRect(hWnd, &m_sSelectRect);
}

void BkgroundUI::onPaint(__in HWND hWnd, __in WPARAM wParam, __in LPARAM lParam)
{
    ScreenSnapshot::Instance()->paintWndRect(hWnd, &m_sSelectRect);

	if (m_sDrawRect.size())
	{
		for (unsigned int i = 0; i < m_sDrawRect.size(); i++)
		{
			drawRect(m_sDrawRect[i]);
		}
	}

	if (m_sDrawPolyRegion.size())
	{
		for (unsigned int i = 0; i < m_sDrawPolyRegion.size(); i++)
		{
			drawPolyRegion(m_sDrawPolyRegion[i]);
		}
	}

	if (!ScreenCommon::isRectEmpty(m_sCurrentDraw))
	{
		if (m_bDrawRect)
		{
			drawRect(m_sCurrentDraw);
		}
		else
		{
			drawPolyRegion(m_sCurrentDraw);
		}
	}
}

void BkgroundUI::onDrawPolyRegion(__in HWND hWnd, __in WPARAM wParam, __in LPARAM lParam)
{
	m_bDrawRect = FALSE;
	LPRECT lpRect = (LPRECT)wParam;
	memcpy(&m_sCurrentDraw, lpRect, sizeof(RECT));

    ScreenSnapshot::Instance()->paintWndRect(hWnd, &m_sSelectRect);

    drawPolyRegion(m_sCurrentDraw);
    ValidateRect(hWnd, NULL);
}

void BkgroundUI::drawPolyRegion(__in RECT &rc)
{
	CCustomPaintDC paintDC(m_hwnd, RGB(255, 0, 0), 2);
	HDC hPaintDC = paintDC.getDC();

	Ellipse(hPaintDC, rc.left, rc.top, rc.right, rc.bottom);
}

void BkgroundUI::onDrawRect(__in HWND hWnd, __in WPARAM wParam, __in LPARAM lParam)
{
	m_bDrawRect = TRUE;

	LPRECT lpRect = (LPRECT)wParam;
	memcpy(&m_sCurrentDraw, lpRect, sizeof(RECT));

     ScreenSnapshot::Instance()->paintWndRect(hWnd, &m_sSelectRect);

    drawRect(m_sCurrentDraw);
    ValidateRect(hWnd, NULL);
}

void BkgroundUI::drawRect(__in RECT &rc)
{
	CCustomPaintDC paintDC(m_hwnd, RGB(255, 0, 0), 2);
	HDC hPaintDC = paintDC.getDC();

	Rectangle(hPaintDC, rc.left + 1, rc.top + 1, rc.right, rc.bottom);
}

void BkgroundUI::closeWindow()
{
	m_sDrawRect.clear();
	m_sDrawPolyRegion.clear();
	memset(&m_sCurrentDraw, 0, sizeof(RECT));
	m_bDrawRect = FALSE;

    ShowWindow(m_hwnd, SW_HIDE);
	PostMessage(m_hwnd, WM_CLOSE, 0, 0);
}

void BkgroundUI::onAddRectItem(__in HWND hWnd, __in WPARAM wParam, __in LPARAM lParam)
{
	LPRECT lpRect = (LPRECT)wParam;
	RECT rc = { 0 };
	memcpy(&rc, lpRect, sizeof(RECT));
	m_sDrawRect.push_back(rc);

    ScreenSnapshot::Instance()->updateRect(lpRect);
}

void BkgroundUI::onAddPolyRegionItem(__in HWND hWnd, __in WPARAM wParam, __in LPARAM lParam)
{
	LPRECT lpRect = (LPRECT)wParam;

	RECT rc = { 0 };
	memcpy(&rc, lpRect, sizeof(RECT));
	m_sDrawPolyRegion.push_back(rc);

    ScreenSnapshot::Instance()->updateRect(lpRect);
}

/******************************************************************************/


-- This is a set of UPDATE statements that tests the bare minimum
-- necessary to start to think that maybe we actually support the
-- subset of SQL that we claim to support.
--
-- In the brave new meta-template world (yeah, okay, kill me), these
-- statements expect that the includer will have set the template
-- @cmp_type to be the _value[???] type that makes sense for the
-- config under test.  So, if the configuration is pushing on string
-- operations, you'll want a line: {@cmp_type = "_value[string]"} in
-- the template file that includes this one.
--
-- Required preprocessor templates:
--
-- @cmp_type: the type of literal to use for comparisons
-- @assign_col: the column to be updated
-- @assign_type: the type of literal to use to generate the update value

--UPDATE
-- Update tests in reverse complexity order since they have persistent effects
-- test where expressions

-- Explicitly using @assign_col instead of _variable here in the SET since we
-- don't fail gracefully if the types of the assignment can't be
-- implicitly cast.  See Ticket 200

--- test logic operators (AND) with comparison ops
UPDATE _table SET @assign_col = @assign_type WHERE (_variable _cmp _variable) _logic (_variable _cmp @cmp_type)
--- test arithmetic operators (+, -, *, /) with comparison ops
-- XXX COMMENTING THIS OUT UNTIL TICKET 201 IS RESOLVED
UPDATE _table SET @assign_col = @assign_type WHERE (_variable _math _value[int:0,100]) _cmp @cmp_type
--- test comparison ops (<, <=, =, >=, >)
UPDATE _table SET @assign_col = @assign_type WHERE _variable _cmp @cmp_type
-- test set expression
--- test arithmetic (+, -, *, /) ops
UPDATE _table SET @assign_col = @assign_col _math _value[int:0,3]
-- test simple update
UPDATE _table SET @assign_col = @assign_type


// Copyright (c) 2010-2017 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com

varying LOWP vec4 colorVarying;
varying MEDP vec2 uvVarying;

uniform sampler2D sampler;

void main() {
	gl_FragColor = texture2D ( sampler, uvVarying ) * colorVarying;
}


// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build arm,linux

package unix

import (
	"syscall"
	"unsafe"
)

func setTimespec(sec, nsec int64) Timespec {
	return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
}

func setTimeval(sec, usec int64) Timeval {
	return Timeval{Sec: int32(sec), Usec: int32(usec)}
}

func Pipe(p []int) (err error) {
	if len(p) != 2 {
		return EINVAL
	}
	var pp [2]_C_int
	err = pipe2(&pp, 0)
	p[0] = int(pp[0])
	p[1] = int(pp[1])
	return
}

//sysnb pipe2(p *[2]_C_int, flags int) (err error)

func Pipe2(p []int, flags int) (err error) {
	if len(p) != 2 {
		return EINVAL
	}
	var pp [2]_C_int
	err = pipe2(&pp, flags)
	p[0] = int(pp[0])
	p[1] = int(pp[1])
	return
}

// Underlying system call writes to newoffset via pointer.
// Implemented in assembly to avoid allocation.
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)

func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
	newoffset, errno := seek(fd, offset, whence)
	if errno != 0 {
		return 0, errno
	}
	return newoffset, nil
}

//sys	accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
//sys	accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error)
//sys	bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
//sys	connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
//sysnb	getgroups(n int, list *_Gid_t) (nn int, err error) = SYS_GETGROUPS32
//sysnb	setgroups(n int, list *_Gid_t) (err error) = SYS_SETGROUPS32
//sys	getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
//sys	setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
//sysnb	socket(domain int, typ int, proto int) (fd int, err error)
//sysnb	getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
//sysnb	getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
//sys	recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
//sys	sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
//sysnb	socketpair(domain int, typ int, flags int, fd *[2]int32) (err error)
//sys	recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
//sys	sendmsg(s int, msg *Msghdr, flags int) (n int, err error)

// 64-bit file system and 32-bit uid calls
// (16-bit uid calls are not always supported in newer kernels)
//sys	Dup2(oldfd int, newfd int) (err error)
//sys	Fchown(fd int, uid int, gid int) (err error) = SYS_FCHOWN32
//sys	Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
//sys	Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
//sysnb	Getegid() (egid int) = SYS_GETEGID32
//sysnb	Geteuid() (euid int) = SYS_GETEUID32
//sysnb	Getgid() (gid int) = SYS_GETGID32
//sysnb	Getuid() (uid int) = SYS_GETUID32
//sysnb	InotifyInit() (fd int, err error)
//sys	Lchown(path string, uid int, gid int) (err error) = SYS_LCHOWN32
//sys	Listen(s int, n int) (err error)
//sys	Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
//sys	sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64
//sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT
//sys	Setfsgid(gid int) (err error) = SYS_SETFSGID32
//sys	Setfsuid(uid int) (err error) = SYS_SETFSUID32
//sysnb	Setregid(rgid int, egid int) (err error) = SYS_SETREGID32
//sysnb	Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32
//sysnb	Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32
//sysnb	Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32
//sys	Shutdown(fd int, how int) (err error)
//sys	Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error)
//sys	Stat(path string, stat *Stat_t) (err error) = SYS_STAT64

// Vsyscalls on amd64.
//sysnb	Gettimeofday(tv *Timeval) (err error)
//sys	EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
//sys	Pause() (err error)

func Time(t *Time_t) (Time_t, error) {
	var tv Timeval
	err := Gettimeofday(&tv)
	if err != nil {
		return 0, err
	}
	if t != nil {
		*t = Time_t(tv.Sec)
	}
	return Time_t(tv.Sec), nil
}

func Utime(path string, buf *Utimbuf) error {
	tv := []Timeval{
		{Sec: buf.Actime},
		{Sec: buf.Modtime},
	}
	return Utimes(path, tv)
}

//sys   Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64
//sys   Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64
//sys	Truncate(path string, length int64) (err error) = SYS_TRUNCATE64
//sys	Ftruncate(fd int, length int64) (err error) = SYS_FTRUNCATE64

func Fadvise(fd int, offset int64, length int64, advice int) (err error) {
	_, _, e1 := Syscall6(SYS_ARM_FADVISE64_64, uintptr(fd), uintptr(advice), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32))
	if e1 != 0 {
		err = errnoErr(e1)
	}
	return
}

//sys	mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error)

func Fstatfs(fd int, buf *Statfs_t) (err error) {
	_, _, e := Syscall(SYS_FSTATFS64, uintptr(fd), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
	if e != 0 {
		err = e
	}
	return
}

func Statfs(path string, buf *Statfs_t) (err error) {
	pathp, err := BytePtrFromString(path)
	if err != nil {
		return err
	}
	_, _, e := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(pathp)), unsafe.Sizeof(*buf), uintptr(unsafe.Pointer(buf)))
	if e != 0 {
		err = e
	}
	return
}

func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
	page := uintptr(offset / 4096)
	if offset != int64(page)*4096 {
		return 0, EINVAL
	}
	return mmap2(addr, length, prot, flags, fd, page)
}

type rlimit32 struct {
	Cur uint32
	Max uint32
}

//sysnb getrlimit(resource int, rlim *rlimit32) (err error) = SYS_UGETRLIMIT

const rlimInf32 = ^uint32(0)
const rlimInf64 = ^uint64(0)

func Getrlimit(resource int, rlim *Rlimit) (err error) {
	err = prlimit(0, resource, nil, rlim)
	if err != ENOSYS {
		return err
	}

	rl := rlimit32{}
	err = getrlimit(resource, &rl)
	if err != nil {
		return
	}

	if rl.Cur == rlimInf32 {
		rlim.Cur = rlimInf64
	} else {
		rlim.Cur = uint64(rl.Cur)
	}

	if rl.Max == rlimInf32 {
		rlim.Max = rlimInf64
	} else {
		rlim.Max = uint64(rl.Max)
	}
	return
}

//sysnb setrlimit(resource int, rlim *rlimit32) (err error) = SYS_SETRLIMIT

func Setrlimit(resource int, rlim *Rlimit) (err error) {
	err = prlimit(0, resource, rlim, nil)
	if err != ENOSYS {
		return err
	}

	rl := rlimit32{}
	if rlim.Cur == rlimInf64 {
		rl.Cur = rlimInf32
	} else if rlim.Cur < uint64(rlimInf32) {
		rl.Cur = uint32(rlim.Cur)
	} else {
		return EINVAL
	}
	if rlim.Max == rlimInf64 {
		rl.Max = rlimInf32
	} else if rlim.Max < uint64(rlimInf32) {
		rl.Max = uint32(rlim.Max)
	} else {
		return EINVAL
	}

	return setrlimit(resource, &rl)
}

func (r *PtraceRegs) PC() uint64 { return uint64(r.Uregs[15]) }

func (r *PtraceRegs) SetPC(pc uint64) { r.Uregs[15] = uint32(pc) }

func (iov *Iovec) SetLen(length int) {
	iov.Len = uint32(length)
}

func (msghdr *Msghdr) SetControllen(length int) {
	msghdr.Controllen = uint32(length)
}

func (cmsg *Cmsghdr) SetLen(length int) {
	cmsg.Len = uint32(length)
}

//sys	poll(fds *PollFd, nfds int, timeout int) (n int, err error)

func Poll(fds []PollFd, timeout int) (n int, err error) {
	if len(fds) == 0 {
		return poll(nil, 0, timeout)
	}
	return poll(&fds[0], len(fds), timeout)
}


# SPDX-License-Identifier: GPL-2.0
#
# Makefile for the linux ext4-filesystem routines.
#

obj-$(CONFIG_EXT4_FS) += ext4.o

ext4-y	:= balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \
		extents_status.o file.o fsmap.o fsync.o hash.o ialloc.o \
		indirect.o inline.o inode.o ioctl.o mballoc.o migrate.o \
		mmp.o move_extent.o namei.o page-io.o readpage.o resize.o \
		super.o symlink.o sysfs.o xattr.o xattr_hurd.o xattr_trusted.o \
		xattr_user.o

ext4-$(CONFIG_EXT4_FS_POSIX_ACL)	+= acl.o
ext4-$(CONFIG_EXT4_FS_SECURITY)		+= xattr_security.o
ext4-inode-test-objs			+= inode-test.o
obj-$(CONFIG_EXT4_KUNIT_TESTS)		+= ext4-inode-test.o
ext4-$(CONFIG_FS_VERITY)		+= verity.o


package com.mploed.dddwithspring.scoring.agencyResult;

import org.junit.Test;

import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

public class AgencyResultTest {

	@Test
	public void testScoring0Ko0Warn95Points() {
		AgencyResultAggregate agencyResultAggregate = new AgencyResultAggregate.AgencyResultBuilder()
				.forPerson("Michael", "Plöd", "Kreuzstrasse 16", "80331", "München")
				.withPoints(95)
				.build();

		assertTrue(agencyResultAggregate.isAcceptable());
		assertEquals(20, agencyResultAggregate.calculateScoringPoints());
	}

	@Test
	public void testScoring0Ko6Warn95Points() {
		AgencyResultAggregate agencyResultAggregate = new AgencyResultAggregate.AgencyResultBuilder()
				.forPerson("Michael", "Plöd", "Kreuzstrasse 16", "80331", "München")
				.withPoints(95)
				.withWarning("1", "---")
				.withWarning("2", "---")
				.withWarning("3", "---")
				.withWarning("4", "---")
				.withWarning("5", "---")
				.withWarning("6", "---")
				.build();
		assertFalse(agencyResultAggregate.isAcceptable());
		assertEquals(15, agencyResultAggregate.calculateScoringPoints());
	}

	@Test
	public void testScoring0Ko0Warn83Points() {
		AgencyResultAggregate agencyResultAggregate = new AgencyResultAggregate.AgencyResultBuilder()
				.forPerson("Michael", "Plöd", "Kreuzstrasse 16", "80331", "München")
				.withPoints(83)
				.build();
		assertTrue(agencyResultAggregate.isAcceptable());
		assertEquals(10, agencyResultAggregate.calculateScoringPoints());
	}

	@Test
	public void testScoring0Ko0Warn90Points() {
		AgencyResultAggregate agencyResultAggregate = new AgencyResultAggregate.AgencyResultBuilder()
				.forPerson("Michael", "Plöd", "Kreuzstrasse 16", "80331", "München")
				.withPoints(90)
				.build();
		assertTrue(agencyResultAggregate.isAcceptable());
		assertEquals(15, agencyResultAggregate.calculateScoringPoints());
	}

	@Test
	public void testScoring0Ko1Warn90Points() {
		AgencyResultAggregate agencyResultAggregate = new AgencyResultAggregate.AgencyResultBuilder()
				.forPerson("Michael", "Plöd", "Kreuzstrasse 16", "80331", "München")
				.withWarning("00", "has only money for cheap pug food")
				.withPoints(90)
				.build();
		assertTrue(agencyResultAggregate.isAcceptable());
		assertEquals(10, agencyResultAggregate.calculateScoringPoints());
	}

	@Test
	public void testScoring1Ko0Warn90Points() {
		AgencyResultAggregate agencyResultAggregate = new AgencyResultAggregate.AgencyResultBuilder()
				.forPerson("Michael", "Plöd", "Kreuzstrasse 16", "80331", "München")
				.withKoCriteria("200", "is bankrupt")
				.withPoints(90)
				.build();
		assertFalse(agencyResultAggregate.isAcceptable());
		assertEquals(0, agencyResultAggregate.calculateScoringPoints());
	}

}


/*******************************************************************************
 * Copyright (c) 2015-2018 Skymind, Inc.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Apache License, Version 2.0 which is available at
 * https://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 ******************************************************************************/

//
//  @author raver119@gmail.com
//

#ifndef DEV_TESTS_SCATTER_H
#define DEV_TESTS_SCATTER_H

#include <array/NDArray.h>

namespace sd {
    namespace ops {
        namespace helpers {
            void scatter(sd::LaunchContext* context, pairwise::Ops op, const NDArray& indices, const NDArray& updates, NDArray& output, const bool lock);

            void scatterND(sd::LaunchContext* context, pairwise::Ops op, const NDArray& indices, const NDArray& updates, NDArray& output, const bool lock);

            void scatterForLoss(sd::LaunchContext* context, const NDArray& indices, NDArray& updates, NDArray& output, const bool calcGrad);

            Nd4jLong checkIndices(sd::LaunchContext *context, const NDArray& indices, const NDArray& output, const int axis = -1);
        }
    }
}

#endif //DEV_TESTS_SCATTER_H


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
	<maintainer type="project">
		<email>selinux@gentoo.org</email>
		<name>SELinux Team</name>
	</maintainer>
</pkgmetadata>


/*
 * Copyright (c) 2015 FUJI Goro (gfx).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.gfx.android.orma.test;

import com.github.gfx.android.orma.ModelFactory;
import com.github.gfx.android.orma.SingleAssociation;
import com.github.gfx.android.orma.rx.RxInserter;
import com.github.gfx.android.orma.test.model.Book;
import com.github.gfx.android.orma.test.model.Book_Schema;
import com.github.gfx.android.orma.test.model.Book_Selector;
import com.github.gfx.android.orma.test.model.OrmaDatabase;
import com.github.gfx.android.orma.test.model.Publisher;
import com.github.gfx.android.orma.test.toolbox.OrmaFactory;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;

import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import io.reactivex.ObservableSource;
import io.reactivex.SingleSource;
import io.reactivex.functions.Function;
import io.reactivex.functions.Predicate;

import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;

@RunWith(AndroidJUnit4.class)
public class RxJava2Test {

    OrmaDatabase db;

    Publisher publisher;

    @Before
    public void setUp() throws Exception {
        db = OrmaFactory.create();

        publisher = db.createPublisher(new ModelFactory<Publisher>() {
            @NonNull
            @Override
            public Publisher call() {
                Publisher publisher = new Publisher();
                publisher.name = "foo bar";
                publisher.startedYear = 2015;
                publisher.startedMonth = 12;

                return publisher;
            }
        });

        db.createBook(new ModelFactory<Book>() {
            @NonNull
            @Override
            public Book call() {
                Book book = new Book();
                book.title = "today";
                book.content = "milk, banana";
                book.inPrint = true;
                book.publisher = SingleAssociation.just(publisher);
                return book;
            }
        });

        db.createBook(new ModelFactory<Book>() {
            @NonNull
            @Override
            public Book call() {
                Book book = new Book();
                book.title = "friday";
                book.content = "apple";
                book.inPrint = false;
                book.publisher = SingleAssociation.just(publisher);
                return book;
            }
        });

        db.createBook(new ModelFactory<Book>() {
            @NonNull
            @Override
            public Book call() {
                Book book = new Book();
                book.title = "tomorrow";
                book.content = "orange";
                book.inPrint = false;
                book.publisher = SingleAssociation.just(publisher);
                return book;
            }
        });
    }

    Book_Selector selector() {
        return db.selectFromBook().titleNotEq("tomorrow");
    }

    @Test
    public void countAsSingle2() throws Exception {
        selector().countAsSingle()
                .test()
                .assertResult(2);
    }

    @Test
    public void selectorObservable2() throws Exception {
        selector().titleEq("today")
                .executeAsObservable()
                .map(new Function<Book, String>() {
                    @Override
                    public String apply(Book book) throws Exception {
                        return book.title;
                    }
                })
                .test()
                .assertResult("today");
    }

    @Test
    public void pluckAsObservable2() throws Exception {
        selector().orderByTitleAsc()
                .pluckAsObservable(Book_Schema.INSTANCE.title)
                .test()
                .assertResult("friday", "today");

        selector().orderByTitleDesc()
                .pluckAsObservable(Book_Schema.INSTANCE.title)
                .test()
                .assertResult("today", "friday");

        selector().orderByTitleAsc()
                .pluckAsObservable(Book_Schema.INSTANCE.inPrint)
                .test()
                .assertResult(false, true);

        selector().orderByTitleDesc()
                .pluckAsObservable(Book_Schema.INSTANCE.inPrint)
                .test()
                .assertResult(true, false);

    }

    @Test
    public void inserterSingle2() throws Exception {
        db.prepareInsertIntoBookAsSingle()
                .flatMap(new Function<RxInserter<Book>, SingleSource<Long>>() {
                    @Override
                    public SingleSource<Long> apply(RxInserter<Book> bookInserter) throws Exception {
                        return bookInserter.executeAsSingle(new Callable<Book>() {
                            @NonNull
                            @Override
                            public Book call() {
                                Book book = new Book();
                                book.title = "single days";
                                book.content = "reactive";
                                book.inPrint = false;
                                book.publisher = SingleAssociation.just(publisher);
                                return book;
                            }
                        });
                    }
                })
                .test()
                .assertValue(new Predicate<Long>() {
                    @Override
                    public boolean test(Long rowId) throws Exception {
                        return rowId != 0L;
                    }
                });

        assertThat(db.selectFromBook().count(), is(4));
    }

    @Test
    public void inserterInsertAllAsSingle2() throws Exception {
        db.prepareInsertIntoBookAsSingle()
                .flatMapObservable(new Function<RxInserter<Book>, ObservableSource<Long>>() {
                    @Override
                    public ObservableSource<Long> apply(RxInserter<Book> bookInserter) throws Exception {
                        Book book = new Book();
                        book.title = "single days";
                        book.content = "reactive";
                        book.inPrint = false;
                        book.publisher = SingleAssociation.just(publisher);
                        return bookInserter.executeAllAsObservable(Collections.singleton(book));
                    }
                })
                .test()
                .assertValue(new Predicate<Long>() {
                    @Override
                    public boolean test(Long rowId) throws Exception {
                        return rowId != 0L;
                    }
                });

        assertThat(db.selectFromBook().count(), is(4));
    }

    @Test
    public void updateSingle2() throws Exception {
        db.updateBook()
                .titleEq("today")
                .content("modified")
                .executeAsSingle()
                .test()
                .assertResult(1);

        assertThat(db.selectFromBook().titleEq("today").value().content, is("modified"));
    }

    @Test
    public void deleteSingle2() throws Exception {
        db.deleteFromBook()
                .titleEq("today")
                .executeAsSingle()
                .test()
                .assertResult(1);

        assertThat(db.selectFromBook().titleEq("today").valueOrNull(), is(nullValue()));
    }

    @Test
    public void exceptionInObservable2() throws Exception {
        @SuppressWarnings("serial")
        class AbortInMapException extends RuntimeException {

        }

        final List<String> mapped = new ArrayList<>();

        db.selectFromBook()
                .executeAsObservable()
                .map(new Function<Book, String>() {
                    @Override
                    public String apply(Book book) throws Exception {
                        mapped.add(book.title);
                        if ("friday".equals(book.title)) {
                            throw new AbortInMapException();
                        }
                        return book.title;
                    }
                })
                .test()
                .assertValues("today")
                .assertNotComplete()
                .assertError(AbortInMapException.class);

        assertThat(mapped, contains("today", "friday"));
    }
}


# This file is distributed under the same license as the Django package.
#
# Translators:
# Jannis Leidel <jannis@leidel.info>, 2011
msgid ""
msgstr ""
"Project-Id-Version: django-core\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-05-02 16:18+0200\n"
"PO-Revision-Date: 2013-04-29 08:30+0000\n"
"Last-Translator: claudep <claude@2xlibre.net>\n"
"Language-Team: Bosnian (http://www.transifex.com/projects/p/django/language/"
"bs/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: bs\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"

#: tests/base.py:100
msgid "lazy message"
msgstr "lijena poruka"


// Distributed under the terms of the MIT license
// Test case submitted to project by https://github.com/practicalswift (practicalswift)
// rdar://18706056

import Foundation
@objc protocol A {
   var a : String { get }
}
class B : A {
    @NSManaged var a : String
}


/*****************************************************************************\
*              efs - General purpose Embedded Filesystem library              *
*          --------------------- -----------------------------------          *
*                                                                             *
* Filename :  extract.h                                                       *
* Description : Headerfile for extract.c                                      *
*                                                                             *
* This program is free software; you can redistribute it and/or               *
* modify it under the terms of the GNU General Public License                 *
* as published by the Free Software Foundation; version 2                     *
* of the License.                                                             *
                                                                              *
* This program is distributed in the hope that it will be useful,             *
* but WITHOUT ANY WARRANTY; without even the implied warranty of              *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
* GNU General Public License for more details.                                *
*                                                                             *
* As a special exception, if other files instantiate templates or             *
* use macros or inline functions from this file, or you compile this          *
* file and link it with other works to produce a work based on this file,     *
* this file does not by itself cause the resulting work to be covered         *
* by the GNU General Public License. However the source code for this         *
* file must still be made available in accordance with section (3) of         *
* the GNU General Public License.                                             *
*                                                                             *
* This exception does not invalidate any other reasons why a work based       *
* on this file might be covered by the GNU General Public License.            *
*                                                                             *
*                                                    (c)2006 Lennart Yseboodt *
*                                                    (c)2006 Michael De Nil   *
\*****************************************************************************/

#ifndef __EXTRACT_H_
#define __EXTRACT_H_

/*****************************************************************************/
#include "config.h"
#include "disc.h"
#include "types.h"
/*****************************************************************************/

#ifdef BIG_ENDIAN

#define ltb_end16(x)  ((((uint16)(x) & 0xff00) >> 8) | \
                      (((uint16)(x) & 0x00ff) << 8))
#define ltb_end32(x)  ((((uint32)(x) & 0xff000000) >> 24) | \
                       (((uint32)(x) & 0x00ff0000) >> 8)  | \
                       (((uint32)(x) & 0x0000ff00) << 8)  | \
                       (((uint32)(x) & 0x000000ff) << 24))

#else

#define ltb_end16(x)  (x)
#define ltb_end32(x)  (x)

#endif

#define btl_end16 ltb_end16
#define btl_end32 ltb_end32

/*****************************************************************************/

euint16 ex_getb16(euint8* buf,euint32 offset);
void ex_setb16(euint8* buf,euint32 offset,euint16 data);

euint32 ex_getb32(euint8* buf,euint32 offset);
void ex_setb32(euint8* buf,euint32 offset,euint32 data);

void ex_getPartitionField(euint8* buf,PartitionField* pf, euint32 offset);
void ex_setPartitionField(euint8* buf,PartitionField* pf, euint32 offset);

#endif