/*-1* Copyright 2016 Netflix, Inc.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11*12* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND13* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE14* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE15* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE16* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL17* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS18* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)19* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT20* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY21* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF22* SUCH DAMAGE.23*/2425#include <efi.h>26#include <efilib.h>2728/*29* CHAR16 related functions moved from loader.30* Perhaps we should move those to libsa afterall, but they are31* needed only by UEFI.32*/3334int35wcscmp(CHAR16 *a, CHAR16 *b)36{3738while (*a && *b && *a == *b) {39a++;40b++;41}42return *a - *b;43}4445/*46* cpy8to16 copies a traditional C string into a CHAR16 string and47* 0 terminates it. len is the size of *dst in bytes.48*/49void50cpy8to16(const char *src, CHAR16 *dst, size_t len)51{52len <<= 1; /* Assume CHAR16 is 2 bytes */53while (len > 0 && *src) {54*dst++ = *src++;55len--;56}57*dst++ = (CHAR16)0;58}5960void61cpy16to8(const CHAR16 *src, char *dst, size_t len)62{63size_t i;6465for (i = 0; i < len && src[i]; i++)66dst[i] = (char)src[i];67if (i < len)68dst[i] = '\0';69}707172