本文整理汇总了C++中GET_FLAG函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_FLAG函数的具体用法?C++ GET_FLAG怎么用?C++ GET_FLAG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GET_FLAG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEXT
*/ REBOOL OS_Request_File(REBRFR *fr)
/*
***********************************************************************/
{
OPENFILENAME ofn = {0};
BOOL ret;
//int err;
REBCHR *filters = TEXT("All files\0*.*\0REBOL scripts\0*.r\0Text files\0*.txt\0" );
ofn.lStructSize = sizeof(ofn);
// ofn.hwndOwner = WIN_WIN(win); // Must find a way to set this
ofn.lpstrTitle = fr->title;
ofn.lpstrInitialDir = fr->dir;
ofn.lpstrFile = fr->files;
ofn.lpstrFilter = fr->filter ? fr->filter : filters;
ofn.nMaxFile = fr->len;
ofn.lpstrFileTitle = 0;
ofn.nMaxFileTitle = 0;
ofn.Flags = OFN_HIDEREADONLY | OFN_EXPLORER | OFN_NOCHANGEDIR; //|OFN_NONETWORKBUTTON; //;
if (GET_FLAG(fr->flags, FRF_MULTI)) ofn.Flags |= OFN_ALLOWMULTISELECT;
if (GET_FLAG(fr->flags, FRF_SAVE))
ret = GetSaveFileName(&ofn);
else
ret = GetOpenFileName(&ofn);
//if (!ret)
// err = CommDlgExtendedError(); // CDERR_FINDRESFAILURE
return ret;
}
示例2: Open_IO
//
// Open_IO: C
//
DEVICE_CMD Open_IO(REBREQ *req)
{
REBDEV *dev;
dev = Devices[req->device];
// Avoid opening the console twice (compare dev and req flags):
if (GET_FLAG(dev->flags, RDF_OPEN)) {
// Device was opened earlier as null, so req must have that flag:
if (GET_FLAG(dev->flags, SF_DEV_NULL))
SET_FLAG(req->modes, RDM_NULL);
SET_FLAG(req->flags, RRF_OPEN);
return DR_DONE; // Do not do it again
}
if (!GET_FLAG(req->modes, RDM_NULL)) {
// Get the raw stdio handles:
Std_Out = GetStdHandle(STD_OUTPUT_HANDLE);
Std_Inp = GetStdHandle(STD_INPUT_HANDLE);
//Std_Err = GetStdHandle(STD_ERROR_HANDLE);
Std_Echo = 0;
Redir_Out = (GetFileType(Std_Out) != 0);
Redir_Inp = (GetFileType(Std_Inp) != 0);
if (!Redir_Inp || !Redir_Out) {
// If either input or output is not redirected, preallocate
// a buffer for conversion from/to UTF-8.
Std_Buf = OS_ALLOC_N(wchar_t, BUF_SIZE);
}
示例3: CLR_FLAG
*/ DEVICE_CMD Write_File(REBREQ *file)
/*
** Bug?: update file->size value after write !?
**
***********************************************************************/
{
if (!file->id) {
file->error = -RFE_NO_HANDLE;
return DR_ERROR;
}
if (GET_FLAG(file->modes, RFM_APPEND)) {
CLR_FLAG(file->modes, RFM_APPEND);
lseek(file->id, 0, SEEK_END);
}
if (file->modes & ((1 << RFM_SEEK) | (1 << RFM_RESEEK) | (1 << RFM_TRUNCATE))) {
CLR_FLAG(file->modes, RFM_RESEEK);
if (!Seek_File_64(file)) return DR_ERROR;
if (GET_FLAG(file->modes, RFM_TRUNCATE))
if (ftruncate(file->id, file->file.index)) return DR_ERROR;
}
if (file->length == 0) return DR_DONE;
file->actual = write(file->id, file->data, file->length);
if (file->actual < 0) {
if (errno == ENOSPC) file->error = -RFE_DISK_FULL;
else file->error = -RFE_BAD_WRITE;
return DR_ERROR;
}
return DR_DONE;
}
示例4: tascii
std::string enchant::print_to_file() const
{
std::stringstream out;
out << "Ench: I " << name_ << "\n" << " T "<< type_ << "\n";
for (std::vector<obj_affected_type>::const_iterator i = affected_.begin(),
iend = affected_.end(); i != iend; ++i)
{
out << " A " << i->location << " " << i->modifier << "\n";
}
*buf = '\0';
tascii(&GET_FLAG(affects_flags_, 0), 4, buf);
out << " F " << buf << "\n";
*buf = '\0';
tascii(&GET_FLAG(extra_flags_, 0), 4, buf);
out << " E " << buf << "\n";
*buf = '\0';
tascii(&GET_FLAG(no_flags_, 0), 4, buf);
out << " N " << buf << "\n";
out << " W " << weight_ << "\n";
out << " B " << ndice_ << "\n";
out << " C " << sdice_ << "\n";
out << "~\n";
return out.str();
}
示例5: find_string
static REBCNT find_string(REBSER *series, REBCNT index, REBCNT end, REBVAL *target, REBCNT len, REBCNT flags, REBINT skip)
{
REBCNT start = index;
if (flags & (AM_FIND_REVERSE | AM_FIND_LAST)) {
skip = -1;
start = 0;
if (flags & AM_FIND_LAST) index = end - len;
else index--;
}
if (ANY_BINSTR(target)) {
// Do the optimal search or the general search?
if (BYTE_SIZE(series) && VAL_BYTE_SIZE(target) && !(flags & ~(AM_FIND_CASE|AM_FIND_MATCH)))
return Find_Byte_Str(series, start, VAL_BIN_DATA(target), len, !GET_FLAG(flags, ARG_FIND_CASE-1), GET_FLAG(flags, ARG_FIND_MATCH-1));
else
return Find_Str_Str(series, start, index, end, skip, VAL_SERIES(target), VAL_INDEX(target), len, flags & (AM_FIND_MATCH|AM_FIND_CASE));
}
else if (IS_BINARY(target)) {
return Find_Byte_Str(series, start, VAL_BIN_DATA(target), len, 0, GET_FLAG(flags, ARG_FIND_MATCH-1));
}
else if (IS_CHAR(target)) {
return Find_Str_Char(series, start, index, end, skip, VAL_CHAR(target), flags);
}
else if (IS_INTEGER(target)) {
return Find_Str_Char(series, start, index, end, skip, (REBUNI)VAL_INT32(target), flags);
}
else if (IS_BITSET(target)) {
return Find_Str_Bitset(series, start, index, end, skip, VAL_SERIES(target), flags);
}
return NOT_FOUND;
}
示例6: delayed_trigger_activity
void
delayed_trigger_activity ()
{
CHAR_DATA *ch;
//for (ch = character_list; ch; ch = ch->next)
for (std::list<char_data*>::iterator tch_iterator = character_list.begin(); tch_iterator != character_list.end(); tch_iterator++)
{
ch = *tch_iterator;
if (ch->deleted)
continue;
if (GET_FLAG (ch, FLAG_INHIBITTED))
{
if (!GET_FLAG (ch, FLAG_ENTERING) &&
!GET_FLAG (ch, FLAG_LEAVING) && !ch->delay)
ch->flags &= ~FLAG_INHIBITTED;
else
continue;
}
if (ch->trigger_delay && !--(ch->trigger_delay))
trigger (ch, "", ch->trigger_id);
}
}
示例7: closeStream
/*
* Stream contains open file descriptors that could not be completed.
* If stream has only pending open file descriptors close file
* descriptors.
*/
static void
closeStream()
{
FileInfo_t *file;
int id;
id = Stream->first;
while (id > EOS) {
PthreadMutexLock(&Stream->mutex);
file = GetFile(id);
PthreadMutexLock(&file->mutex);
if (GET_FLAG(file->flags, FI_DCACHE_CLOSE)) {
if (close(file->dcache) == -1) {
WarnSyscallError(HERE,
"close", "");
}
CLEAR_FLAG(file->flags, FI_DCACHE);
NumOpenFiles--;
} else if (GET_FLAG(file->flags, FI_DCACHE)) {
SendErrorResponse(file);
}
id = file->next;
PthreadMutexUnlock(&Stream->mutex);
PthreadMutexUnlock(&file->mutex);
}
if (GET_FLAG(Stream->flags, SR_UNAVAIL)) {
rejectRequest(ENODEV, B_TRUE);
} else {
rejectRequest(0, B_TRUE);
}
}
示例8: OS_Make
*/ DEVICE_CMD Read_DNS(REBREQ *sock)
/*
** Initiate the GetHost request and return immediately.
** Note the temporary results buffer (must be freed later).
**
***********************************************************************/
{
void *host;
#ifdef HAS_ASYNC_DNS
HANDLE handle;
#else
HOSTENT *he;
#endif
host = OS_Make(MAXGETHOSTSTRUCT); // be sure to free it
#ifdef HAS_ASYNC_DNS
if (!GET_FLAG(sock->modes, RST_REVERSE)) // hostname lookup
handle = WSAAsyncGetHostByName(Event_Handle, WM_DNS, sock->data, host, MAXGETHOSTSTRUCT);
else
handle = WSAAsyncGetHostByAddr(Event_Handle, WM_DNS, (char*)&(sock->net.remote_ip), 4, AF_INET, host, MAXGETHOSTSTRUCT);
if (handle != 0) {
sock->net.host_info = host;
sock->handle = handle;
return DR_PEND; // keep it on pending list
}
#else
// Use old-style blocking DNS (mainly for testing purposes):
if (GET_FLAG(sock->modes, RST_REVERSE)) {
he = gethostbyaddr((char*)&sock->net.remote_ip, 4, AF_INET);
if (he) {
sock->net.host_info = host; //???
sock->data = he->h_name;
SET_FLAG(sock->flags, RRF_DONE);
return DR_DONE;
}
}
else {
he = gethostbyname(sock->data);
if (he) {
sock->net.host_info = host; // ?? who deallocs?
COPY_MEM((char*)&(sock->net.remote_ip), (char *)(*he->h_addr_list), 4); //he->h_length);
SET_FLAG(sock->flags, RRF_DONE);
return DR_DONE;
}
}
#endif
OS_Free(host);
sock->net.host_info = 0;
sock->error = GET_ERROR;
//Signal_Device(sock, EVT_ERROR);
return DR_ERROR; // Remove it from pending list
}
示例9: SET_FLAG
*/ int OS_Do_Device(REBREQ *req, REBCNT command)
/*
** Tell a device to perform a command. Non-blocking in many
** cases and will attach the request for polling.
**
** Returns:
** =0: for command success
** >0: for command still pending
** <0: for command error
**
***********************************************************************/
{
REBDEV *dev;
REBINT result;
req->error = 0; // A94 - be sure its cleared
// Validate device:
if (req->device >= RDI_MAX || !(dev = Devices[req->device])) {
req->error = RDE_NO_DEVICE;
return -1;
}
// Confirm device is initialized. If not, return an error or init
// it if auto init option is set.
if (!GET_FLAG(dev->flags, RDF_INIT)) {
if (GET_FLAG(dev->flags, RDO_MUST_INIT)) {
req->error = RDE_NO_INIT;
return -1;
}
if (!dev->commands[RDC_INIT] || !dev->commands[RDC_INIT]((REBREQ*)dev))
SET_FLAG(dev->flags, RDF_INIT);
}
// Validate command:
if (command > dev->max_command || dev->commands[command] == 0) {
req->error = RDE_NO_COMMAND;
return -1;
}
// Do the command:
req->command = command;
result = dev->commands[command](req);
// If request is pending, attach it to device for polling:
if (result > 0) Attach_Request(&dev->pending, req);
else if (dev->pending) {
Detach_Request(&dev->pending, req); // often a no-op
if (result == DR_ERROR && GET_FLAG(req->flags, RRF_ALLOC)) { // not on stack
Signal_Device(req, EVT_ERROR);
}
}
return result;
}
示例10: catalog_validate_objects
void catalog_validate_objects()
{
catalog_object_header * i = local_catalog->invalid_list;
while (i != NULL) {
if (GET_FLAG(i->flags, CAT_OBJECT_DELETED_FLAG)) {
} else if (GET_FLAG(i->flags, CAT_OBJECT_INVALID_FLAG)) {
i->validate();
}
i = i->next_invalid;
}
local_catalog->invalid_list = NULL;
}
示例11: VAL_CLR_OPT
*/ static void Protect_Word(REBVAL *value, REBCNT flags)
/*
***********************************************************************/
{
if (GET_FLAG(flags, PROT_WORD)) {
if (GET_FLAG(flags, PROT_SET)) VAL_SET_OPT(value, OPTS_LOCK);
else VAL_CLR_OPT(value, OPTS_LOCK);
}
if (GET_FLAG(flags, PROT_HIDE)) {
if GET_FLAG(flags, PROT_SET) VAL_SET_OPT(value, OPTS_HIDE);
else VAL_CLR_OPT(value, OPTS_HIDE);
}
示例12: CLEAR_FLAGS
/**
* Get the flags associated with a format string
* @param format The format string to search.
* @param flags A pointer to flags that are turned on.
* @return A pointer to the format string
*/
const char *_get_flags(const char *format, uchar *flags)
{
uchar f;
uchar done = 0;
// start with no flags
CLEAR_FLAGS(f, PRINTF_ALL);
// skip past the % char
++format;
while(!done) {
char ch = *format++;
switch(ch) {
case '-':
// justify, overrides padding
SET_FLAGS(f, PRINTF_JUSTIFY);
CLEAR_FLAGS(f, PRINTF_PADDING);
break;
case '+':
// sign, overrides space
SET_FLAGS(f, PRINTF_SIGN);
CLEAR_FLAGS(f, PRINTF_SPACE);
break;
case ' ':
if(!GET_FLAG(f, PRINTF_SIGN)) {
SET_FLAGS(f, PRINTF_SPACE);
}
break;
case '#':
SET_FLAGS(f, PRINTF_PREFIX);
break;
case '0':
if(!GET_FLAG(f, PRINTF_JUSTIFY)) {
SET_FLAGS(f, PRINTF_PADDING);
}
break;
default:
done = 1;
--format;
}
}
*flags = f;
return format;
}
示例13: GET_ANY_CHAR
*/ REBCNT Find_Str_Char(REBSER *ser, REBCNT head, REBCNT index, REBCNT tail, REBINT skip, REBUNI c2, REBCNT flags)
/*
** General purpose find a char in a string.
**
** Supports: forward/reverse with skip, cased/uncase, Unicode/byte.
**
** Skip can be set positive or negative (for reverse).
**
** Flags are set according to ALL_FIND_REFS
**
***********************************************************************/
{
REBUNI c1;
REBOOL uncase = !GET_FLAG(flags, ARG_FIND_CASE-1); // uncase = case insenstive
if (uncase && c2 < UNICODE_CASES) c2 = LO_CASE(c2);
for (; index >= head && index < tail; index += skip) {
c1 = GET_ANY_CHAR(ser, index);
if (uncase && c1 < UNICODE_CASES) c1 = LO_CASE(c1);
if (c1 == c2) return index;
if GET_FLAG(flags, ARG_FIND_MATCH-1) break;
}
return NOT_FOUND;
}
示例14:
*/ int OS_Quit_Devices(int flags)
/*
** Terminate all devices in preparation to quit.
**
** Allows devices to perform cleanup and resource freeing.
**
** Set flags to zero for now. (May later be used to indicate
** a device query check or a brute force quit.)
**
** Returns: 0 for now.
**
***********************************************************************/
{
int d;
REBDEV *dev;
for (d = RDI_MAX-1; d >= 0; d--) {
dev = Devices[d];
if (dev && GET_FLAG(dev->flags, RDF_INIT) && dev->commands[RDC_QUIT]) {
dev->commands[RDC_QUIT]((REBREQ*)dev);
}
}
return 0;
}
示例15: process_output
int
process_output (DESCRIPTOR_DATA * t)
{
char i[MAX_STRING_LENGTH + 1];
if (!t->prompt_mode && !t->connected && t->edit_index == -1)
if (write_to_descriptor (t, "\r\n") < 0)
return (-1);
/* Cycle thru output queue */
while (get_from_q (&t->output, i))
{
if (t->snoop.snoop_by && t->snoop.snoop_by->desc != NULL
&& !IS_NPC (t->snoop.snoop_by))
{
write_to_q ("% ", &t->snoop.snoop_by->desc->output);
write_to_q (i, &t->snoop.snoop_by->desc->output);
}
if (write_to_descriptor (t, i))
return (-1);
}
if (!t->connected && !(t->character && !IS_NPC (t->character) &&
GET_FLAG (t->character, FLAG_COMPACT)))
if (IS_SET (t->edit_mode, MODE_DONE_EDITING) && t->edit_index == -1)
if (write_to_descriptor (t, "\r\n") < 0)
return (-1);
return (1);
}