Group common includes into common.h

Include config.h and compat.h in common.h, and include common.h from all
source files.
This commit is contained in:
Romain Vimont 2021-01-08 19:18:02 +01:00
parent 6385b8c162
commit 59feb2a15c
53 changed files with 30 additions and 63 deletions

View file

@ -5,8 +5,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "config.h"
#include "common.h"
#include "util/log.h" #include "util/log.h"
#include "util/str_util.h" #include "util/str_util.h"

View file

@ -4,7 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <inttypes.h> #include <inttypes.h>
#include "config.h" #include "common.h"
#include "util/process.h" #include "util/process.h"

View file

@ -6,7 +6,6 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "config.h"
#include "scrcpy.h" #include "scrcpy.h"
#include "util/log.h" #include "util/log.h"
#include "util/str_util.h" #include "util/str_util.h"

View file

@ -3,7 +3,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "config.h" #include "common.h"
#include "scrcpy.h" #include "scrcpy.h"
struct scrcpy_cli_args { struct scrcpy_cli_args {

View file

@ -2,6 +2,7 @@
#define COMMON_H #define COMMON_H
#include "config.h" #include "config.h"
#include "compat.h"
#define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0])) #define ARRAY_LEN(a) (sizeof(a) / sizeof(a[0]))
#define MIN(X,Y) (X) < (Y) ? (X) : (Y) #define MIN(X,Y) (X) < (Y) ? (X) : (Y)

View file

@ -3,7 +3,6 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "config.h"
#include "util/buffer_util.h" #include "util/buffer_util.h"
#include "util/log.h" #include "util/log.h"
#include "util/str_util.h" #include "util/str_util.h"

View file

@ -5,7 +5,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "config.h" #include "common.h"
#include "android/input.h" #include "android/input.h"
#include "android/keycodes.h" #include "android/keycodes.h"
#include "coords.h" #include "coords.h"

View file

@ -2,7 +2,6 @@
#include <assert.h> #include <assert.h>
#include "config.h"
#include "util/lock.h" #include "util/lock.h"
#include "util/log.h" #include "util/log.h"

View file

@ -5,7 +5,7 @@
#include <SDL2/SDL_mutex.h> #include <SDL2/SDL_mutex.h>
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include "config.h" #include "common.h"
#include "control_msg.h" #include "control_msg.h"
#include "receiver.h" #include "receiver.h"
#include "util/cbuf.h" #include "util/cbuf.h"

View file

@ -7,8 +7,6 @@
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include <unistd.h> #include <unistd.h>
#include "config.h"
#include "compat.h"
#include "events.h" #include "events.h"
#include "recorder.h" #include "recorder.h"
#include "video_buffer.h" #include "video_buffer.h"

View file

@ -4,7 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include "config.h" #include "common.h"
struct video_buffer; struct video_buffer;

View file

@ -1,6 +1,5 @@
#include "device.h" #include "device.h"
#include "config.h"
#include "util/log.h" #include "util/log.h"
bool bool

View file

@ -3,7 +3,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "config.h" #include "common.h"
#include "coords.h" #include "coords.h"
#include "util/net.h" #include "util/net.h"

View file

@ -2,7 +2,6 @@
#include <string.h> #include <string.h>
#include "config.h"
#include "util/buffer_util.h" #include "util/buffer_util.h"
#include "util/log.h" #include "util/log.h"

View file

@ -5,7 +5,7 @@
#include <stdint.h> #include <stdint.h>
#include <unistd.h> #include <unistd.h>
#include "config.h" #include "common.h"
#define DEVICE_MSG_MAX_SIZE (1 << 18) // 256k #define DEVICE_MSG_MAX_SIZE (1 << 18) // 256k
// type: 1 byte; length: 4 bytes // type: 1 byte; length: 4 bytes

View file

@ -1,7 +1,5 @@
#include "event_converter.h" #include "event_converter.h"
#include "config.h"
#define MAP(FROM, TO) case FROM: *to = TO; return true #define MAP(FROM, TO) case FROM: *to = TO; return true
#define FAIL default: return false #define FAIL default: return false

View file

@ -4,7 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <SDL2/SDL_events.h> #include <SDL2/SDL_events.h>
#include "config.h" #include "common.h"
#include "control_msg.h" #include "control_msg.h"
bool bool

View file

@ -3,7 +3,6 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "config.h"
#include "adb.h" #include "adb.h"
#include "util/lock.h" #include "util/lock.h"
#include "util/log.h" #include "util/log.h"

View file

@ -5,7 +5,7 @@
#include <SDL2/SDL_mutex.h> #include <SDL2/SDL_mutex.h>
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include "config.h" #include "common.h"
#include "adb.h" #include "adb.h"
#include "util/cbuf.h" #include "util/cbuf.h"

View file

@ -3,7 +3,6 @@
#include <assert.h> #include <assert.h>
#include <SDL2/SDL_timer.h> #include <SDL2/SDL_timer.h>
#include "config.h"
#include "util/lock.h" #include "util/lock.h"
#include "util/log.h" #include "util/log.h"

View file

@ -7,7 +7,7 @@
#include <SDL2/SDL_mutex.h> #include <SDL2/SDL_mutex.h>
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include "config.h" #include "common.h"
struct fps_counter { struct fps_counter {
SDL_Thread *thread; SDL_Thread *thread;

View file

@ -3,7 +3,6 @@
#include <assert.h> #include <assert.h>
#include <SDL2/SDL_keycode.h> #include <SDL2/SDL_keycode.h>
#include "config.h"
#include "event_converter.h" #include "event_converter.h"
#include "util/lock.h" #include "util/lock.h"
#include "util/log.h" #include "util/log.h"

View file

@ -5,7 +5,7 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "config.h" #include "common.h"
#include "controller.h" #include "controller.h"
#include "fps_counter.h" #include "fps_counter.h"
#include "scrcpy.h" #include "scrcpy.h"

View file

@ -7,9 +7,8 @@
#define SDL_MAIN_HANDLED // avoid link error on Linux Windows Subsystem #define SDL_MAIN_HANDLED // avoid link error on Linux Windows Subsystem
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "config.h" #include "common.h"
#include "cli.h" #include "cli.h"
#include "compat.h"
#include "util/log.h" #include "util/log.h"
static void static void

View file

@ -4,7 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <SDL2/SDL_opengl.h> #include <SDL2/SDL_opengl.h>
#include "config.h" #include "common.h"
struct sc_opengl { struct sc_opengl {
const char *version; const char *version;

View file

@ -3,7 +3,6 @@
#include <assert.h> #include <assert.h>
#include <SDL2/SDL_clipboard.h> #include <SDL2/SDL_clipboard.h>
#include "config.h"
#include "device_msg.h" #include "device_msg.h"
#include "util/lock.h" #include "util/lock.h"
#include "util/log.h" #include "util/log.h"

View file

@ -5,7 +5,7 @@
#include <SDL2/SDL_mutex.h> #include <SDL2/SDL_mutex.h>
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include "config.h" #include "common.h"
#include "util/net.h" #include "util/net.h"
// receive events from the device // receive events from the device

View file

@ -3,8 +3,6 @@
#include <assert.h> #include <assert.h>
#include <libavutil/time.h> #include <libavutil/time.h>
#include "config.h"
#include "compat.h"
#include "util/lock.h" #include "util/lock.h"
#include "util/log.h" #include "util/log.h"

View file

@ -6,7 +6,7 @@
#include <SDL2/SDL_mutex.h> #include <SDL2/SDL_mutex.h>
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include "config.h" #include "common.h"
#include "coords.h" #include "coords.h"
#include "scrcpy.h" #include "scrcpy.h"
#include "util/queue.h" #include "util/queue.h"

View file

@ -13,8 +13,6 @@
# include <windows.h> # include <windows.h>
#endif #endif
#include "config.h"
#include "compat.h"
#include "controller.h" #include "controller.h"
#include "decoder.h" #include "decoder.h"
#include "device.h" #include "device.h"

View file

@ -5,7 +5,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "config.h" #include "common.h"
enum sc_log_level { enum sc_log_level {
SC_LOG_LEVEL_DEBUG, SC_LOG_LEVEL_DEBUG,

View file

@ -4,9 +4,6 @@
#include <string.h> #include <string.h>
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "config.h"
#include "common.h"
#include "compat.h"
#include "icon.xpm" #include "icon.xpm"
#include "scrcpy.h" #include "scrcpy.h"
#include "tiny_xpm.h" #include "tiny_xpm.h"

View file

@ -5,7 +5,7 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include "config.h" #include "common.h"
#include "coords.h" #include "coords.h"
#include "opengl.h" #include "opengl.h"

View file

@ -9,7 +9,6 @@
#include <SDL2/SDL_timer.h> #include <SDL2/SDL_timer.h>
#include <SDL2/SDL_platform.h> #include <SDL2/SDL_platform.h>
#include "config.h"
#include "adb.h" #include "adb.h"
#include "util/lock.h" #include "util/lock.h"
#include "util/log.h" #include "util/log.h"

View file

@ -6,7 +6,7 @@
#include <stdint.h> #include <stdint.h>
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include "config.h" #include "common.h"
#include "adb.h" #include "adb.h"
#include "scrcpy.h" #include "scrcpy.h"
#include "util/log.h" #include "util/log.h"

View file

@ -8,8 +8,6 @@
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include <unistd.h> #include <unistd.h>
#include "config.h"
#include "compat.h"
#include "decoder.h" #include "decoder.h"
#include "events.h" #include "events.h"
#include "recorder.h" #include "recorder.h"

View file

@ -7,7 +7,7 @@
#include <SDL2/SDL_atomic.h> #include <SDL2/SDL_atomic.h>
#include <SDL2/SDL_thread.h> #include <SDL2/SDL_thread.h>
#include "config.h" #include "common.h"
#include "util/net.h" #include "util/net.h"
struct video_buffer; struct video_buffer;

View file

@ -11,8 +11,6 @@
#include "util/process.h" #include "util/process.h"
#include "config.h"
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>

View file

@ -3,7 +3,6 @@
#include <assert.h> #include <assert.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "config.h"
#include "util/log.h" #include "util/log.h"
#include "util/str_util.h" #include "util/str_util.h"

View file

@ -6,7 +6,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "config.h"
#include "util/log.h" #include "util/log.h"
struct index { struct index {

View file

@ -3,7 +3,7 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include "config.h" #include "common.h"
SDL_Surface * SDL_Surface *
read_xpm(char *xpm[]); read_xpm(char *xpm[]);

View file

@ -4,7 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include "config.h" #include "common.h"
static inline void static inline void
buffer_write16be(uint8_t *buf, uint16_t value) { buffer_write16be(uint8_t *buf, uint16_t value) {

View file

@ -5,7 +5,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h> #include <unistd.h>
#include "config.h" #include "common.h"
// To define a circular buffer type of 20 ints: // To define a circular buffer type of 20 ints:
// struct cbuf_int CBUF(int, 20); // struct cbuf_int CBUF(int, 20);

View file

@ -4,7 +4,7 @@
#include <stdint.h> #include <stdint.h>
#include <SDL2/SDL_mutex.h> #include <SDL2/SDL_mutex.h>
#include "config.h" #include "common.h"
#include "log.h" #include "log.h"
static inline void static inline void

View file

@ -3,7 +3,6 @@
#include <stdio.h> #include <stdio.h>
#include <SDL2/SDL_platform.h> #include <SDL2/SDL_platform.h>
#include "config.h"
#include "log.h" #include "log.h"
#ifdef __WINDOWS__ #ifdef __WINDOWS__

View file

@ -17,7 +17,7 @@
typedef int socket_t; typedef int socket_t;
#endif #endif
#include "config.h" #include "common.h"
bool bool
net_init(void); net_init(void);

View file

@ -3,7 +3,7 @@
#include <stdbool.h> #include <stdbool.h>
#include "config.h" #include "common.h"
#ifdef _WIN32 #ifdef _WIN32

View file

@ -6,7 +6,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include "config.h" #include "common.h"
// To define a queue type of "struct foo": // To define a queue type of "struct foo":
// struct queue_foo QUEUE(struct foo); // struct queue_foo QUEUE(struct foo);

View file

@ -12,8 +12,6 @@
#include <SDL2/SDL_stdinc.h> #include <SDL2/SDL_stdinc.h>
#include "config.h"
size_t size_t
xstrncpy(char *dest, const char *src, size_t n) { xstrncpy(char *dest, const char *src, size_t n) {
size_t i; size_t i;

View file

@ -4,7 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include "config.h" #include "common.h"
// like strncpy, except: // like strncpy, except:
// - it copies at most n-1 chars // - it copies at most n-1 chars

View file

@ -5,7 +5,6 @@
#include <libavutil/avutil.h> #include <libavutil/avutil.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include "config.h"
#include "util/lock.h" #include "util/lock.h"
#include "util/log.h" #include "util/log.h"

View file

@ -4,7 +4,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <SDL2/SDL_mutex.h> #include <SDL2/SDL_mutex.h>
#include "config.h" #include "common.h"
#include "fps_counter.h" #include "fps_counter.h"
// forward declarations // forward declarations

View file

@ -1,8 +1,8 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "cli.h"
#include "common.h" #include "common.h"
#include "cli.h"
#include "scrcpy.h" #include "scrcpy.h"
static void test_flag_version(void) { static void test_flag_version(void) {