示例#1
0
/* fopn [-m mode] [-t num] fname */
HRESULT CALLBACK fopn(PDEBUG_CLIENT4 Client, PCSTR args)
{
    HRESULT ret=E_FAIL;
    set_client(Client);

    flag_desc_t flags_dsc[] = {{'m', TRUE}, {'t', TRUE}, {0}};
    size_t rd_sz = read_flags(args, flags_dsc);
    args += rd_sz;

    char mode[16] = "r+";
    if (flags_dsc[0].is_pres) {
        memcpy(mode,
            flags_dsc[0].pc_arg, min(flags_dsc[0].arg_len, sizeof(mode)));
        mode[sizeof(mode)-1]=0;
    }

    char pr_name[MAX_PR_NAME];
    if (flags_dsc[1].is_pres) {
        if (!get_pr_name(&flags_dsc[1], pr_name)) goto finish;
    } else {
        /* set default pseudo-reg */
        strcpy(pr_name, "$t0");
    }

    if (file_open(args, mode, pr_name)) ret=S_OK;

finish:
    return ret;
}
示例#2
0
文件: argv.c 项目: Julow/ft_ls
t_args			*get_args(int argc, char **argv)
{
	t_args			*args;

	args = MAL1(t_args);
	args->args = MAL1(char*);
	args->args[0] = NULL;
	args->args_count = 0;
	args->flags = 0;
	while (--argc > 0 && argv++)
		if (ft_strequ(*argv, "--"))
			break ;
		else if (**argv == '-' && *(*argv + 1) != '\0')
			read_flags(args, *argv, *argv);
		else
		{
			add_arg(args, *argv);
			break ;
		}
	while (--argc > 0 && argv++)
		add_arg(args, *argv);
	if (args->args_count == 0)
		add_arg(args, ".");
	return (args);
}
static int check_report_filter(uint8_t procedure, le_advertising_info *info)
{
    uint8_t flags;

    /* If no discovery procedure is set, all reports are treat as valid */
    if (procedure == 0)
        return 1;

    /* Read flags AD type value from the advertising report if it exists */
    if (read_flags(&flags, info->data, info->length))
        return 0;

    switch (procedure) {
    case 'l': /* Limited Discovery Procedure */
        if (flags & FLAGS_LIMITED_MODE_BIT)
            return 1;
        break;
    case 'g': /* General Discovery Procedure */
        if (flags & (FLAGS_LIMITED_MODE_BIT | FLAGS_GENERAL_MODE_BIT))
            return 1;
        break;
    default:
        fprintf(stderr, "Unknown discovery procedure\n");
    }

    return 0;
}
示例#4
0
tbuilder_gridcell::tbuilder_gridcell(const config& cfg) :
	tbuilder_widget(cfg),
	flags(read_flags(cfg)),
	border_size(lexical_cast_default<unsigned>((cfg)["border_size"])),
	widget(create_builder_widget(cfg))
{
}
示例#5
0
文件: main.c 项目: kunulee/f-stm
void pmu_stop(void){
  unsigned int cycle_count, overflow, counter0, counter1, counter2, counter3, counter4, counter5;

      disable_ccnt();            // Stop CCNT
      disable_pmn(0);            // Stop counter 0
      disable_pmn(1);            // Stop counter 1
      disable_pmn(2);            // Stop counter 2
      disable_pmn(3);            // Stop counter 3
      disable_pmn(4);            // Stop counter 4
      disable_pmn(5);            // Stop counter 5

      counter0 = read_pmn(0); // Read counter 0
      counter1 = read_pmn(1); // Read counter 1
      counter2 = read_pmn(2); // Read counter 2
      counter3 = read_pmn(3); // Read counter 3
      counter4 = read_pmn(4); // Read counter 4
      counter5 = read_pmn(5); // Read counter 5
      cycle_count = read_ccnt(); // Read CCNT
      overflow=read_flags();        //Check for overflow flag
      printf("%d\t%d %d %d %d %d %d\n", cycle_count/667, counter0/667, counter1/667, counter2/667 ,counter3/667,counter4/667,counter5/667);
 
 	if(overflow)
        printf("Warning Overflow Occured\n");
																																		                                                             // printf("Overflow: %d, Cycle Count: %d \n\n", overflow,cycle_count);
};
示例#6
0
static void
__read_ttyent ()
{
	char *c, dump[ENTRY_SIZE];
	/* one label for gotos, used when discarding bad lines */
restart:
	*tabbuf = '#';
	c = tabbuf;
	while (*c == '#') {	/* skip comments */
		if (!fgets (tabbuf, ENTRY_SIZE, tabfile)) {	/* EOF */
			__free_bufs ();
			return;
		}
		c = tabbuf;
		while (isspace (*c) && *c) ++c;
		if (!*c) goto restart;
	}

	/* discard the end of lines longer than ENTRY_SIZE */
	if (tabbuf [strlen (tabbuf) - 1] != '\n')
		do {
			if (!fgets (dump, ENTRY_SIZE, tabfile)) break;
		} while (dump [strlen (dump) - 1] != '\n');

	entry->ty_name = c;	/* get name */
	while (*c && !isspace (*c)) ++c;
	if (!*c) goto restart;
	*(c++) = '\0';
	while (*c && isspace (*c)) ++c;
	if (!*c) goto restart;
	if (*c == '"') {	/* getty is quoted */
		entry->ty_getty = ++c;
		while (*c && *c != '"') ++c;
		if (!*c) goto restart;
		*(c++) = '\0';
	} else {	/* getty in not quoted */
		entry->ty_getty = c;
		while (*c && !isspace (*c)) ++c;
		if (!*c) goto restart;
		*(c++) = '\0';
	}
	while (*c && isspace (*c)) ++c;
	if (!*c) goto restart;
	entry->ty_type = c;	/* term type */
	while (*c && !isspace (*c)) ++c;
	if (*c) *(c++) = '\0';

	/* defaults for optional parts */
	entry->ty_status = 0;
	entry->ty_window = (char *)NULL;
	entry->ty_comment = (char *)NULL;

	/* check for remaining flags, don't truly enforce format */
	read_flags (c, entry);
}
示例#7
0
// set_gen_notify(string)
int ModApiMapgen::l_set_gen_notify(lua_State *L)
{
	u32 flags = 0, flagmask = 0;

	if (read_flags(L, 1, flagdesc_gennotify, &flags, &flagmask)) {
		EmergeManager *emerge = getServer(L)->getEmergeManager();
		emerge->gennotify = flags;
	}

	return 0;
}
示例#8
0
bool getflagsfield(lua_State *L, int table, const char *fieldname,
	FlagDesc *flagdesc, u32 *flags, u32 *flagmask)
{
	lua_getfield(L, table, fieldname);

	bool success = read_flags(L, -1, flagdesc, flags, flagmask);

	lua_pop(L, 1);

	return success;
}
static int read_flags(enum rcc_flag flag) {
        if (flags || STATUS_FLAG == flag)
                return flags & 1 << STATUS_FLAG;

        flags |= 1 << STATUS_FLAG;
        flags |= RCC_GetFlagStatus(RCC_FLAG_IWDGRST) << WATCHDOG_FLAG;
        flags |= RCC_GetFlagStatus(RCC_FLAG_PORRST) << POWERON_FLAG;

        RCC_ClearFlag();
        return read_flags(flag);
}
示例#10
0
static int _read_flag_config(struct config_node *n, uint64_t *status, int type)
{
    struct config_node *cn;
    *status = 0;

    if (!(cn = find_config_node(n, "status"))) {
        log_error("Could not find status flags.");
        return 0;
    }

    if (!(read_flags(status, type | STATUS_FLAG, cn->v))) {
        log_error("Could not read status flags.");
        return 0;
    }

    if ((cn = find_config_node(n, "flags"))) {
        if (!(read_flags(status, type, cn->v))) {
            log_error("Could not read flags.");
            return 0;
        }
    }

    return 1;
}
示例#11
0
void printk (const char *fmt, ...)
{
	unsigned long eflags;
	static char buffer[1024];
	va_list args;

	eflags = read_flags ();
	cli ();

	args = va_start (args, fmt);
	vsprintf (buffer, fmt, args);
	va_end (args);

	tty_write (0, buffer, strlen (buffer));

	write_flags (eflags);
}
示例#12
0
void init_sched (void)
{
	unsigned long eflags;

	eflags = read_flags ();

	if ((idle_task = kmalloc (sizeof (Task), 0)) == NULL) {
		printk ("init_sched: not enough memory\n");
		write_flags (eflags);
		return;
	}

	idle_task->pid		= next_pid++;
	idle_task->next		= idle_task;
#if 0
	idle_task->kernel_stack	= kstack;
#endif
	idle_task->tss.link	= 0;
	idle_task->tss.esp0	= (unsigned long) &kstack[PAGE_SIZE >> 2];
	idle_task->tss.ss0	= KERNEL_DS;
	idle_task->tss.cr3	= (unsigned long) &pg_dir[0];
	idle_task->tss.es	= KERNEL_DS;
	idle_task->tss.cs	= KERNEL_CS;
	idle_task->tss.ss	= KERNEL_DS;
	idle_task->tss.ds	= KERNEL_DS;
	idle_task->tss.fs	= KERNEL_DS;
	idle_task->tss.gs	= KERNEL_DS;

	current = idle_task;
	set_tss (idle_task);

	write_tr (idle_task->tss.tr);

	cli ();
	register_interrupt (0x08, do_timer);
	register_interrupt (0x80, do_fork);

	outb(0x36,0x43);
	outb(0xa9,0x40);
	outb(0x04,0x40);

	write_flags (eflags);
}
示例#13
0
文件: melody.c 项目: rdebath/sgt
static void read_note (MelodyLine *ml) {
    MelodyEvent *me = mmalloc (sizeof(MelodyEvent));
    NoteStem *ns = &me->u.n;	       /* for ease of access */
    int i;

    me->type = EV_NOTE;
    me->line = line_no;
    me->col = col_no;
    ns->hhead = ns->htail = NULL;
    ns->fhead = ns->ftail = NULL;

    if (!(i=read_duration (ns)))
	return;
    if (i!=2 && !read_pitches (ns))
	return;
    if (!read_flags (ns))
	return;

    add_event (ml, me);
}
示例#14
0
// set_gen_notify(flags, {deco_id_table})
int ModApiMapgen::l_set_gen_notify(lua_State *L)
{
	u32 flags = 0, flagmask = 0;
	EmergeManager *emerge = getServer(L)->getEmergeManager();

	if (read_flags(L, 1, flagdesc_gennotify, &flags, &flagmask)) {
		emerge->gen_notify_on &= ~flagmask;
		emerge->gen_notify_on |= flags;
	}

	if (lua_istable(L, 2)) {
		lua_pushnil(L);
		while (lua_next(L, 2)) {
			if (lua_isnumber(L, -1))
				emerge->gen_notify_on_deco_ids.insert(lua_tonumber(L, -1));
			lua_pop(L, 1);
		}
	}

	return 0;
}
示例#15
0
/* sxtr input/pattern/replacement */
HRESULT CALLBACK sxtr(PDEBUG_CLIENT4 Client, PCSTR args)
{
    HRESULT ret=E_FAIL;
    set_client(Client);

    flag_desc_t flags_dsc[] = {{'t', TRUE}, {0}};
    size_t rd_sz = read_flags(args, flags_dsc);
    args += rd_sz;

    char pr_name[MAX_PR_NAME];
    if (flags_dsc[0].is_pres) {
        if (!get_pr_name(&flags_dsc[0], pr_name)) goto finish;
        str_extr(args, pr_name);
    } else {
        str_extr(args, NULL);
    }

    ret=S_OK;
finish:
    return ret;
}
int watchdog_device_is_watchdog_reset()
{
        return read_flags(WATCHDOG_FLAG);
}
示例#17
0
tbuilder_grid::tbuilder_grid(const config& cfg) :
	tbuilder_widget(cfg),
	id(cfg["id"]),
	rows(0),
	cols(0),
	row_grow_factor(),
	col_grow_factor(),
	flags(),
	border_size(),
	widgets()
{
/*WIKI
 * @page = GUIToolkitWML
 * @order = 2_cell
 *
 * = Cell =
 *
 * Every grid cell has some cell configuration values and one widget in the grid
 * cell. Here we describe the what is available more information about the usage
 * can be found here [[GUILayout]].
 *
 * == Row values ==
 *
 * For every row the following variables are available:
 *
 * @start_table = config
 *     grow_factor (unsigned = 0)      The grow factor for a row.
 * @end_table
 *
 * == Cell values ==
 *
 * For every column the following variables are available:
 * @start_table = config
 *     grow_factor (unsigned = 0)      The grow factor for a column, this value
 *                                     is only read for the first row.
 *
 *     border_size (unsigned = 0)      The border size for this grid cell.
 *     border (border = "")            Where to place the border in this grid
 *                                     cell.
 *
 *     vertical_alignment (v_align = "")
 *                                     The vertical alignment of the widget in
 *                                     the grid cell. (This value is ignored if
 *                                     vertical_grow is true.)
 *     horizontal_alignment (h_align = "")
 *                                     The horizontal alignment of the widget in
 *                                     the grid cell.(This value is ignored if
 *                                     horizontal_grow is true.)
 *
 *     vertical_grow (bool = false)    Does the widget grow in vertical
 *                                     direction when the grid cell grows in the
 *                                     vertical directon. This is used if the
 *                                     grid cell is wider as the best width for
 *                                     the widget.
 *     horizontal_grow (bool = false)  Does the widget grow in horizontal
 *                                     direction when the grid cell grows in the
 *                                     horizontal directon. This is used if the
 *                                     grid cell is higher as the best width for
 *                                     the widget.
 * @end_table
 *
 */
	log_scope2(gui_parse, "Window builder: parsing a grid");

	const config::child_list& row_cfgs = cfg.get_children("row");
	for(std::vector<config*>::const_iterator row_itor = row_cfgs.begin();
			row_itor != row_cfgs.end(); ++row_itor) {

		unsigned col = 0;

		row_grow_factor.push_back(lexical_cast_default<unsigned>((**row_itor)["grow_factor"]));

		const config::child_list& col_cfgs = (**row_itor).get_children("column");
		for(std::vector<config*>::const_iterator col_itor = col_cfgs.begin();
				col_itor != col_cfgs.end(); ++col_itor) {

			flags.push_back(read_flags(**col_itor));
			border_size.push_back(lexical_cast_default<unsigned>((**col_itor)["border_size"]));
			if(rows == 0) {
				col_grow_factor.push_back(lexical_cast_default<unsigned>((**col_itor)["grow_factor"]));
			}

			widgets.push_back(create_builder_widget(**col_itor));

			++col;
		}

		++rows;
		if(row_itor == row_cfgs.begin()) {
			cols = col;
		} else {
			VALIDATE(col, _("A row must have a column."));
			VALIDATE(col == cols, _("Number of columns differ."));
		}

	}

	DBG_G_P << "Window builder: grid has "
		<< rows << " rows and " << cols << " columns.\n";
}
int watchdog_device_is_poweron_reset()
{
        return read_flags(POWERON_FLAG);
}
示例#19
0
文件: key.c 项目: ennorehling/eressea
static int a_readkeys(variant *var, void *owner, gamedata *data) {
    int n, ksn, *keys;

    READ_INT(data->store, &n);
    assert(n < 4096 && n >= 0);
    if (n == 0) {
        return AT_READ_FAIL;
    }
    ksn = keys_size(n);
    keys = malloc((ksn * 2 + 1) * sizeof(int));
    if (data->version >= FIXATKEYS_VERSION) {
        n = read_keyval(data, keys + 1, n);
    }
    else if (data->version >= KEYVAL_VERSION) {
        int m = read_keyval_orig(data, keys + 1, n);
        if (n != m) {
            int ksm = keys_size(m);
            if (ksm != ksn) {
                int *nkeys = (int *)realloc(keys, (ksm * 2 + 1) * sizeof(int));
                if (nkeys != NULL) {
                    keys = nkeys;
                }
                else {
                    log_error("a_readkeys allocation failed: %s", strerror(errno));
                    return AT_READ_FAIL;
                }
            }
            n = m;
        }
    }
    else {
        n = read_flags(data, keys + 1, n);
    }
    keys[0] = n;
    if (data->version < SORTKEYS_VERSION) {
        int i, e = 1;
        for (i = 1; i != n; ++i) {
            int k = keys[i * 2 + 1];
            int v = keys[i * 2 + 2];
            int l = keys_lower_bound(keys, k, 0, e);
            if (l != e) {
                int km = keys[l * 2 + 1];
                if (km == k) {
                    int vm = keys[l * 2 + 2];
                    if (v != vm) {
                        log_error("key %d has values %d and %d", k, v, vm);
                    }
                    --e;
                }
                else {
                    if (e > l) {
                        memmove(keys + 2 * l + 3, keys + 2 * l + 1, (e - l) * 2 * sizeof(int));
                    }
                    keys[2 * l + 1] = k;
                    keys[2 * l + 2] = v;
                }
            }
            ++e;
        }
        if (e != n) {
            int sz = keys_size(n);
            if (e > sz) {
                int *k;
                sz = keys_size(e);
                k = realloc(keys, sizeof(int)*(2 * sz + 1));
                if (!k) {
                    free(keys);
                    abort();
                }
                keys = k;
                keys[0] = e;
            }
        }
    }
    var->v = keys;
    return AT_READ_OK;
}