本文整理汇总了C++中readable函数的典型用法代码示例。如果您正苦于以下问题:C++ readable函数的具体用法?C++ readable怎么用?C++ readable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 */
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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 */
}
示例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;
}
示例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 */
}
示例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;
}
示例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;
}
示例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++;
}
示例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);
}
}
示例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);
}
示例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);
}