Example #1
0
struct rtpp_node *rtpengine_hash_table_lookup(str callid, str viabranch, enum rtpe_operation op) {
	struct rtpengine_hash_entry *entry, *last_entry;
	unsigned int hash_index;
	struct rtpp_node *node;

	// sanity checks
	if (!rtpengine_hash_table_sanity_checks()) {
		LM_ERR("sanity checks failed\n");
		return 0;
	}

	// get first entry from entry list; jump over unused list head
	hash_index = str_hash(callid);
	entry = rtpengine_hash_table->row_entry_list[hash_index];
	last_entry = entry;

	// lock
	if (rtpengine_hash_table->row_locks[hash_index]) {
		lock_get(rtpengine_hash_table->row_locks[hash_index]);
	} else {
		LM_ERR("NULL rtpengine_hash_table->row_locks[%d]\n", hash_index);
		return 0;
	}

	while (entry) {
		// if callid found, return entry
		if ((str_equal(entry->callid, callid) && str_equal(entry->viabranch, viabranch)) ||
		    (str_equal(entry->callid, callid) && viabranch.len == 0 && op == OP_DELETE)) {
			node = entry->node;

			// unlock
			lock_release(rtpengine_hash_table->row_locks[hash_index]);

			return node;
		}

		// if expired entry discovered, delete it
		if (entry->tout < get_ticks()) {
			// set pointers; exclude entry
			last_entry->next = entry->next;

			// free current entry; entry points to unknown
			rtpengine_hash_table_free_entry(entry);

			// set pointers
			entry = last_entry;

			// update total
			rtpengine_hash_table->row_totals[hash_index]--;
		}

		last_entry = entry;
		entry = entry->next;
	}

	// unlock
	lock_release(rtpengine_hash_table->row_locks[hash_index]);

	return NULL;
}
Example #2
0
File: str.c Project: hollow/lucid
int str_path_isabs(const char *str)
{
	int abs = 1;

	if (str_isempty(str))
		return 0;

	if (*str != '/')
		return 0;

	strtok_t _st, *st = &_st, *p;

	if (!strtok_init_str(st, str, "/", 0))
		return -1;

	strtok_for_each(st, p) {
		if (str_equal(p->token, ".") || str_equal(p->token, "..") ||
		    !str_isgraph(p->token)) {
			abs = 0;
			break;
		}
	}

	strtok_free(st);

	return abs;
}
Example #3
0
/*
To check whether the current packet is in the cs list(\gamma)
*/
bool matched(char src[13], char dst[13], char  mac1[13],char mac2[13],int t){
	if ( (str_equal(mac_zero,mac1,2*MAC_LEN) == 1) &&
           (str_equal(mac_zero,mac2,2*MAC_LEN) == 1) )
                return false;    // not vavid data
	if ((control_address(mac1) == 1) &&
	   (  (str_equal(mac2,src,2*MAC_LEN) == 1)||(str_equal(mac2,dst,2*MAC_LEN) == 1) ))
	{
		return true;
	}
	if ((control_address(mac2) == 1) &&
	   (  (str_equal(mac1,src,2*MAC_LEN) == 1)||(str_equal(mac1,dst,2*MAC_LEN) == 1) ))
	{
		return true;
	}
	
	
	if ( (str_equal(mac1,src,2*MAC_LEN) == 1) &&
           (str_equal(mac2,dst,2*MAC_LEN) == 1) )
	{
		return true;
	}
        if ( (str_equal(mac1,dst,2*MAC_LEN) == 1) &&
           (str_equal(mac2,src,2*MAC_LEN) == 1) )
	{
		return true;
	}
        return false;
}
Example #4
0
int main(int argc, char** argv) {
  STR s1 = "abcd";
  STR s2 = "1234";
  if (str_equal(s1,s1) == NO)
    return 1;
  if (str_equal(s1,s2) == YES)
    return 2;
  return 0;
}
Example #5
0
/*
To judge whether the current packet are broadcast, cts, ack or control packet(\gamma)
*/
bool control_address(char mac1[13]){
 	if (str_equal(mac_zero,mac1,2*MAC_LEN) == 1)
                return true;
 	if (str_equal(mac_FFFF,mac1,2*MAC_LEN) == 1)
                return true;
 	if (str_equal(mac_ffff,mac1,2*MAC_LEN) == 1)
                return true;
        return false;
}
Example #6
0
void process_command() {
  int command_ptr  = 0;

  initialize_array(command, 80, 0);
  copy_string(command, buffer + C(current_line, 2));
  initialize_array(argument, ARGUMENT_HEAP_SIZE, 0);

  send_rs(command, 10);
  next_line();

  if (str_equal(c_exit, command, 4)) {
    put_char('b');
    put_char('y');
    put_char('e');
    send_display(buffer);
    halt();

  } else if (str_equal(c_cd, command, 3)) {
    int length = copy_string(argument, command + 3);
    change_directory(argument, length);

  } else if (command[0] == 0) {
    return;

  } else {
    int ptr = 0;
    while (command[command_ptr] != ' '
           && command[command_ptr] != 0
           && command_ptr < COLS) {
      int byte = command[command_ptr];
      if (byte >= 'a' && byte <= 'z') {
        byte -= 0x20;
      }
      program_name[ptr] = byte;
      command_ptr += 1;
      ptr += 1;
    }
    program_name[ptr] = 0;

    while (command[command_ptr] == ' ' && command_ptr < COLS) {
      command_ptr += 1;
    }

    ptr = 0;
    while (command[command_ptr] != ' '
           && command[command_ptr] != 0
           && command_ptr < COLS) {
      argument[ptr] = command[command_ptr];
      command_ptr += 1;
      ptr += 1;
    }
    argument[ptr] = 0;
    argument[ARGUMENT_HEAP_SIZE-1] = current_directory_id;
    execute_bin(program_name, argument);
  }
}
/**
 * @details Given a status code, this function finds the correct index in 
 *          the credit_totals array member of the Ledger type. credit_totals
 *          is an array indexed by the transaction status given in the
 *          Status_Macros module. If no index is found for the given
 *          status code, NO_INDEX is returned.
 */
index_t which_credit_total(char *status){
  if(status == NULL)
    return NO_INDEX;

  if(str_equal(status, CREDIT_NOT_THERE_YET))
     return I_NOT_THERE_YET;
  else if(str_equal(status, CREDIT_PENDING))
    return I_PENDING;
  else if(str_equal(status, CREDIT_CHARGED))
    return I_CLEARED;
  else
    return NO_INDEX;
}
Example #8
0
int
main (int argc, char * const argv[])
{
    PROG = "aa-sync";

    if (argc == 1)
    {
        sync ();
        return 0;
    }

    if (argc == 2 && (str_equal (argv[1], "-V") || str_equal (argv[1], "--version")))
        aa_die_version ();
    dieusage ((argc == 2 && (str_equal (argv[1], "-h") || str_equal (argv[1], "--help"))) ? 0 : 1);
}
Example #9
0
static int
it_kill (direntry *d, void *data)
{
    stralloc *sa = data;
    char c;
    int l;
    int r;

    /* ignore files, not-number dirs, PID 1 and ourself */
    if (d->d_type != DT_DIR || *d->d_name < '1' || *d->d_name > '9'
            || str_equal (d->d_name, "1") || str_equal (d->d_name, ownpid))
        return 0;

    l = sa->len;
    sa->s[l - 1] = '/';
    if (stralloc_cats (sa, d->d_name)
            && stralloc_catb (sa, "/cmdline", sizeof ("/cmdline")))
        r = openreadnclose (sa->s, &c, 1);
    else
        r = -1;
    sa->len = l;
    sa->s[l - 1] = '\0';

    /* skip empty cmdline (kernel threads) and anything starting with '@' */
    if (r == 1 && c != '@')
    {
        unsigned int u;
        pid_t pid;

        if (!uint_scan (d->d_name, &u))
            goto done;
        pid = (pid_t) u;
        if (pid != u)
            goto done;
        if (send.hup)
            _kill (pid, SIGHUP);
        if (send.term)
        {
            _kill (pid, SIGTERM);
            _kill (pid, SIGCONT);
        }
        if (send.kill)
            _kill (pid, SIGKILL);
    }

done:
    return 0;
}
static void do_sc(const char *action)
{
  int r;

  if (hashok(action,ACTION_SC)) {
    if (modsub.s != 0 && !(ismod && str_equal(sender,target.s))) {
      store_from(&fromline,target.s);	/* save from line, if requested */
					/* since transaction not complete */
      doconfirm(ACTION_TC);
      copy_act("text/mod-sub-confirm");
      copybottom(0);
      sendtomods();
    } else {
      r = geton(action);
      copybottom(0);
      qmail_to(&qq,target.s);
      if (r && flagcopyowner > 1) to_owner();
    }
  } else {
    doconfirm(ACTION_SC);
    copy_act("text/sub-bad");
    copybottom(0);
    qmail_to(&qq,target.s);
  }
}
Example #11
0
void test_equal(void) {
    str test_a;
    str test_b;

    str_create_from_cstr(&test_a, "prepended_testdataappended_X");

    str_create_from_cstr(&test_b, "prepended_testdataappended_X");
    CU_ASSERT(str_equal(&test_a, &test_b) == 1);
    str_free(&test_b);

    str_create_from_cstr(&test_b, "awesome!");
    CU_ASSERT(str_equal(&test_a, &test_b) == 0);
    str_free(&test_b);

    str_free(&test_a);
}
Example #12
0
stmt_ty *
stmt_if_alloc(blob_list_ty *condition, stmt_ty *then_clause,
    stmt_ty *else_clause)
{
    stmt_if_ty      *result;
    blob_list_ty    *c2;
    table_ty        *tp;

    trace(("stmt_if_alloc()\n{\n"));
    result = (stmt_if_ty *)stmt_alloc(&method);

    assert(condition->length >= 1);
    for (tp = table; tp < ENDOF(table); ++tp)
    {
        if (!tp->fast)
            tp->fast = str_from_c(tp->name);
        if (str_equal(condition->list[0]->text, tp->fast))
            break;
    }
    assert(tp < ENDOF(table));
    if (tp >= ENDOF(table))
        tp = &table[0];
    c2 = tp->rewrite(condition, &result->ref);
    blob_list_free(condition);

    result->condition = c2;
    result->then_clause = then_clause;
    result->else_clause = else_clause;

    stmt_variable_merge((stmt_ty *)result, then_clause);
    if (else_clause)
        stmt_variable_merge((stmt_ty *)result, else_clause);
    trace(("}\n"));
    return (stmt_ty *)result;
}
Example #13
0
void getlarg(long *l) {
  unsigned long ul;

  if (str_equal(optarg, "=")) { *l =-1; return; }
  if (optarg[scan_ulong(optarg, &ul)]) usage();
  *l =ul;
}
Example #14
0
int Shash_del(T *hash, char *key)
{
    int index, flag = 0;
    NODE_T **p, *q;
    BUCKET_T *bucket;

    assert(key);
    assert(hash);
    index  = MOD(str_hash(key), hash->len);
    bucket = &hash->buckets[index];

    if (!bucket->list)
        return -1;

    p = &bucket->list;
    do {
        q = (*p)->next;
        if (str_equal((*p)->key, key)) {
            FREE(*p);
            *p   = q;
            flag = 1;
            break;
        }
        p = &(*p)->next;
    } while (q);
    return flag? 0 : -1;
}
Example #15
0
static int
enable_service (const char *name, intptr_t from_next)
{
    int offset;
    int r;
    int i;

    if (*name == '/')
        cur_name = name + byte_rchr (name, strlen (name), '/') + 1;
    else
        cur_name = name;

    if (!from_next)
    {
        /* check if it was already added to be done next (via auto-enable), in
         * which case we need to remove it.
         * We do this instead of simply skipping it and having it done later
         * because:
         * - if there's a folder here, we want to use it as config folder
         * - in upgrade mode, the auto-added are treated differently, so
         *   anything specified needs to be treated now (even w/out folder)
         */
        for (i = 0; i < genalloc_len (int, &ga_next); ++i)
            if (str_equal (cur_name, names.s + list_get (&ga_next, i)))
            {
                offset = list_get (&ga_next, i);
                ga_remove (int, &ga_next, i);
                goto process;
            }

        offset = names.len;
        stralloc_catb (&names, cur_name, strlen (cur_name) + 1);
    }
Example #16
0
 STDMETHODIMP voice_token::OpenKey(LPCWSTR pszSubKeyName,ISpDataKey **ppSubKey)
 {
   if(pszSubKeyName==0)
     return E_INVALIDARG;
   if(ppSubKey==0)
     return E_POINTER;
   *ppSubKey=0;
   try
     {
       if(!str_equal(pszSubKeyName,L"Attributes"))
         return SPERR_NOT_FOUND;
       com::object<ISpDataKeyImpl > obj;
       for(attribute_map::const_iterator it=attributes.begin();it!=attributes.end();++it)
         {
           obj->set(it->first,it->second);
         }
       com::interface_ptr<ISpDataKey> int_ptr(obj);
       *ppSubKey=int_ptr.get();
       return S_OK;
     }
   catch(const std::bad_alloc&)
     {
       return E_OUTOFMEMORY;
     }
   catch(...)
     {
       return E_UNEXPECTED;
     }
 }
Example #17
0
recipe_ty *
cook_implicit_nth_by_name(long n, string_ty *name)
{
    static string_ty *prev;
    static recipe_list_ty *rlp;

    if (!name)
    {
        /* used to clear the state between passes */
        if (prev)
            str_free(prev);
        prev = 0;
        rlp = 0;
        return 0;
    }
    if (!prev || !str_equal(prev, name))
    {
        if (prev)
            str_free(prev);
        prev = str_copy(name);
        rlp = cook_implicit_find(name);
    }
    if (n < 0 || (size_t) n >= rlp->nrecipes)
        return 0;
    return rlp->recipe[n];
}
Example #18
0
int main(int argc, char **argv) {

    long long r,w;

    if (argv[0])
        if (argv[1])
            if (str_equal(argv[1], "-h"))
                die_usage();

    for (;;) {
        r = readblock(0, buf, BLOCK);
        if (r == -1) die_fatal("unable to read input", 0);

        for (;;) {
            if (r <= 0) goto end;
            if (buf[r - 1] == '\n') { --r; continue; }
            if (buf[r - 1] == '\r') { --r; continue; }
            break;
        }
        buf[r] = 0;
        if (r % 2) { errno = 0; die_fatal("unable to decode from hex", 0); }
        w = r / 2;
        if (!hexparse(buf, w, (char *)buf)) { errno = 0; die_fatal("unable to decode from hex", 0); }
        if (writeall(1, buf, w) == -1) die_fatal("unable to write output", 0);
        if (r != BLOCK) break;
    }

end:
    if (fsyncfd(1) == -1) die_fatal("unable to write output", 0);
    _exit(0);
}
Example #19
0
void
symtab_delete(symtab_ty *stp, string_ty *key)
{
    str_hash_ty     idx;
    symtab_row_ty   **pp;

    trace(("symtab_delete(stp = %08lX, key = \"%s\")\n{\n",
        (long)stp, key->str_text));
    idx = key->str_hash & stp->hash_mask;

    pp = &stp->hash_table[idx];
    for (;;)
    {
        symtab_row_ty   *p;

        p = *pp;
        if (!p)
            break;
        if (str_equal(key, p->key))
        {
            if (stp->reap)
                stp->reap(p->data);
            str_free(p->key);
            *pp = p->overflow;
            mem_free(p);
            stp->hash_load--;
            break;
        }
        pp = &p->overflow;
    }
    trace(("}\n"));
}
Example #20
0
void
symtab_assign(symtab_ty *stp, string_ty *key, void *data)
{
    str_hash_ty     idx;
    symtab_row_ty   *p;

    trace(("symtab_assign(stp = %08lX, key = \"%s\", data = %08lX)\n{\n",
        (long)stp, key->str_text, (long)data));
    idx = key->str_hash & stp->hash_mask;
    for (p = stp->hash_table[idx]; p; p = p->overflow)
    {
        if (str_equal(key, p->key))
        {
            trace(("modify existing entry\n"));
            if (stp->reap)
                stp->reap(p->data);
            p->data = data;
            goto done;
        }
    }

    trace(("new entry\n"));
    p = mem_alloc(sizeof(symtab_row_ty));
    p->key = str_copy(key);
    p->overflow = stp->hash_table[idx];
    p->data = data;
    stp->hash_table[idx] = p;

    stp->hash_load++;
    if (stp->hash_load * 10 >= stp->hash_modulus * 8)
        split(stp);
    done:
    trace(("}\n"));
}
Example #21
0
void *
symtab_query(symtab_ty *stp, string_ty *key)
{
    str_hash_ty     idx;
    symtab_row_ty   *p;
    void            *result;

    trace(("symtab_query(stp = %08lX, key = \"%s\")\n{\n",
        (long)stp, key->str_text));
    result = 0;

    idx = key->str_hash & stp->hash_mask;
    for (p = stp->hash_table[idx]; p; p = p->overflow)
    {
        if (str_equal(key, p->key))
        {
            result = p->data;
            break;
        }
    }

    trace(("return %08lX;\n", (long)result));
    trace(("}\n"));
    return result;
}
Example #22
0
static TinyRet DDD_LoadIconList(UpnpDevice *thiz, TinyXmlNode *iconList)
{
    TinyRet ret = TINY_RET_OK;

#if 0
    do
    {
        uint32_t count = 0;
        uint32_t i = 0;

        count = TinyXmlNode_GetChildren(iconList);
        if (count == 0)
        {
            ret = TINY_RET_E_XML_INVALID;
            break;
        }

        for (i = 0; i < count; i++)
        {
            TinyXmlNode *child = NULL;
            UpnpIcon *icon = NULL;
            const char *mimetype = NULL;
            const char *width = NULL;
            const char *height = NULL;
            const char *depth = NULL;
            const char *url = NULL;

            child = TinyXmlNode_GetChildAt(iconList, i);
            if (!str_equal(TinyXmlNode_GetName(child), DDD_ICON, true))
            {
                continue;
            }

            mimetype = TinyXmlNode_GetChildContent(child, DDD_ICON_MIMETYPE);
            width = TinyXmlNode_GetChildContent(child, DDD_ICON_WIDTH);
            height = TinyXmlNode_GetChildContent(child, DDD_ICON_HEIGHT);
            depth = TinyXmlNode_GetChildContent(child, DDD_ICON_DEPTH);
            url = TinyXmlNode_GetChildContent(child, DDD_ICON_URL);
            if (mimetype == NULL || width == NULL || height == NULL || depth == NULL || url == NULL)
            {
                continue;
            }

            icon = UpnpIcon_New();
            if (icon == NULL)
            {
                ret = TINY_RET_E_OUT_OF_MEMORY;
                break;
            }

            UpnpIcon_Set(icon, mimetype, atoi(width), atoi(height), atoi(depth), url);

            ScList_AddTail(&thiz->icons, icon);
        }
    } while (0);
#endif

    return ret;
}
Example #23
0
int dnszones_namefind(struct dnszones *dnszones,char *fqdn) {

    long long i;

    for(i = 0; i < dnszones->zoneslen; ++i) {
        if (str_equal(fqdn, dnszones->zones[i]->fqdn)) return 1;
    }
    return 0;
}
Example #24
0
int main(int argc, char **argv) {

    unsigned char *x;
    unsigned long long xlen;

    if (argv[0])
        if (argv[1]) {
            if (str_equal(argv[1], "-h"))
                die_usage(0);
        }

    /* get password  */
    x = (unsigned char *)env_get("PASSWORD");
    if (!x) { errno = 0; die_usage("$PASSWORD not set"); }
    xlen = str_len((char *)x);

    /* create salt */
    randombytes(s, sizeof s);

    /* derive key  */
    if (sha512hmacpbkdf2(h, sizeof h, x, xlen, s, sizeof s, ROUNDS) == -1) die_fatal("unable to derive keys", 0);
    byte_zero(x, xlen);

    /* create nonce */
    randombytes(n, sizeof n);
    uint64_pack(n, nanoseconds());
    sha512(nk, (unsigned char *)MAGIC, MAGICBYTES);
    crypto_block_aes256vulnerable(n, n, nk);

    /* initialize */
    crypto_init(&ctx, n, h, MAGIC);
    randombytes(h, sizeof h);
    sha512_init(&shactx);

    /* write header */
    if (writeall(1, MAGIC, MAGICBYTES) == -1) die_fatal("unable to write output", 0);
    if (writeall(1, s, sizeof s) == -1) die_fatal("unable to write output", 0);
    randombytes(s, sizeof s);
    if (writeall(1, n, sizeof n) == -1) die_fatal("unable to write output", 0);

    for (;;) {
        inlen = readblock(in, BLOCK);
        if (inlen != BLOCK) break;
        if (sha512_block(&shactx, in, inlen) != 0) die_fatal("unable to compute hash", 0);
        if (crypto_block(&ctx, in, inlen) != 0) die_fatal("unable to encrypt stream", 0);
        if (writeall(1, in, inlen) == -1) die_fatal("unable to write output", 0);
    }
    if (sha512_last(&shactx, h, in, inlen) != 0) die_fatal("unable to compute hash", 0);
    byte_copy(in + inlen, CHECKSUMBYTES, h);
    inlen += CHECKSUMBYTES;
    if (crypto_last(&ctx, in, inlen) != 0) die_fatal("unable to encrypt stream", 0);
    if (writeall(1, in, inlen) == -1) die_fatal("unable to write output", 0);

    if (fsyncfd(1) == -1) die_fatal("unable to write output", 0);
    cleanup();
    _exit(0);
}
Example #25
0
/* vg.remove(string group, string name) */
xmlrpc_value *m_vg_remove(xmlrpc_env *env, xmlrpc_value *p, void *c)
{
	LOG_TRACEME

	xmlrpc_value *params;
	char *group, *name;
	int rc, gid = 0;
	xid_t xid;

	params = method_init(env, p, c, VCD_CAP_AUTH, 0);
	method_return_if_fault(env);

	xmlrpc_decompose_value(env, params,
			"{s:s,s:s,*}",
			"group", &group,
			"name",  &name);
	method_return_if_fault(env);

	if (!validate_group(group))
		method_return_faultf(env, MEINVAL,
				"invalid group value: %s", group);

	if (str_equal(group, "all"))
		method_return_faultf(env, MEINVAL,
				"cannot remove reserved group '%s'", group);

	if (!(gid = vxdb_getgid(group)))
		method_return_fault(env, MENOVG);

	if (!str_isempty(name)) {
		if (!validate_name(name))
			method_return_faultf(env, MEINVAL,
					"invalid name value: %s", name);

		if (!(xid = vxdb_getxid(name)))
			method_return_fault(env, MENOVPS);

		rc = vxdb_exec(
				"DELETE FROM xid_gid_map WHERE xid = %d AND gid = %d",
				xid, gid);
	}

	else {
		rc = vxdb_exec(
				"BEGIN EXCLUSIVE TRANSACTION;"
				"DELETE FROM xid_gid_map WHERE gid = %d;"
				"DELETE FROM groups WHERE gid = %d;"
				"COMMIT TRANSACTION;",
				gid, gid);
	}

	if (rc != VXDB_OK)
		method_return_vxdb_fault(env);

	return xmlrpc_nil_new(env);
}
Example #26
0
    static int			/* -1 | index into "oparr[]" */
epd_find_op_inx( EpdJob* ejp, const char* op )
{
    register int	i;

    for( i=0 ; i<ejp->opfull ; ++i ) {
	if( str_equal(ejp->oparr[i].op, op) ) return i;
    }
    return -1;			/* not found */
}
Example #27
0
static int smb_handle_negotiate_request(unsigned char* c,size_t len,struct smb_response* sr) {
  size_t i,j,k;
  int ack;
  const char nr[2*17+100*2]=
    "\x11"	// word count 17
    "xx"	// dialect index; ofs 1
    "\x02"	// security mode, for NT: plaintext passwords XOR unicode
#if 0
    "\x02\x00"	// Max Mpx Count 2
    "\x01\x00"	// Max VCs 1
#else
    "\x10\x00"	// Max Mpx Count 16
    "\x10\x00"	// Max VCs 16
#endif
    "\x04\x41\x00\x00"	// Max Buffer Size (16644, like XP)
    "\x00\x00\x01\x00"	// Max Raw Buffer (65536, like XP)
    "\x01\x02\x03\x04"	// Session Key
    "\x5e\x40\x00\x00"	// Capabilities, the bare minimum
    "xxxxxxxx"	// system time; ofs 24
    "xx"	// server time zone; ofs 32
    "\x00"	// key len
    "xx"	// byte count; ofs 35
    ;		// workgroup name; ofs 37
  char* x;

  if (len<3) return -1;
  j=uint16_read((char*)c+1);
  if (len<3+j) return -1;
  ack=-1;
  for (k=0,i=3; i<3+j; ++k) {
    if (c[i]!=2) return -1;
    if (str_equal((char*)c+i+1,"NT LM 0.12")) { ack=k; break; }
    i+=2+str_len((char*)c+i+1);
  }
  if (ack==-1) return -1;	// wrong dialect

  if (!(x=add_smb_response2(sr,nr,38+wglen16,0x72))) return -1;
  uint16_pack(x+1,ack);

  {
    struct timeval t;
    unsigned long long ntdate;
    gettimeofday(&t,&tz);
    ntdate=10000000ll * ( t.tv_sec + 11644473600ll ) + t.tv_usec * 10ll;
    uint32_pack(x+24,ntdate&0xffffffff);
    uint32_pack(x+24+4,ntdate>>32);
    uint16_pack(x+32,tz.tz_minuteswest);
  }

  uint16_pack(x+35,wglen16);
  byte_copy(x+37,wglen16,workgroup_utf16);

  return 0;
}
Example #28
0
int main(int argc, char **argv, char **envp) {

    if (!argv[0]) die_usage();
    if (!argv[1]) die_usage();
    if (str_equal(argv[1], "-h")) die_usage();

    if (extremesandbox_droproot() == -1) die_fatal("unable to drop root privileges", 0);

    pathexec_run(argv[1], argv + 1, envp);
    die_fatal("unable to run", argv[1]);
    return 111;
}
Example #29
0
static void
ae_cb (const char *name, aa_enable_flags type)
{
    int i;

    for (i = 0; i < names.len; i += strlen (names.s + i) + 1)
        if (str_equal (name, names.s + i))
            return;

    genalloc_append (int, &ga_next, &names.len);
    stralloc_catb (&names, name, strlen (name) + 1);
}
Example #30
0
File: str.c Project: Einheri/wl500g
int
str_contains_line(const struct mystr* p_str, const struct mystr* p_line_str)
{
  static struct mystr s_curr_line_str;
  unsigned int pos = 0;
  while (str_getline(p_str, &s_curr_line_str, &pos))
  {
    if (str_equal(&s_curr_line_str, p_line_str))
    {
      return 1;
    }
  }
  return 0;
}