예제 #1
0
static int
processCompressOptions(char* opt)
{
	if (streq(opt, "none"))
		compression = COMPRESSION_NONE;
	else if (streq(opt, "packbits"))
		compression = COMPRESSION_PACKBITS;
	else if (strneq(opt, "jpeg", 4)) {
		char* cp = strchr(opt, ':');

                compression = COMPRESSION_JPEG;
                while (cp)
                {
                    if (isdigit((int)cp[1]))
			quality = atoi(cp+1);
                    else if (cp[1] == 'r' )
			jpegcolormode = JPEGCOLORMODE_RAW;
                    else
                        usage();

                    cp = strchr(cp+1,':');
                }
	} else if (strneq(opt, "g3", 2)) {
		processG3Options(opt);
		compression = COMPRESSION_CCITTFAX3;
	} else if (streq(opt, "g4")) {
		compression = COMPRESSION_CCITTFAX4;
	} else if (strneq(opt, "lzw", 3)) {
		char* cp = strchr(opt, ':');
		if (cp)
			predictor = atoi(cp+1);
		compression = COMPRESSION_LZW;
	} else if (strneq(opt, "zip", 3)) {
		char* cp = strchr(opt, ':');
		if (cp)
			predictor = atoi(cp+1);
		compression = COMPRESSION_DEFLATE;
	} else
		return (0);
	return (1);
}
예제 #2
0
static int
s_subscriber (zloop_t *loop, zmq_pollitem_t *poller, void *args)
{
    clonesrv_t *self = (clonesrv_t *) args;
    //  Get state snapshot if necessary
    if (self->kvmap == NULL) {
        self->kvmap = zhash_new ();
        void *snapshot = zsocket_new (self->ctx, ZMQ_DEALER);
        zsocket_connect (snapshot, "tcp://localhost:%d", self->peer);
        zclock_log ("I: asking for snapshot from: tcp://localhost:%d",
                    self->peer);
        zstr_sendm (snapshot, "ICANHAZ?");
        zstr_send (snapshot, ""); // blank subtree to get all
        while (true) {
            kvmsg_t *kvmsg = kvmsg_recv (snapshot);
            if (!kvmsg)
                break;          //  Interrupted
            if (streq (kvmsg_key (kvmsg), "KTHXBAI")) {
                self->sequence = kvmsg_sequence (kvmsg);
                kvmsg_destroy (&kvmsg);
                break;          //  Done
            }
            kvmsg_store (&kvmsg, self->kvmap);
        }
        zclock_log ("I: received snapshot=%d", (int) self->sequence);
        zsocket_destroy (self->ctx, snapshot);
    }
    //  Find and remove update off pending list
    kvmsg_t *kvmsg = kvmsg_recv (poller->socket);
    if (!kvmsg)
        return 0;

    if (strneq (kvmsg_key (kvmsg), "HUGZ")) {
        if (!s_was_pending (self, kvmsg)) {
            //  If active update came before client update, flip it
            //  around, store active update (with sequence) on pending
            //  list and use to clear client update when it comes later
            zlist_append (self->pending, kvmsg_dup (kvmsg));
        }
        //  If update is more recent than our kvmap, apply it
        if (kvmsg_sequence (kvmsg) > self->sequence) {
            self->sequence = kvmsg_sequence (kvmsg);
            kvmsg_store (&kvmsg, self->kvmap);
            zclock_log ("I: received update=%d", (int) self->sequence);
        }
        else
            kvmsg_destroy (&kvmsg);
    }
    else
        kvmsg_destroy (&kvmsg);

    return 0;
}
예제 #3
0
파일: pem.c 프로젝트: intliang/libreswan
/*
 * check the presence of a pattern in a character string
 */
static bool present(const char* pattern, chunk_t* ch)
{
	u_int pattern_len = strlen(pattern);

	if (ch->len >= pattern_len &&
		strneq((char *)ch->ptr, pattern, pattern_len)) {
		ch->ptr += pattern_len;
		ch->len -= pattern_len;
		return TRUE;
	}
	return FALSE;
}
예제 #4
0
파일: gif2tiff.c 프로젝트: Starlink/tkimg
static int
processCompressOptions(char* opt)
{
	if (streq(opt, "none"))
		compression = COMPRESSION_NONE;
	else if (streq(opt, "packbits"))
		compression = COMPRESSION_PACKBITS;
	else if (strneq(opt, "lzw", 3)) {
		char* cp = strchr(opt, ':');
		if (cp)
			predictor = atoi(cp+1);
		compression = COMPRESSION_LZW;
	} else if (strneq(opt, "zip", 3)) {
		char* cp = strchr(opt, ':');
		if (cp)
			predictor = atoi(cp+1);
		compression = COMPRESSION_DEFLATE;
	} else
		return (0);
	return (1);
}
예제 #5
0
static void check(const char *test, char** expected, bool trailing) {
        const char *word, *state;
        size_t l;
        int i = 0;

        printf("<<<%s>>>\n", test);
        FOREACH_WORD_QUOTED(word, l, test, state) {
                _cleanup_free_ char *t = NULL;

                assert_se(t = strndup(word, l));
                assert_se(strneq(expected[i++], word, l));
                printf("<%s>\n", t);
        }
예제 #6
0
파일: zfl_device.c 프로젝트: mkoppanen/zfl
char *
zfl_device_property (zfl_device_t *self, char *device_name, char *property)
{
    assert (self);
    assert (device_name);
    assert (strneq (device_name, "context"));
    assert (property);

    zfl_config_t *config = zfl_config_locate (self->config, device_name);
    if (!config)
        return "";              //  No such device
    return zfl_config_resolve (config, property, "");
}
예제 #7
0
파일: zfl_config.c 프로젝트: dell-esdk/zfl
//  --------------------------------------------------------------------------
//  Creates a named 0MQ socket within a named device, and configures the
//  socket as specified in the configuration data.  Returns NULL if the
//  device or socket do not exist, or if there was an error configuring the
//  socket.
//
void *
zfl_config_socket (zfl_config_t *self, char *device, char *name, int type)
{
    assert (self);
    assert (device);
    assert (strneq (device, "context"));

    zfl_tree_t *tree = zfl_tree_locate (self->tree, device);
    if (!tree)
        return NULL;            //  No such device

    void *socket = zmq_socket (self->context, type);
    if (!socket)
        return NULL;            //  Can't create socket

    if (zfl_config_verbose (self))
        printf ("I: Configuring '%s' socket in '%s' device...\n", name, device);

    //  Find socket in device
    int rc = 0;
    tree = zfl_tree_locate (tree, name);
    if (tree) {
        tree = zfl_tree_child (tree);
        while (tree && rc == 0) {
            char *name = zfl_tree_name (tree);
            if (streq (name, "bind"))
                rc = zmq_bind (socket, zfl_tree_string (tree));
            else
            if (streq (name, "connect"))
                rc = zmq_connect (socket, zfl_tree_string (tree));
            else
            if (streq (name, "option"))
                rc = s_setsockopt (self, socket, tree);
            else
            if (self->verbose)
                printf ("W: ignoring socket setting '%s'\n", name);

            tree = zfl_tree_next (tree);
        }
    }
    else
    if (self->verbose)
        printf ("W: No configuration found for '%s'\n", name);

    if (rc) {
        printf ("E: configuration failed - %s\n", zmq_strerror (errno));
        zmq_close (socket);
        socket = NULL;
    }
    return socket;
}
예제 #8
0
파일: fsck.c 프로젝트: RoadRunnr/systemd
static int parse_proc_cmdline(void) {
        char *line, *w, *state;
        int r;
        size_t l;

        if (detect_container(NULL) > 0)
                return 0;

        r = read_one_line_file("/proc/cmdline", &line);
        if (r < 0) {
                log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
                return 0;
        }

        FOREACH_WORD_QUOTED(w, l, line, state) {

                if (strneq(w, "fsck.mode=auto", l))
                        arg_force = arg_skip = false;
                else if (strneq(w, "fsck.mode=force", l))
                        arg_force = true;
                else if (strneq(w, "fsck.mode=skip", l))
                        arg_skip = true;
                else if (startswith(w, "fsck"))
                        log_warning("Invalid fsck parameter. Ignoring.");
#ifdef HAVE_SYSV_COMPAT
                else if (strneq(w, "fastboot", l)) {
                        log_error("Please pass 'fsck.mode=skip' rather than 'fastboot' on the kernel command line.");
                        arg_skip = true;
                } else if (strneq(w, "forcefsck", l)) {
                        log_error("Please pass 'fsck.mode=force' rather than 'forcefsck' on the kernel command line.");
                        arg_force = true;
                }
#endif
        }

        free(line);
        return 0;
}
예제 #9
0
void trigger_onlyregistered_touch()
{
	if ( strneq( other->s.v.classname, "player" ) )
		return;
	if ( self->attack_finished > g_globalvars.time )
		return;

	self->attack_finished = g_globalvars.time + 2;
	if ( trap_cvar( "registered" ) )
	{
		self->s.v.message = "";
		activator = other;
		SUB_UseTargets();
		ent_remove( self );
	} else
	{
		if ( self->s.v.message && strneq( self->s.v.message, "" ) )
		{
			G_centerprint( other, self->s.v.message );
			sound( other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM );
		}
	}
}
예제 #10
0
파일: string.c 프로젝트: celskeggs/libca
string strstr(string str, string substr) {
	char first = *substr;
	if (first == 0) {
		return str;
	}
	ulen count = strlen(substr);
	while (*str) {
		if (*str == first && strneq(str + 1, substr + 1, count - 1)) {
			return str;
		}
		str++;
	}
	return NULL;
}
예제 #11
0
/*
===============================================================================

ARMOR

===============================================================================
*/
void armor_touch()
{
	float           type = 0, value = 0;
	int             bit = 0;

	if ( other->s.v.health <= 0 )
		return;
	if ( strneq( other->s.v.classname, "player" ) )
		return;
	if ( !strcmp( self->s.v.classname, "item_armor1" ) )
	{
		type = 0.3;
		value = 100;
		bit = IT_ARMOR1;
	}
	if ( !strcmp( self->s.v.classname, "item_armor2" ) )
	{
		type = 0.6;
		value = 150;
		bit = IT_ARMOR2;
	}
	if ( !strcmp( self->s.v.classname, "item_armorInv" ) )
	{
		type = 0.8;
		value = 200;
		bit = IT_ARMOR3;
	}
	if ( other->s.v.armortype * other->s.v.armorvalue >= type * value )
		return;

	other->s.v.armortype = type;
	other->s.v.armorvalue = value;
	other->s.v.items +=
	    -( ( int ) other->s.v.items & ( IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3 ) ) + bit;

	self->s.v.solid = SOLID_NOT;
	self->s.v.model = "";
	if ( deathmatch != 2 )
		self->s.v.nextthink = g_globalvars.time + 20;
	self->s.v.think = ( func_t ) SUB_regen;


	G_sprint( other, PRINT_LOW, "You got armor\n" );
// armor touch sound
	sound( other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM );
	stuffcmd( other, "bf\n" );

	activator = other;
	SUB_UseTargets();	// fire all targets / killtargets
}
예제 #12
0
zauth_t *
zauth_new (zctx_t *ctx)
{    
    zauth_t *self = (zauth_t *) zmalloc (sizeof (zauth_t));
    assert (self);
    
    //  Start background agent and wait for it to initialize
    self->pipe = zthread_fork (ctx, s_agent_task, NULL);
    char *status = zstr_recv (self->pipe);
    if (strneq (status, "OK"))
        zauth_destroy (&self);
    free (status);
    return self;
}
예제 #13
0
파일: sflxml.c 프로젝트: imatix/Xitami-25
void
xml_modify_value  (XML_ITEM *item, const char *value)
{
    ASSERT (item);

    if (!item-> value)
        item-> value = mem_strdup (value);
    else
        if (! value || (strneq (value, item-> value)))
          {
            mem_free (item-> value);
            item-> value = mem_strdup (value);
          }
}
예제 #14
0
static void
readXvHeader(FILE *         const ifP,
             unsigned int * const colsP,
             unsigned int * const rowsP,
             unsigned int * const maxvalP) {

    char buf[256];
    unsigned int cols, rows, maxval;
    int rc;
    bool endOfComments;

    getLine(ifP, buf, sizeof(buf));

    if (!strneq(buf, "P7 332", 6))
        pm_error("Input is not a XV thumbnail picture.  It does not "
                 "begin with the characters 'P7 332'.");

    endOfComments = FALSE;
    while (!endOfComments) {
        getLine(ifP, buf, sizeof(buf));
        if (strneq(buf, "#END_OF_COMMENTS", 16))
            endOfComments = TRUE;
        else if (strneq(buf, "#BUILTIN", 8))
            pm_error("This program does not know how to "
                     "convert builtin XV thumbnail pictures");
    }
    getLine(ifP, buf, sizeof(buf));
    rc = sscanf(buf, "%u %u %u", &cols, &rows, &maxval);
    if (rc != 3)
        pm_error("error parsing dimension info '%s'.  "
                 "It does not consist of 3 decimal numbers.", buf);
    if (maxval != 255)
        pm_error("bogus XV thumbnail maxval %u.  Should be 255", maxval);
    *colsP = cols;
    *rowsP = rows;
    *maxvalP = maxval;
}
예제 #15
0
파일: zproxy.c 프로젝트: maxkozlovsky/czmq
static zsock_t *
s_self_create_socket (self_t *self, char *type_name, char *endpoints, proxy_socket selected_socket)
{
    //  This array matches ZMQ_XXX type definitions
    assert (ZMQ_PAIR == 0);
    char *type_names [] = {
        "PAIR", "PUB", "SUB", "REQ", "REP",
        "DEALER", "ROUTER", "PULL", "PUSH",
        "XPUB", "XSUB", type_name
    };
    //  We always match type at least at end of table
    int index;
    for (index = 0; strneq (type_name, type_names [index]); index++) ;
    if (index > ZMQ_XSUB) {
        zsys_error ("zproxy: invalid socket type '%s'", type_name);
        return NULL;
    }
    zsock_t *sock = zsock_new (index);
    if (sock) {
#if (ZMQ_VERSION_MAJOR == 4)
        if (self->domain [selected_socket]) {
            // Apply authentication domain
            zsock_set_zap_domain (sock, self->domain [selected_socket]);
        }
        if (self->auth_type [selected_socket] == AUTH_PLAIN) {
            // Enable plain authentication
            zsock_set_plain_server (sock, 1);
        }
        else
        if (self->auth_type [selected_socket] == AUTH_CURVE) {
            // Apply certificate keys
            char *public_key = self->public_key [selected_socket];
            assert(public_key);
            char *secret_key = self->secret_key [selected_socket];
            assert(secret_key);
            zsock_set_curve_publickey (sock, public_key);
            zsock_set_curve_secretkey (sock, secret_key);

            // Enable curve authentication
            zsock_set_curve_server (sock, 1);
        }
#endif
        if (zsock_attach (sock, endpoints, true)) {
            zsys_error ("zproxy: invalid endpoints '%s'", endpoints);
            zsock_destroy (&sock);
        }
    }
    return sock;
}
예제 #16
0
mtn_message_type
get_message_type(const char* message)
{
    mtn_message_type type = MTN_UNKNOWN;

    if(strneq(message, MTN_REQUEST_TXT, MTN_MSG_TYPE_LEN))
    {
        type = MTN_REQUEST;
    }
    else if(strneq(message, MTN_RESPONSE_TXT, MTN_MSG_TYPE_LEN))
    {
        type = MTN_RESPONSE;
    }
    else if(strneq(message, MTN_DM_HEAD_TXT, MTN_MSG_TYPE_LEN))
    {
        type = MTN_DM_HEAD;
    }
    else if(strneq(message, MTN_DM_BLOCK_TXT, MTN_MSG_TYPE_LEN))
    {
        type = MTN_DM_BLOCK;
    }

    return type;
}
예제 #17
0
파일: u.c 프로젝트: dbremner/aplusdev
S si(const C *n)
{
  S s,a=(S)(((S *)(SymHashTable->b))+((SymHashTable->nb-1)&HA(n)));

  for(;(s=a->s)&&strneq(n,s->n);a=s) ;
  if(s==0)
    {
      int rc;

#if defined(linux)
      static int initMutex=1;
      if(initMutex)
	initMutex=_initMutex();
#endif

      if(0!=(rc=pthread_mutex_lock(&newSymbol_lock)))
        {
          perror("si() pthread_mutex_lock");
        }
      {
        /* Need to re-check for Symbol after getting lock */
        S a=(S)(((S *)(SymHashTable->b))+((SymHashTable->nb-1)&HA(n)));
        for(;(s=a->s)&&strneq(n,s->n);a=s) ;
        if(s==0)
          {
            s=newSymbol(n,a);
          }
      }

      if(rc==0 && pthread_mutex_unlock(&newSymbol_lock))
        {
          perror("si() pthread_mutex_unlock");
        }
    }
  R s;
}
예제 #18
0
파일: env-util.c 프로젝트: hosiet/systemd
bool strv_env_is_valid(char **e) {
        char **p, **q;

        STRV_FOREACH(p, e) {
                size_t k;

                if (!env_assignment_is_valid(*p))
                        return false;

                /* Check if there are duplicate assginments */
                k = strcspn(*p, "=");
                STRV_FOREACH(q, p + 1)
                        if (strneq(*p, *q, k) && (*q)[k] == '=')
                                return false;
        }
예제 #19
0
int m17n_mainX(int ac,const char *av[],FILE *in,FILE *out){
	int ai;
	const char *arg;
	M17nCCX *m17n;
	int fini = 0;

	m17n = (M17nCCX*)m17n_ccx_new(0,0,0,0);
	m17n->m_icnam = "iso-2022-jp";
	m17n->m_ocnam = "iso-2022-jp";
	for( ai = 1; ai < ac; ai++ ){
		arg = av[ai];
		if( strneq(arg,"-i",2) ){
			m17n->m_icnam = arg+2;
		}else
		if( strneq(arg,"-o",2) ){
			m17n->m_ocnam = arg+2;
		}else
		if( strneq(arg,"-d",2) ){
			sscanf(arg+2,"%X",&m17n->m_trace);
		}else
		if( strneq(arg,"-x",2) ){
			fini = 1;
		}
	}
	if( m17n_ccx_init(m17n,m17n->m_icnam,m17n->m_ocnam) != 0 ){
		return -1;
	}
	m17n_ccx_filter(m17n,in,out);
	if( fini ){
		m17n_Fini();
	}
	m17n_ccx_free(m17n);
	LAP("finish");
	fflush(out);
	return 0;
}
예제 #20
0
파일: preopen.c 프로젝트: IanYXXL/A1
/* Open all the preloaded modules from the named originator, executing
   a callback for each one.  If ORIGINATOR is NULL, then call FUNC for
   each preloaded module from the program itself.  */
int
lt_dlpreload_open (const char *originator, lt_dlpreload_callback_func *func)
{
  symlist_chain *list;
  int		 errors = 0;
  int		 found  = 0;

  /* For each symlist in the chain...  */
  for (list = preloaded_symlists; list; list = list->next)
    {
      /* ...that was preloaded by the requesting ORIGINATOR... */
      if ((originator && streq (list->symlist->name, originator))
          || (!originator && streq (list->symlist->name, "@PROGRAM@")))
	{
	  const lt_dlsymlist *symbol;
	  unsigned int idx = 0;

	  ++found;

	  /* ...load the symbols per source compilation unit:
	     (we preincrement the index to skip over the originator entry)  */
	  while ((symbol = &list->symlist[++idx])->name != 0)
	    {
	      if ((symbol->address == 0)
		  && (strneq (symbol->name, "@PROGRAM@")))
		{
		  lt_dlhandle handle = lt_dlopen (symbol->name);
		  if (handle == 0)
		    {
		      ++errors;
		    }
		  else
		    {
		      errors += (*func) (handle);
		    }
		}
	    }
	}
    }

  if (!found)
    {
      LT__SETERROR(CANNOT_OPEN);
      ++errors;
    }

  return errors;
}
예제 #21
0
/*
================
secret_touch

Prints messages
================
*/
void secret_touch()
{
	if ( strneq( other->s.v.classname, "player" ) )
		return;
	
	if ( self->attack_finished > g_globalvars.time )
		return;

	self->attack_finished = g_globalvars.time + 2;

	if ( self->s.v.message )
	{
		G_centerprint( other, self->s.v.message );
		sound( other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM );
	}
}
예제 #22
0
파일: zfl_device.c 프로젝트: mkoppanen/zfl
//  --------------------------------------------------------------------------
//  Returns the name of the Nth device in the property config. The first
//  device following the context specification has index 0, following C
//  conventions for arrays. Returns NULL if there is no such device.
//
char *
zfl_device_locate (zfl_device_t *self, int index)
{
    assert (self);

    //  Check children of root item, skip any called "context"
    zfl_config_t *config = zfl_config_child (self->config);
    while (config) {
        if (strneq (zfl_config_name (config), "context")) {
            if (index)
                index--;
            else
                return zfl_config_name (config);
        }
        config = zfl_config_next (config);
    }
    return NULL;
}
예제 #23
0
파일: zfl_config.c 프로젝트: dell-esdk/zfl
//  --------------------------------------------------------------------------
//  Returns the name of the Nth device in the configuration tree.  The first
//  device is index 0, following C conventions for arrays.  Returns NULL if
//  there is no such device.
//
char *
zfl_config_device (zfl_config_t *self, int index)
{
    assert (self);

    //  Check children of root item, skip any called "context"
    zfl_tree_t *tree = zfl_tree_child (self->tree);
    while (tree) {
        if (strneq (zfl_tree_name (tree), "context")) {
            if (index)
                index--;
            else
                return zfl_tree_name (tree);
        }
        tree = zfl_tree_next (tree);
    }
    return NULL;
}
예제 #24
0
파일: test-util.c 프로젝트: banada/systemd
static void test_foreach_word(void) {
        char *w, *state;
        size_t l;
        int i = 0;
        const char test[] = "test abc d\te   f   ";
        const char * const expected[] = {
                "test",
                "abc",
                "d",
                "e",
                "f",
                "",
                NULL
        };

        FOREACH_WORD(w, l, test, state) {
                assert_se(strneq(expected[i++], w, l));
        }
static bool enable_name_policy(void) {
        _cleanup_free_ char *line = NULL;
        const char *word, *state;
        int r;
        size_t l;

        r = proc_cmdline(&line);
        if (r < 0) {
                log_warning_errno(r, "Failed to read /proc/cmdline, ignoring: %m");
                return true;
        }

        FOREACH_WORD_QUOTED(word, l, line, state)
                if (strneq(word, "net.ifnames=0", l))
                        return false;

        return true;
}
예제 #26
0
void q_touch()
{
//gedict_t*    stemp;
//float     best;

	if ( strneq( other->s.v.classname, "player" ) )
		return;
	if ( other->s.v.health <= 0 )
		return;

	self->mdl = self->s.v.model;

	sound( other, CHAN_VOICE, self->s.v.noise, 1, ATTN_NORM );
	stuffcmd( other, "bf\n" );

	self->s.v.solid = SOLID_NOT;
	other->s.v.items = ( ( int ) other->s.v.items ) | IT_QUAD;
	self->s.v.model = "";

	if ( deathmatch == 4 )
	{
		other->s.v.armortype = 0;
		other->s.v.armorvalue = 0 * 0.01;
		other->s.v.ammo_cells = 0;
	}
// do the apropriate action
	other->super_time = 1;
	other->super_damage_finished = self->cnt;

	if ( deathmatch == 4 )
		G_bprint( PRINT_LOW,
			  "%s recovered an OctaPower with %d seconds remaining!\n",
			  other->s.v.netname,
			  ( int ) ( other->super_damage_finished - g_globalvars.time ) );
	else
		G_bprint( PRINT_LOW, "%s recovered a Quad with %d seconds remaining!\n",
			  other->s.v.netname,
			  ( int ) ( other->super_damage_finished - g_globalvars.time ) );


	activator = other;
	SUB_UseTargets();	// fire all targets / killtargets
}
예제 #27
0
void multi_touch()
{
	if ( !other->s.v.classname )
		return;
	if ( strneq( other->s.v.classname, "player" ) )
		return;

// if the trigger has an angles field, check player's facing direction
	if ( self->s.v.movedir[0] != 0 && self->s.v.movedir[1] != 0
	     && self->s.v.movedir[2] != 0 )
	{
		makevectors( other->s.v.angles );
		if ( DotProduct( g_globalvars.v_forward, self->s.v.movedir ) < 0 )
			return;	// not facing the right way
	}

	self->s.v.enemy = EDICT_TO_PROG( other );
	multi_trigger();
}
예제 #28
0
파일: zloop.c 프로젝트: bumptech/czmq
int
zloop_poller (zloop_t *self, zmq_pollitem_t *item, zloop_fn handler, void *arg)
{
    assert (self);
    s_poller_t *poller = s_poller_new (item, handler, arg);
    if (poller) {
        if (zlist_push (self->pollers, poller))
            return -1;

        self->dirty = TRUE;
        if (self->verbose)
            zclock_log ("I: zloop: register %s poller (%p, %d)",
                item->socket? zsocket_type_str (item->socket): "FD",
                item->socket, item->fd);
        assert (strneq (zsocket_type_str (item->socket), "UNKNOWN"));
        return 0;
    }
    else
        return -1;
}
예제 #29
0
파일: smtrdns.c 프로젝트: INNOAUS/gsl
MODULE lookup_ip_in_cache (THREAD *thread)
{
    SYMBOL
        *symbol;
    long
        current_time;

    tcb = thread-> tcb;                 /*  Point to thread's context        */

    the_next_event = not_found_event;
    for (symbol = cache_table-> symbols; symbol; symbol = symbol-> next)
      {
         if(symbol-> value
         && streq (symbol-> value, tcb-> cur_request-> host_address))
           {
             current_time = (long)time (NULL);
             if (symbol-> data          /*  Check Time to live               */
             && (   *(long *)symbol-> data == -1
                 || *(long *)symbol-> data >= current_time))
               {
                 if (strneq (symbol-> name, symbol-> value))
                   {
                     mem_strfree (&tcb-> host_name);
                     tcb-> host_name = mem_strdup (symbol-> name);
                     if (dns_debug_mode)
                         coputs ("Found in cache");
                     the_next_event = found_event;
                   }
                 else                   /*  Found bad result in cache        */
                     the_next_event = found_bad_event;
               }
             else
             if (symbol-> data)         /*  Delete cache entry: expired time */
               {
                 mem_free (symbol-> data);
                 sym_delete_symbol (cache_table, symbol);
               }
             break;
           }
      }
}
예제 #30
0
int
pathcheck(const char* package, const char* tool, Pathcheck_t* pc)
{
#ifdef PARANOID
	register char*	s;
	struct stat	st;

	if (strmatch(tool, PARANOID) && environ && (s = *environ) && *s++ == '_' && *s++ == '=' && !stat(s, &st))
	{
		unsigned long	n;
		unsigned long	o;
		Sfio_t*		sp;

		n = time(NiL);
		o = st.st_ctime;
		if (n > o && (n - o) > (unsigned long)(60 * 60 * 24 * 90) && (sp = sfopen(NiL, "/etc/hosts", "r")))
		{
			/*
			 * this part is infallible
			 */

			n = 0;
			o = 0;
			while (n++ < 64 && (s = sfgetr(sp, '\n', 0)))
				if (strmatch(s, PARANOID_PAY))
				{
					error(1, "licensed for external use -- %s employees should contact %s for the internal license", PARANOID_COMPANY, PARANOID_MAIL);
					break;
				}
				else if (*s != '#' && !isspace(*s) && !strneq(s, "127.", 4) && !strmatch(s, PARANOID_FREE) && o++ > 4)
					break;
			sfclose(sp);
		}
	}
#else
	NoP(tool);
#endif
	NoP(package);
	if (pc) memzero(pc, sizeof(*pc));
	return(0);
}