mirror of https://github.com/Genymobile/scrcpy
Add adb devices parser
Add a parser of `adb device -l` output, to extract a list of devices with their serial, state and model. PR #3005 <https://github.com/Genymobile/scrcpy/pull/3005>pull/3005/head
parent
85ff70fc95
commit
4389de1c23
@ -0,0 +1,26 @@
|
|||||||
|
#include "adb_device.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_adb_device_destroy(struct sc_adb_device *device) {
|
||||||
|
free(device->serial);
|
||||||
|
free(device->state);
|
||||||
|
free(device->model);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_adb_device_move(struct sc_adb_device *dst, struct sc_adb_device *src) {
|
||||||
|
*dst = *src;
|
||||||
|
src->serial = NULL;
|
||||||
|
src->state = NULL;
|
||||||
|
src->model = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_adb_devices_destroy_all(struct sc_adb_device *devices, size_t count) {
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
sc_adb_device_destroy(&devices[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef SC_ADB_DEVICE_H
|
||||||
|
#define SC_ADB_DEVICE_H
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
struct sc_adb_device {
|
||||||
|
char *serial;
|
||||||
|
char *state;
|
||||||
|
char *model;
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_adb_device_destroy(struct sc_adb_device *device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move src to dst
|
||||||
|
*
|
||||||
|
* After this call, the content of src is undefined, except that
|
||||||
|
* sc_adb_device_destroy() can be called.
|
||||||
|
*
|
||||||
|
* This is useful to take a device from a list that will be destroyed, without
|
||||||
|
* making unnecessary copies.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
sc_adb_device_move(struct sc_adb_device *dst, struct sc_adb_device *src);
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_adb_devices_destroy_all(struct sc_adb_device *devices, size_t count);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue