本文整理汇总了C++中ACCESS函数的典型用法代码示例。如果您正苦于以下问题:C++ ACCESS函数的具体用法?C++ ACCESS怎么用?C++ ACCESS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ACCESS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: monitorSytemCalls
/** Begin System call monitoring ************************************************************/
int monitorSytemCalls(FILE * logf, struct SCRIPT * script, struct TYPING * types,
unsigned long location, struct LINE * line){
char * tokens = (char *) calloc(TOKENMAXNB*TOKENSIZE,sizeof(char));
int nbtokens, i;
//Search for control operations
if(monitorFileControl(logf,script,types,location,line)) return 1;
if(monitorRegControl(logf,script,types,location,line)) return 1;
if(monitorMailControl(logf,script,types,location,line)) return 1;
//Search for input/output operations
if(monitorFileIO(logf,script,types,location,line)) return 1;
if(monitorRegIO(logf,script,types,location,line)) return 1;
if(monitorMailIO(logf,script,types,location,line)) return 1;
//Special folder (ignored in this version)
if(strcasestr(line->line,".GetSpecialFolder")) return 1;
//Parse line for script exit
nbtokens = decomposeLine(line->line,(char*)tokens,TOKENMAXNB,TOKENSIZE);
for(i=0;i<nbtokens;i++){
//Script generic object
if(isStaticScriptObject(ACCESS(tokens,i))>-1){
if(!strcasecmp(ACCESS(tokens,i+1),STOP0)){
line->type = SYSCALL;
printLogEntry(logf, types, OP_STOP, 0, 0);
return 1;
}//if
}
}//for
free(tokens);
return 0;
}
开发者ID:khanjani,项目名称:malwarebehavioralautomata,代码行数:33,代码来源:ExecutionExplorer.c
示例2: xenmem_access_to_p2m_access
static bool xenmem_access_to_p2m_access(struct p2m_domain *p2m,
xenmem_access_t xaccess,
p2m_access_t *paccess)
{
static const p2m_access_t memaccess[] = {
#define ACCESS(ac) [XENMEM_access_##ac] = p2m_access_##ac
ACCESS(n),
ACCESS(r),
ACCESS(w),
ACCESS(rw),
ACCESS(x),
ACCESS(rx),
ACCESS(wx),
ACCESS(rwx),
ACCESS(rx2rw),
ACCESS(n2rwx),
#undef ACCESS
};
switch ( xaccess )
{
case 0 ... ARRAY_SIZE(memaccess) - 1:
*paccess = memaccess[xaccess];
break;
case XENMEM_access_default:
*paccess = p2m->default_access;
break;
default:
return false;
}
return true;
}
开发者ID:mirage,项目名称:xen,代码行数:33,代码来源:mem_access.c
示例3: SetState
// Initialize the application and telephony API. Blocks.
State * TeleKarma::Initialize(Action * a, State * s)
{
if (s->id != STATE_UNINITIALIZED) return s;
bool flag = false;
InitializeAction * ia = dynamic_cast<InitializeAction *>(a);
State * result = NULL;
if (ia == NULL) {
result = SetState(new State(STATE_INITIALIZING, s->turn+1));
result = SetState(new State(result->id, result->turn, STATUS_FAILED, "Programming error: action cast failed"));
result = SetState(new State(STATE_UNINITIALIZED, result->turn+1));
} else {
// set stun server **before** entering INITIALIZING state
model->SetStunServer(ia->stunServer);
result = SetState(new State(STATE_INITIALIZING, s->turn+1));
// verify existence and type of 'logs' folder
const char * strPath1 = "logs";
struct stat status;
stat(strPath1, &status);
bool existsLogs = !((ACCESS(strPath1, 0) == -1) || !(status.st_mode & S_IFDIR));
// verify existence and type of 'recordings' folder
const char * strPath2 = "recordings";
stat(strPath2, &status);
bool existsRecordings = !((ACCESS(strPath2, 0) == -1) || !(status.st_mode & S_IFDIR));
if (!(existsLogs || existsRecordings)){
result = SetState(new State(result->id, result->turn, STATUS_FAILED, "Please create \"logs\" and \"recordings\" folders in your TeleKarma program folder."));
flag = true;
} else if (!existsLogs) {
result = SetState(new State(result->id, result->turn, STATUS_FAILED, "Please create a \"logs\" folder in your TeleKarma program folder."));
flag = true;
} else if (!existsRecordings) {
result = SetState(new State(result->id, result->turn, STATUS_FAILED, "Please create a \"recordings\" folder in your TeleKarma program folder."));
flag = true;
}
if (flag) {
result = SetState(new State(STATE_UNINITIALIZED, result->turn+1));
} else {
// create log file
PTime now;
PString logFName("logs/log");
logFName += now.AsString("_yyyy.MM.dd_hh.mm.ss");
logFName += ".txt";
PTrace::Initialise(3, logFName);
// initialize telephony (blocking call)
phone->Initialise(ia->stunServer);
PSTUNClient * stunClient = phone->GetSTUNClient();
if (stunClient != NULL) {
model->SetStunType(stunClient->GetNatTypeName());
} else {
model->SetStunType("none");
}
result = SetState(new State(STATE_INITIALIZED, result->turn+1));
}
}
return result;
}
开发者ID:TeleKarma,项目名称:TeleKarma,代码行数:56,代码来源:telekarma.cpp
示例4: write_pid_file
/**
* Write PID file.
*
* @param sctx service context
* @param pid PID to write (should be equal to 'getpid()'
* @return #GNUNET_OK on success (including no work to be done)
*/
static int
write_pid_file (struct GNUNET_SERVICE_Context *sctx, pid_t pid)
{
FILE *pidfd;
char *pif;
char *user;
char *rdir;
int len;
if (NULL == (pif = get_pid_file_name (sctx)))
return GNUNET_OK; /* no file desired */
user = get_user_name (sctx);
rdir = GNUNET_strdup (pif);
len = strlen (rdir);
while ((len > 0) && (rdir[len] != DIR_SEPARATOR))
len--;
rdir[len] = '\0';
if (0 != ACCESS (rdir, F_OK))
{
/* we get to create a directory -- and claim it
* as ours! */
(void) GNUNET_DISK_directory_create (rdir);
if ((NULL != user) && (0 < strlen (user)))
GNUNET_DISK_file_change_owner (rdir, user);
}
if (0 != ACCESS (rdir, W_OK | X_OK))
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", rdir);
GNUNET_free (rdir);
GNUNET_free_non_null (user);
GNUNET_free (pif);
return GNUNET_SYSERR;
}
GNUNET_free (rdir);
pidfd = FOPEN (pif, "w");
if (NULL == pidfd)
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "fopen", pif);
GNUNET_free (pif);
GNUNET_free_non_null (user);
return GNUNET_SYSERR;
}
if (0 > FPRINTF (pidfd, "%u", pid))
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fprintf", pif);
GNUNET_break (0 == FCLOSE (pidfd));
if ((NULL != user) && (0 < strlen (user)))
GNUNET_DISK_file_change_owner (pif, user);
GNUNET_free_non_null (user);
GNUNET_free (pif);
return GNUNET_OK;
}
开发者ID:tg-x,项目名称:gnunet,代码行数:58,代码来源:service.c
示例5: access_game
access_game (char *filename, char *mode, size_t (*af) ())
{
FILE *fd;
fd = fopen (filename, mode);
if (fd != NULL)
{
ACCESS (map)
ACCESS (men)
ACCESS (man)
ACCESS (mutant)
ACCESS (level)
fclose (fd);
}
}
开发者ID:jbailhache,项目名称:log,代码行数:14,代码来源:COLONY.C
示例6: playWav
void playWav(char* filename, float samplerate)
{
int fp= STDIN_FILENO;
if(filename[0]!='-') fp = open(filename, 'r');
//int sz = lseek(fp, 0L, SEEK_END);
//lseek(fp, 0L, SEEK_SET);
//short* data = (short*)malloc(sz);
//read(fp, data, sz);
int bufPtr=0;
float datanew, dataold = 0;
short data;
for (int i=0; i<22; i++)
read(fp, &data, 2); // read past header
while (read(fp, &data, 2)) {
float fmconstant = samplerate * 50.0e-6; // for pre-emphisis filter. 50us time constant
int clocksPerSample = 22500.0/samplerate*1400.0; // for timing
datanew = (float)(data)/32767;
float sample = datanew + (dataold-datanew) / (1-fmconstant); // fir of 1 + s tau
float dval = sample*15.0; // actual transmitted sample. 15 is bandwidth (about 75 kHz)
int intval = (int)(round(dval)); // integer component
float frac = (dval - (float)intval)/2 + 0.5;
unsigned int fracval = frac*clocksPerSample;
bufPtr++;
while( ACCESS(DMABASE + 0x04 /* CurBlock*/) == (int)(instrs[bufPtr].p)) usleep(1000);
((struct CB*)(instrs[bufPtr].v))->SOURCE_AD = (int)constPage.p + 2048 + intval*4 - 4 ;
bufPtr++;
while( ACCESS(DMABASE + 0x04 /* CurBlock*/) == (int)(instrs[bufPtr].p)) usleep(1000);
((struct CB*)(instrs[bufPtr].v))->TXFR_LEN = clocksPerSample-fracval;
bufPtr++;
while( ACCESS(DMABASE + 0x04 /* CurBlock*/) == (int)(instrs[bufPtr].p)) usleep(1000);
((struct CB*)(instrs[bufPtr].v))->SOURCE_AD = (int)constPage.p + 2048 + intval*4+4;
bufPtr=(bufPtr+1) % (1024);
while( ACCESS(DMABASE + 0x04 /* CurBlock*/) == (int)(instrs[bufPtr].p)) usleep(1000);
((struct CB*)(instrs[bufPtr].v))->TXFR_LEN = fracval;
dataold = datanew;
}
close(fp);
}
开发者ID:valenting,项目名称:SoundBerryer,代码行数:49,代码来源:pifm.c
示例7: Cmiss_differential_operator
Cmiss_differential_operator(FE_region *fe_region, int dimension, int term) :
fe_region(ACCESS(FE_region)(fe_region)),
dimension(dimension),
term(term),
access_count(1)
{
}
开发者ID:A1kmm,项目名称:libzinc,代码行数:7,代码来源:differential_operator.hpp
示例8: CWE367_TOC_TOU__access_01_bad
void CWE367_TOC_TOU__access_01_bad()
{
{
char filename[100] = "";
int fileDesc = -1;
if (fgets(filename, 100, stdin) == NULL)
{
printLine("fgets() failed");
/* Restore NUL terminator if fgets fails */
filename[0] = '\0';
}
if (strlen(filename) > 0)
{
filename[strlen(filename)-1] = '\0'; /* remove newline */
}
/* FLAW: Open and write to the file after checking the status information */
if (ACCESS(filename, W_OK) == -1)
{
exit(1);
}
fileDesc = OPEN(filename, O_RDWR);
if (fileDesc == -1)
{
exit(1);
}
if (WRITE(fileDesc, BAD_SINK_STRING, strlen(BAD_SINK_STRING)) == -1)
{
exit(1);
}
if (fileDesc != -1)
{
CLOSE(fileDesc);
}
}
}
开发者ID:gpwi970725,项目名称:testJuliet2,代码行数:35,代码来源:CWE367_TOC_TOU__access_01.c
示例9: getScreenDC
UINT AviConverter::run() {
try {
CPicture picture;
picture.load(m_nameArray[0]);
const CSize imageSize = picture.getSize();
HDC screenDC = getScreenDC();
m_dc = CreateCompatibleDC(screenDC);
m_bitmap = CreateCompatibleBitmap(screenDC, imageSize.cx, imageSize.cy);
DeleteDC(screenDC);
DWORD codec = 0; // mmioFOURCC('w','m','v',' ');
if(ACCESS(m_outFileName, 0) == 0) {
UNLINK(m_outFileName);
}
CAviFile aviFile(m_outFileName, true, codec, m_framesPerSecond);
for(m_index = 0; m_index < (int)m_nameArray.size(); m_index += m_useEvery) {
if(isInterrupted()) {
throwException(_T("Interrupted by user"));
}
picture.load(m_nameArray[m_index]);
HGDIOBJ oldGDI = SelectObject(m_dc, m_bitmap);
picture.show(m_dc);
SelectObject(m_dc, oldGDI);
aviFile.appendNewFrame(m_bitmap);
}
} catch(Exception e) {
m_ok = false;
m_msg = e.what();
}
return 0;
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:33,代码来源:MakeAviDlg.cpp
示例10: ensure_dir
int ensure_dir(const char *sPathName)
{
char DirName[MAX_PATH];
int i, len = 0;
strcpy(DirName, sPathName);
len = (int)strlen(DirName);
if (DirName[len - 1] != '/')
strcat(DirName, "/");
len = (int)strlen(DirName);
for (i = 1; i < len; i++) {
if (DirName[i] == '/' || DirName[i] == '\\') {
DirName[i] = 0;
// printf("%s\n", DirName);
if (ACCESS(DirName, 0) != 0) {
if (MKDIR(DirName) != 0) {
printf("mkdir %s error %d\n", DirName, GETLASTERROR);
return -1;
}
}
DirName[i] = '/';
}
}
return 0;
}
开发者ID:zhifeichen,项目名称:libcapture,代码行数:27,代码来源:css_util.c
示例11: Lia_Fifo_Read
/*********************************************
Functon: Lia_Fifo_Read
Description: read context from fifo
Author: liujian
Date: 2015/09/04
Input: void * pBuf:the context being readed from fifo
pi8Path:fifo path
i32MaxReadLen:maxium length of read
Returns: 0 indicates success
negative numbers indicate failure
*********************************************/
Int32 Lia_Fifo_Read(Int8 *pi8Path,void * pBuf,Int32 i32MaxReadLen)
{
Int32 i32Fd=-1;
Int32 i32ReadCnt = -1;
JUDGE_POINTER_IS_NULL(pBuf);
JUDGE_POINTER_IS_NULL(pi8Path);
ACCESS(pi8Path,F_OK);
i32Fd=open(pi8Path, O_RDONLY,0);
if (i32Fd < 0)
{
printf("open error:%s\n", strerror(errno));
return -1;
}
i32ReadCnt = read(i32Fd, pBuf, i32MaxReadLen);
if (i32ReadCnt<0)
{
printf("read error\n");
return -1;
}
else if(0== i32ReadCnt)//write fifo has closed,unlink the read fifo
{
unlink(pi8Path);
}
close(i32Fd);
return 0;
}
开发者ID:liuchanchen,项目名称:Test,代码行数:38,代码来源:LiaFifoApi.c
示例12: defined
bool QFile::exists( const char *fileName )
{
#if defined(CHECK_NULL)
ASSERT( fileName != 0 );
#endif
return ACCESS( fileName, F_OK ) == 0;
}
开发者ID:kthxbyte,项目名称:Qt1.45-Linaro,代码行数:7,代码来源:qfile.cpp
示例13: setup_fm
void setup_fm()
{
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem \n");
exit (-1);
}
allof7e = (unsigned *)mmap(
NULL,
0x01000000, //len
PROT_READ|PROT_WRITE,
MAP_SHARED,
mem_fd,
0x20000000 //base
);
if ((int)allof7e==-1) exit(-1);
SETBIT(GPFSEL0 , 14);
CLRBIT(GPFSEL0 , 13);
CLRBIT(GPFSEL0 , 12);
struct GPCTL setupword = {6/*SRC*/, 1, 0, 0, 0, 1,0x5a};
ACCESS(CM_GP0CTL) = *((int*)&setupword);
}
开发者ID:valenting,项目名称:SoundBerryer,代码行数:29,代码来源:pifm.c
示例14: jackpifm_setup_fm
int jackpifm_setup_fm() {
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
fprintf(stderr, "Can't open /dev/mem: %s\n", strerror(errno));
return 1;
}
allof7e = (unsigned *)mmap(
NULL,
0x01000000, //len
PROT_READ|PROT_WRITE,
MAP_SHARED,
mem_fd,
0x20000000 //base
);
if ((int)allof7e==-1) return 1;
SETBIT(GPFSEL0 , 14);
CLRBIT(GPFSEL0 , 13);
CLRBIT(GPFSEL0 , 12);
struct GPCTL setupword = {6/*SRC*/, 1, 0, 0, 0, 1,0x5a};
ACCESS(CM_GP0CTL) = *((int*)(&setupword));
return 0;
}
开发者ID:jmendeth,项目名称:jackpifm,代码行数:26,代码来源:outputter.c
示例15: defined
// create the file, fail if it already exists and bOverwrite
bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode)
{
// if bOverwrite we create a new file or truncate the existing one,
// otherwise we only create the new file and fail if it already exists
#if defined(__WXMAC__) && !defined(__UNIX__) && !wxUSE_UNICODE
// Dominic Mazzoni [[email protected]] reports that open is still broken on the mac, so we replace
// int fd = open( szFileName , O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
int fd = creat( szFileName , accessMode);
#else
int fd = wxOpen( szFileName,
O_BINARY | O_WRONLY | O_CREAT |
(bOverwrite ? O_TRUNC : O_EXCL)
ACCESS(accessMode) );
#endif
if ( fd == -1 )
{
wxLogSysError(_("can't create file '%s'"), szFileName);
return false;
}
else
{
Attach(fd);
return true;
}
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:26,代码来源:file.cpp
示例16: startFunction
/** Begin Code emulation ********************************************************************/
void startFunction(FILE * logf, struct SCRIPT * script,
struct TYPING * types, int funcindex, struct LINE * line){
char * tokens = (char *) calloc(TOKENMAXNB*TOKENSIZE,sizeof(char));
int parameters[10];
char arguments[10][TOKENSIZE];
int i, j, retobj, nbtokens, nbarg, nextparam, pos = 0;
//Jump to function
printf("[+] Jump inside function %s\n",
script->functionslist[funcindex].name);
//Merge parameters with local aliases from the signature
nbarg = script->functionslist[funcindex].nbarg;
nbtokens = decomposeLine(line->line,(char*)tokens,TOKENMAXNB,TOKENSIZE);
for(i=0;i<nbtokens;i++){
if(!strcasecmp(ACCESS(tokens,i),script->functionslist[funcindex].name)) break;
}
nextparam = i+1;
for(j=1;j<=nbarg;j++){
processExpression(logf,script,types,FUNCLEVEL|funcindex,
line,nextparam,0,arguments[j-1],&nextparam);
parameters[j-1] = updateTypesBeforeLocCall(types, arguments[j-1],
script->functionslist[funcindex].arguments[j-1]);
}
//Following the execution path
while(pos<script->functionslist[funcindex].nblines){
//Analyze code
pos = processLines(logf,script,types,FUNCLEVEL|funcindex,pos);
}//while
//Return from function
printf("[+] Return from function %s\n",script->functionslist[funcindex].name);
//Unmerge parameters with local aliases from the signature
for(j=1;j<=nbarg;j++){
removeObjectReference(types, parameters[j-1],
script->functionslist[funcindex].arguments[j-1]);
}
retobj = isKnownObject(types,script->functionslist[funcindex].name);
if(retobj>-1){
removeObjectReference(types,retobj,script->functionslist[funcindex].name);
//If the return value is affected
if(i>1 && ((char*)ACCESS(tokens,i-1))[0]== '='){
addObjectReference(types,retobj,ACCESS(tokens,i-2));
}//if affectation
}
free(tokens);
}
开发者ID:khanjani,项目名称:malwarebehavioralautomata,代码行数:48,代码来源:ExecutionExplorer.c
示例17: jackpifm_outputter_sync
void jackpifm_outputter_sync() {
void *pos = (void *)(ACCESS(DMABASE + 0x04 /* CurBlock*/) & ~ 0x7F);
for (bufPtr = 0; bufPtr < BUFFERINSTRUCTIONS; bufPtr += 4)
if (instrs[bufPtr].p == pos) return;
// We should never get here
abort();
}
开发者ID:jmendeth,项目名称:jackpifm,代码行数:8,代码来源:outputter.c
示例18: Lia_Fifo_UnInit
/************************************
Functon: Lia_Fifo_UnInit
Description: unlink fifo.If the fifo has
been unlinked, return -1
Author: liujian
Date: 2015/09/04
Input: const Int8 * pi8Path £ºFIFO path name
Returns: 0 indicates success
negative number indicates failure
************************************/
Int32 Lia_Fifo_UnInit(const Int8 * pi8Path)
{
JUDGE_POINTER_IS_NULL(pi8Path);
ACCESS(pi8Path,F_OK);//determines fifo if path exists
unlink(pi8Path);
return 0;
}
开发者ID:liuchanchen,项目名称:Test,代码行数:18,代码来源:LiaFifoApi.c
示例19: bench_iteration
static inline void
bench_iteration()
{
const long line_size = bench_settings.line_size;
for (long i = 0; i < bench_size; i += line_size)
ACCESS(next_address());
}
开发者ID:andysan,项目名称:ubench,代码行数:8,代码来源:random.c
示例20: get_my_cnf_path
/**
* Obtain the location of ".my.cnf".
*
* @param cfg our configuration
* @param section the section
* @return NULL on error
*/
static char *
get_my_cnf_path (const struct GNUNET_CONFIGURATION_Handle *cfg,
const char *section)
{
char *cnffile;
char *home_dir;
struct stat st;
#ifndef WINDOWS
struct passwd *pw;
#endif
int configured;
#ifndef WINDOWS
pw = getpwuid (getuid ());
if (!pw)
{
GNUNET_log_from_strerror (GNUNET_ERROR_TYPE_ERROR, "mysql", "getpwuid");
return NULL;
}
if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg, section, "CONFIG"))
{
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_filename (cfg, section,
"CONFIG",
&cnffile));
configured = GNUNET_YES;
}
else
{
home_dir = GNUNET_strdup (pw->pw_dir);
GNUNET_asprintf (&cnffile, "%s/.my.cnf", home_dir);
GNUNET_free (home_dir);
configured = GNUNET_NO;
}
#else
home_dir = (char *) GNUNET_malloc (_MAX_PATH + 1);
plibc_conv_to_win_path ("~/", home_dir);
GNUNET_asprintf (&cnffile, "%s/.my.cnf", home_dir);
GNUNET_free (home_dir);
configured = GNUNET_NO;
#endif
GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, "mysql",
_("Trying to use file `%s' for MySQL configuration.\n"),
cnffile);
if ((0 != STAT (cnffile, &st)) || (0 != ACCESS (cnffile, R_OK)) ||
(!S_ISREG (st.st_mode)))
{
if (configured == GNUNET_YES)
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "mysql",
_("Could not access file `%s': %s\n"), cnffile,
STRERROR (errno));
GNUNET_free (cnffile);
return NULL;
}
return cnffile;
}
开发者ID:GNUnet,项目名称:gnunet,代码行数:64,代码来源:mysql.c
注:本文中的ACCESS函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论