本文整理汇总了C++中CLEAR函数的典型用法代码示例。如果您正苦于以下问题:C++ CLEAR函数的具体用法?C++ CLEAR怎么用?C++ CLEAR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CLEAR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: win32_signal_clear
void
win32_signal_clear (struct win32_signal *ws)
{
CLEAR (*ws);
}
开发者ID:angelol,项目名称:iOpenVPN,代码行数:5,代码来源:win32.c
示例2: plugin_open_item
static void
plugin_open_item (struct plugin *p,
const struct plugin_option *o,
struct openvpn_plugin_string_list **retlist,
const char **envp,
const int init_point)
{
ASSERT (p->initialized);
/* clear return list */
if (retlist)
*retlist = NULL;
if (!p->plugin_handle && init_point == p->requested_initialization_point)
{
struct gc_arena gc = gc_new ();
dmsg (D_PLUGIN_DEBUG, "PLUGIN_INIT: PRE");
plugin_show_args_env (D_PLUGIN_DEBUG, o->argv, envp);
/*
* Call the plugin initialization
*/
if (p->open3) {
struct openvpn_plugin_args_open_in args = { p->plugin_type_mask,
(const char ** const) o->argv,
(const char ** const) envp,
&callbacks,
SSLAPI };
struct openvpn_plugin_args_open_return retargs;
CLEAR(retargs);
retargs.return_list = retlist;
if ((*p->open3)(OPENVPN_PLUGINv3_STRUCTVER, &args, &retargs) == OPENVPN_PLUGIN_FUNC_SUCCESS) {
p->plugin_type_mask = retargs.type_mask;
p->plugin_handle = retargs.handle;
} else {
p->plugin_handle = NULL;
}
} else if (p->open2)
p->plugin_handle = (*p->open2)(&p->plugin_type_mask, o->argv, envp, retlist);
else if (p->open1)
p->plugin_handle = (*p->open1)(&p->plugin_type_mask, o->argv, envp);
else
ASSERT (0);
msg (D_PLUGIN, "PLUGIN_INIT: POST %s '%s' intercepted=%s %s",
p->so_pathname,
print_argv (o->argv, &gc, PA_BRACKET),
plugin_mask_string (p->plugin_type_mask, &gc),
(retlist && *retlist) ? "[RETLIST]" : "");
if ((p->plugin_type_mask | plugin_supported_types()) != plugin_supported_types())
msg (M_FATAL, "PLUGIN_INIT: plugin %s expressed interest in unsupported plugin types: [want=0x%08x, have=0x%08x]",
p->so_pathname,
p->plugin_type_mask,
plugin_supported_types());
if (p->plugin_handle == NULL)
msg (M_FATAL, "PLUGIN_INIT: plugin initialization function failed: %s",
p->so_pathname);
gc_free (&gc);
}
}
开发者ID:joeunsjmoon,项目名称:OpenVPN,代码行数:65,代码来源:plugin.c
示例3: main
int main(int argc, char **argv)
{
struct v4l2_format fmt;
struct v4l2_buffer buf;
struct v4l2_requestbuffers req;
enum v4l2_buf_type type;
fd_set fds;
struct timeval tv;
int r, fd = -1;
unsigned int i, n_buffers;
char *dev_name = "/dev/video0";
char out_name[256];
FILE *fout;
struct buffer *buffers;
fd = v4l2_open(dev_name, O_RDWR | O_NONBLOCK, 0);
if (fd < 0) {
perror("Cannot open device");
exit(EXIT_FAILURE);
}
CLEAR(fmt);
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.width = 1920;
fmt.fmt.pix.height = 1080;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
xioctl(fd, VIDIOC_S_FMT, &fmt);
if (fmt.fmt.pix.pixelformat != V4L2_PIX_FMT_RGB24) {
printf("Libv4l didn't accept RGB24 format. Can't proceed.\n");
exit(EXIT_FAILURE);
}
if ((fmt.fmt.pix.width != 640) || (fmt.fmt.pix.height != 480))
printf("Warning: driver is sending image at %dx%d\n",
fmt.fmt.pix.width, fmt.fmt.pix.height);
CLEAR(req);
req.count = 2;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
xioctl(fd, VIDIOC_REQBUFS, &req);
buffers = calloc(req.count, sizeof(*buffers));
for (n_buffers = 0; n_buffers < req.count; ++n_buffers) {
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = n_buffers;
xioctl(fd, VIDIOC_QUERYBUF, &buf);
buffers[n_buffers].length = buf.length;
buffers[n_buffers].start = v4l2_mmap(NULL, buf.length,
PROT_READ | PROT_WRITE, MAP_SHARED,
fd, buf.m.offset);
if (MAP_FAILED == buffers[n_buffers].start) {
perror("mmap");
exit(EXIT_FAILURE);
}
}
for (i = 0; i < n_buffers; ++i) {
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = i;
xioctl(fd, VIDIOC_QBUF, &buf);
}
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
xioctl(fd, VIDIOC_STREAMON, &type);
for (i = 0; i < 20; i++) {
do {
FD_ZERO(&fds);
FD_SET(fd, &fds);
/* Timeout. */
tv.tv_sec = 2;
tv.tv_usec = 0;
r = select(fd + 1, &fds, NULL, NULL, &tv);
} while ((r == -1 && (errno = EINTR)));
if (r == -1) {
perror("select");
return errno;
}
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
xioctl(fd, VIDIOC_DQBUF, &buf);
sprintf(out_name, "grabber%03d.ppm", i);
fout = fopen(out_name, "w");
if (!fout) {
perror("Cannot open image");
exit(EXIT_FAILURE);
}
//.........这里部分代码省略.........
开发者ID:AdrianoRuseler,项目名称:exploringrpi,代码行数:101,代码来源:grabber.c
示例4: mainScreen
void mainScreen(void){
uint32 ReadWord;
int16 xvalue,yvalue;
ft_char8_t StringArray[100];
Ft_Gpu_CoCmd_Dlstart(phost);
Ft_App_WrCoCmd_Buffer(phost,CLEAR_COLOR_RGB(64,64,64));
Ft_App_WrCoCmd_Buffer(phost,CLEAR(1,1,1));
Ft_App_WrCoCmd_Buffer(phost,COLOR_RGB(255,255,255));
Ft_Gpu_CoCmd_Button(phost, 10, 200, 130, 30, 28, 0, "Smart Mirror");
if(!saved){
Ft_Gpu_CoCmd_Button(phost, 200, 200, 110, 30, 28, 0, "Save data");
} else{
Ft_Gpu_CoCmd_Button(phost, 200, 200, 110, 30, 28, 0, "Saved");
}
StringArray[0] = '\0';
strcat(StringArray,"Outside: ");
Ft_Gpu_Hal_Dec2Ascii(StringArray,(ft_int32_t)tempOut);
strcat(StringArray," C");
Ft_Gpu_CoCmd_Text(phost, 10, 20, 26, 0, StringArray);
StringArray[0] = '\0';
strcat(StringArray,"Inside: ");
Ft_Gpu_Hal_Dec2Ascii(StringArray,(ft_int32_t)tempIn);
strcat(StringArray," C");
Ft_Gpu_CoCmd_Text(phost, 10, 40, 26, 0, StringArray);
StringArray[0] = '\0';
strcat(StringArray,"Engine: ");
Ft_Gpu_Hal_Dec2Ascii(StringArray,(ft_int32_t)tempEngine);
strcat(StringArray," C");
Ft_Gpu_CoCmd_Text(phost, 10, 60, 26, 0, StringArray);
StringArray[0] = '\0';
strcat(StringArray,"GPS: ");
Ft_Gpu_CoCmd_Text(phost, 220, 20, 26, 0, StringArray);
ReadWord = Ft_Gpu_Hal_Rd32(phost, REG_TOUCH_DIRECT_XY);
yvalue = (int16)(ReadWord & 0xffff);
xvalue = (int16)((ReadWord>>16) & 0xffff);
if(xvalue > 70 && xvalue < 460 && yvalue > 70 && yvalue < 190){
printf("Smart mirror \n");
screenNR = 2;
} else if(xvalue > 630 && xvalue < 950 && yvalue > 70 && yvalue < 190){
saved = !saved;
printf("Save Data = %i\n", saved);
} else
printf("x = %i y = %i\n", xvalue, yvalue);
Ft_App_WrCoCmd_Buffer(phost,DISPLAY());
Ft_Gpu_CoCmd_Swap(phost);
/* Download the commands into fifo */
Ft_App_Flush_Co_Buffer(phost);
/* Wait till coprocessor completes the operation */
Ft_Gpu_Hal_WaitCmdfifo_empty(phost);
Ft_Gpu_Hal_Sleep(30);
}
开发者ID:henio180,项目名称:PracaMagisterska,代码行数:62,代码来源:SampleApp.c
示例5: matcher
/*
- matcher - the actual matching engine
== static int matcher(struct re_guts *g, const char *string, \
== size_t nmatch, regmatch_t pmatch[], int eflags);
*/
static int /* 0 success, REG_NOMATCH failure */
matcher(struct re_guts *g,
const char *string,
size_t nmatch,
regmatch_t pmatch[],
int eflags)
{
const char *endp;
int i;
struct match mv;
struct match *m = &mv;
const char *dp;
const sopno gf = g->firststate+1; /* +1 for OEND */
const sopno gl = g->laststate;
const char *start;
const char *stop;
/* Boyer-Moore algorithms variables */
const char *pp;
int cj, mj;
const char *mustfirst;
const char *mustlast;
int *matchjump;
int *charjump;
/* simplify the situation where possible */
if (g->cflags®_NOSUB)
nmatch = 0;
if (eflags®_STARTEND) {
start = string + pmatch[0].rm_so;
stop = string + pmatch[0].rm_eo;
} else {
start = string;
stop = start + strlen(start);
}
if (stop < start)
return(REG_INVARG);
/* prescreening; this does wonders for this rather slow code */
if (g->must != NULL) {
if (g->charjump != NULL && g->matchjump != NULL) {
mustfirst = g->must;
mustlast = g->must + g->mlen - 1;
charjump = g->charjump;
matchjump = g->matchjump;
pp = mustlast;
for (dp = start+g->mlen-1; dp < stop;) {
/* Fast skip non-matches */
while (dp < stop && charjump[(int)*dp])
dp += charjump[(int)*dp];
if (dp >= stop)
break;
/* Greedy matcher */
/* We depend on not being used for
* for strings of length 1
*/
while (*--dp == *--pp && pp != mustfirst);
if (*dp == *pp)
break;
/* Jump to next possible match */
mj = matchjump[pp - mustfirst];
cj = charjump[(int)*dp];
dp += (cj < mj ? mj : cj);
pp = mustlast;
}
if (pp != mustfirst)
return(REG_NOMATCH);
} else {
for (dp = start; dp < stop; dp++)
if (*dp == g->must[0] &&
stop - dp >= g->mlen &&
memcmp(dp, g->must, (size_t)g->mlen) == 0)
break;
if (dp == stop) /* we didn't find g->must */
return(REG_NOMATCH);
}
}
/* match struct setup */
m->g = g;
m->eflags = eflags;
m->pmatch = NULL;
m->lastpos = NULL;
m->offp = string;
m->beginp = start;
m->endp = stop;
STATESETUP(m, 4);
SETUP(m->st);
SETUP(m->fresh);
SETUP(m->tmp);
SETUP(m->empty);
CLEAR(m->empty);
//.........这里部分代码省略.........
开发者ID:5432935,项目名称:crossbridge,代码行数:101,代码来源:engine.c
示例6: BookPGNReadFromFile
void BookPGNReadFromFile (const char *file)
/****************************************************************************
*
* To read a game from a PGN file and store out the hash entries to book.
*
****************************************************************************/
{
FILE *fp;
int moveno, ngames = 0;
time_t t1, t2;
double et;
int error;
/* TODO: Fix reading from file */
et = 0.0;
t1 = time(NULL);
fp = fopen (file, "r");
if (fp == NULL)
{
fprintf(stderr, "Cannot open file %s: %s\n",
file, strerror(errno));
return;
}
yyin = fp;
/* Maybe add some more clever error handling later */
if (BookBuilderOpen() != BOOK_SUCCESS)
return;
newpos = existpos = 0;
data_dest = DEST_BOOK;
while(1) {
InitVars ();
NewPosition ();
CLEAR (flags, MANUAL);
CLEAR (flags, THINK);
myrating = opprating = 0;
error = yylex();
if (error) break;
ngames++;
if (ngames % 10 == 0) printf("Games processed: %d\r",ngames);
fflush(stdout);
}
fclose (fp);
if (BookBuilderClose() != BOOK_SUCCESS) {
perror("Error writing opening book during BookBuilderClose");
}
/* Reset the board otherwise we leave the last position in the book
on the board. */
InitVars ();
NewPosition ();
CLEAR (flags, MANUAL);
CLEAR (flags, THINK);
myrating = opprating = 0;
t2 = time(NULL);
et += difftime(t2, t1);
putchar('\n');
/* Handle divide-by-zero problem */
if (et < 0.5) { et = 1.0; };
printf("Time = %.0f seconds\n", et);
printf("Games compiled: %d\n",ngames);
printf("Games per second: %f\n",ngames/et);
printf("Positions scanned: %d\n",newpos+existpos);
printf("Positions per second: %f\n",(newpos+existpos)/et);
printf("New & unique added: %d positions\n",newpos);
printf("Duplicates not added: %d positions\n",existpos);
}
开发者ID:heisencoder,项目名称:gnuchess,代码行数:76,代码来源:pgn.c
示例7: main
int main(int argc, char **argv) {
char buf[4096];
pid_t chld_listener=-1, chld_sender=-1;
uint8_t status=0, msg_type=0, ecount=0;
size_t msg_len=0;
struct sigaction chsa;
uint8_t *ptr=NULL;
int lports=IPC_BINDPORT_START;
uint8_t all_done=0;
char verbose_level[4];
drone_t *c=NULL;
ident=IDENT_MASTER;
ident_name_ptr=IDENT_MASTER_NAME;
CLEAR(buf);
s=(settings_t *)xmalloc(sizeof(settings_t));
memset(s, 0, sizeof(settings_t));
s->vi=(interface_info_t *)xmalloc(sizeof(interface_info_t));
memset(s->vi, 0, sizeof(interface_info_t));
s->forked=0; /* not required, for clarity */
/* s->display=&display_builtin; */
getconfig_argv(argc, argv);
if (s->interface_str == NULL) {
if (get_default_route_interface(&s->interface_str) != 1) {
MSG(M_WARN, "Can't find default route, and matching device, using default interface `%s'", DEFAULT_NETDEV);
s->interface_str=xstrdup(DEFAULT_NETDEV);
}
if (s->verbose > 1) {
MSG(M_VERB, "Using interface %s", s->interface_str);
}
}
if (!(GET_OVERRIDE())) {
/* let the listener tell us then, the user didnt request a specific address */
CLEAR(s->vi->myaddr_s); CLEAR(s->vi->hwaddr_s);
sprintf(s->vi->myaddr_s, "0.0.0.0");
sprintf(s->vi->hwaddr_s, "00:00:00:00:00:00");
memset(&s->vi->myaddr, 0, sizeof(s->vi->myaddr));
memset(&s->vi->hwaddr, 0, sizeof(s->vi->hwaddr));
}
else {
/* complete the information we need like hwaddr, cause its impossible to specify that currently */
if (s->verbose > 1) MSG(M_DBG2, "Spoofing from `%s [%s]'", s->vi->myaddr_s, s->vi->hwaddr_s);
/* the ip info is already filled in, so just complete the rest */
CLEAR(s->vi->hwaddr_s);
sprintf(s->vi->hwaddr_s, "00:00:00:00:00:00");
memset(&s->vi->hwaddr, 0, sizeof(s->vi->hwaddr));
}
s->vi->mtu=0; /* the listener HAS to tell us this, seeing as how the real limitation is there */
time(&(s->s_time));
if (s->forklocal) {
if (s->verbose > 5) MSG(M_DBG2, "children will be forked, setting up signal handler for them");
memset(&chsa, 0, sizeof(chsa));
chsa.sa_handler=&child_dead;
if (sigaction(SIGCHLD, &chsa, NULL) < 0) {
MSG(M_ERR, "Cant register SIGCHLD handler");
terminate(TERM_ERROR);
}
}
arc4random_stir();
if (init_modules() < 0) {
MSG(M_ERR, "Can't initialize module structures, quiting");
terminate(TERM_ERROR);
}
if (ipc_init() < 0) {
MSG(M_ERR, "Cant initialize IPC, quiting");
terminate(TERM_ERROR);
}
if (s->verbose > 0) {
char low[32], high[32];
uint32_t ips=0;
CLEAR(low); CLEAR(high);
ips=ntohl(s->_low_ip);
snprintf(low, sizeof(low) -1, "%s", inet_ntoa((*(struct in_addr *)&ips)));
ips=ntohl(s->_high_ip);
snprintf(high, sizeof(high) -1, "%s", inet_ntoa((*(struct in_addr *)&ips)));
MSG(M_VERB, "Scanning: %s -> %s : %s from %s [%s] at %u pps", low, high, (s->mode == MODE_ARPSCAN ? "Arp" : s->port_str), s->vi->myaddr_s, s->vi->hwaddr_s, s->pps);
}
if (s->verbose > 3) MSG(M_DBG1, "Main process id is %d", getpid());
snprintf(verbose_level, sizeof(verbose_level) -1, "%d", s->verbose);
/* initialize senders */
//.........这里部分代码省略.........
开发者ID:Jubei-Mitsuyoshi,项目名称:aaa-unicornscan,代码行数:101,代码来源:main.c
示例8: prim_parsepropex
void
prim_parsepropex(PRIM_PROTOTYPE)
{
struct inst* oper1 = NULL; /* prevents reentrancy issues! */
struct inst* oper2 = NULL; /* prevents reentrancy issues! */
struct inst* oper3 = NULL; /* prevents reentrancy issues! */
struct inst* oper4 = NULL; /* prevents reentrancy issues! */
stk_array* vars;
const char* mpi;
char* str = 0;
array_iter idx;
extern int varc; /* from msgparse.c */
int mvarcnt = 0;
char* buffers = NULL;
int novars;
int hashow = 0;
int i;
int len;
char tname[BUFFER_LEN];
char buf[BUFFER_LEN];
CHECKOP(4);
oper4 = POP(); /* int:Private */
oper3 = POP(); /* dict:Vars */
oper2 = POP(); /* str:Prop */
oper1 = POP(); /* ref:Object */
if (mlev < 3)
abort_interp("Mucker level 3 or greater required.");
if (oper1->type != PROG_OBJECT)
abort_interp("Non-object argument. (1)");
if (oper2->type != PROG_STRING)
abort_interp("Non-string argument. (2)");
if (oper3->type != PROG_ARRAY)
abort_interp("Non-array argument. (3)");
if (oper3->data.array && (oper3->data.array->type != ARRAY_DICTIONARY))
abort_interp("Dictionary array expected. (3)");
if (oper4->type != PROG_INTEGER)
abort_interp("Non-integer argument. (4)");
if (!valid_object(oper1))
abort_interp("Invalid object. (1)");
if (!oper2->data.string)
abort_interp("Empty string argument. (2)");
if ((oper4->data.number != 0) && (oper4->data.number != 1))
abort_interp("Integer of 0 or 1 expected. (4)");
CHECKREMOTE(oper1->data.objref);
if (!prop_read_perms(ProgUID, oper1->data.objref, oper2->data.string->data, mlev))
abort_interp("Permission denied.");
len = oper2->data.string->length;
strcpyn(tname, sizeof(tname), oper2->data.string->data);
while (len-- > 0 && tname[len] == PROPDIR_DELIMITER) {
tname[len] = '\0';
}
mpi = get_property_class(oper1->data.objref, tname);
vars = oper3->data.array;
novars = array_count(vars);
if (check_mvar_overflow(novars))
abort_interp("Out of MPI variables. (3)");
if (array_first(vars, &idx))
{
do
{
array_data* val = array_getitem(vars, &idx);
if (idx.type != PROG_STRING)
{
CLEAR(&idx);
abort_interp("Only string keys supported. (3)");
}
if (idx.data.string == NULL)
{
CLEAR(&idx);
abort_interp("Empty string keys not supported. (3)");
}
if (strlen(idx.data.string->data) > MAX_MFUN_NAME_LEN)
{
CLEAR(&idx);
abort_interp("Key too long to be an MPI variable. (3)");
}
switch(val->type)
{
case PROG_INTEGER:
case PROG_FLOAT:
case PROG_OBJECT:
case PROG_STRING:
case PROG_LOCK:
break;
//.........这里部分代码省略.........
开发者ID:hyena,项目名称:fuzzball,代码行数:101,代码来源:p_props.c
示例9: mroute_addr_init
void
mroute_addr_init(struct mroute_addr *addr)
{
CLEAR(*addr);
}
开发者ID:OpenVPN,项目名称:openvpn,代码行数:5,代码来源:mroute.c
示例10: RecieveClientThread
void* RecieveClientThread(void* data) // recieve udp packets containing message/voice to the other client
{
struct thread* new_data = data;
printf("you are recieving from %s IP address\n", new_data->IPaddr);
PaStreamParameters outputParam;
PaStream *stream = NULL;
char *sampleBlock;
int i, sockfd, numBytes;
PaError error;
struct sockaddr_in servaddr, cliaddr;
sockfd = socket(AF_INET, SOCK_DGRAM, 0); // make udp socket
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr(new_data->IPaddr);
servaddr.sin_port = htons(new_data->Port);
bind(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr));
fflush(stdout);
numBytes = FRAMES_BUFFER * SAMPLE_SIZE * 2;
sampleBlock = (char *) malloc(numBytes);
if(sampleBlock == NULL){
printf("Could not allocate record array.\n");
exit(1);
}
CLEAR(sampleBlock);
printf("Initializing the devices...\n");
error = Pa_Initialize();
if(error != paNoError)
goto errorState;
outputParam.device = Pa_GetDefaultOutputDevice();
printf( "Output device # %d.\n", outputParam.device );
outputParam.channelCount = 2;
outputParam.sampleFormat = paFloat32;
outputParam.suggestedLatency = Pa_GetDeviceInfo( outputParam.device )->defaultHighOutputLatency;
outputParam.hostApiSpecificStreamInfo = NULL;
error = Pa_OpenStream(&stream, NULL, &outputParam, SAMPLE_RATE, FRAMES_BUFFER, paClipOff, NULL, NULL );
if( error != paNoError )
goto errorState;
error = Pa_StartStream( stream );
if( error != paNoError )
goto errorState;
printf("The client is talking to you\n");
fflush(stdout);
while(1){
recvfrom(sockfd, sampleBlock, 4096, 0, NULL, NULL); // recieve packet containing voice data from the other client
error = Pa_WriteStream(stream, sampleBlock, FRAMES_BUFFER);
if(error && UNDERFLOW)
goto exitState;
}
error = Pa_StopStream(stream);
if(error != paNoError)
goto errorState;
CLEAR(sampleBlock);
free(sampleBlock);
Pa_Terminate();
return 0;
exitState:
if(stream){
Pa_AbortStream(stream);
Pa_CloseStream(stream);
}
free(sampleBlock);
Pa_Terminate();
if(error & paOutputUnderflow)
fprintf(stderr, "Output Underflow.\n");
return (void*)-2;
errorState:
if(stream) {
Pa_AbortStream(stream);
Pa_CloseStream(stream);
}
free(sampleBlock);
Pa_Terminate();
fprintf(stderr, "An error occured while using the portaudio stream\n");
fprintf(stderr, "Error number: %d\n", error);
fprintf(stderr, "Error message: %s\n", Pa_GetErrorText(error));
return (void*)-1;
}
开发者ID:Alireza-R,项目名称:VchatApp,代码行数:92,代码来源:RecieveClientThread.c
示例11: semaphore_clear
void
semaphore_clear (struct semaphore *s)
{
CLEAR (*s);
}
开发者ID:angelol,项目名称:iOpenVPN,代码行数:5,代码来源:win32.c
示例12: window_title_clear
void
window_title_clear (struct window_title *wt)
{
CLEAR (*wt);
}
开发者ID:angelol,项目名称:iOpenVPN,代码行数:5,代码来源:win32.c
示例13: win32_signal_open
void
win32_signal_open (struct win32_signal *ws,
int force,
const char *exit_event_name,
bool exit_event_initial_state)
{
CLEAR (*ws);
ws->mode = WSO_MODE_UNDEF;
ws->in.read = INVALID_HANDLE_VALUE;
ws->in.write = INVALID_HANDLE_VALUE;
ws->console_mode_save = 0;
ws->console_mode_save_defined = false;
if (force == WSO_NOFORCE || force == WSO_FORCE_CONSOLE)
{
/*
* Try to open console.
*/
ws->in.read = GetStdHandle (STD_INPUT_HANDLE);
if (ws->in.read != INVALID_HANDLE_VALUE)
{
if (GetConsoleMode (ws->in.read, &ws->console_mode_save))
{
/* running on a console */
const DWORD new_console_mode = ws->console_mode_save
& ~(ENABLE_WINDOW_INPUT
| ENABLE_PROCESSED_INPUT
| ENABLE_LINE_INPUT
| ENABLE_ECHO_INPUT
| ENABLE_MOUSE_INPUT);
if (new_console_mode != ws->console_mode_save)
{
if (!SetConsoleMode (ws->in.read, new_console_mode))
msg (M_ERR, "Error: win32_signal_open: SetConsoleMode failed");
ws->console_mode_save_defined = true;
}
ws->mode = WSO_MODE_CONSOLE;
}
else
ws->in.read = INVALID_HANDLE_VALUE; /* probably running as a service */
}
}
/*
* If console open failed, assume we are running
* as a service.
*/
if ((force == WSO_NOFORCE || force == WSO_FORCE_SERVICE)
&& !HANDLE_DEFINED (ws->in.read) && exit_event_name)
{
struct security_attributes sa;
if (!init_security_attributes_allow_all (&sa))
msg (M_ERR, "Error: win32_signal_open: init SA failed");
ws->in.read = CreateEvent (&sa.sa,
TRUE,
exit_event_initial_state ? TRUE : FALSE,
exit_event_name);
if (ws->in.read == NULL)
{
msg (M_WARN|M_ERRNO, "NOTE: CreateEvent '%s' failed", exit_event_name);
}
else
{
if (WaitForSingleObject (ws->in.read, 0) != WAIT_TIMEOUT)
msg (M_FATAL, "ERROR: Exit Event ('%s') is signaled", exit_event_name);
else
ws->mode = WSO_MODE_SERVICE;
}
}
}
开发者ID:angelol,项目名称:iOpenVPN,代码行数:74,代码来源:win32.c
示例14: muf_debugger
//.........这里部分代码省略.........
}
}
i = (DBFETCH(program)->sp.program.code +
DBFETCH(program)->sp.program.siz - 1)->line;
if (startline > i) {
anotify_nolisten(player, CFAIL "Starting line is beyond end of program.", 1);
return 0;
}
if (startline < 1) startline = 1;
if (endline > i) endline = i;
if (endline < startline) endline = startline;
anotify_nolisten(player, CINFO "Listing:", 1);
if (!string_compare(cmd, "listi")) {
for (i = startline; i <= endline; i++) {
pinst = linenum_to_pc(program, i);
if (pinst) {
sprintf(buf, "line %d: %s", i, (i == fr->pc->line) ?
show_line_prims(program, fr->pc, STACK_SIZE, 1) :
show_line_prims(program, pinst, STACK_SIZE, 0));
notify_nolisten(player, buf, 1);
}
}
} else {
list_proglines(player, program, fr, startline, endline);
}
fr->brkpt.lastlisted = endline;
anotify_nolisten(player, CINFO "Done.", 1);
return 0;
} else if (!string_compare(cmd, "quit")) {
anotify_nolisten(player, CINFO "Halting execution.", 1);
return 1;
} else if (!string_compare(cmd, "trace")) {
add_muf_read_event(descr, player, program, fr);
if (!string_compare(arg, "on")) {
fr->brkpt.showstack = 1;
anotify_nolisten(player, CSUCC "Trace turned on.", 1);
} else if (!string_compare(arg, "off")) {
fr->brkpt.showstack = 0;
anotify_nolisten(player, CSUCC "Trace turned off.", 1);
} else {
sprintf(buf, CINFO "Trace is currently %s.",
fr->brkpt.showstack? "on" : "off");
anotify_nolisten(player, buf, 1);
}
return 0;
} else if (!string_compare(cmd, "words")) {
list_program_functions(player, program, arg);
add_muf_read_event(descr, player, program, fr);
return 0;
} else if (!string_compare(cmd, "print")) {
debug_printvar(player, fr, arg);
add_muf_read_event(descr, player, program, fr);
return 0;
} else if (!string_compare(cmd, "push")) {
push_arg(player, fr, arg);
add_muf_read_event(descr, player, program, fr);
return 0;
} else if (!string_compare(cmd, "pop")) {
fr->argument.top--;
CLEAR(fr->argument.st + fr->argument.top);
anotify_nolisten(player, CSUCC "Stack item popped.", 1);
add_muf_read_event(descr, player, program, fr);
return 0;
} else if (!string_compare(cmd, "help")) {
notify_nolisten(player, "cont continues execution until a breakpoint is hit.", 1);
notify_nolisten(player, "finish completes execution of current function.", 1);
notify_nolisten(player, "step [NUM] executes one (or NUM, 1) lines of muf.", 1);
notify_nolisten(player, "stepi [NUM] executes one (or NUM, 1) muf instructions.", 1);
notify_nolisten(player, "next [NUM] like step, except skips CALL and EXECUTE.", 1);
notify_nolisten(player, "nexti [NUM] like stepi, except skips CALL and EXECUTE.", 1);
notify_nolisten(player, "break LINE# sets breakpoint at given LINE number.", 1);
notify_nolisten(player, "break FUNCNAME sets breakpoint at start of given function.", 1);
notify_nolisten(player, "breaks lists all currently set breakpoints.", 1);
notify_nolisten(player, "delete NUM deletes breakpoint by NUM, as listed by 'breaks'", 1);
notify_nolisten(player, "where [LEVS] displays function call backtrace of up to num levels deep.", 1);
notify_nolisten(player, "stack [NUM] shows the top num items on the stack.", 1);
notify_nolisten(player, "print v# displays the value of given global variable #.", 1);
notify_nolisten(player, "print lv# displays the value of given local variable #.", 1);
notify_nolisten(player, "trace [on|off] turns on/off debug stack tracing.", 1);
notify_nolisten(player, "list [L1,[L2]] lists source code of given line range.", 1);
notify_nolisten(player, "list FUNCNAME lists source code of given function.", 1);
notify_nolisten(player, "listi [L1,[L2]] lists instructions in given line range.", 1);
notify_nolisten(player, "listi FUNCNAME lists instructions in given function.", 1);
notify_nolisten(player, "words lists all function word names in program.", 1);
notify_nolisten(player, "words PATTERN lists all function word names that match PATTERN.", 1);
notify_nolisten(player, "exec FUNCNAME calls given function with the current stack data.", 1);
notify_nolisten(player, "prim PRIMITIVE executes given primitive with current stack data.", 1);
notify_nolisten(player, "push DATA pushes an int, dbref, var, or string onto the stack.", 1);
notify_nolisten(player, "pop pops top data item off the stack.", 1);
notify_nolisten(player, "help displays this help screen.", 1);
notify_nolisten(player, "quit stop execution here.", 1);
add_muf_read_event(descr, player, program, fr);
return 0;
} else {
anotify_nolisten(player, CINFO "I don't understand that debugger command. Type 'help' for help.", 1);
add_muf_read_event(descr, player, program, fr);
return 0;
}
return 0;
}
开发者ID:CyberLeo,项目名称:protomuck,代码行数:101,代码来源:debugger.c
示例15: prim_getprop
void
prim_getprop(PRIM_PROTOTYPE)
{
const char *temp;
PropPtr prptr;
dbref obj2;
CHECKOP(2);
oper1 = POP();
oper2 = POP();
if (oper1->type != PROG_STRING)
abort_interp("Non-string argument (2)");
if (!oper1->data.string)
abort_interp("Empty string argument (2)");
if (!valid_object(oper2))
abort_interp("Non-object argument (1)");
CHECKREMOTE(oper2->data.objref);
{
char type[BUFFER_LEN];
int len = oper1->data.string->length;
if (!prop_read_perms(ProgUID, oper2->data.objref, oper1->data.string->data, mlev))
abort_interp("Permission denied.");
strcpyn(type, sizeof(type), oper1->data.string->data);
while (len-- > 0 && type[len] == PROPDIR_DELIMITER) {
type[len] = '\0';
}
obj2 = oper2->data.objref;
prptr = get_property(obj2, type);
#ifdef LOG_PROPS
log2file("props.log", "#%d (%d) GETPROP: o=%d n=\"%s\"",
program, pc->line, oper2->data.objref, type);
#endif
CLEAR(oper1);
CLEAR(oper2);
if (prptr) {
#ifdef DISKBASE
propfetch(obj2, prptr);
#endif
switch (PropType(prptr)) {
case PROP_STRTYP:
temp = PropDataStr(prptr);
PushString(temp);
break;
case PROP_LOKTYP:
if (PropFlags(prptr) & PROP_ISUNLOADED) {
PushLock(TRUE_BOOLEXP);
} else {
PushLock(PropDataLok(prptr));
}
break;
case PROP_REFTYP:
PushObject(PropDataRef(prptr));
break;
case PROP_INTTYP:
PushInt(PropDataVal(prptr));
break;
case PROP_FLTTYP:
PushFloat(PropDataFVal(prptr));
break;
default:
result = 0;
PushInt(result);
break;
}
} else {
result = 0;
PushInt(result);
}
/* if (Typeof(oper2->data.objref) != TYPE_PLAYER)
ts_lastuseobject(oper2->data.objref); */
}
}
开发者ID:hyena,项目名称:fuzzball,代码行数:78,代码来源:p_props.c
示例16: http_proxy_new
struct http_proxy_info *
http_proxy_new (const struct http_proxy_options *o,
struct auto_proxy_info *auto_proxy_info)
{
struct http_proxy_info *p;
struct http_proxy_options opt;
if (auto_proxy_info)
{
if (o && o->server)
{
/* if --http-proxy explicitly given, disable auto-proxy */
auto_proxy_info = NULL;
}
else
{
/* if no --http-proxy explicitly given and no auto settings, fail */
if (!auto_proxy_info->http.server)
return NULL;
if (o)
{
opt = *o;
}
else
{
CLEAR (opt);
/* These settings are only used for --auto-proxy */
opt.timeout = 5;
opt.http_version = "1.0";
}
opt.server = auto_proxy_info->http.server;
opt.port = auto_proxy_info->http.port;
if (!opt.auth_retry)
opt.auth_retry = PAR_ALL;
o = &opt;
}
}
if (!o || !o->server)
msg (M_FATAL, "HTTP_PROXY: server not specified");
ASSERT (legal_ipv4_port (o->port));
ALLOC_OBJ_CLEAR (p, struct http_proxy_info);
p->options = *o;
/* parse authentication method */
p->auth_method = HTTP_AUTH_NONE;
if (o->auth_method_string)
{
if (!strcmp (o->auth_method_string, "none"))
p->auth_method = HTTP_AUTH_NONE;
else if (!strcmp (o->auth_method_string, "basic"))
p->auth_method = HTTP_AUTH_BASIC;
#if NTLM
else if (!strcmp (o->auth_method_string, "ntlm"))
p->auth_method = HTTP_AUTH_NTLM;
else if (!strcmp (o->auth_method_string, "ntlm2"))
p->auth_method = HTTP_AUTH_NTLM2;
#endif
else
msg (M_FATAL, "ERROR: unknown HTTP authentication method: '%s'",
o->auth_method_string);
}
/* only basic and NTLM/NTLMv2 authentication supported so far */
if (p->auth_method == HTTP_AUTH_BASIC || p->auth_method == HTTP_AUTH_NTLM || p->auth_method == HTTP_AUTH_NTLM2)
{
get_user_pass_http (p, true);
}
#if !NTLM
if (p->auth_method == HTTP_AUTH_NTLM || p->auth_method == HTTP_AUTH_NTLM2)
msg (M_FATAL, "Sorry, this version of " PACKAGE_NAME " was built without NTLM Proxy support.");
#endif
p->defined = true;
return p;
}
开发者ID:andj,项目名称:openvpn-ssl-refactoring,代码行数:83,代码来源:proxy.c
示例17: prim_envprop
void
prim_envprop(PRIM_PROTOTYPE)
{
double fresult;
CHECKOP(2);
oper1 = POP();
oper2 = POP();
if (oper1->type != PROG_STRING)
abort_interp("Non-string argument (2)");
if (!oper1->data.string)
abort_interp("Empty string argument (2)");
if (!valid_object(oper2))
abort_interp("Non-object argument (1)");
CHECKREMOTE(oper2->data.objref);
{
char tname[BUFFER_LEN];
dbref what;
PropPtr ptr;
int len = oper1->data.string->length;
strcpyn(tname, sizeof(tname), oper1->data.string->data);
while (len-- > 0 && tname[len] == PROPDIR_DELIMITER) {
tname[len] = '\0';
}
what = oper2->data.objref;
ptr = envprop(&what, tname, 0);
if (what != NOTHING) {
if (!prop_read_perms(ProgUID, what, oper1->data.string->data, mlev))
abort_interp("Permission denied.");
}
CLEAR(oper1);
CLEAR(oper2);
PushObject(what);
if (!ptr) {
result = 0;
PushInt(result);
} else {
#ifdef DISKBASE
propfetch(what, ptr);
#endif
switch (PropType(ptr)) {
case PROP_STRTYP:
PushString(PropDataStr(ptr));
break;
case PROP_INTTYP:
result = PropDataVal(ptr);
PushInt(result);
break;
case PROP_FLTTYP:
fresult = PropDataFVal(ptr);
PushFloat(fresult);
break;
case PROP_REFTYP:
ref = PropDataRef(ptr);
PushObject(ref);
break;
case PROP_LOKTYP:
if (PropFlags(ptr) & PROP_ISUNLOADED) {
PushLock(TRUE_BOOLEXP);
} else {
PushLock(PropDataLok(ptr));
}
break;
default:
result = 0;
PushInt(result);
break;
}
}
}
}
开发者ID:hyena,项目名称:fuzzball,代码行数:74,代码来源:p_props.c
示例18: slow
/*
- slow - step through the string more deliberately
== static const char *slow(struct match *m, const char *start, \
== const char *stop, sopno startst, sopno stopst);
*/
static const char * /* where it ended */
slow( struct match *m,
const char *start,
const char *stop,
sopno startst,
sopno stopst)
{
states st = m->st;
states empty = m->empty;
states tmp = m->tmp;
const char *p = start;
wint_t c;
wint_t lastc; /* previous c */
wint_t flagch;
int i;
const char *matchp; /* last p at which a match ended */
size_t clen;
AT("slow", start, stop, startst, stopst);
CLEAR(st);
SET1(st, startst);
SP("sstart", st, *p);
st = step(m->g, startst, stopst, st, NOTHING, st);
matchp = NULL;
if (start == m->beginp)
c = OUT;
else {
/*
* XXX Wrong if the previous character was multi-byte.
* Newline never is (in encodings supported by FreeBSD),
* so this only breaks the ISWORD tests below.
*/
c = (uch)*(start - 1);
}
for (;;) {
/* next character */
lastc = c;
if (p == m->endp) {
c = OUT;
clen = 0;
} else
clen = XMBRTOWC(&c, p, m->endp - p, &m->mbs, BADCHAR);
/* is there an EOL and/or BOL between lastc and c? */
flagch = '\0';
i = 0;
if ( (lastc == '\n' && m->g->cflags®_NEWLINE) ||
(lastc == OUT && !(m->eflags®_NOTBOL)) ) {
flagch = BOL;
i = m->g->nbol;
}
if ( (c == '\n' && m->g->cflags®_NEWLINE) ||
(c == OUT && !(m->eflags®_NOTEOL)) ) {
flagch = (flagch == BOL) ? BOLEOL : EOL;
i += m->g->neol;
}
if (i != 0) {
for (; i > 0; i--)
st = step(m->g, startst, stopst, st, flagch, st);
SP("sboleol", st, c);
}
/* how about a word boundary? */
if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) &&
(c != OUT && ISWORD(c)) ) {
flagch = BOW;
}
if ( (lastc != OUT && ISWORD(lastc)) &&
(flagch == EOL || (c != OUT && !ISWORD(c))) ) {
flagch = EOW;
}
if (flagch == BOW || flagch == EOW) {
st = step(m->g, startst, stopst, st, flagch, st);
SP("sboweow", st, c);
}
/* are we done? */
if (ISSET(st, stopst))
matchp = p;
if (EQ(st, empty) || p == stop || clen > stop - p)
break; /* NOTE BREAK OUT */
/* no, we must deal with this character */
ASSIGN(tmp, st);
ASSIGN(st, empty);
assert(c != OUT);
st = step(m->g, startst, stopst, tmp, c, st);
SP("saft", st, c);
assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st));
p += clen;
}
return(matchp);
}
开发者ID:5432935,项目名称:crossbridge,代码行数:99,代码来源:engine.c
|
请发表评论