本文整理汇总了C++中dbgprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ dbgprintf函数的具体用法?C++ dbgprintf怎么用?C++ dbgprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbgprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: padInitialize
/* initialize controller */
inline void
padInitialize (padBtnData *pdata )
{
dbgprintf ( "pad initializing..." ) ;
/* initialize state variables */
pdata->now = 0 ;
pdata->last = 0 ;
/* initialize semaphore attributes */
pdata->sem_attr.key = PAD_KEY ;
pdata->sem_attr.attr_protocol = SYS_SEM_ATTR_PROTOCOL ;
pdata->sem_attr.attr_pshared = SYS_SEM_ATTR_PSHARED ;
/* initialize mutex attributes */
pdata->mutex_attr.key = PAD_KEY ;
pdata->mutex_attr.attr_protocol = SYS_MUTEX_PROTOCOL_FIFO ;
pdata->mutex_attr.attr_pshared = SYS_MUTEX_ATTR_PSHARED ;
pdata->mutex_attr.attr_recursive = SYS_MUTEX_ATTR_RECURSIVE ;
pdata->mutex_attr.attr_adaptive = SYS_MUTEX_ATTR_ADAPTIVE ;
/* initialize condition attributes */
pdata->cond_attr.key = PAD_KEY ;
pdata->cond_attr.attr_pshared = SYS_COND_ATTR_PSHARED ;
/* create semaphore */
//sysSemCreate ( &pdata->sem, &pdata->sem_attr, 1, SEM_CONSUMERS ) ;
/* create mutex */
sysMutexCreate ( &pdata->mutex, &pdata->mutex_attr ) ;
/* create cond */
sysCondCreate ( &pdata->cond, pdata->mutex, &pdata->cond_attr ) ;
ioPadInit ( 7 ) ;
}
开发者ID:an0nym0u5,项目名称:PSL1GHT,代码行数:37,代码来源:pad.c
示例2: assert
/* Add a new outchannel line
* returns pointer to new object if it succeeds, NULL otherwise.
* An outchannel line is primarily a set of fields delemited by commas.
* There might be some whitespace between the field (but not within)
* and the commas. This can be removed.
*/
struct outchannel *ochAddLine(char* pName, uchar** ppRestOfConfLine)
{
struct outchannel *pOch;
uchar *p;
assert(pName != NULL);
assert(ppRestOfConfLine != NULL);
if((pOch = ochConstruct()) == NULL)
return NULL;
pOch->iLenName = strlen(pName);
pOch->pszName = (char*) MALLOC(sizeof(char) * (pOch->iLenName + 1));
if(pOch->pszName == NULL) {
dbgprintf("ochAddLine could not alloc memory for outchannel name!");
pOch->iLenName = 0;
return NULL;
/* I know - we create a memory leak here - but I deem
* it acceptable as it is a) a very small leak b) very
* unlikely to happen. rgerhards 2004-11-17
*/
}
memcpy(pOch->pszName, pName, pOch->iLenName + 1);
/* now actually parse the line */
p = *ppRestOfConfLine;
assert(p != NULL);
/* get params */
get_Field(&p, &pOch->pszFileTemplate);
if(*p) get_off_t(&p, &pOch->uSizeLimit);
if(*p) get_restOfLine(&p, &pOch->cmdOnSizeLimit);
*ppRestOfConfLine = p;
return(pOch);
}
开发者ID:Altiscale,项目名称:rsyslog,代码行数:42,代码来源:outchannel.c
示例3: matecomponent_plug_expose_event
static gboolean
matecomponent_plug_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
gboolean retval;
retval = GTK_WIDGET_CLASS (matecomponent_plug_parent_class)->expose_event (widget, event);
dbgprintf ("matecomponent_plug_expose_event %p (%d, %d), (%d, %d)"
"%s (%d && %d == %d)\n",
widget,
event->area.x, event->area.y,
event->area.width, event->area.height,
GTK_WIDGET_TOPLEVEL (widget) ? "toplevel" : "bin class",
GTK_WIDGET_VISIBLE (widget),
GTK_WIDGET_MAPPED (widget),
GTK_WIDGET_DRAWABLE (widget));
#ifdef DEBUG_CONTROL
gdk_draw_line (widget->window,
widget->style->black_gc,
event->area.x + event->area.width,
event->area.y,
event->area.x,
event->area.y + event->area.height);
gdk_draw_line (widget->window,
widget->style->black_gc,
widget->allocation.x,
widget->allocation.y,
widget->allocation.x + widget->allocation.width,
widget->allocation.y + widget->allocation.height);
#endif
return retval;
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:36,代码来源:matecomponent-plug.c
示例4: ChargeConsume
static
void
ChargeConsume(int pktlen)
{
struct timeval now;
if (g_ctc_packets)
g_ctc_packets--;
if (g_ctc_bytes)
g_ctc_bytes -= pktlen;
IF_TRACED(TRC_CHARGE)
dbgprintf("ChargeConsume: CTC now has bytes=" FMT_UINT32 " & packets=" FMT_UINT32 "\n",
g_ctc_bytes, g_ctc_packets);
END_TRACE
/* Reset charge timer */
gettimeofday(&now, NULL);
timeval_add_ms(&now, TOPO_CHARGE_TIMEOUT);
CANCEL(g_charge_timer);
g_charge_timer = event_add(&now, state_charge_timeout, /*state:*/NULL);
}
开发者ID:Einheri,项目名称:wl500g,代码行数:24,代码来源:mapping.c
示例5: matecomponent_control_destroy
static void
matecomponent_control_destroy (MateComponentObject *object)
{
MateComponentControl *control = (MateComponentControl *) object;
dbgprintf ("matecomponent_control_destroy %p\n", object);
if (control->priv->plug)
matecomponent_control_set_plug (control, NULL);
matecomponent_control_unset_control_frame (control, NULL);
matecomponent_control_set_properties (control, CORBA_OBJECT_NIL, NULL);
matecomponent_control_set_ui_component (control, NULL);
matecomponent_control_disconnected (control);
if (control->priv->widget) {
gtk_widget_destroy (GTK_WIDGET (control->priv->widget));
g_object_unref (control->priv->widget);
}
control->priv->widget = NULL;
control->priv->popup_ui_container = matecomponent_object_unref (
(MateComponentObject *) control->priv->popup_ui_container);
if (control->priv->popup_ui_engine)
g_object_unref (control->priv->popup_ui_engine);
control->priv->popup_ui_engine = NULL;
control->priv->popup_ui_component = matecomponent_object_unref (
(MateComponentObject *) control->priv->popup_ui_component);
control->priv->popup_ui_sync = NULL;
control->priv->inproc_frame = NULL;
MATECOMPONENT_OBJECT_CLASS (matecomponent_control_parent_class)->destroy (object);
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:36,代码来源:matecomponent-control.c
示例6: strdup
char *csp_header(const char *str)
{
char *csppol = NULL;
char *returnstr = NULL;
if (getenv("XYMON_NOCSPHEADER")) return NULL;
if (strncmp(str, "enadis", 6) == 0) csppol = strdup("script-src 'self' 'unsafe-inline'; connect-src 'self'; form-action 'self'; sandbox allow-forms allow-scripts;");
else if (strncmp(str, "useradm", 7) == 0) csppol = strdup("script-src 'self'; connect-src 'self'; form-action 'self';");
else if (strncmp(str, "chpasswd", 8) == 0) csppol = strdup("script-src 'self'; connect-src 'self'; form-action 'self';");
else if (strncmp(str, "ackinfo", 7) == 0) csppol = strdup("script-src 'self'; connect-src 'self'; form-action 'self';");
else if (strncmp(str, "acknowledge", 11) == 0) csppol = strdup("script-src 'self'; connect-src 'self'; form-action 'self';");
else if (strncmp(str, "criticaleditor", 14) == 0) csppol = strdup("script-src 'self'; connect-src 'self'; form-action 'self';");
else if (strncmp(str, "svcstatus", 9) == 0) csppol = strdup("script-src 'self'; connect-src 'self'; form-action 'self'; sandbox allow-forms;");
else if (strncmp(str, "historylog", 10) == 0) csppol = strdup("script-src 'self'; connect-src 'self'; form-action 'self'; sandbox allow-forms;");
else {
errprintf(" csp_header: page %s not listed, no CSP returned\n", str);
}
if ((!csppol) || (*csppol == '\0')) return NULL;
returnstr = (char *)malloc(3 * strlen(csppol) + 512);
snprintf(returnstr, (3 * strlen(csppol) + 512), "Content-Security-Policy: %s\nX-Content-Security-Policy: %s\nX-Webkit-CSP: %s\n", csppol, csppol, csppol);
dbgprintf("CSP return is %s", returnstr);
return returnstr;
}
开发者ID:Kotty666,项目名称:xymon,代码行数:24,代码来源:cgi.c
示例7: matecomponent_control_add_listener
void
matecomponent_control_add_listener (CORBA_Object object,
GCallback fn,
gpointer user_data,
CORBA_Environment *ev)
{
MateCORBAConnectionStatus status;
if (object == CORBA_OBJECT_NIL)
return;
status = MateCORBA_small_listen_for_broken (
object, fn, user_data);
switch (status) {
case MATECORBA_CONNECTION_CONNECTED:
break;
default:
dbgprintf ("premature CORBA_Object death");
matecomponent_exception_general_error_set (
ev, NULL, "Control died prematurely");
break;
}
}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:24,代码来源:matecomponent-control.c
示例8: PatchWidescreen
bool PatchWidescreen(u32 FirstVal, u32 Buffer)
{
if(FirstVal == FLT_ASPECT_0_913 && read32(Buffer+4) == 0x2e736200)
{
write32(Buffer, FLT_ASPECT_1_218);
dbgprintf("PatchWidescreen:[Aspect Ratio 1.218] applied (0x%08X)\r\n", Buffer );
return true;
}
else if(FirstVal == FLT_ASPECT_1_200 && (read32(Buffer+4) == 0x43F00000 ||
(read32(Buffer+4) == 0 && read32(Buffer+8) == 0x43F00000)))
{ //All Mario Party games share this value
write32(Buffer, FLT_ASPECT_1_600);
dbgprintf("PatchWidescreen:[Aspect Ratio 1.600] applied (0x%08X)\r\n", Buffer );
return true;
}
else if(FirstVal == FLT_ASPECT_1_266 && read32(Buffer+4) == 0x44180000)
{
write32(Buffer, FLT_ASPECT_1_688);
dbgprintf("PatchWidescreen:[Aspect Ratio 1.688] applied (0x%08X)\r\n", Buffer );
return true;
}
else if(FirstVal == FLT_ASPECT_1_333 && (read32(Buffer+4) == 0x481c4000 ||
read32(Buffer+4) == 0x3f800000 || read32(Buffer+4) == 0xbf800000))
{
write32(Buffer, FLT_ASPECT_1_777);
dbgprintf("PatchWidescreen:[Aspect Ratio 1.777] applied (0x%08X)\r\n", Buffer );
return true;
}
else if(FirstVal == FLT_ASPECT_1_357 && read32(Buffer+4) == 0x481c4000)
{
write32(Buffer, FLT_ASPECT_1_809);
dbgprintf("PatchWidescreen:[Aspect Ratio 1.809] applied (0x%08X)\r\n", Buffer );
return true;
}
else if(FirstVal == FLT_ASPECT_1_428 && read32(Buffer+4) == 0x3e99999a)
{
write32(Buffer, FLT_ASPECT_1_905);
dbgprintf("PatchWidescreen:[Aspect Ratio 1.905] applied (0x%08X)\r\n", Buffer );
return true;
}
return false;
}
开发者ID:carnage702,项目名称:Nintendont,代码行数:42,代码来源:PatchWidescreen.c
示例9: _start
int
_start(int argc,char** argv)
{
sys_sem_t Sema;
int iRet;
dbgprintf("PS2IP: Module Loaded.\n");
if ((iRet=RegisterLibraryEntries(&_exp_ps2ip))!=0)
{
printf("PS2IP: RegisterLibraryEntries returned: %d\n",iRet);
}
sys_init();
mem_init();
memp_init();
pbuf_init();
dbgprintf("PS2IP: sys_init, mem_init, memp_init, pbuf_init called\n");
netif_init();
dbgprintf("PS2IP: netif_init called\n");
Sema=sys_sem_new(0);
dbgprintf("PS2IP: Calling tcpip_init\n");
tcpip_init(InitDone,&Sema);
sys_arch_sem_wait(Sema,0);
sys_sem_free(Sema);
dbgprintf("PS2IP: tcpip_init called\n");
AddLoopIF();
InitTimer();
dbgprintf("PS2IP: System Initialised\n");
return iRet;
}
开发者ID:AzagraMac,项目名称:PS2_SDK,代码行数:40,代码来源:ps2ip.c
示例10: loadnsl
static GSM_Error loadnsl(FILE *file, GSM_MultiBitmap *bitmap)
{
unsigned char block[6],buffer[505];
size_t block_size;
size_t readbytes;
GSM_Bitmap_Types OldType;
while (fread(block,1,6,file)==6) {
block_size = block[4]*256 + block[5];
dbgprintf(NULL, "Block %c%c%c%c, size %ld\n",block[0],block[1],block[2],block[3],(long)block_size);
if (!strncmp(block, "FORM", 4)) {
dbgprintf(NULL, "File ID\n");
} else {
if (block_size>504) return ERR_FILENOTSUPPORTED;
if (block_size!=0) {
readbytes = fread(buffer,1,block_size,file);
if (readbytes != block_size) return ERR_FILENOTSUPPORTED;
/* if it's string, we end it with 0 */
buffer[block_size]=0;
#ifdef DEBUG
if (!strncmp(block, "VERS", 4)) dbgprintf(NULL, "File saved by: %s\n",buffer);
if (!strncmp(block, "MODL", 4)) dbgprintf(NULL, "Logo saved from: %s\n",buffer);
if (!strncmp(block, "COMM", 4)) dbgprintf(NULL, "Phone was connected to COM port: %s\n",buffer);
#endif
if (!strncmp(block, "NSLD", 4)) {
bitmap->Bitmap[0].BitmapHeight = 48;
bitmap->Bitmap[0].BitmapWidth = 84;
OldType = bitmap->Bitmap[0].Type;
PHONE_DecodeBitmap(GSM_NokiaStartupLogo, buffer, &bitmap->Bitmap[0]);
if (OldType != GSM_None) bitmap->Bitmap[0].Type = OldType;
dbgprintf(NULL, "Startup logo (size %ld)\n",(long)block_size);
}
}
}
}
bitmap->Number = 1;
return(ERR_NONE);
}
开发者ID:daladim,项目名称:gammu,代码行数:38,代码来源:gsmlogo.c
示例11: padCheckState
/* check controller buttons */
inline int
padCheckState ( padBtnData *pdata )
{
s32 ret = padCheck ( pdata ) ;
switch ( ret )
{
case 0:
break ;
case PAD_TRIANGLE:
dbgprintf ( "PAD_TRIANGLE" ) ;
*pdata->exitapp = 1 ;
break ;
case PAD_CIRCLE:
dbgprintf ( "PAD_CIRCLE" ) ;
*pdata->exitapp = 1 ;
break ;
case PAD_CROSS:
dbgprintf ( "PAD_CROSS" ) ;
*pdata->exitapp = 0 ;
break ;
case PAD_SQUARE:
dbgprintf ( "PAD_SQUARE" ) ;
*pdata->exitapp = 1 ;
break ;
case PAD_SELECT:
dbgprintf ( "PAD_SELECT" ) ;
*pdata->exitapp = 1 ;
break ;
case PAD_START:
dbgprintf ( "PAD_START" ) ;
*pdata->exitapp = 0 ;
break ;
default:
argprintf ( "default: %d", ret ) ;
break ;
}
return 0 ;
}
开发者ID:an0nym0u5,项目名称:PSL1GHT,代码行数:39,代码来源:pad.c
示例12: event_read_siblings
static void event_read_siblings(char* directory) {
static unsigned read_limit;
static int has_read_limit = 0;
char discard[4096], subfile[4096];
unsigned data_read, amt;
DIR* dir;
FILE* file;
struct dirent* ent;
struct stat st;
int is_regular;
dbgprintf(stderr, "daemon: siblings %s\n", directory);
if (!has_read_limit) {
has_read_limit = 1;
read_limit = 16;
if (getenv("CHISTKA_SIBLINGS"))
read_limit = atoi(getenv("CHISTKA_SIBLINGS"));
read_limit *= 1024*1024;
}
dir = opendir(directory);
if (!dir) return;
data_read = 0;
/* Iterate through the directory and read any regular file encountered */
while (data_read < read_limit && (ent = readdir(dir))) {
read_input();
if (sizeof(subfile) > strlen(directory) + 1 /* slash */ +
strlen(ent->d_name)) {
strcpy(subfile, directory);
strcat(subfile, "/");
strcat(subfile, ent->d_name);
} else {
/* Path name too long */
continue;
}
/* If possible, get the type of the file from the dirent. If we get
* unknown, or the system does not have DT_REG and DT_UNKNOWN, resort to
* stat()ing the file to find out what it is.
*/
#if defined(DT_REG) && defined(DT_UNKNOWN)
if (ent->d_type == DT_REG) {
is_regular = 1;
} else if (ent->d_type == DT_UNKNOWN) {
#endif
/* Either the filesystem can't tell us what the file is, or the system
* doesn't support returning file types within the dirent.
*
* Stat the file to find out what it is.
*/
is_regular = !stat(subfile, &st) && S_ISREG(st.st_mode);
#if defined(DT_REG) && defined(DT_UNKNOWN)
} else {
/* Known and not REG */
is_regular = 0;
}
#endif
if (is_regular && (file = fopen(subfile, "r"))) {
dbgprintf(stderr, "daemon: sibling read: %s\n", subfile);
do {
read_input();
amt = fread(discard, 1, sizeof(discard), file);
data_read += amt;
} while (amt == sizeof(discard) && data_read < read_limit);
fclose(file);
}
}
closedir(dir);
}
开发者ID:AltSysrq,项目名称:libchistka,代码行数:74,代码来源:daemon.c
示例13: event_print
/* Dummy event for testing */
static void event_print(char* filename) {
dbgprintf(stderr, "daemon: %s\n", filename);
}
开发者ID:AltSysrq,项目名称:libchistka,代码行数:4,代码来源:daemon.c
示例14: main
/* allows a user to run as us */
int
main(int argc, char **argv)
{
int ok, arg, status;
FILE *infd;
struct utsname udata;
struct stat statbuf;
struct passwd *pw;
char *pc, inbuf[BUFSIZ];
char user[BUFSIZ], mach[BUFSIZ], cmd[BUFSIZ];
char alwduser[BUFSIZ], alwdmach[BUFSIZ], alwdcmd[BUFSIZ];
/* open debug file */
dbgopen(DEBUGFILE);
/* check if any cmds were given */
DBGDUMP("%s\n", "starting suid ...");
if (argc < 2)
{
dbgprintf("%s: no cmds given. (errno=%d)\n",
argv[0], EINVAL);
fprintf(stderr, "%s: no cmds given. (errno=%d)\n",
argv[0], EINVAL);
dbgclose();
exit(2);
}
/* dump ids */
DBGDUMP("uid = %d\n", getuid());
DBGDUMP("euid = %d\n", geteuid());
DBGDUMP("gid = %d\n", getgid());
DBGDUMP("egid = %d\n", getegid());
/* this tool is used specifically to allow set-uid.
* if the setuid has not taken, then we should error
* out immediately. verify that the effective uid
* matches the owning uid for the suid tool.
*/
DBGDUMP("%s\n", "checking SETUID worked ...");
if (stat(SUID_PATH, &statbuf) != 0)
{
dbgprintf("%s: stat failed for file %s. (errno=%d)\n",
argv[0], SUID_PATH, errno);
fprintf(stderr,
"%s: stat failed for file %s. (errno=%d)\n",
argv[0], SUID_PATH, errno);
exit(2);
}
if (statbuf.st_uid != geteuid())
{
dbgprintf("%s: SUID != EUID !!!. SUID=%d, EUID=%d\n",
argv[0], statbuf.st_uid, geteuid());
fprintf(stderr,
"%s: SET UID FAILED !!!. EUID=%d, SUID=%d\n",
argv[0], statbuf.st_uid, geteuid());
dbgclose();
exit(2);
}
if (statbuf.st_gid != getegid())
{
dbgprintf("%s: SGID != EGID !!!. SGID=%d, EGID=%d\n",
argv[0], statbuf.st_gid, getegid());
fprintf(stderr,
"%s: SET GID FAILED !!!. EGID=%d, SGID=%d\n",
argv[0], statbuf.st_gid, getegid());
dbgclose();
exit(2);
}
/* set environment variable to indicate owner called a tool */
DBGDUMP("statbuf.st_uid = %d\n", statbuf.st_uid);
DBGDUMP("statbuf.st_gid = %d\n", statbuf.st_gid);
DBGDUMP("getuid = %d\n", getuid());
DBGDUMP("getgid = %d\n", getgid());
if ((statbuf.st_uid == getuid()) && (statbuf.st_gid == getgid()))
{
DBGDUMP("FILEOWNER ... %s\n", owneryes);
(void)putenv(owneryes);
}
else
{
DBGDUMP("FILEOWNER ... %s\n", ownerno);
(void)putenv(ownerno);
}
/* get the name of the current machine */
DBGDUMP("%s\n", "calling uname ...");
if (uname(&udata) == -1)
{
dbgprintf("%s: uname failed. (errno=%d)\n",
argv[0], errno);
fprintf(stderr, "%s: uname failed. (errno=%d)\n",
argv[0], errno);
dbgclose();
exit(2);
}
strcpy(mach, udata.nodename);
DBGDUMP("machine is %s\n", mach);
//.........这里部分代码省略.........
开发者ID:ombt,项目名称:ombt,代码行数:101,代码来源:suid.c
示例15: readconfig
void readconfig(char *cfgfn, int verbose)
{
static void *cfgfiles = NULL;
FILE *cfgfd;
strbuffer_t *inbuf;
struct req_t *reqitem = NULL;
int tasksleep = atoi(xgetenv("TASKSLEEP"));
mibdef_t *mib;
/* Check if config was modified */
if (cfgfiles) {
if (!stackfmodified(cfgfiles)) {
dbgprintf("No files changed, skipping reload\n");
return;
}
else {
stackfclist(&cfgfiles);
cfgfiles = NULL;
}
}
cfgfd = stackfopen(cfgfn, "r", &cfgfiles);
if (cfgfd == NULL) {
errprintf("Cannot open configuration files %s\n", cfgfn);
return;
}
inbuf = newstrbuffer(0);
while (stackfgets(inbuf, NULL)) {
char *bot, *p, *mibidx;
char savech;
sanitize_input(inbuf, 0, 0);
bot = STRBUF(inbuf) + strspn(STRBUF(inbuf), " \t");
if ((*bot == '\0') || (*bot == '#')) continue;
if (*bot == '[') {
char *intvl = strchr(bot, '/');
/*
* See if we're running a non-standard interval.
* If yes, then process only the records that match
* this TASKSLEEP setting.
*/
if (tasksleep != 300) {
/* Non-default interval. Skip the host if it HASN'T got an interval setting */
if (!intvl) continue;
/* Also skip the hosts that have an interval different from the current */
*intvl = '\0'; /* Clip the interval from the hostname */
if (atoi(intvl+1) != tasksleep) continue;
}
else {
/* Default interval. Skip the host if it HAS an interval setting */
if (intvl) continue;
}
reqitem = (req_t *)calloc(1, sizeof(req_t));
p = strchr(bot, ']'); if (p) *p = '\0';
reqitem->hostname = strdup(bot + 1);
if (p) *p = ']';
reqitem->hostip[0] = reqitem->hostname;
reqitem->version = SNMP_VERSION_1;
reqitem->authmethod = SNMP_V3AUTH_MD5;
reqitem->next = reqhead;
reqhead = reqitem;
continue;
}
/* If we have nowhere to put the data, then skip further processing */
if (!reqitem) continue;
if (strncmp(bot, "ip=", 3) == 0) {
char *nextip = strtok(strdup(bot+3), ",");
int i = 0;
do {
reqitem->hostip[i++] = nextip;
nextip = strtok(NULL, ",");
} while (nextip);
continue;
}
if (strncmp(bot, "version=", 8) == 0) {
switch (*(bot+8)) {
case '1': reqitem->version = SNMP_VERSION_1; break;
case '2': reqitem->version = SNMP_VERSION_2c; break;
case '3': reqitem->version = SNMP_VERSION_3; break;
}
continue;
}
if (strncmp(bot, "community=", 10) == 0) {
reqitem->community = strdup(bot+10);
continue;
//.........这里部分代码省略.........
开发者ID:gvsurenderreddy,项目名称:xymon-2,代码行数:101,代码来源:xymon-snmpcollect.c
示例16: asynch_response
/*
* response handler
*/
int asynch_response(int operation, struct snmp_session *sp, int reqid, struct snmp_pdu *pdu, void *magic)
{
struct req_t *req = (struct req_t *)magic;
if (operation == NETSNMP_CALLBACK_OP_RECEIVED_MESSAGE) {
struct snmp_pdu *snmpreq = NULL;
int okoid = 1;
if (dataoperation == GET_KEYS) {
/*
* We're doing GETNEXT's when retrieving keys, so we will get a response
* which has nothing really to do with the data we're looking for. In that
* case, we should NOT process data from this response.
*/
struct variable_list *vp = pdu->variables;
okoid = ((vp->name_length >= req->currentkey->indexmethod->rootoidlen) &&
(memcmp(req->currentkey->indexmethod->rootoid, vp->name, req->currentkey->indexmethod->rootoidlen * sizeof(oid)) == 0));
}
switch (pdu->errstat) {
case SNMP_ERR_NOERROR:
/* Pick up the results, but only if the OID is valid */
if (okoid) print_result(STAT_SUCCESS, req, pdu);
break;
case SNMP_ERR_NOSUCHNAME:
dbgprintf("Host %s item %s: No such name\n", req->hostname, req->curr_oid->devname);
if (req->hostip[req->hostipidx+1]) {
req->hostipidx++;
startonehost(req, 1);
}
break;
case SNMP_ERR_TOOBIG:
toobigcount++;
errprintf("Host %s item %s: Response too big\n", req->hostname, req->curr_oid->devname);
break;
default:
errorcount++;
errprintf("Host %s item %s: SNMP error %d\n", req->hostname, req->curr_oid->devname, pdu->errstat);
break;
}
/* Now see if we should send another request */
switch (dataoperation) {
case GET_KEYS:
/*
* While fetching keys, walk the current key-table until we reach the end of the table.
* When we reach the end of one key-table, start with the next.
* FIXME: Could optimize so we dont fetch the whole table, but only those rows we need.
*/
if (pdu->errstat == SNMP_ERR_NOERROR) {
struct variable_list *vp = pdu->variables;
if ( (vp->name_length >= req->currentkey->indexmethod->rootoidlen) &&
(memcmp(req->currentkey->indexmethod->rootoid, vp->name, req->currentkey->indexmethod->rootoidlen * sizeof(oid)) == 0) ) {
/* Still more data in the current key table, get the next row */
snmpreq = snmp_pdu_create(SNMP_MSG_GETNEXT);
pducount++;
/* Probably only one variable to fetch, but never mind ... */
while (vp) {
varcount++;
snmp_add_null_var(snmpreq, vp->name, vp->name_length);
vp = vp->next_variable;
}
}
else {
/* End of current key table. If more keys to be found, start the next table. */
do {
req->currentkey = req->currentkey->next;
} while (req->currentkey && req->currentkey->indexoid);
if (req->currentkey) {
snmpreq = snmp_pdu_create(SNMP_MSG_GETNEXT);
pducount++;
snmp_add_null_var(snmpreq,
req->currentkey->indexmethod->rootoid,
req->currentkey->indexmethod->rootoidlen);
}
}
}
break;
case GET_DATA:
/* Generate a request for the next dataset, if any */
if (req->next_oid) {
snmpreq = generate_datarequest(req);
}
else {
dbgprintf("No more oids left\n");
}
break;
}
/* Send the request we just made */
//.........这里部分代码省略.........
开发者ID:gvsurenderreddy,项目名称:xymon-2,代码行数:101,代码来源:xymon-snmpcollect.c
示例17: print_result
/*
* Store data received in response PDU
*/
int print_result (int status, req_t *req, struct snmp_pdu *pdu)
{
struct variable_list *vp;
size_t len;
keyrecord_t *kwalk;
int keyoidlen;
oid_t *owalk;
int done;
switch (status) {
case STAT_SUCCESS:
if (pdu->errstat == SNMP_ERR_NOERROR) {
unsigned char *valstr = NULL, *oidstr = NULL;
size_t valsz = 0, oidsz = 0;
okcount++;
switch (dataoperation) {
case GET_KEYS:
/*
* Find the keyrecord currently processed for this request, and
* look through the unresolved keys to see if we have a match.
* If we do, determine the index for data retrieval.
*/
vp = pdu->variables;
len = 0; sprint_realloc_value(&valstr, &valsz, &len, 1, vp->name, vp->name_length, vp);
len = 0; sprint_realloc_objid(&oidstr, &oidsz, &len, 1, vp->name, vp->name_length);
dbgprintf("Got key-oid '%s' = '%s'\n", oidstr, valstr);
for (kwalk = req->currentkey, done = 0; (kwalk && !done); kwalk = kwalk->next) {
/* Skip records where we have the result already, or that are not keyed */
if (kwalk->indexoid || (kwalk->indexmethod != req->currentkey->indexmethod)) {
continue;
}
keyoidlen = strlen(req->currentkey->indexmethod->keyoid);
switch (kwalk->indexmethod->idxtype) {
case MIB_INDEX_IN_OID:
/* Does the key match the value we just got? */
if (*kwalk->key == '*') {
/* Match all. Add an extra key-record at the end. */
keyrecord_t *newkey;
newkey = (keyrecord_t *)calloc(1, sizeof(keyrecord_t));
memcpy(newkey, kwalk, sizeof(keyrecord_t));
newkey->indexoid = strdup(oidstr + keyoidlen + 1);
newkey->key = valstr; valstr = NULL;
newkey->next = kwalk->next;
kwalk->next = newkey;
done = 1;
}
else if (strcmp(valstr, kwalk->key) == 0) {
/* Grab the index part of the OID */
kwalk->indexoid = strdup(oidstr + keyoidlen + 1);
done = 1;
}
break;
case MIB_INDEX_IN_VALUE:
/* Does the key match the index-part of the result OID? */
if (*kwalk->key == '*') {
/* Match all. Add an extra key-record at the end. */
keyrecord_t *newkey;
newkey = (keyrecord_t *)calloc(1, sizeof(keyrecord_t));
memcpy(newkey, kwalk, sizeof(keyrecord_t));
newkey->indexoid = valstr; valstr = NULL;
newkey->key = strdup(oidstr + keyoidlen + 1);
newkey->next = kwalk->next;
kwalk->next = newkey;
done = 1;
}
else if ((*(oidstr+keyoidlen) == '.') && (strcmp(oidstr+keyoidlen+1, kwalk->key)) == 0) {
/*
* Grab the index which is the value.
* Avoid a strdup by grabbing the valstr pointer.
*/
kwalk->indexoid = valstr; valstr = NULL; valsz = 0;
done = 1;
}
break;
}
}
break;
case GET_DATA:
owalk = req->curr_oid;
vp = pdu->variables;
while (vp) {
valsz = len = 0;
sprint_realloc_value((unsigned char **)&owalk->result, &valsz, &len, 1,
vp->name, vp->name_length, vp);
owalk = owalk->next; vp = vp->next_variable;
}
break;
}
//.........这里部分代码省略.........
开发者ID:gvsurenderreddy,项目名称:xymon-2,代码行数:101,代码来源:xymon-snmpcollect.c
示例18: main
int main (int argc, char **argv) {
SDL_Surface *s = NULL;
if (argc == 1){
fprintf(stderr, "pictool: no input files\n");
exit(1);
}
if(argc == 2){
if(!strcmp(argv[1], "--help")){
show_help();
exit(0);
}
else{
if(picdetails(argv[1])){
fprintf(stderr, "pictool: bad format\n");
exit(4);
}
exit(0);
}
}
if(argc == 3){
fprintf(stderr, "pictool: not enough arguments\n");
exit(2);
}
SDL_Init(SDL_INIT_VIDEO);
if(argc == 5 && !strcmp(argv[4], "--topic")){
int error;
dbgprintf(":: Loading from bitmap %s\n", argv[3]);
s = SDL_LoadBMP(argv[3]);
dbgprintf(":: Success\n");
if (error = writepic(argv[1], atoi(argv[2]), s))
{
printf("Error writing pic: %d\n", error);
exit(error);
}
SDL_FreeSurface(s);
}
else if(argc == 4 || !strcmp(argv[4], "--tobmp")){
if(readpic(argv[1], atoi(argv[2]), &s)){
fprintf(stderr, "pictool: conversion to bmp failed: bad format\n");
SDL_Quit();
exit(4);
}
dbgprintf(":: Saving to %s\n", argv[3]);
if(SDL_SaveBMP(s, argv[3])){
fprintf(stderr, "pictool: saving to bmp failed\n");
SDL_Quit();
exit(6);
}
dbgprintf(":: Success\n");
SDL_FreeSurface(s);
}
else{
fprintf(stderr, "pictool: unrecognized argument\n");
SDL_Quit();
exit(5);
}
dbgprintf(":: SDLQuit\n");
SDL_Quit();
dbgprintf(":: Return\n");
return 0;
}
开发者ID:AdamSC1-ddg,项目名称:yatc,代码行数:66,代码来源:main.c
示例19: getID
/*
* getID - Determines the ID of an instruction, consuming the ModR/M byte as
* appropriate for extended and escape opcodes. Determines the attributes and
* context for the instruction before doing so.
*
* @param insn - The instruction whose ID is to be determined.
* @return - 0 if the ModR/M could be read when needed or was not needed;
* nonzero otherwise.
*/
static int getID(struct InternalInstruction* insn, void *miiArg) {
uint8_t attrMask;
uint16_t instructionID;
dbgprintf(insn, "getID()");
attrMask = ATTR_NONE;
if (insn->mode == MODE_64BIT)
attrMask |= ATTR_64BIT;
if (insn->vexSize) {
attrMask |= ATTR_VEX;
if (insn->vexSize == 3) {
switch (ppFromVEX3of3(insn->vexPrefix[2])) {
case VEX_PREFIX_66:
attrMask |= ATTR_OPSIZE;
break;
case VEX_PREFIX_F3:
attrMask |= ATTR_XS;
break;
case VEX_PREFIX_F2:
attrMask |= ATTR_XD;
break;
}
if (lFromVEX3of3(insn->vexPrefix[2]))
attrMask |= ATTR_VEXL;
}
else if (insn->vexSize == 2) {
switch (ppFromVEX2of2(insn->vexPrefix[1])) {
case VEX_PREFIX_66:
attrMask |= ATTR_OPSIZE;
break;
case VEX_PREFIX_F3:
attrMask |= ATTR_XS;
break;
case VEX_PREFIX_F2:
attrMask |= ATTR_XD;
break;
}
if (lFromVEX2of2(insn->vexPrefix[1]))
attrMask |= ATTR_VEXL;
}
else {
return -1;
}
}
else {
if (isPrefixAtLocation(insn, 0x66, insn->necessaryPrefixLocation))
attrMask |= ATTR_OPSIZE;
else if (isPrefixAtLocation(insn, 0x67, insn->necessaryPrefixLocation))
attrMask |= ATTR_ADSIZE;
else if (isPrefixAtLocation(insn, 0xf3, insn->necessaryPrefixLocation))
attrMask |= ATTR_XS;
else if (isPrefixAtLocation(insn, 0xf2, insn->necessaryPrefixLocation))
attrMask |= ATTR_XD;
}
if (insn->rexPrefix & 0x08)
attrMask |= ATTR_REXW;
if (getIDWithAttrMask(&instructionID, insn, attrMask))
return -1;
/* The following clauses compensate for limitations of the tables. */
if ((attrMask & ATTR_VEXL) && (attrMask & ATTR_REXW) &&
!(attrMask & ATTR_OPSIZE)) {
/*
* Some VEX instructions ignore the L-bit, but use the W-bit. Normally L-bit
* has precedence since there are no L-bit with W-bit entries in the tables.
* So if the L-bit isn't significant we should use the W-bit instead.
* We only need to do this if the instruction doesn't specify OpSize since
* there is a VEX_L_W_OPSIZE table.
*/
const struct InstructionSpecifier *spec;
uint16_t instructionIDWithWBit;
const struct InstructionSpecifier *specWithWBit;
spec = specifierForUID(instructionID);
if (getIDWithAttrMask(&instructionIDWithWBit,
insn,
(attrMask & (~ATTR_VEXL)) | ATTR_REXW)) {
insn->instructionID = instructionID;
insn->spec = spec;
return 0;
//.........这里部分代码省略.........
开发者ID:groue,项目名称:llvm,代码行数:101,代码来源:X86DisassemblerDecoder.c
示例20: readPrefixes
/*
* readPrefixes - Consumes all of an instruction's prefix bytes, and marks the
* instruction as having them. Also sets the instruction's default operand,
* address, and other relevant data sizes to report operands correctly.
*
* @param insn - The instruction whose prefixes are to be read.
* @return - 0 if the instruction could be read until the end of the prefix
* bytes, and no prefixes conflicted; nonzero otherwise.
*/
static int readPrefixes(struct InternalInstruction* insn) {
BOOL isPrefix = TRUE;
BOOL prefixGroups[4] = { FALSE };
uint64_t prefixLocation;
uint8_t byte = 0;
BOOL hasAdSize = FALSE;
BOOL hasOpSize = FALSE;
dbgprintf(insn, "readPrefixes()");
while (isPrefix) {
prefixLocation = insn->readerCursor;
if (consumeByte(insn, &byte))
return -1;
switch (byte) {
case 0xf0: /* LOCK */
case 0xf2: /* REPNE/REPNZ */
case 0xf3: /* REP or REPE/REPZ */
if (prefixGroups[0])
dbgprintf(insn, "Redundant Group 1 prefix");
prefixGroups[0] = TRUE;
setPrefixPresent(insn, byte, prefixLocation);
break;
case 0x2e: /* CS segment override -OR- Branch not taken */
case 0x36: /* SS segment override -OR- Branch taken */
case 0x3e: /* DS segment override */
case 0x26: /* ES segment override */
case 0x64: /* FS segment override */
case 0x65: /* GS segment override */
switch (byte) {
case 0x2e:
insn->segmentOverride = SEG_OVERRIDE_CS;
break;
case 0x36:
insn->segmentOverride = SEG_OVERRIDE_SS;
break;
case 0x3e:
insn->segmentOverride = SEG_OVERRIDE_DS;
break;
case 0x26:
insn->segmentOverride = SEG_OVERRIDE_ES;
break;
case 0x64:
insn->segmentOverride = SEG_OVERRIDE_FS;
break;
case 0x65:
insn->segmentOverride = SEG_OVERRIDE_GS;
break;
default:
debug("Unhandled override");
return -1;
}
if (prefixGroups[1])
dbgprintf(insn, "Redundant Group 2 prefix");
prefixGroups[1] = TRUE;
setPrefixPresent(insn, byte, prefixLocation);
break;
case 0x66: /* Operand-size override */
if (prefixGroups[2])
dbgprintf(insn, "Redundant Group 3 prefix");
prefixGroups[2] = TRUE;
hasOpSize = TRUE;
setPrefixPresent(insn, byte, prefixLocation);
break;
case 0x67: /* Address-size override */
if (prefixGroups[3])
dbgprintf(insn, "Redundant Group 4 prefix");
prefixGroups[3] = TRUE;
hasAdSize = TRUE;
setPrefixPresent(insn, byte, prefixLocation);
break;
default: /* Not a prefix byte */
isPrefix = FALSE;
break;
}
if (isPrefix)
dbgprintf(insn, "Found prefix 0x%hhx", byte);
}
insn->vexSize = 0;
if (byte == 0xc4) {
uint8_t byte1;
if (lookAtByte(insn, &byte1)) {
dbgprintf(insn, "Couldn't read second byte of VEX");
return -1;
//.........这里部分代码省略.........
开发者ID:groue,项目名称:llvm,代码行数:101,代码来源:X86DisassemblerDecoder.c
注:本文中的dbgprintf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论