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

#ifndef _BUILD_TOOLS_APPLYPATCH_UTILS_H
#define _BUILD_TOOLS_APPLYPATCH_UTILS_H

#include <sys/types.h>

#include <stdio.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <err.h>
#include <fcntl.h>

#ifndef _WIN32
#include <unistd.h>
#endif

#define free_ptr(ptr) if(ptr!=NULL)free(ptr);ptr=NULL;
#define close_fp(fp) if(fp!=NULL)fclose(fp);fp=NULL;
#define safe_free(x) do { if(x) {free(x); x=NULL;} } while(0)

#define GOERR_IF_FAIL(x)  do{if((x) < 0) goto  out_error;}while(0)

#define GOERR_IF_NOK(x)  do{if((x) != 0) goto  out_error;}while(0)

typedef unsigned int uint32_t;
typedef int int32_t;
typedef unsigned char u_char;
typedef unsigned char uint8_t;

#define MIN(x,y) (((x)<(y)) ? (x) : (y))
#define MAX(x,y) (((x)>(y)) ? (x) : (y))

#define safe_free(x) do { if(x) {free(x); x=NULL;} } while(0)

#define log(fmt, args...) do {printf("[%s:%d]"fmt"\n", __FUNCTION__, __LINE__, ##args);}while(0)
#define LOGD(fmt, args...) do {printf("[%s:%d]"fmt"\n", __FUNCTION__, __LINE__, ##args);}while(0)
#define LOGE(fmt, args...) do {printf("[%s:%d]"fmt"\n", __FUNCTION__, __LINE__, ##args);}while(0)

#define GOERR_IF_FAIL(x)  do{if((x) < 0) goto  out_error;}while(0)

unsigned char * readfile(const char *dir, const char *name, size_t *len);
int write_file(FILE* fp, const void *buf, int count);

void dump_data(const u_char* data, int n);
uint32_t little_endian_offin(u_char *buf);
void little_endian_offout(uint32_t x, u_char *buf);
FILE*  create_new_file(const char* name);
char *dir_name(char * path);
int write_file_by_path(const char*path, const char*value, int size);
int read_file_by_path(const char*path, char*buf, int sz);

// Read and write little-endian values of various sizes.

void Write4(int value, FILE* f);
void Write8(long long value, FILE* f);
int Read2(void* p);
int Read4(void* p);
long long Read8(void* p);

#endif //  _BUILD_TOOLS_APPLYPATCH_UTILS_H
