예제 #1
0
bool_t bst_add(bst_key_t k, node_t* root, int id){
	//fprintf(stderr, "bst add\n");
	// node_t* pred;
	// node_t* curr;
	node_t* new_node;
	// operation_t* pred_op;
	// operation_t* curr_op;
	operation_t* cas_op;
	// search_res_t result;
	bst_search_result_t* my_result;

	while(TRUE) {
		//root is now a global pointer to a node, not a node
		my_result = bst_find(k, /*&pred, &pred_op, &curr, &curr_op, */root, root, id);
		if (my_result->result == FOUND) {
			return FALSE;
		}
		// allocate memory 
		// new_node = new Node(k);
		new_node = (node_t*) ssalloc(sizeof(node_t));
		new_node->key = k;
		new_node->op = NULL;
		new_node->left = NULL;
		new_node->right = NULL;

		// fprintf(stderr, "new_node address: %p, 64bit aligned: %d key address %p, left node addr: %p, right node addr: %p, op addr: %p\n", new_node, ((unsigned long)new_node & 7) == 0,&(new_node->key), &(new_node->left), &(new_node->right), &(new_node->op)
	 // );

		bool_t is_left = (my_result->result == NOT_FOUND_L);
		node_t* old;
		if (is_left) {
			old = my_result->curr->left;
		} else {
			old = my_result->curr->right;
		}

		// allocate memory
		//cas_op = new child_cas_op_t(is_left, old, new_node)
		cas_op = (operation_t*) ssalloc_alloc(1, sizeof(operation_t));
		cas_op->child_cas_op.is_left = is_left;
		cas_op->child_cas_op.expected = old;
		cas_op->child_cas_op.update = new_node;

		// fprintf(stderr, "cas_op address: %p, is_left address: %p, expected addr: %p, update addr: %p\n", (unsigned long)cas_op, &(cas_op->child_cas_op.is_left), &(cas_op->child_cas_op.expected), &(cas_op->child_cas_op.update)
	 // );

		if (CAS_PTR(&(my_result->curr->op), my_result->curr_op, FLAG(cas_op, STATE_OP_CHILDCAS)) == my_result->curr_op) {
			// legit cast? YES!! verif
			bst_help_child_cas(cas_op, my_result->curr/*, root*/);
			return TRUE;
		}
	}
}
예제 #2
0
파일: ls_dirs.c 프로젝트: Julow/ft_ls
static void		check_dirent(struct dirent *ent, t_array *dirs, t_file *file,
	t_args *args)
{
	t_file			*tmp;

	if (args->args_count < 2)
		args->args_count = 2;
	if (FLAG(FLAG_RR) && ent->d_type == DT_DIR && !ft_strequ(file->real, ".") &&
		!ft_strequ(file->real, "..") && (!FLAG(FLAG_L) ||
			(file->stats->st_mode & S_IFMT) != S_IFLNK))
	{
		tmp = MAL1(t_file);
		tmp->name = ft_stringdup(file->name);
		tmp->path = ft_stringdup(file->path);
		tmp->dir = NULL;
		tmp->real = ent->d_name;
		tmp->err = 0;
		tmp->stats = MAL1(struct stat);
		ft_memmove(tmp->stats, file->stats, sizeof(struct stat));
		ft_arrayadd(dirs, tmp);
	}
예제 #3
0
파일: refer3.c 프로젝트: cmxcn/CSAPP_labs
/*
 * Initialize: return -1 on error, 0 on success.
 */
int mm_init(void) {
    /* Create the initial empty heap */
    if ((heap_listp = mem_sbrk(WSIZE + SEG_LEVLL * DSIZE)) == (void *)-1) 
        return -1;
    flist_tbl = heap_listp;
    init_free_list();
    int table_off = 2 * SEG_LEVLL * WSIZE;
    PUT(heap_listp + table_off, PACK(4, 1));     /* Prologue header */ 
    PUT(heap_listp + table_off + 4, PACK(0, 1));     /* Epilogue header */

    FLAG(heap_listp + table_off);
    FLAG(heap_listp + table_off + 4);                /* set the alloc FLAG in next block */
    heap_listp += table_off + 4;

    /* Extend the empty heap with a free block of CHUNKSIZE bytes */
    char *freeb = extend_heap(CHUNKSIZE/WSIZE);
    if (freeb == NULL) {    
        return -1;
    }
    return 0;
}
예제 #4
0
파일: test.c 프로젝트: kext/liboptions
int main(int argc, char **argv)
{
  int flag_all = 0;
  int flag_debug = 0;
  char *input_file = "";
  char *log_level = "";
  int i;

  program = argv[0];
  parse_options(&argc, &argv, OPTIONS(
    FLAG('a', "all", flag_all, 1),
    FLAG('d', "debug", flag_debug, 1),
    PARAMETER('i', "input-file", input_file),
    PARAMETER_DEFAULT('l', "log-level", log_level, "error"),
    FLAG_CALLBACK('h', "help", help),
    FLAG_CALLBACK('v', 0, verbose)
  ));

  for (i = 0; i <= argc; ++i) {
    if (argv[i])
      printf("argv[%d] = \"%s\";\n", i, argv[i]);
    else
      printf("argv[%d] = 0;\n", i);
  }

  printf(
    "      All: %s\n"
    "    Debug: %s\n"
    "Verbosity: %d\n"
    "    Input: '%s'\n"
    "Log Level: '%s'\n",
    ON(flag_all),
    ON(flag_debug),
    verbosity,
    input_file,
    log_level
  );

  return 0;
}
예제 #5
0
bool_t bst_help_relocate(operation_t* op, node_t* pred, operation_t* pred_op, node_t* curr/*, node_t* root*/){
	//fprintf(stderr, "bst help relocate\n");
	int seen_state = op->relocate_op.state;
	if (seen_state == STATE_OP_ONGOING) {
		//VCAS in original implementation
		operation_t* seen_op = CAS_PTR(&(op->relocate_op.dest->op), op->relocate_op.dest_op, FLAG(op, STATE_OP_RELOCATE));
		if ((seen_op == op->relocate_op.dest_op) || (seen_op == (operation_t *)FLAG(op, STATE_OP_RELOCATE))){
			CAS_PTR(&(op->relocate_op.state), STATE_OP_ONGOING, STATE_OP_SUCCESSFUL);
			seen_state = STATE_OP_SUCCESSFUL;
		} else {
			// VCAS
			seen_state = CAS_PTR(&(op->relocate_op.state), STATE_OP_ONGOING, STATE_OP_FAILED);
		}
	}

	if (seen_state == STATE_OP_SUCCESSFUL) {
		// TODO not clear in the paper code
		CAS_PTR(&(op->relocate_op.dest->key), op->relocate_op.remove_key, op->relocate_op.replace_key);
		CAS_PTR(&(op->relocate_op.dest->op), FLAG(op, STATE_OP_RELOCATE), FLAG(op, STATE_OP_NONE));
	}

	bool_t result = (seen_state == STATE_OP_SUCCESSFUL);
	if (op->relocate_op.dest == curr) {
		return result;
	}

	CAS_PTR(&(curr->op), FLAG(op, STATE_OP_RELOCATE), FLAG(op, result ? STATE_OP_MARK : STATE_OP_NONE));
	if (result) {
		if (op->relocate_op.dest == pred) {
			pred_op = (operation_t *)FLAG(op, STATE_OP_NONE);
		}
		bst_help_marked(pred, pred_op, curr/*, root*/);
	}
	return result;
}
예제 #6
0
파일: memory.c 프로젝트: Sciumo/minix
static char *cr4_str(u32_t e)
{
	static char str[80];
	strcpy(str, "");
	FLAG(I386_CR4_VME);
	FLAG(I386_CR4_PVI);
	FLAG(I386_CR4_TSD);
	FLAG(I386_CR4_DE);
	FLAG(I386_CR4_PSE);
	FLAG(I386_CR4_PAE);
	FLAG(I386_CR4_MCE);
	FLAG(I386_CR4_PGE);
	if(e) { strcat(str, " (++)"); }
	return str;
}
예제 #7
0
/* Converts a point P(px, py, pz) from Jacobian projective coordinates to
 * affine coordinates R(rx, ry).  P and R can share x and y coordinates.
 * Assumes input is already field-encoded using field_enc, and returns
 * output that is still field-encoded. */
mp_err
ec_GFp_pt_jac2aff(const mp_int *px, const mp_int *py, const mp_int *pz,
                                  mp_int *rx, mp_int *ry, const ECGroup *group)
{
        mp_err res = MP_OKAY;
        mp_int z1, z2, z3;

        MP_DIGITS(&z1) = 0;
        MP_DIGITS(&z2) = 0;
        MP_DIGITS(&z3) = 0;
        MP_CHECKOK(mp_init(&z1, FLAG(px)));
        MP_CHECKOK(mp_init(&z2, FLAG(px)));
        MP_CHECKOK(mp_init(&z3, FLAG(px)));

        /* if point at infinity, then set point at infinity and exit */
        if (ec_GFp_pt_is_inf_jac(px, py, pz) == MP_YES) {
                MP_CHECKOK(ec_GFp_pt_set_inf_aff(rx, ry));
                goto CLEANUP;
        }

        /* transform (px, py, pz) into (px / pz^2, py / pz^3) */
        if (mp_cmp_d(pz, 1) == 0) {
                MP_CHECKOK(mp_copy(px, rx));
                MP_CHECKOK(mp_copy(py, ry));
        } else {
                MP_CHECKOK(group->meth->field_div(NULL, pz, &z1, group->meth));
                MP_CHECKOK(group->meth->field_sqr(&z1, &z2, group->meth));
                MP_CHECKOK(group->meth->field_mul(&z1, &z2, &z3, group->meth));
                MP_CHECKOK(group->meth->field_mul(px, &z2, rx, group->meth));
                MP_CHECKOK(group->meth->field_mul(py, &z3, ry, group->meth));
        }

  CLEANUP:
        mp_clear(&z1);
        mp_clear(&z2);
        mp_clear(&z3);
        return res;
}
예제 #8
0
파일: scfglib2.c 프로젝트: ftnapps/pkg-sbbs
long aftol(char *str)
{
	char	ch;
	size_t	c=0;
	ulong	l=0UL;

	while(str[c]) {
		ch=toupper(str[c]);
		if(ch>='A' && ch<='Z')
			l|=FLAG(ch);
		c++; 
	}
	return(l);
}
예제 #9
0
파일: qchar.cpp 프로젝트: phen89/rtqt
/*!
    Returns true if the character is a letter (Letter_* categories);
    otherwise returns false.
*/
bool QChar::isLetter() const
{
    const int test = FLAG(Letter_Uppercase) |
                     FLAG(Letter_Lowercase) |
                     FLAG(Letter_Titlecase) |
                     FLAG(Letter_Modifier) |
                     FLAG(Letter_Other);
    return FLAG(qGetProp(ucs)->category) & test;
}
예제 #10
0
/* Elliptic curve scalar-point multiplication. Computes R(x, y) = k * P(x,
 * y).  If x, y = NULL, then P is assumed to be the generator (base point)
 * of the group of points on the elliptic curve. Input and output values
 * are assumed to be NOT field-encoded. */
mp_err
ECPoint_mul(const ECGroup *group, const mp_int *k, const mp_int *px,
                        const mp_int *py, mp_int *rx, mp_int *ry)
{
        mp_err res = MP_OKAY;
        mp_int kt;

        ARGCHK((k != NULL) && (group != NULL), MP_BADARG);
        MP_DIGITS(&kt) = 0;

        /* want scalar to be less than or equal to group order */
        if (mp_cmp(k, &group->order) > 0) {
                MP_CHECKOK(mp_init(&kt, FLAG(k)));
                MP_CHECKOK(mp_mod(k, &group->order, &kt));
        } else {
                MP_SIGN(&kt) = MP_ZPOS;
                MP_USED(&kt) = MP_USED(k);
                MP_ALLOC(&kt) = MP_ALLOC(k);
                MP_DIGITS(&kt) = MP_DIGITS(k);
        }

        if ((px == NULL) || (py == NULL)) {
                if (group->base_point_mul) {
                        MP_CHECKOK(group->base_point_mul(&kt, rx, ry, group));
                } else {
                        MP_CHECKOK(group->
                                           point_mul(&kt, &group->genx, &group->geny, rx, ry,
                                                                 group));
                }
        } else {
                if (group->meth->field_enc) {
                        MP_CHECKOK(group->meth->field_enc(px, rx, group->meth));
                        MP_CHECKOK(group->meth->field_enc(py, ry, group->meth));
                        MP_CHECKOK(group->point_mul(&kt, rx, ry, rx, ry, group));
                } else {
                        MP_CHECKOK(group->point_mul(&kt, px, py, rx, ry, group));
                }
        }
        if (group->meth->field_dec) {
                MP_CHECKOK(group->meth->field_dec(rx, rx, group->meth));
                MP_CHECKOK(group->meth->field_dec(ry, ry, group->meth));
        }

  CLEANUP:
        if (MP_DIGITS(&kt) != MP_DIGITS(k)) {
                mp_clear(&kt);
        }
        return res;
}
예제 #11
0
sval_t bst_remove(skey_t key, node_t* node_r) {
    bool_t injecting = TRUE; 
    node_t* leaf;
    sval_t val = 0;
    while (1) {
      UPDATE_TRY();

        bst_seek(key, node_r);
        val = seek_record->leaf->value;
        node_t* parent = seek_record->parent;

        node_t** child_addr;
        if (key < parent->key) {
            child_addr = (node_t**) &(parent->left);
        } else {
            child_addr = (node_t**) &(parent->right);
        }

        if (injecting == TRUE) {
            leaf = seek_record->leaf;
            if (leaf->key != key) {
                return 0;
            }
            node_t* lf = ADDRESS(leaf);
            node_t* result = CAS_PTR(child_addr, lf, FLAG(lf));
            if (result == ADDRESS(leaf)) {
                injecting = FALSE;
                bool_t done = bst_cleanup(key);
                if (done == TRUE) {
                    return val;
                }
            } else {
                node_t* chld = *child_addr;
                if ( (ADDRESS(chld) == leaf) && (GETFLAG(chld) || GETTAG(chld)) ) {
                    bst_cleanup(key);
                }
            }
        } else {
            if (seek_record->leaf != leaf) {
                return val; 
            } else {
                bool_t done = bst_cleanup(key);
                if (done == TRUE) {
                    return val;
                }
            }
        }
    }
}
예제 #12
0
파일: madwifi.c 프로젝트: ajdiaz/collectd
static int madwifi_real_init(void) {
  size_t max = STATIC_ARRAY_SIZE(specs);

  for (size_t i = 0; i < STATIC_ARRAY_SIZE(bounds); i++)
    bounds[i] = 0;

  watchlist_set(watch_items, 0);
  watchlist_set(misc_items, 0);

  for (size_t i = 0; i < max; i++) {
    bounds[specs[i].flags & SRC_MASK] = i;

    if (specs[i].flags & LOG)
      watch_items[i / 32] |= FLAG(i);

    if (specs[i].flags & SU)
      misc_items[i / 32] |= FLAG(i);
  }

  for (size_t i = 0; i < STATIC_ARRAY_SIZE(bounds); i++)
    bounds[i]++;

  return (0);
}
		// Process a blam scenario for the current operating mode (editing or cache building).
		// Returns the blam scenario's handle or datum_index::null
		Yelo::datum_index YeloPrepareDefinitions(cstring scenario_name, const bool for_build_cache)
		{
			// If we're not building a cache file, just load the scenario into memory without any of its references
			datum_index scenario_index = tag_load<TagGroups::scenario>(scenario_name, for_build_cache ? 
				FLAG(Flags::_tag_load_verify_exist_first_bit) : 
				FLAG(Flags::_tag_load_non_resolving_references_bit));

			if(!scenario_index.IsNull())
			{
				TagGroups::scenario* scenario = tag_get<TagGroups::scenario>(scenario_index);

				datum_index yelo = YeloPrepareDefinitionsYeloScenario(
					scenario->GetYeloReferenceHack(), for_build_cache);

				// if we're not building a cache, then this is sapien and we want it to load 
				// the scenario and all of it's dependencies after we return the code flow 
				// back to it
				if(!for_build_cache) tag_unload(scenario_index);

				return yelo;
			}

			return datum_index::null;
		}
예제 #14
0
static void
format_ai_flags (FILE *out, struct addrinfo *ai)
{
  if (ai == NULL)
    return;

  if (ai->ai_flags != 0)
    {
      fprintf (out, "flags:");
      int flags_printed = 0;
#define FLAG(flag) format_ai_flags_1 (out, ai, flag, #flag, &flags_printed)
      FLAG (AI_PASSIVE);
      FLAG (AI_CANONNAME);
      FLAG (AI_NUMERICHOST);
      FLAG (AI_V4MAPPED);
      FLAG (AI_ALL);
      FLAG (AI_ADDRCONFIG);
      FLAG (AI_IDN);
      FLAG (AI_CANONIDN);
      FLAG (AI_NUMERICSERV);
#undef FLAG
      int remaining = ai->ai_flags & ~flags_printed;
      if (remaining != 0)
        fprintf (out, " %08x", remaining);
      fprintf (out, "\n");
    }

  /* Report flag mismatches within the list.  */
  int flags = ai->ai_flags;
  int index = 1;
  ai = ai->ai_next;
  while (ai != NULL)
    {
      if (ai->ai_flags != flags)
        fprintf (out, "error: flags at %d: 0x%x expected, 0x%x actual\n",
                 index, flags, ai->ai_flags);
      ai = ai->ai_next;
      ++index;
    }
}
예제 #15
0
파일: Cells.cpp 프로젝트: andysoftdev/ht4c
	void Cells::add( const char* row, const char* columnFamily, const char* columnQualifier, uint64_t timestamp, const void* value, uint32_t valueLength, uint8_t flag ) {
		if( valueLength > Cell::MaxSize ) {
			HT4C_THROW_ARGUMENT("cell value exceeds the limit", "valueLength");
		}

		flag = FLAG( columnFamily, columnQualifier, flag );
		Cell cell( row
						 , CF(columnFamily)
						 , columnQualifier
						 , TIMESTAMP(timestamp, flag)
						 , value
						 , valueLength
						 , flag);

		cellsBuilder->add( cell.get(), true );
	}
예제 #16
0
파일: memory.c 프로젝트: Sciumo/minix
static char *cr0_str(u32_t e)
{
	static char str[80];
	strcpy(str, "");
#define FLAG(v) do { if(e & (v)) { strcat(str, #v " "); e &= ~v; } } while(0)
	FLAG(I386_CR0_PE);
	FLAG(I386_CR0_MP);
	FLAG(I386_CR0_EM);
	FLAG(I386_CR0_TS);
	FLAG(I386_CR0_ET);
	FLAG(I386_CR0_PG);
	FLAG(I386_CR0_WP);
	if(e) { strcat(str, " (++)"); }
	return str;
}
예제 #17
0
bool_t bst_add(bst_key_t k, node_t* root){

	node_t* pred;
	node_t* curr;
	node_t* new_node;
	operation_t* pred_op;
	operation_t* curr_op;
	operation_t* cas_op;
	search_res_t result;

	while(TRUE) {

		result = bst_find(k, &pred, &pred_op, &curr, &curr_op, root, root);
		if (result == FOUND) {
			return FALSE;
		}

		new_node = (node_t*) ssalloc(sizeof(node_t));
		new_node->key = k;
		new_node->op = NULL;
		new_node->left = NULL;
		new_node->right = NULL;

		bool_t is_left = (result == NOT_FOUND_L);
		node_t* old;
		if (is_left) {
			old = curr->left;
		} else {
			old = curr->right;
		}

		cas_op = (operation_t*) ssalloc_alloc(1, sizeof(operation_t));
		cas_op->child_cas_op.is_left = is_left;
		cas_op->child_cas_op.expected = old;
		cas_op->child_cas_op.update = new_node;

#if defined(__tile__)
		MEM_BARRIER;
#endif
		if (CAS_PTR(&curr->op, curr_op, FLAG(cas_op, STATE_OP_CHILDCAS)) == curr_op) {

			bst_help_child_cas(cas_op, curr, root);
			return TRUE;
		}
	}
}
예제 #18
0
파일: zborg8.c 프로젝트: jcheatham/Zangband
/* Get food and rest at the inn */
static bool borg_build_inn(void)
{
	int i;
	list_item *l_ptr;
	bool rest = TRUE;

	/* Is it light outside */
	rest &= (bp_ptr->hour < 6 || bp_ptr->hour > 17);
	 
	/* This is a respectable place */
	rest &= !bp_ptr->status.cut && !bp_ptr->status.poisoned;

	/* Check the vampire flag */
	rest &= !FLAG(bp_ptr, TR_HURT_LITE);

	/* Loop through the equipment */
	for (i = 0; i < equip_num; i++)
	{
		l_ptr = look_up_equip_slot(i);

		/* Check the equipment for that flag */
		if (l_ptr) rest &= !KN_FLAG(l_ptr, TR_HURT_LITE);
	}

	/* If the borg wants a rest */
	if (rest && borg_gold > 25)
	{
		/* Wait for daybreak */
		borg_keypress('R');
	}

	/* Can the borg use more food? */
	if (!bp_ptr->status.full && borg_gold > 25)
	{
		/* Have dinner */
		borg_keypress('E');
	}

	/* One pass takes care of all needs */
	return (FALSE);
}
예제 #19
0
파일: parse.c 프로젝트: HackerFoo/poprc
cell_t *parse_word(seg_t w, cell_t *module, unsigned int n, cell_t *entry) {
  cell_t *c;
  cell_t *data = NULL;
  csize_t in = 0, out = 1;
  if(w.s[0] == '?' && w.n == 1) {
    c = param(T_ANY, entry);
  } else if(in = 1, out = 1, match_param_word("ap", w, &in, &out)) {
    c = func(OP_ap, ++in, ++out);
  } else if(in = 1, out = 1, match_param_word("comp", w, &in, &out)) {
    in += 2;
    c = func(OP_compose, in, ++out);
  } else if(in = 1, out = 1, match_param_word("external", w, &in, &out)) {
    c = func(OP_external, ++in, out);
  } else {
    cell_t *e = lookup_word(w);
    if(!e) e = module_lookup_compiled(w, &module);
    if(e) {
      in = e->entry.in;
      out = e->entry.out;
      if(FLAG(*e, entry, PRIMITIVE)) {
        if(e->op == OP_placeholder) {
          c = func(OP_placeholder, n + 1, 1);
          int x = trace_alloc(entry, n + 2);
          in = n;
          out = 1;
          data = var_create(T_LIST, tc_get(entry, x), 0, 0);
        } else {
          c = func(e->op, e->entry.in, e->entry.out);
        }
      } else {
        c = func(OP_exec, e->entry.in + 1, e->entry.out);
        data = e;
      }
    } else {
      return NULL;
    }
  }
  if(in) c->expr.arg[0] = (cell_t *)(intptr_t)(in - 1);
  TRAVERSE(c, out) {
    *p = dep(c);
  }
예제 #20
0
/* Construct a generic ECGroup for elliptic curves over prime fields with
 * field arithmetic implemented in Montgomery coordinates. */
ECGroup *
ECGroup_consGFp_mont(const mp_int *irr, const mp_int *curvea,
					 const mp_int *curveb, const mp_int *genx,
					 const mp_int *geny, const mp_int *order, int cofactor)
{
	mp_err res = MP_OKAY;
	ECGroup *group = NULL;

	group = ECGroup_new(FLAG(irr));
	if (group == NULL)
		return NULL;

	group->meth = GFMethod_consGFp_mont(irr);
	if (group->meth == NULL) {
		res = MP_MEM;
		goto CLEANUP;
	}
	MP_CHECKOK(group->meth->
			   field_enc(curvea, &group->curvea, group->meth));
	MP_CHECKOK(group->meth->
			   field_enc(curveb, &group->curveb, group->meth));
	MP_CHECKOK(group->meth->field_enc(genx, &group->genx, group->meth));
	MP_CHECKOK(group->meth->field_enc(geny, &group->geny, group->meth));
	MP_CHECKOK(mp_copy(order, &group->order));
	group->cofactor = cofactor;
	group->point_add = &ec_GFp_pt_add_aff;
	group->point_sub = &ec_GFp_pt_sub_aff;
	group->point_dbl = &ec_GFp_pt_dbl_aff;
	group->point_mul = &ec_GFp_pt_mul_jm_wNAF;
	group->base_point_mul = NULL;
	group->points_mul = &ec_GFp_pts_mul_jac;
	group->validate_point = &ec_GFp_validate_point;

  CLEANUP:
	if (res != MP_OKAY) {
		ECGroup_free(group);
		return NULL;
	}
	return group;
}
예제 #21
0
void bst_help_marked(node_t* pred, operation_t* pred_op, node_t* curr, node_t* root){

	node_t* new_ref;
	if (ISNULL(curr->left)) {
		if (ISNULL(curr->right)) {
			new_ref = (node_t*)SETNULL(curr);
		} else {
			new_ref = curr->right;
		}
	} else {
		new_ref = curr->left;
	}

	operation_t* cas_op = (operation_t*) ssalloc_alloc(1, sizeof(operation_t));
	cas_op->child_cas_op.is_left = (curr == pred->left);
	cas_op->child_cas_op.expected = curr;
	cas_op->child_cas_op.update = new_ref;

	if (CAS_PTR(&(pred->op), pred_op, FLAG(cas_op, STATE_OP_CHILDCAS)) == pred_op) {
		bst_help_child_cas(cas_op, pred, root);
	}
}
예제 #22
0
파일: Critter.cpp 프로젝트: BHjr132/fonline
void CCritter::DrawText(CFOFont* lpfnt)
{
  __invariant();
  if(!text_str && FLAG(flags,FCRIT_MOB)) return;
  if(visible)
  {
    int x=drect.left+((drect.right-drect.left)>>1)-100+cmn_scr_ox;
    int y=drect.top-73+cmn_scr_oy;

    RECT r={x,y,x+200,y+70};
    lpfnt->RenderText(r,text_str?text_str:name,FT_CENTERX|FT_BOTTOM,text_color);
  }

  if(GetTickCount()-SetTime>=text_delay)
  {
    if (text_str != NULL) {
      delete [] text_str;
      text_str = NULL;
    }
    text_color=COLOR_CRITNAME;
  }
}
예제 #23
0
파일: refer3.c 프로젝트: cmxcn/CSAPP_labs
/* 
 * place - Place block of asize bytes at start of free block bp 
 *         and split if remainder would be at least minimum block size
 */
static void place(void *bp, size_t asize){
    size_t csize = GET_SIZE(HDRP(bp));   

    if (IS_VALID(csize - asize)) {  
        /* we want to make sure the new free block satisfy the minimum requirement */            
        int t = (bp == heap_tailp);
        delete_node(get_level(GET_SIZE(HDRP(bp))), bp); /* remove the record in the free block list */
        SET_SIZE(HDRP(bp), asize);
        MARK_ALLOC(HDRP(bp));
        bp = NEXT_BLKP(bp);
        PUT(HDRP(bp), PACK3(csize-asize, 2, 0));
        PUT(FTRP(bp), PACK3(csize-asize, 2, 0));  
        insert_node(get_level(GET_SIZE(HDRP(bp))), bp);
        if (t) {
            heap_tailp = bp;
        }
    }else { 
        delete_node(get_level(GET_SIZE(HDRP(bp))), bp);
        MARK_ALLOC(HDRP(bp));
        FLAG(HDRP(NEXT_BLKP(bp)));
    }
}
예제 #24
0
/* Construct a generic ECGroup for elliptic curves over binary polynomial
 * fields. */
ECGroup *
ECGroup_consGF2m(const mp_int *irr, const unsigned int irr_arr[5],
				 const mp_int *curvea, const mp_int *curveb,
				 const mp_int *genx, const mp_int *geny,
				 const mp_int *order, int cofactor)
{
	mp_err res = MP_OKAY;
	ECGroup *group = NULL;

	group = ECGroup_new(FLAG(irr));
	if (group == NULL)
		return NULL;

	group->meth = GFMethod_consGF2m(irr, irr_arr);
	if (group->meth == NULL) {
		res = MP_MEM;
		goto CLEANUP;
	}
	MP_CHECKOK(mp_copy(curvea, &group->curvea));
	MP_CHECKOK(mp_copy(curveb, &group->curveb));
	MP_CHECKOK(mp_copy(genx, &group->genx));
	MP_CHECKOK(mp_copy(geny, &group->geny));
	MP_CHECKOK(mp_copy(order, &group->order));
	group->cofactor = cofactor;
	group->point_add = &ec_GF2m_pt_add_aff;
	group->point_sub = &ec_GF2m_pt_sub_aff;
	group->point_dbl = &ec_GF2m_pt_dbl_aff;
	group->point_mul = &ec_GF2m_pt_mul_mont;
	group->base_point_mul = NULL;
	group->points_mul = &ec_pts_mul_basic;
	group->validate_point = &ec_GF2m_validate_point;

  CLEANUP:
	if (res != MP_OKAY) {
		ECGroup_free(group);
		return NULL;
	}
	return group;
}
예제 #25
0
void
dump_dns(const u_char *payload, size_t paylen,
	  FILE *trace, const char *endline)
{
	u_int opcode, rcode, id;
	const char *sep;
	ns_msg msg;

	fprintf(trace, " %sdns ", endline);
	if (ns_initparse(payload, paylen, &msg) < 0) {
		fputs(strerror(errno), trace);
		return;
	}
	opcode = ns_msg_getflag(msg, ns_f_opcode);
	rcode = ns_msg_getflag(msg, ns_f_rcode);
	id = ns_msg_id(msg);
	fprintf(trace, "%s,%s,%u", p_opcode(opcode), p_rcode(rcode), id);
	sep = ",";
#define FLAG(t,f) if (ns_msg_getflag(msg, f)) { \
			fprintf(trace, "%s%s", sep, t); \
			sep = "|"; \
		  }
	FLAG("qr", ns_f_qr);
	FLAG("aa", ns_f_aa);
	FLAG("tc", ns_f_tc);
	FLAG("rd", ns_f_rd);
	FLAG("ra", ns_f_ra);
	FLAG("z", ns_f_z);
	FLAG("ad", ns_f_ad);
	FLAG("cd", ns_f_cd);
#undef FLAG
	dump_dns_sect(&msg, ns_s_qd, trace, endline);
	dump_dns_sect(&msg, ns_s_an, trace, endline);
	dump_dns_sect(&msg, ns_s_ns, trace, endline);
	dump_dns_sect(&msg, ns_s_ar, trace, endline);
}
예제 #26
0
파일: qchar.cpp 프로젝트: phen89/rtqt
/*!
    Returns true if the character is a printable character; otherwise
    returns false. This is any character not of category Cc or Cn.

    Note that this gives no indication of whether the character is
    available in a particular font.
*/
bool QChar::isPrint() const
{
    const int test = FLAG(Other_Control) |
                     FLAG(Other_NotAssigned);
    return !(FLAG(qGetProp(ucs)->category) & test);
}
예제 #27
0
/* Computes R = nP where R is (rx, ry) and P is the base point. Elliptic
 * curve points P and R can be identical. Uses mixed Modified-Jacobian
 * co-ordinates for doubling and Chudnovsky Jacobian coordinates for
 * additions. Assumes input is already field-encoded using field_enc, and
 * returns output that is still field-encoded. Uses 5-bit window NAF
 * method (algorithm 11) for scalar-point multiplication from Brown,
 * Hankerson, Lopez, Menezes. Software Implementation of the NIST Elliptic
 * Curves Over Prime Fields. */
mp_err
ec_GFp_pt_mul_jm_wNAF(const mp_int *n, const mp_int *px, const mp_int *py,
                                          mp_int *rx, mp_int *ry, const ECGroup *group)
{
        mp_err res = MP_OKAY;
        mp_int precomp[16][2], rz, tpx, tpy;
        mp_int raz4;
        mp_int scratch[MAX_SCRATCH];
        signed char *naf = NULL;
        int i, orderBitSize;

        MP_DIGITS(&rz) = 0;
        MP_DIGITS(&raz4) = 0;
        MP_DIGITS(&tpx) = 0;
        MP_DIGITS(&tpy) = 0;
        for (i = 0; i < 16; i++) {
                MP_DIGITS(&precomp[i][0]) = 0;
                MP_DIGITS(&precomp[i][1]) = 0;
        }
        for (i = 0; i < MAX_SCRATCH; i++) {
                MP_DIGITS(&scratch[i]) = 0;
        }

        ARGCHK(group != NULL, MP_BADARG);
        ARGCHK((n != NULL) && (px != NULL) && (py != NULL), MP_BADARG);

        /* initialize precomputation table */
        MP_CHECKOK(mp_init(&tpx, FLAG(n)));
        MP_CHECKOK(mp_init(&tpy, FLAG(n)));;
        MP_CHECKOK(mp_init(&rz, FLAG(n)));
        MP_CHECKOK(mp_init(&raz4, FLAG(n)));

        for (i = 0; i < 16; i++) {
                MP_CHECKOK(mp_init(&precomp[i][0], FLAG(n)));
                MP_CHECKOK(mp_init(&precomp[i][1], FLAG(n)));
        }
        for (i = 0; i < MAX_SCRATCH; i++) {
                MP_CHECKOK(mp_init(&scratch[i], FLAG(n)));
        }

        /* Set out[8] = P */
        MP_CHECKOK(mp_copy(px, &precomp[8][0]));
        MP_CHECKOK(mp_copy(py, &precomp[8][1]));

        /* Set (tpx, tpy) = 2P */
        MP_CHECKOK(group->
                           point_dbl(&precomp[8][0], &precomp[8][1], &tpx, &tpy,
                                                 group));

        /* Set 3P, 5P, ..., 15P */
        for (i = 8; i < 15; i++) {
                MP_CHECKOK(group->
                                   point_add(&precomp[i][0], &precomp[i][1], &tpx, &tpy,
                                                         &precomp[i + 1][0], &precomp[i + 1][1],
                                                         group));
        }

        /* Set -15P, -13P, ..., -P */
        for (i = 0; i < 8; i++) {
                MP_CHECKOK(mp_copy(&precomp[15 - i][0], &precomp[i][0]));
                MP_CHECKOK(group->meth->
                                   field_neg(&precomp[15 - i][1], &precomp[i][1],
                                                         group->meth));
        }

        /* R = inf */
        MP_CHECKOK(ec_GFp_pt_set_inf_jac(rx, ry, &rz));

        orderBitSize = mpl_significant_bits(&group->order);

        /* Allocate memory for NAF */
#ifdef _KERNEL
        naf = (signed char *) kmem_alloc((orderBitSize + 1), FLAG(n));
#else
        naf = (signed char *) malloc(sizeof(signed char) * (orderBitSize + 1));
        if (naf == NULL) {
                res = MP_MEM;
                goto CLEANUP;
        }
#endif

        /* Compute 5NAF */
        ec_compute_wNAF(naf, orderBitSize, n, 5);

        /* wNAF method */
        for (i = orderBitSize; i >= 0; i--) {
                /* R = 2R */
                ec_GFp_pt_dbl_jm(rx, ry, &rz, &raz4, rx, ry, &rz,
                                             &raz4, scratch, group);
                if (naf[i] != 0) {
                        ec_GFp_pt_add_jm_aff(rx, ry, &rz, &raz4,
                                                                 &precomp[(naf[i] + 15) / 2][0],
                                                                 &precomp[(naf[i] + 15) / 2][1], rx, ry,
                                                                 &rz, &raz4, scratch, group);
                }
        }

        /* convert result S to affine coordinates */
        MP_CHECKOK(ec_GFp_pt_jac2aff(rx, ry, &rz, rx, ry, group));

  CLEANUP:
        for (i = 0; i < MAX_SCRATCH; i++) {
                mp_clear(&scratch[i]);
        }
        for (i = 0; i < 16; i++) {
                mp_clear(&precomp[i][0]);
                mp_clear(&precomp[i][1]);
        }
        mp_clear(&tpx);
        mp_clear(&tpy);
        mp_clear(&rz);
        mp_clear(&raz4);
#ifdef _KERNEL
        kmem_free(naf, (orderBitSize + 1));
#else
        free(naf);
#endif
        return res;
}
예제 #28
0
/****** compute_winpos ********************************************************
PROTO	void compute_winpos(picstruct *field, picstruct *wfield,
			objstruct *obj)
PURPOSE	Compute windowed source barycenter.
INPUT	Picture structure pointer,
	Weight-map structure pointer,
	object structure.
OUTPUT  -.
NOTES   obj->posx and obj->posy are taken as initial centroid guesses.
AUTHOR  E. Bertin (IAP)
VERSION 03/05/2011
 ***/
void	compute_winpos(picstruct *field, picstruct *wfield, objstruct *obj)

  {
   float		r2,invtwosig2, raper,raper2, rintlim,rintlim2,rextlim2,
			dx,dx1,dy,dy2, sig, invngamma, pdbkg,
                        offsetx,offsety,scalex,scaley,scale2, locarea;
   double               tv, norm, pix, var, backnoise2, invgain, locpix,
			dxpos,dypos, err,err2, emx2,emy2,emxy,
			esum, temp,temp2, mx2, my2,mxy,pmx2, theta, mx,my,
			mx2ph, my2ph;
   int                  i,x,y, x2,y2, xmin,xmax,ymin,ymax, sx,sy, w,h,
                        fymin,fymax, pflag,corrflag, gainflag, errflag,
			momentflag;
   long                 pos;
   PIXTYPE              *strip,*stript, *wstrip,*wstript,
                        wthresh = 0.0;

  if (wfield)
    wthresh = wfield->weight_thresh;
  wstrip = wstript = NULL;
  w = field->width;
  h = field->stripheight;
  fymin = field->ymin;
  fymax = field->ymax;
  pflag = (prefs.detect_type==PHOTO)? 1:0;
  corrflag = (prefs.mask_type==MASK_CORRECT);
  gainflag = wfield && prefs.weightgain_flag;
  errflag = FLAG(obj2.winposerr_mx2) | FLAG(obj2.fluxerr_win);
  momentflag = FLAG(obj2.win_mx2) | FLAG(obj2.winposerr_mx2);
  var = backnoise2 = field->backsig*field->backsig;
  invgain = field->gain>0.0? 1.0/field->gain : 0.0;
  sig = obj2->hl_radius*2.0/2.35; /* From half-FWHM to sigma */
  invtwosig2 = 1.0/(2.0*sig*sig);

/* Integration radius */
  raper = WINPOS_NSIG*sig;

/* For photographic data */
  if (pflag)
    {
    invngamma = 1.0/field->ngamma;
    pdbkg = expf(obj->dbkg*invngamma);
    }
  else
    {
    invngamma = 0.0;
    pdbkg = 0.0;
    }
  raper2 = raper*raper;
/* Internal radius of the oversampled annulus (<r-sqrt(2)/2) */
  rintlim = raper - 0.75;
  rintlim2 = (rintlim>0.0)? rintlim*rintlim: 0.0;
/* External radius of the oversampled annulus (>r+sqrt(2)/2) */
  rextlim2 = (raper + 0.75)*(raper + 0.75);
  scaley = scalex = 1.0/WINPOS_OVERSAMP;
  scale2 = scalex*scaley;
  offsetx = 0.5*(scalex-1.0);
  offsety = 0.5*(scaley-1.0);
/* Use isophotal centroid as a first guess */
  mx = obj2->posx - 1.0;
  my = obj2->posy - 1.0;

  for (i=0; i<WINPOS_NITERMAX; i++)
    {
    xmin = (int)(mx-raper+0.499999);
    xmax = (int)(mx+raper+1.499999);
    ymin = (int)(my-raper+0.499999);
    ymax = (int)(my+raper+1.499999);
    mx2ph = mx*2.0 + 0.49999;
    my2ph = my*2.0 + 0.49999;

    if (xmin < 0)
      {
      xmin = 0;
      obj->flag |= OBJ_APERT_PB;
      }
    if (xmax > w)
      {
      xmax = w;
      obj->flag |= OBJ_APERT_PB;
      }
    if (ymin < fymin)
      {
      ymin = fymin;
      obj->flag |= OBJ_APERT_PB;
      }
    if (ymax > fymax)
      {
      ymax = fymax;
      obj->flag |= OBJ_APERT_PB;
      }

    tv = esum = emxy = emx2 = emy2 = mx2 = my2 = mxy = 0.0;
    dxpos = dypos = 0.0;
    strip = field->strip;
    wstrip = wstript = NULL;		/* To avoid gcc -Wall warnings */
    if (wfield)
      wstrip = wfield->strip;
    for (y=ymin; y<ymax; y++)
      {
      stript = strip + (pos = (y%h)*w + xmin);
      if (wfield)
        wstript = wstrip + pos;
      for (x=xmin; x<xmax; x++, stript++, wstript++)
        {
        dx = x - mx;
        dy = y - my;
        if ((r2=dx*dx+dy*dy)<rextlim2)
          {
          if (WINPOS_OVERSAMP>1 && r2> rintlim2)
            {
            dx += offsetx;
            dy += offsety;
            locarea = 0.0;
            for (sy=WINPOS_OVERSAMP; sy--; dy+=scaley)
              {
              dx1 = dx;
              dy2 = dy*dy;
              for (sx=WINPOS_OVERSAMP; sx--; dx1+=scalex)
                if (dx1*dx1+dy2<raper2)
                  locarea += scale2;
              }
            }
          else
            locarea = 1.0;
          locarea *= expf(-r2*invtwosig2);
/*-------- Here begin tests for pixel and/or weight overflows. Things are a */
/*-------- bit intricated to have it running as fast as possible in the most */
/*-------- common cases */
          if ((pix=*stript)<=-BIG || (wfield && (var=*wstript)>=wthresh))
            {
            if (corrflag
		&& (x2=(int)(mx2ph-x))>=0 && x2<w
		&& (y2=(int)(my2ph-y))>=fymin && y2<fymax
		&& (pix=*(strip + (pos = (y2%h)*w + x2)))>-BIG)
              {
              if (wfield)
                {
                var = *(wstrip + pos);
                if (var>=wthresh)
                  pix = var = 0.0;
                }
              }
            else
              {
              pix = 0.0;
              if (wfield)
                var = 0.0;
              }
            }
          if (pflag)
            pix = expf(pix*invngamma);
          dx = x - mx;
          dy = y - my;
          locpix = locarea*pix;
          tv += locpix;
          dxpos += locpix*dx;
          dypos += locpix*dy;
          if (errflag)
            {
            err = var;
            if (pflag)
              err *= locpix*pix*invngamma*invngamma;
            else if (invgain>0.0 && pix>0.0)
              {
              if (gainflag)
                err += pix*invgain*var/backnoise2;
              else
                err += pix*invgain;
              }
            err2 = locarea*locarea*err;
            esum += err2;
            emx2 += err2*(dx*dx+0.0833);	/* Finite pixel size */
            emy2 += err2*(dy*dy+0.0833);	/* Finite pixel size */
            emxy += err2*dx*dy;
            }
          if (momentflag)
            {
            mx2 += locpix*dx*dx;
            my2 += locpix*dy*dy;
            mxy += locpix*dx*dy;
            }
          }
        }
      }

    if (tv>0.0)
      {
      mx += (dxpos /= tv)*WINPOS_FAC;
      my += (dypos /= tv)*WINPOS_FAC;
      }
    else
      break;

/*-- Stop here if position does not change */
    if (dxpos*dxpos+dypos*dypos < WINPOS_STEPMIN*WINPOS_STEPMIN)
      break;
    }
  mx2 = mx2/tv - dxpos*dxpos;
  my2 = my2/tv - dypos*dypos;
  mxy = mxy/tv - dxpos*dypos;
  obj2->winpos_x = mx + 1.0;	/* The dreaded 1.0 FITS offset */
  obj2->winpos_y = my + 1.0; 	/* The dreaded 1.0 FITS offset */
  obj2->winpos_niter = i+1;

/* WINdowed flux */
  if (FLAG(obj2.flux_win))
    {
    obj2->flux_win = tv;
    obj2->fluxerr_win = sqrt(esum);
    obj2->snr_win = esum>(1.0/BIG)? obj2->flux_win / obj2->fluxerr_win: BIG;
    }
  temp2=mx2*my2-mxy*mxy;
  obj2->win_flag = (tv <= 0.0)*4 + (mx2 < 0.0 || my2 < 0.0)*2 + (temp2<0.0);
  if (obj2->win_flag)
    {
/*--- Negative values: revert to isophotal estimates */
    if (FLAG(obj2.winposerr_mx2))
      {
      obj2->winposerr_mx2 = obj->poserr_mx2;
      obj2->winposerr_my2 = obj->poserr_my2;
      obj2->winposerr_mxy = obj->poserr_mxy;
      if (FLAG(obj2.winposerr_a))
        {
        obj2->winposerr_a = obj2->poserr_a;
        obj2->winposerr_b = obj2->poserr_b;
        obj2->winposerr_theta = obj2->poserr_theta;
        }
      if (FLAG(obj2.winposerr_cxx))
        {
        obj2->winposerr_cxx = obj2->poserr_cxx;
        obj2->winposerr_cyy = obj2->poserr_cyy;
        obj2->winposerr_cxy = obj2->poserr_cxy;
        }
      }
    if (momentflag)
      {
      obj2->win_mx2 = obj->mx2;
      obj2->win_my2 = obj->my2;
      obj2->win_mxy = obj->mxy;
      if (FLAG(obj2.win_cxx))
        {
        obj2->win_cxx = obj->cxx;
        obj2->win_cyy = obj->cyy;
        obj2->win_cxy = obj->cxy;
        }
      if (FLAG(obj2.win_a))
        {
        obj2->win_a = obj->a;
        obj2->win_b = obj->b;
        obj2->win_polar = obj2->polar;
        obj2->win_theta = obj->theta;
        }
      }
    }
  else
    {
    if (FLAG(obj2.winposerr_mx2))
      {
      norm = WINPOS_FAC*WINPOS_FAC/(tv*tv);
      emx2 *= norm;
      emy2 *= norm;
      emxy *= norm;
/*-- Handle fully correlated profiles (which cause a singularity...) */
      esum *= 0.08333*norm;
      if (obj->singuflag && (emx2*emy2-emxy*emxy) < esum*esum)
        {
        emx2 += esum;
        emy2 += esum;
        }

      obj2->winposerr_mx2 = emx2;
      obj2->winposerr_my2 = emy2;
      obj2->winposerr_mxy = emxy;
/*---- Error ellipse parameters */
      if (FLAG(obj2.winposerr_a))
        {
         double	pmx2,pmy2,temp,theta;

        if (fabs(temp=emx2-emy2) > 0.0)
          theta = atan2(2.0 * emxy,temp) / 2.0;
        else
          theta = PI/4.0;

        temp = sqrt(0.25*temp*temp+ emxy*emxy);
        pmy2 = pmx2 = 0.5*(emx2+emy2);
        pmx2+=temp;
        pmy2-=temp;

        obj2->winposerr_a = (float)sqrt(pmx2);
        obj2->winposerr_b = (float)sqrt(pmy2);
        obj2->winposerr_theta = theta*180.0/PI;
        }

      if (FLAG(obj2.winposerr_cxx))
        {
         double	temp;

        obj2->winposerr_cxx = (float)(emy2/(temp=emx2*emy2-emxy*emxy));
        obj2->winposerr_cyy = (float)(emx2/temp);
        obj2->winposerr_cxy = (float)(-2*emxy/temp);
        }
      }

    if (momentflag)
      {
/*-- Handle fully correlated profiles (which cause a singularity...) */
      if ((temp2=mx2*my2-mxy*mxy)<0.00694)
        {
        mx2 += 0.0833333;
        my2 += 0.0833333;
        temp2 = mx2*my2-mxy*mxy;
        }
      obj2->win_mx2 = mx2;
      obj2->win_my2 = my2;
      obj2->win_mxy = mxy;

      if (FLAG(obj2.win_cxx))
        {
        obj2->win_cxx = (float)(my2/temp2);
        obj2->win_cyy = (float)(mx2/temp2);
        obj2->win_cxy = (float)(-2*mxy/temp2);
        }

      if (FLAG(obj2.win_a))
        {
        if ((fabs(temp=mx2-my2)) > 0.0)
          theta = atan2(2.0 * mxy,temp) / 2.0;
        else
          theta = PI/4.0;

        temp = sqrt(0.25*temp*temp+mxy*mxy);
        pmx2 = 0.5*(mx2+my2);
        obj2->win_a = (float)sqrt(pmx2 + temp);
        obj2->win_b = (float)sqrt(pmx2 - temp);
        if (FLAG(obj2.win_polar))
          obj2->win_polar = temp / pmx2;
        obj2->win_theta = theta*180.0/PI;
        }
      }
    }

  return;
  }
예제 #29
0
파일: lnk.c 프로젝트: Sunmonds/wine
void lnk_dump(void)
{
    const LINK_HEADER*        hdr;
    const DATABLOCK_HEADER*   bhdr;
    DWORD dwFlags;

    offset = 0;
    hdr = fetch_block();
    if (!hdr)
        return;

    printf("Header\n");
    printf("------\n\n");
    printf("Size:    %04x\n", hdr->dwSize);
    printf("GUID:    %s\n", get_guid_str(&hdr->MagicGuid));

    printf("FileAttr: %08x\n", hdr->dwFileAttr);
    printf("FileLength: %08x\n", hdr->dwFileLength);
    printf("nIcon: %d\n", hdr->nIcon);
    printf("Startup: %d\n", hdr->fStartup);
    printf("HotKey: %08x\n", hdr->wHotKey);
    printf("Unknown5: %08x\n", hdr->Unknown5);
    printf("Unknown6: %08x\n", hdr->Unknown6);

    /* dump out all the flags */
    printf("Flags:   %04x ( ", hdr->dwFlags);
    dwFlags=hdr->dwFlags;
#define FLAG(x) do \
                { \
                    if (dwFlags & SLDF_##x) \
                    { \
                        printf("%s ", #x); \
                        dwFlags&=~SLDF_##x; \
                    } \
                } while (0)
    FLAG(HAS_ID_LIST);
    FLAG(HAS_LINK_INFO);
    FLAG(HAS_NAME);
    FLAG(HAS_RELPATH);
    FLAG(HAS_WORKINGDIR);
    FLAG(HAS_ARGS);
    FLAG(HAS_ICONLOCATION);
    FLAG(UNICODE);
    FLAG(FORCE_NO_LINKINFO);
    FLAG(HAS_EXP_SZ);
    FLAG(RUN_IN_SEPARATE);
    FLAG(HAS_LOGO3ID);
    FLAG(HAS_DARWINID);
    FLAG(RUNAS_USER);
    FLAG(HAS_EXP_ICON_SZ);
    FLAG(NO_PIDL_ALIAS);
    FLAG(FORCE_UNCNAME);
    FLAG(RUN_WITH_SHIMLAYER);
    FLAG(FORCE_NO_LINKTRACK);
    FLAG(ENABLE_TARGET_METADATA);
    FLAG(DISABLE_KNOWNFOLDER_RELATIVE_TRACKING);
    FLAG(RESERVED);
#undef FLAG
    if (dwFlags)
        printf("+%04x", dwFlags);
    printf(")\n");

    printf("Length:  %04x\n", hdr->dwFileLength);
    printf("\n");

    if (hdr->dwFlags & SLDF_HAS_ID_LIST)
        dump_pidl();
    if (hdr->dwFlags & SLDF_HAS_LINK_INFO)
        dump_location();
    if (hdr->dwFlags & SLDF_HAS_NAME)
        dump_string("Description", hdr->dwFlags & SLDF_UNICODE);
    if (hdr->dwFlags & SLDF_HAS_RELPATH)
        dump_string("Relative path", hdr->dwFlags & SLDF_UNICODE);
    if (hdr->dwFlags & SLDF_HAS_WORKINGDIR)
        dump_string("Working directory", hdr->dwFlags & SLDF_UNICODE);
    if (hdr->dwFlags & SLDF_HAS_ARGS)
        dump_string("Arguments", hdr->dwFlags & SLDF_UNICODE);
    if (hdr->dwFlags & SLDF_HAS_ICONLOCATION)
        dump_string("Icon path", hdr->dwFlags & SLDF_UNICODE);

    bhdr=fetch_block();
    while (bhdr)
    {
        if (!bhdr->cbSize)
            break;
        switch (bhdr->dwSignature)
        {
        case EXP_SZ_LINK_SIG:
            dump_sz_block(bhdr, "exp.link");
            break;
        case EXP_SPECIAL_FOLDER_SIG:
            dump_special_folder_block(bhdr);
            break;
        case EXP_SZ_ICON_SIG:
            dump_sz_block(bhdr, "icon");
            break;
        case EXP_DARWIN_ID_SIG:
            dump_darwin_id(bhdr);
            break;
        default:
            dump_raw_block(bhdr);
        }
        bhdr=fetch_block();
    }
}
예제 #30
0
		static TStorage Flag(TEnumBitsClass bit_member)
		{
			return FLAG(bit_member);
		}