本文整理汇总了C++中readable函数的典型用法代码示例。如果您正苦于以下问题:C++ readable函数的具体用法?C++ readable怎么用?C++ readable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: luaL_buffinit
static const wchar_t *searchpath(lua_State *L, const char *name,
const wchar_t *path,
const wchar_t *sep,
const wchar_t *dirsep)
{
const wchar_t *wname;
luaL_Buffer msg; /* to build error message */
luaL_buffinit(L, &msg);
lua_pushstring(L, name);
wname = utf8_to_utf16(L, -1, NULL); /* `name' is encoded in UTF-8 */
if(*sep != 0) /* non-empty separator? */
wname = LF_Gsub(L, wname, sep, dirsep); /* replace it by 'dirsep' */
while((path = pushnexttemplate(L, path)) != NULL)
{
const wchar_t *filename = LF_Gsub(L, (const wchar_t*)lua_tostring(L, -1),
LUA_PATH_MARK, wname);
lua_remove(L, -2); /* remove path template */
if(readable(filename)) /* does file exist and is readable? */
return filename; /* return that file name */
push_utf8_string(L, filename, -1);
lua_pushfstring(L, "\n\tno file " LUA_QS, lua_tostring(L, -1));
lua_remove(L, -2); /* remove UTF-8 file name */
lua_remove(L, -2); /* remove UTF-16 file name */
luaL_addvalue(&msg); /* concatenate error msg. entry */
}
luaL_pushresult(&msg); /* create error message */
return NULL; /* not found */
}
开发者ID:CyberShadow,项目名称:FAR,代码行数:33,代码来源:uloadlib52.c
示例2: NVIC_DisableIRQ
void BeagleBone::read(char *str, const int len) {
NVIC_DisableIRQ(UART3_IRQn);
char c = 0;
for (int i = 0; c != '\n' && i < len; i++) {
if (!readable()) {
NVIC_EnableIRQ(UART3_IRQn);
while(!readable());
NVIC_DisableIRQ(UART3_IRQn);
}
c = rx_buffer_[rx_out_];
str[i] = c;
rx_out_ = (rx_out_ + 1) % kBufferLen;
}
NVIC_EnableIRQ(UART3_IRQn);
return;
}
开发者ID:stvnrhodes,项目名称:me135,代码行数:16,代码来源:BeagleBone.cpp
示例3: luaQ_getfield
static const char *pushfilename (lua_State *L, const char *name)
{
const char *path;
const char *filename;
luaQ_getfield(L, LUA_GLOBALSINDEX, "package");
luaQ_getfield(L, -1, "cpath");
lua_remove(L, -2);
if (! (path = lua_tostring(L, -1)))
luaL_error(L, LUA_QL("package.cpath") " must be a string");
lua_pushliteral(L, "");
while ((path = pushnexttemplate(L, path))) {
filename = luaL_gsub(L, lua_tostring(L, -1), "?", name);
lua_remove(L, -2);
if (readable(filename))
{ // stack: cpath errmsg filename
lua_remove(L, -3);
lua_remove(L, -2);
return lua_tostring(L, -1);
}
lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
lua_remove(L, -2); /* remove file name */
lua_concat(L, 2); /* add entry to possible error message */
}
lua_pushfstring(L, "module " LUA_QS " not found", name);
lua_replace(L, -3);
lua_concat(L, 2);
lua_error(L);
return 0;
}
开发者ID:2ndforks,项目名称:torch7-custom,代码行数:29,代码来源:qtluautils.cpp
示例4: main
int main(int argc, char** argv){
if(argc > 2){
fprintf(stderr, "Too many command line arguments, expected 0..1");
return -1;
}
char* path;
path = calloc(4096, sizeof(char));
if (argc == 2){
path = argv[1];
} else {
getcwd(path, 4096);
}
readable(path);
//printf("%s \n", path);
//if (isDirectory(path)){
// printf("Is a directory!");
//}
return 0;
}
开发者ID:BobLocke,项目名称:Classwork,代码行数:25,代码来源:p3.c
示例5: pickPixmap
void
pickPixmap(Display * display, Drawable drawable, char *name,
int default_width, int default_height, unsigned char *default_bits,
int *width, int *height, Pixmap * pixmap,
int *graphics_format)
{
int x_hot, y_hot; /* dummy */
if (name && *name) {
if (readable(name)) {
if (BitmapSuccess == XReadBitmapFile(display, drawable, name,
(unsigned int *) width, (unsigned int *) height,
pixmap, &x_hot, &y_hot)) {
*graphics_format = IS_XBMFILE;
}
if (*graphics_format <= 0)
(void) fprintf(stderr,
"\"%s\" not xbm format\n", name);
} else {
(void) fprintf(stderr,
"could not read file \"%s\"\n", name);
}
}
if (*graphics_format <= 0) {
*width = default_width;
*height = default_height;
*graphics_format = IS_XBM;
*pixmap = XCreateBitmapFromData(display, drawable,
(char *) default_bits, *width, *height);
}
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:31,代码来源:iostuff.c
示例6: getModeFont
char *
getModeFont(char *infont)
{
static char *localfont = (char *) NULL;
if (localfont != NULL) {
free(localfont);
localfont = (char *) NULL;
}
if (infont && strlen(infont)) {
#ifdef STANDALONE
localfont = infont;
#else
if ((localfont = (char *) malloc(256)) == NULL) {
(void) fprintf(stderr , "no memory for \"%s\"\n" ,
infont);
return (char *) NULL;
}
(void) strncpy(localfont, infont, 256);
#if HAVE_DIRENT_H
getRandomFile(infont, localfont);
#endif
#endif /* STANDALONE */
}
if (localfont && strlen(localfont) && !readable(localfont)) {
(void) fprintf(stderr,
"could not read file \"%s\"\n", localfont);
if (localfont) {
free(localfont);
localfont = (char *) NULL;
}
}
return localfont;
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:34,代码来源:iostuff.c
示例7: luaL_buffinit
static const char *searchpath (lua_State *L, const char *name,
const char *path, const char *sep,
const char *dirsep)
{
luaL_Buffer msg; /* to build error message */
luaL_buffinit(L, &msg);
if (*sep != '\0') /* non-empty separator? */
name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */
while ((path = pushnexttemplate(L, path)) != NULL) {
const char *filename = luaL_gsub(L, lua_tostring(L, -1),
LUA_PATH_MARK, name);
lua_remove(L, -2); /* remove path template */
// @Voidious: Use lua_State->cwd in place of current dir.
const char *absFilename = luaL_gsub(L, filename, "~", lua_getcwd(L));
if (readable(absFilename)) { /* does file exist and is readable? */
lua_pop(L, 1);
#if defined(_WIN32)
const char *relativeFilename = luaL_gsub(L, filename, "~\\", "");
#else
const char *relativeFilename = luaL_gsub(L, filename, "~/", "");
#endif
lua_remove(L, -2); /* remove file name */
return relativeFilename;
}
lua_pop(L, 1);
lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
lua_remove(L, -2); /* remove file name */
luaL_addvalue(&msg); /* concatenate error msg. entry */
}
luaL_pushresult(&msg); /* create error message */
return NULL; /* not found */
}
开发者ID:Voidious,项目名称:BerryBots,代码行数:32,代码来源:lib_package.c
示例8: DBG
//0 for non-blocking (returns immediately), -1 for infinite blocking
/*virtual*/ int USBSerialStream::write(uint8_t* buf, size_t length, uint32_t timeout/*=-1*/)
{
DBG("Trying to write %d chars", length);
do
{
int ret = waitSpace(timeout);
if(ret)
{
WARN("Error %d while waiting for space", ret);
return ret;
}
int s = space(); //Prevent macro issues
int writeLen = MIN( s, length );
DBG("Writing %d chars", writeLen);
setupWriteableISR(false);
while(writeLen)
{
m_outBuf.queue(*buf);
buf++;
length--;
writeLen--;
}
//If m_serial tx fifo is empty we need to start the packet write
if( m_outBuf.available() && m_serialTxFifoEmpty )
{
writeable();
}
setupWriteableISR(true);
} while(length);
DBG("Write successful");
readable();
return OK;
}
开发者ID:HeydayGuan,项目名称:Nucleo_RemoteUpdate,代码行数:36,代码来源:USBSerialStream.cpp
示例9: get_current_path
static const char *findfile (lua_State *L, const char *name,
const char *pname) {
get_current_path(L, 2); /* ROCKLUA ADDED */
const char *current_path = lua_tostring(L, -1);
const char *path;
name = luaL_gsub(L, name, ".", LUA_DIRSEP);
lua_getfield(L, LUA_ENVIRONINDEX, pname);
path = lua_tostring(L, -1);
if (path == NULL)
luaL_error(L, LUA_QL("package.%s") " must be a string", pname);
lua_pushliteral(L, ""); /* error accumulator */
while ((path = pushnexttemplate(L, path)) != NULL) {
const char *filename;
filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name);
if(current_path != NULL) filename = luaL_gsub(L, filename, "$", current_path);
lua_remove(L, -2); /* remove path template */
if (readable(filename)) /* does file exist and is readable? */
return filename; /* return that file name */
lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
lua_remove(L, -2); /* remove file name */
lua_concat(L, 2); /* add entry to possible error message */
}
return NULL; /* not found */
}
开发者ID:Rockbox,项目名称:rockbox,代码行数:25,代码来源:loadlib.c
示例10: read
long connection::
read (
char* buf,
long num,
unsigned long timeout
)
{
if (readable(timeout) == false)
return TIMEOUT;
const long max_recv_length = 1024*1024*100;
// Make sure to cap the max value num can take on so that if it is
// really large (it might be big on 64bit platforms) so that the OS
// can't possibly get upset about it being large.
const long length = std::min(max_recv_length, num);
long status = recv(connection_socket,buf,length,0);
if (status == SOCKET_ERROR)
{
// if this error is the result of a shutdown call then return SHUTDOWN
if (sd_called())
return SHUTDOWN;
else
return OTHER_ERROR;
}
else if (status == 0 && sd_called())
{
return SHUTDOWN;
}
return status;
}
开发者ID:23119841,项目名称:FERA-2015,代码行数:30,代码来源:sockets_kernel_1.cpp
示例11: MX_ASSERT
uint32_t MessageBuffer::fullForGet(mxos::IOVEC* vec, uint32_t count) const
{
MX_ASSERT(NULL != vec && count > 0);
int rable = readable();
MX_ASSERT(rable > 0);
int len = capacity_ - readPos_;
if (len > rable)
{
len = rable;
}
vec[0].iov_base = buffer_ + readPos_;
vec[0].iov_len = len;
rable -= len;
if (rable > 0 && count > 1)
{
vec[1].iov_base = buffer_;
vec[1].iov_len = rable;
return 2;
}
return 1;
}
开发者ID:denofiend,项目名称:code-lib,代码行数:27,代码来源:MessageBuffer.cpp
示例12: format
static void
format(FTSENT *cur, FTSENT_PRT *prt)
{
char buf[NAME_BUFSZ];
cur->fts_pointer=prt;
if (f_inodenum)
UP(buf, "%llu", (LLU)cur->fts_statp->st_ino, prt->s_inode);
/**
* st_blocks is a calculated number of blocks via file system block size
* the value is the same with that displayed when using default ls
* it can also be calculated via:
* howmany(st_blocks, blocksize) e.g. st_blocks/blocksize
*/
if (f_longfmt || f_dispblock) {
LL b=(LL)cur->fts_statp->st_blocks;
b/=block_size_factor;
UP(buf, "%lld", b, prt->s_block);
prt->t_block+=b;
}
if (f_longfmt) {
mode_t m=cur->fts_statp->st_mode;
if (f_kilobytes) {
LLU s=cur->fts_statp->st_size;
UP(buf, "%llu", (LLU)(s/1024.0+0.5), prt->s_float);
} else if (f_readable) {
LLU s=cur->fts_statp->st_size;
char *read=readable(s);
prt->s_read=MAX(prt->s_read, strlen(read));
free(read);
} else {
UP(buf, "%llu", (LLU)cur->fts_statp->st_size, prt->s_size);
}
UP(buf, "%hu", (short)cur->fts_statp->st_nlink, prt->s_link);
if (S_ISCHR(m) || S_ISBLK(m)) {
UP(buf, "%d", major(cur->fts_statp->st_rdev), prt->s_major);
UP(buf, "%d", minor(cur->fts_statp->st_rdev), prt->s_minor);
}
}
if (f_numric) {
UP(buf, "%d", cur->fts_statp->st_uid, prt->s_uid);
UP(buf, "%d", cur->fts_statp->st_gid, prt->s_gid);
} else if (f_longfmt) {
char *username=get_username(cur->fts_statp->st_uid);
char *groupname=get_groupname(cur->fts_statp->st_uid);
if (username!=NULL)
UP(buf, "%s", username, prt->s_uname);
if (groupname!=NULL)
UP(buf, "%s", groupname, prt->s_gname);
free(username);
free(groupname);
}
UP(buf, "%s", cur->fts_name, prt->s_name);
prt->col_length=MAX(prt->col_length, prt->s_name);
prt->entries++;
}
开发者ID:Kaikaiw,项目名称:apue,代码行数:60,代码来源:ls.c
示例13: assert
void NetMessage::read_string(std::string *out_value)
{
assert(readable() > 0);
const uint8_t *eos = data();
while (*eos++);
size_t lenght = eos - data() - 1;
assert(readable() >= lenght);
out_value->clear();
if (lenght > 0)
{
out_value->resize(lenght);
memcpy(const_cast<char*>(out_value->data()), data(), lenght);
retrieve(lenght);
}
}
开发者ID:zhangpanyi,项目名称:eddyserver,代码行数:16,代码来源:net_message.cpp
示例14: get
Value Property::get(const UserObject& object) const
{
// Check if the property is readable
if (!readable(object))
PONDER_ERROR(ForbiddenRead(name()));
return getValue(object);
}
开发者ID:APTriTec,项目名称:ponder,代码行数:8,代码来源:property.cpp
示例15: exists
//-------------------------------------------------------------------------------------------------
bool DictionaryProperty::exists(const UserObject& object, const camp::Value& key) const
{
// Check if the property is readable
if (!readable(object))
CAMP_ERROR(ForbiddenRead(name()));
return queryExists(object,key);
}
开发者ID:Gohla,项目名称:camp,代码行数:9,代码来源:dictionaryproperty.cpp
示例16: size
//-------------------------------------------------------------------------------------------------
std::size_t DictionaryProperty::size(const UserObject& object) const
{
// Check if the property is readable
if (!readable(object))
CAMP_ERROR(ForbiddenRead(name()));
return getSize(object);
}
开发者ID:Gohla,项目名称:camp,代码行数:9,代码来源:dictionaryproperty.cpp
示例17: iterator
//-------------------------------------------------------------------------------------------------
DictionaryIteratorPtr DictionaryProperty::iterator(const UserObject& object) const
{
// Check if the property is readable
if (!readable(object))
CAMP_ERROR(ForbiddenRead(name()));
return getIterator(object);
}
开发者ID:Gohla,项目名称:camp,代码行数:9,代码来源:dictionaryproperty.cpp
示例18: next_prompt
/*
* next_prompt - Print the shell response until the next prompt or EOF
* Returns 1 if OK, 0 on EOF or timeout
*/
int next_prompt(void)
{
int n;
bzero(buf, MAXBUF);
if (readable(datafd[0], DRIVER_TIMEOUT) == 0) {
printf("%s: Runtrace timed out waiting for next shell prompt\n",
tracefile);
print_child_status();
return 0;
}
else {
if ((n = recv(datafd[0], buf, MAXBUF, 0)) < 0) {
perror("next_prompt:recv1");
exit(1);
}
else if (n == 0) { /* EOF */
return 0;
}
}
while(strcmp(buf, PROMPT)) {
printf("%s", buf);
bzero(buf, MAXBUF);
if (readable(datafd[0], DRIVER_TIMEOUT) == 0) {
printf("%s: Runtrace timed out waiting for next shell prompt\n",
tracefile);
print_child_status();
return 0;
}
else {
if ((n = recv(datafd[0], buf, MAXBUF, 0)) < 0) {
perror("next_prompt:recv1");
exit(1);
}
else if (n == 0) { /* EOF */
return 0;
}
}
}
return 1;
}
开发者ID:TorinYu,项目名称:spring15213,代码行数:47,代码来源:runtrace.c
示例19: readable
void TimeCodeData::save( SaveContext *context ) const
{
Data::save( context );
IndexedIO *container = context->rawContainer();
const Imf::TimeCode &timeCode = readable();
/// \todo: should we be using FILM24_PACKING rather than the default?
unsigned data[2] = { timeCode.timeAndFlags(), timeCode.userData() };
container->write( g_valueEntry, data, 2 );
}
开发者ID:Alwnikrotikz,项目名称:cortex-vfx,代码行数:10,代码来源:TimeCodeData.cpp
示例20: readable
void DateTimeData::save( SaveContext *context ) const
{
Data::save( context );
IndexedIO *container = context->rawContainer();
/// This is cross-platform and handles special values cleanly. It's also going to be smaller than
/// creating a proper container, and storing the day/month/year/time_of_day components individually.
/// Boost doesn't make this any easier for us as many of the time functions deal with "long" integer types,
/// meaning that on 32-bit platforms can't just store the number of nanoseconds since midnight (there are
/// ~10^14 nanoseconds in a day)
container->write( g_valueEntry, boost::posix_time::to_iso_string( readable() ) );
}
开发者ID:Alwnikrotikz,项目名称:cortex-vfx,代码行数:12,代码来源:DateTimeData.cpp
注:本文中的readable函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论