本文整理汇总了C++中ASTRDUP函数的典型用法代码示例。如果您正苦于以下问题:C++ ASTRDUP函数的具体用法?C++ ASTRDUP怎么用?C++ ASTRDUP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ASTRDUP函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: avdInfo_newForAndroidBuild
AvdInfo*
avdInfo_newForAndroidBuild( const char* androidBuildRoot,
const char* androidOut,
AvdInfoParams* params )
{
AvdInfo* i;
ANEW0(i);
i->inAndroidBuild = 1;
i->androidBuildRoot = ASTRDUP(androidBuildRoot);
i->androidOut = ASTRDUP(androidOut);
i->contentPath = ASTRDUP(androidOut);
i->targetArch = path_getBuildTargetArch(i->androidOut);
i->apiLevel = path_getBuildTargetApiLevel(i->androidOut);
/* TODO: find a way to provide better information from the build files */
i->deviceName = ASTRDUP("<build>");
/* There is no config.ini in the build */
i->configIni = NULL;
if (_avdInfo_getCoreHwIniPath(i, i->androidOut) < 0 )
goto FAIL;
/* Read the build skin's hardware.ini, if any */
_avdInfo_getBuildSkinHardwareIni(i);
return i;
FAIL:
avdInfo_free(i);
return NULL;
}
开发者ID:bindassdost,项目名称:razrd,代码行数:34,代码来源:info.c
示例2: camera_device_open
CameraDevice*
camera_device_open(const char* name, int inp_channel)
{
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
LinuxCameraDevice* cd;
/* Allocate and initialize the descriptor. */
cd = _camera_device_alloc();
//cd->device_name = name != NULL ? ASTRDUP(name) : ASTRDUP("/dev/video0");
//Gemdroid added
cd->device_name = name != NULL ? ASTRDUP(name) : ASTRDUP("/dev/video1");
//Gemdroid added
cd->input_channel = inp_channel;
/* Open the device. */
if (_camera_device_open(cd)) {
_camera_device_free(cd);
return NULL;
}
/* Select video input, video standard and tune here. */
cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
_xioctl(cd->handle, VIDIOC_CROPCAP, &cropcap);
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
crop.c = cropcap.defrect; /* reset to default */
_xioctl (cd->handle, VIDIOC_S_CROP, &crop);
return &cd->header;
}
开发者ID:abhinavjayanthy,项目名称:GemDroid,代码行数:30,代码来源:camera-capture-linux.c
示例3: path_get_absolute
char*
path_get_absolute( const char* path )
{
if (path_is_absolute(path)) {
return ASTRDUP(path);
}
#ifdef _WIN32
{
char* result;
int pathLen = strlen(path);
int currentLen = GetCurrentDirectory(0, NULL);
if (currentLen <= 0) {
/* Could not get size of working directory. something is
* really fishy here, return a simple copy */
return ASTRDUP(path);
}
result = malloc(currentLen + pathLen + 2);
GetCurrentDirectory(currentLen+1, result);
if (currentLen == 0 || result[currentLen-1] != '\\') {
result[currentLen++] = '\\';
}
memcpy(result + currentLen, path, pathLen+1);
return result;
}
#else
{
int pathLen = strlen(path);
char currentDir[PATH_MAX];
int currentLen;
char* result;
if (getcwd(currentDir, sizeof(currentDir)) == NULL) {
/* Could not get the current working directory. something is really
* fishy here, so don't do anything and return a copy */
return ASTRDUP(path);
}
/* Make a new path with <current-path>/<path> */
currentLen = strlen(currentDir);
result = malloc(currentLen + pathLen + 2);
memcpy(result, currentDir, currentLen);
if (currentLen == 0 || result[currentLen-1] != '/') {
result[currentLen++] = '/';
}
memcpy(result + currentLen, path, pathLen+1);
return result;
}
#endif
}
开发者ID:Dazdin9o,项目名称:DECAF,代码行数:55,代码来源:path.c
示例4: _checkSkinSkinsDir
/* Check that there is a skin named 'skinName' listed from 'skinDirRoot'
* this returns the full path of the skin directory (after alias expansions),
* including the skin name, or NULL on failure.
*/
static char*
_checkSkinSkinsDir( const char* skinDirRoot,
const char* skinName )
{
DirScanner* scanner;
char* result;
char temp[MAX_PATH], *p = temp, *end = p + sizeof(temp);
p = bufprint(temp, end, "%s/skins/%s", skinDirRoot, skinName);
DD("Probing skin directory: %s", temp);
if (p >= end || !path_exists(temp)) {
DD(" ignore bad skin directory %s", temp);
return NULL;
}
/* first, is this a normal skin directory ? */
if (_checkSkinPath(temp)) {
/* yes */
DD(" found skin directory: %s", temp);
return ASTRDUP(temp);
}
/* second, is it an alias to another skin ? */
*p = 0;
result = NULL;
scanner = dirScanner_new(temp);
if (scanner != NULL) {
for (;;) {
const char* file = dirScanner_next(scanner);
if (file == NULL)
break;
if (strncmp(file, "alias-", 6) || file[6] == 0)
continue;
p = bufprint(temp, end, "%s/skins/%s", skinDirRoot, file+6);
if (p < end && _checkSkinPath(temp)) {
/* yes, it's an alias */
DD(" skin alias '%s' points to skin directory: %s",
file+6, temp);
result = ASTRDUP(temp);
break;
}
}
dirScanner_free(scanner);
}
return result;
}
开发者ID:bindassdost,项目名称:razrd,代码行数:53,代码来源:info.c
示例5: _getFullFilePath
/* TODO: Put in shared source file */
static char*
_getFullFilePath( const char* rootPath, const char* fileName )
{
if (path_is_absolute(fileName)) {
return ASTRDUP(fileName);
} else {
char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp);
p = bufprint(temp, end, "%s/%s", rootPath, fileName);
if (p >= end) {
return NULL;
}
return ASTRDUP(temp);
}
}
开发者ID:MarvelHq,项目名称:DECAF,代码行数:16,代码来源:main.c
示例6: _wecam_setup
/* Initialized webcam emulation record in camera service descriptor.
* Param:
* csd - Camera service descriptor to initialize a record in.
* disp_name - Display name of a web camera ('webcam<N>') to use for emulation.
* dir - Direction ('back', or 'front') that emulated camera is facing.
* ci, ci_cnt - Array of webcam information for enumerated web cameras connected
* to the host.
*/
static void
_wecam_setup(CameraServiceDesc* csd,
const char* disp_name,
const char* dir,
CameraInfo* ci,
int ci_cnt)
{
/* Find webcam record in the list of enumerated web cameras. */
CameraInfo* found = _camera_info_get_by_display_name(disp_name, ci, ci_cnt);
if (found == NULL) {
W("Camera name '%s' is not found in the list of connected cameras.\n"
"Use '-webcam-list' emulator option to obtain the list of connected camera names.\n",
disp_name);
return;
}
/* Save to the camera info array that will be used by the service. */
memcpy(csd->camera_info + csd->camera_count, found, sizeof(CameraInfo));
/* This camera is taken. */
found->in_use = 1;
/* Update direction parameter. */
if (csd->camera_info[csd->camera_count].direction != NULL) {
free(csd->camera_info[csd->camera_count].direction);
}
csd->camera_info[csd->camera_count].direction = ASTRDUP(dir);
D("Camera %d '%s' connected to '%s' facing %s using %.4s pixel format",
csd->camera_count, csd->camera_info[csd->camera_count].display_name,
csd->camera_info[csd->camera_count].device_name,
csd->camera_info[csd->camera_count].direction,
(const char*)(&csd->camera_info[csd->camera_count].pixel_format));
csd->camera_count++;
}
开发者ID:3a9LL,项目名称:panda,代码行数:40,代码来源:camera-service.c
示例7: _avdInfo_getContentPath
/* Returns the AVD's content path, i.e. the directory that contains
* the AVD's content files (e.g. data partition, cache, sd card, etc...).
*
* We extract this by parsing the root config .ini file, looking for
* a "path" elements.
*/
static int
_avdInfo_getContentPath( AvdInfo* i )
{
char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp);
i->contentPath = iniFile_getString(i->rootIni, ROOT_ABS_PATH_KEY, NULL);
if (i->contentPath == NULL) {
derror("bad config: %s",
"virtual device file lacks a "ROOT_ABS_PATH_KEY" entry");
return -1;
}
if (!path_is_dir(i->contentPath)) {
// If the absolute path doesn't match an actual directory, try
// the relative path if present.
const char* relPath = iniFile_getString(i->rootIni, ROOT_REL_PATH_KEY, NULL);
if (relPath != NULL) {
p = bufprint_config_path(temp, end);
p = bufprint(p, end, PATH_SEP "%s", relPath);
if (p < end && path_is_dir(temp)) {
AFREE(i->contentPath);
i->contentPath = ASTRDUP(temp);
}
}
}
D("virtual device content at %s", i->contentPath);
return 0;
}
开发者ID:jvaemape,项目名称:qemu-android,代码行数:36,代码来源:info.c
示例8: enumerate_camera_devices
int
enumerate_camera_devices(CameraInfo* cis, int max)
{
char dev_name[24];
int found = 0;
int n;
for (n = 0; n < max; n++) {
CameraDevice* cd;
sprintf(dev_name, "/dev/video%d", n);
cd = camera_device_open(dev_name, 0);
if (cd != NULL) {
LinuxCameraDevice* lcd = (LinuxCameraDevice*)cd->opaque;
if (!_camera_device_get_info(lcd, cis + found)) {
char user_name[24];
sprintf(user_name, "webcam%d", found);
cis[found].display_name = ASTRDUP(user_name);
cis[found].in_use = 0;
found++;
}
camera_device_close(cd);
} else {
break;
}
}
return found;
}
开发者ID:abhinavjayanthy,项目名称:GemDroid,代码行数:29,代码来源:camera-capture-linux.c
示例9: _avdInfo_getSdkFilePath
/* Search a file in the SDK search directories. Return NULL if not found,
* or a strdup() otherwise.
*/
static char*
_avdInfo_getSdkFilePath(AvdInfo* i, const char* fileName)
{
char temp[MAX_PATH], *p = temp, *end = p + sizeof(temp);
do {
/* try the search paths */
int nn;
for (nn = 0; nn < i->numSearchPaths; nn++) {
const char* searchDir = i->searchPaths[nn];
p = bufprint(temp, end, "%s/%s", searchDir, fileName);
if (p < end && path_exists(temp)) {
DD("found %s in search dir: %s", fileName, searchDir);
goto FOUND;
}
DD(" no %s in search dir: %s", fileName, searchDir);
}
return NULL;
} while (0);
FOUND:
return ASTRDUP(temp);
}
开发者ID:bindassdost,项目名称:razrd,代码行数:30,代码来源:info.c
示例10: avdInfo_getKernelPath
char*
avdInfo_getKernelPath( AvdInfo* i )
{
const char* imageName = _imageFileNames[ AVD_IMAGE_KERNEL ];
char* kernelPath = _avdInfo_getContentOrSdkFilePath(i, imageName);
if (kernelPath == NULL && i->inAndroidBuild) {
/* When in the Android build, look into the prebuilt directory
* for our target architecture.
*/
char temp[PATH_MAX], *p = temp, *end = p + sizeof(temp);
const char* suffix = "";
char* abi;
/* If the target ABI is armeabi-v7a, then look for
* kernel-qemu-armv7 instead of kernel-qemu in the prebuilt
* directory. */
abi = path_getBuildTargetAbi(i->androidOut);
if (!strcmp(abi,"armeabi-v7a")) {
suffix = "-armv7";
}
AFREE(abi);
p = bufprint(temp, end, "%s/prebuilts/qemu-kernel/%s/kernel-qemu%s",
i->androidBuildRoot, i->targetArch, suffix);
if (p >= end || !path_exists(temp)) {
derror("bad workspace: cannot find prebuilt kernel in: %s", temp);
exit(1);
}
kernelPath = ASTRDUP(temp);
}
return kernelPath;
}
开发者ID:bindassdost,项目名称:razrd,代码行数:34,代码来源:info.c
示例11: _getSearchPaths
/* Parse a given config.ini file and extract the list of SDK search paths
* from it. Returns the number of valid paths stored in 'searchPaths', or -1
* in case of problem.
*
* Relative search paths in the config.ini will be stored as full pathnames
* relative to 'sdkRootPath'.
*
* 'searchPaths' must be an array of char* pointers of at most 'maxSearchPaths'
* entries.
*/
static int
_getSearchPaths( IniFile* configIni,
const char* sdkRootPath,
int maxSearchPaths,
char** searchPaths )
{
char temp[PATH_MAX], *p = temp, *end= p+sizeof temp;
int nn, count = 0;
for (nn = 0; nn < maxSearchPaths; nn++) {
char* path;
p = bufprint(temp, end, "%s%d", SEARCH_PREFIX, nn+1 );
if (p >= end)
continue;
path = iniFile_getString(configIni, temp, NULL);
if (path != NULL) {
DD(" found image search path: %s", path);
if (!path_is_absolute(path)) {
p = bufprint(temp, end, "%s/%s", sdkRootPath, path);
AFREE(path);
path = ASTRDUP(temp);
}
searchPaths[count++] = path;
}
}
return count;
}
开发者ID:bindassdost,项目名称:razrd,代码行数:39,代码来源:info.c
示例12: find_target_compiler
/* Find target compiler using a path from COLLECT_GCC or COMPILER_PATH. */
static char *
find_target_compiler (const char *name)
{
bool found = false;
char **paths = NULL;
unsigned n_paths, i;
char *target_compiler;
const char *collect_gcc = getenv ("COLLECT_GCC");
const char *gcc_path = dirname (ASTRDUP (collect_gcc));
const char *gcc_exec = basename (ASTRDUP (collect_gcc));
if (strcmp (gcc_exec, collect_gcc) == 0)
{
/* collect_gcc has no path, so it was found in PATH. Make sure we also
find accel-gcc in PATH. */
target_compiler = XDUPVEC (char, name, strlen (name) + 1);
found = true;
goto out;
}
开发者ID:AHelper,项目名称:gcc,代码行数:20,代码来源:intelmic-mkoffload.c
示例13: path_getBuildBootProp
char* path_getBuildBootProp(const char* androidOut) {
char temp[MAX_PATH], *p = temp, *end = p + sizeof(temp);
p = bufprint(temp, end, "%s/boot.prop", androidOut);
if (p >= end) {
D("ANDROID_BUILD_OUT is too long: %s\n", androidOut);
return NULL;
}
if (!path_exists(temp)) {
D("Cannot find boot properties file: %s\n", temp);
return NULL;
}
return ASTRDUP(temp);
}
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_external_qemu,代码行数:13,代码来源:util.c
示例14: camera_device_open
CameraDevice*
camera_device_open(const char* name, int inp_channel)
{
WndCameraDevice* wcd;
/* Allocate descriptor and initialize windows-specific fields. */
wcd = _camera_device_alloc();
if (wcd == NULL) {
E("%s: Unable to allocate WndCameraDevice instance", __FUNCTION__);
return NULL;
}
wcd->window_name = (name != NULL) ? ASTRDUP(name) :
ASTRDUP(_default_window_name);
if (wcd->window_name == NULL) {
E("%s: Unable to save window name", __FUNCTION__);
_camera_device_free(wcd);
return NULL;
}
wcd->input_channel = inp_channel;
/* Create capture window that is a child of HWND_MESSAGE window.
* We make it invisible, so it doesn't mess with the UI. Also
* note that we supply standard HWND_MESSAGE window handle as
* the parent window, since we don't want video capturing
* machinery to be dependent on the details of our UI. */
wcd->cap_window = capCreateCaptureWindow(wcd->window_name, WS_CHILD, 0, 0,
0, 0, HWND_MESSAGE, 1);
if (wcd->cap_window == NULL) {
E("%s: Unable to create video capturing window '%s': %d",
__FUNCTION__, wcd->window_name, GetLastError());
_camera_device_free(wcd);
return NULL;
}
/* Save capture window descriptor as window's user data. */
capSetUserData(wcd->cap_window, wcd);
return &wcd->header;
}
开发者ID:0omega,项目名称:platform_external_qemu,代码行数:38,代码来源:camera-capture-windows.c
示例15: _avdInfo_getContentFilePath
/* Look for a named file inside the AVD's content directory.
* Returns NULL if it doesn't exist, or a strdup() copy otherwise.
*/
static char*
_avdInfo_getContentFilePath(AvdInfo* i, const char* fileName)
{
char temp[MAX_PATH], *p = temp, *end = p + sizeof(temp);
p = bufprint(p, end, "%s/%s", i->contentPath, fileName);
if (p >= end) {
derror("can't access virtual device content directory");
return NULL;
}
if (!path_exists(temp)) {
return NULL;
}
return ASTRDUP(temp);
}
开发者ID:bindassdost,项目名称:razrd,代码行数:18,代码来源:info.c
示例16: path_getRootIniPath
/* Return the path to the AVD's root configuration .ini file. it is located in
* ~/.android/avd/<name>.ini or Windows equivalent
*
* This file contains the path to the AVD's content directory, which
* includes its own config.ini.
*/
char*
path_getRootIniPath( const char* avdName )
{
char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp);
p = bufprint_config_path(temp, end);
p = bufprint(p, end, PATH_SEP ANDROID_AVD_DIR PATH_SEP "%s.ini", avdName);
if (p >= end) {
return NULL;
}
if (!path_exists(temp)) {
return NULL;
}
return ASTRDUP(temp);
}
开发者ID:PDi-Communication-Systems-Inc,项目名称:lollipop_external_qemu,代码行数:21,代码来源:util.c
示例17: avdInfo_getTracePath
char*
avdInfo_getTracePath( AvdInfo* i, const char* traceName )
{
char tmp[MAX_PATH], *p=tmp, *end=p + sizeof(tmp);
if (i == NULL || traceName == NULL || traceName[0] == 0)
return NULL;
if (i->inAndroidBuild) {
p = bufprint( p, end, "%s" PATH_SEP "traces" PATH_SEP "%s",
i->androidOut, traceName );
} else {
p = bufprint( p, end, "%s" PATH_SEP "traces" PATH_SEP "%s",
i->contentPath, traceName );
}
return ASTRDUP(tmp);
}
开发者ID:bindassdost,项目名称:razrd,代码行数:17,代码来源:info.c
示例18: _getSkinPathFromName
/* try to see if the skin name leads to a magic skin or skin path directly
* returns 1 on success, 0 on error.
*
* on success, this sets up '*pSkinName' and '*pSkinDir'
*/
static int
_getSkinPathFromName( const char* skinName,
const char* sdkRootPath,
char** pSkinName,
char** pSkinDir )
{
char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp);
/* if the skin name has the format 'NNNNxNNN' where
* NNN is a decimal value, then this is a 'magic' skin
* name that doesn't require a skin directory
*/
if (isdigit(skinName[0])) {
int width, height;
if (sscanf(skinName, "%dx%d", &width, &height) == 2) {
D("'magic' skin format detected: %s", skinName);
*pSkinName = ASTRDUP(skinName);
*pSkinDir = NULL;
return 1;
}
}
/* is the skin name a direct path to the skin directory ? */
if (path_is_absolute(skinName) && _checkSkinPath(skinName)) {
goto FOUND_IT;
}
/* is the skin name a relative path from the SDK root ? */
p = bufprint(temp, end, "%s/%s", sdkRootPath, skinName);
if (p < end && _checkSkinPath(temp)) {
skinName = temp;
goto FOUND_IT;
}
/* nope */
return 0;
FOUND_IT:
if (path_split(skinName, pSkinDir, pSkinName) < 0) {
derror("malformed skin name: %s", skinName);
exit(2);
}
D("found skin '%s' in directory: %s", *pSkinName, *pSkinDir);
return 1;
}
开发者ID:bindassdost,项目名称:razrd,代码行数:50,代码来源:info.c
示例19: create_tmp_var_name
tree
create_tmp_var_name (const char *prefix)
{
char *tmp_name;
if (prefix)
{
char *preftmp = ASTRDUP (prefix);
remove_suffix (preftmp, strlen (preftmp));
clean_symbol_name (preftmp);
prefix = preftmp;
}
ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix ? prefix : "T", tmp_var_id_num++);
return get_identifier (tmp_name);
}
开发者ID:WojciechMigda,项目名称:gcc,代码行数:18,代码来源:gimple-expr.c
示例20: _camera_device_get_info
/* Collects information about an opened camera device.
* The information collected in this routine contains list of pixel formats,
* supported by the device, and list of frame dimensions supported by the camera
* for each pixel format.
* Param:
* cd - Opened camera device descriptor.
* cis - Upon success contains information collected from the camera device.
* Return:
* 0 on success, != 0 on failure.
*/
static int
_camera_device_get_info(LinuxCameraDevice* cd, CameraInfo* cis)
{
int f;
int chosen = -1;
QemuPixelFormat* formats = NULL;
int num_pix_fmts = _camera_device_enum_pixel_formats(cd, &formats);
if (num_pix_fmts <= 0) {
return -1;
}
/* Lets see if camera supports preferred formats */
for (f = 0; f < _preferred_format_num; f++) {
chosen = _get_format_index(_preferred_formats[f], formats, num_pix_fmts);
if (chosen >= 0) {
printf("chosen :::%d, f:::::%d\n", chosen, f);
break;
}
}
if (chosen < 0) {
/* Camera doesn't support any of the chosen formats. Then it doesn't
* matter which one we choose. Lets choose the first one. */
chosen = 0;
}
cis->device_name = ASTRDUP(cd->device_name);
cis->inp_channel = cd->input_channel;
cis->pixel_format = formats[chosen].format;
cis->frame_sizes_num = formats[chosen].dim_num;
/* Swap instead of copy. */
cis->frame_sizes = formats[chosen].dims;
formats[chosen].dims = NULL;
cis->in_use = 0;
for (f = 0; f < num_pix_fmts; f++) {
_qemu_pixel_format_free(formats + f);
}
free(formats);
return 0;
}
开发者ID:abhinavjayanthy,项目名称:GemDroid,代码行数:52,代码来源:camera-capture-linux.c
注:本文中的ASTRDUP函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论