本文整理汇总了C++中read_groups函数的典型用法代码示例。如果您正苦于以下问题:C++ read_groups函数的具体用法?C++ read_groups怎么用?C++ read_groups使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_groups函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_item_definition
ItemDefinition read_item_definition(lua_State *L, int index,
ItemDefinition default_def)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
// Read the item definition
ItemDefinition def = default_def;
def.type = (ItemType)getenumfield(L, index, "type",
es_ItemType, ITEM_NONE);
getstringfield(L, index, "name", def.name);
getstringfield(L, index, "description", def.description);
getstringfield(L, index, "inventory_image", def.inventory_image);
getstringfield(L, index, "wield_image", def.wield_image);
lua_getfield(L, index, "wield_scale");
if(lua_istable(L, -1)){
def.wield_scale = check_v3f(L, -1);
}
lua_pop(L, 1);
def.stack_max = getintfield_default(L, index, "stack_max", def.stack_max);
if(def.stack_max == 0)
def.stack_max = 1;
lua_getfield(L, index, "on_use");
def.usable = lua_isfunction(L, -1);
lua_pop(L, 1);
getboolfield(L, index, "liquids_pointable", def.liquids_pointable);
warn_if_field_exists(L, index, "tool_digging_properties",
"deprecated: use tool_capabilities");
lua_getfield(L, index, "tool_capabilities");
if(lua_istable(L, -1)){
def.tool_capabilities = new ToolCapabilities(
read_tool_capabilities(L, -1));
}
// If name is "" (hand), ensure there are ToolCapabilities
// because it will be looked up there whenever any other item has
// no ToolCapabilities
if(def.name == "" && def.tool_capabilities == NULL){
def.tool_capabilities = new ToolCapabilities();
}
lua_getfield(L, index, "groups");
read_groups(L, -1, def.groups);
lua_pop(L, 1);
// Client shall immediately place this node when player places the item.
// Server will update the precise end result a moment later.
// "" = no prediction
getstringfield(L, index, "node_placement_prediction",
def.node_placement_prediction);
return def;
}
示例2: print_counts
static void
print_counts(perf_event_desc_t *fds, int num)
{
int i;
unsigned long int values[10];
read_groups(fds, num);
for(i=0; i < num; i++) {
double ratio;
unsigned long int val;
val = fds[i].value - fds[i].prev_value;
ratio = 0.0;
if (fds[i].enabled)
ratio = 1.0 * fds[i].running / fds[i].enabled;
/* separate groups */
/*if (perf_is_group_leader(fds, i))
putchar('\n');*/
// if (fds[i].value < fds[i].prev_value) {
// fprintf(output_file, "inconsistent scaling %s (cur=%'"PRIu64" : prev=%'"PRIu64")\n", fds[i].name, fds[i].value, fds[i].prev_value);
// continue;
// }
values[i] = val;
/*printf("%'20"PRIu64" %s (%.2f%% scaling, ena=%'"PRIu64", run=%'"PRIu64")\n",
val,
fds[i].name,
(1.0-ratio)*100.0,
fds[i].enabled,
fds[i].running);*/
}
/*if (acc_cycles == 0) {
acc_cycles = values[0];
} else {
acc_cycles += values[0];
}*/
//for(i=0; i < num; i++) {
// printf("%lu \t %lu \t %lu \t %.2f\n",
output_file = fopen(file_name, "w");
//fprintf(output_file, "%lu\t%lu\t%lu\n",
fprintf(output_file, "%lu\t%lu\n",
values[0],
//values[1],
// values[2],
values[1]);
// fflush(output_file);
//}
fclose(output_file);
}
示例3: l_get_hit_params
// get_hit_params(groups, tool_capabilities[, time_from_last_punch])
static int l_get_hit_params(lua_State *L)
{
std::map<std::string, int> groups;
read_groups(L, 1, groups);
ToolCapabilities tp = read_tool_capabilities(L, 2);
if(lua_isnoneornil(L, 3))
push_hit_params(L, getHitParams(groups, &tp));
else
push_hit_params(L, getHitParams(groups, &tp,
luaL_checknumber(L, 3)));
return 1;
}
示例4: checkobject
// set_armor_groups(self, groups)
int ObjectRef::l_set_armor_groups(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
if (co == NULL) return 0;
// Do it
ItemGroupList groups;
read_groups(L, 2, groups);
co->setArmorGroups(groups);
return 0;
}
示例5: read_groups
// get_dig_params(groups, tool_capabilities[, time_from_last_punch])
int ModApiUtil::l_get_dig_params(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ItemGroupList groups;
read_groups(L, 1, groups);
ToolCapabilities tp = read_tool_capabilities(L, 2);
if(lua_isnoneornil(L, 3))
push_dig_params(L, getDigParams(groups, &tp));
else
push_dig_params(L, getDigParams(groups, &tp,
luaL_checknumber(L, 3)));
return 1;
}
示例6: read_groups
// get_hit_params(groups, tool_capabilities[, time_from_last_punch])
int ModApiUtil::l_get_hit_params(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
std::map<std::string, int> groups;
read_groups(L, 1, groups);
ToolCapabilities tp = read_tool_capabilities(L, 2);
if(lua_isnoneornil(L, 3))
push_hit_params(L, getHitParams(groups, &tp));
else
push_hit_params(L, getHitParams(groups, &tp,
luaL_checknumber(L, 3)));
return 1;
}
示例7: weston_launch_allowed
static bool
weston_launch_allowed(struct weston_launch *wl)
{
struct group *gr;
gid_t *groups;
int i;
#ifdef HAVE_SYSTEMD_LOGIN
char *session, *seat;
int err;
#endif
if (getuid() == 0)
return true;
gr = getgrnam("weston-launch");
if (gr) {
groups = read_groups();
if (groups) {
for (i = 0; groups[i]; ++i) {
if (groups[i] == gr->gr_gid) {
free(groups);
return true;
}
}
free(groups);
}
}
#ifdef HAVE_SYSTEMD_LOGIN
err = sd_pid_get_session(getpid(), &session);
if (err == 0 && session) {
if (sd_session_is_active(session) &&
sd_session_get_seat(session, &seat) == 0) {
free(seat);
free(session);
return true;
}
free(session);
}
#endif
return false;
}
示例8: print_counts
static void
print_counts(perf_event_desc_t *fds, int num)
{
double ratio;
uint64_t val, delta;
int i;
read_groups(fds, num);
for(i=0; i < num; i++) {
val = perf_scale(fds[i].values);
delta = perf_scale_delta(fds[i].values, fds[i].prev_values);
ratio = perf_scale_ratio(fds[i].values);
/* separate groups */
if (perf_is_group_leader(fds, i))
putchar('\n');
if (options.print)
printf("%'20"PRIu64" %'20"PRIu64" %s (%.2f%% scaling, ena=%'"PRIu64", run=%'"PRIu64")\n",
val,
delta,
fds[i].name,
(1.0-ratio)*100.0,
fds[i].values[1],
fds[i].values[2]);
else
printf("%'20"PRIu64" %s (%.2f%% scaling, ena=%'"PRIu64", run=%'"PRIu64")\n",
val,
fds[i].name,
(1.0-ratio)*100.0,
fds[i].values[1],
fds[i].values[2]);
fds[i].prev_values[0] = fds[i].values[0];
fds[i].prev_values[1] = fds[i].values[1];
fds[i].prev_values[2] = fds[i].values[2];
}
}
示例9: test_group_readwrite
static void test_group_readwrite(CuTest * tc)
{
faction * f;
group *g;
ally *al;
storage store;
FILE *F;
stream strm;
F = fopen("test.dat", "wb");
fstream_init(&strm, F);
binstore_init(&store, &strm);
test_cleanup();
test_create_world();
f = test_create_faction(0);
g = new_group(f, "test", 42);
al = ally_add(&g->allies, f);
al->status = HELP_GIVE;
write_groups(&store, f);
binstore_done(&store);
fstream_done(&strm);
F = fopen("test.dat", "rb");
fstream_init(&strm, F);
binstore_init(&store, &strm);
f->groups = 0;
free_group(g);
read_groups(&store, f);
binstore_done(&store);
fstream_done(&strm);
CuAssertPtrNotNull(tc, f->groups);
CuAssertPtrNotNull(tc, f->groups->allies);
CuAssertPtrEquals(tc, 0, f->groups->allies->next);
CuAssertPtrEquals(tc, f, f->groups->allies->faction);
CuAssertIntEquals(tc, HELP_GIVE, f->groups->allies->status);
remove("test.dat");
test_cleanup();
}
示例10: serve
serve()
{
char line[NNTP_STRLEN];
char host[MAXHOSTNAMELEN];
char gdbuf[MAXBUFLEN];
char **argp;
char *timeptr, *cp;
int argnum, i;
double Tstart, Tfinish;
double user, sys;
#ifdef USG
time_t start, finish;
#else not USG
struct timeval start, finish;
#endif not USG
extern char *ctime();
#ifdef POSTER
struct passwd *pp;
#endif
#ifdef LOG
# ifdef USG
struct tms cpu;
# else not USG
struct rusage me, kids;
# endif not USG
# ifdef TIMEOUT
void timeout();
# endif
grps_acsd = arts_acsd = 0;
#endif
/* Not all systems pass fd's 1 and 2 from inetd */
(void) close(1);
(void) close(2);
(void) dup(0);
(void) dup(0);
/* If we're ALONE, then we've already opened syslog */
#ifndef ALONE
# ifdef SYSLOG
# ifdef BSD_42
openlog("nntpd", LOG_PID);
# else
openlog("nntpd", LOG_PID, SYSLOG);
# endif
# endif
#endif
#ifdef ALONE
#ifndef USG
(void) signal(SIGCHLD, SIG_IGN);
#endif not USG
#endif
/* Ignore SIGPIPE, since we'll see closed connections with read */
(void) signal(SIGPIPE, SIG_IGN);
/* Get permissions and see if we can talk to this client */
host_access(&canread, &canpost, &canxfer, gdbuf);
if (gethostname(host, sizeof(host)) < 0)
(void) strcpy(host, "Amnesiac");
if (!canread && !canxfer) {
printf("%d %s NNTP server can't talk to you. Goodbye.\r\n",
ERR_ACCESS, host);
(void) fflush(stdout);
#ifdef LOG
syslog(LOG_INFO, "%s refused connection", hostname);
#endif
exit(1);
}
/* If we can talk, proceed with initialization */
ngpermcount = get_nglist(&ngpermlist, gdbuf);
#ifdef POSTER
pp = getpwnam(POSTER);
if (pp != NULL) {
uid_poster = pp->pw_uid;
gid_poster = pp->pw_gid;
} else
#endif
uid_poster = gid_poster = 0;
#ifndef FASTFORK
num_groups = 0;
num_groups = read_groups(); /* Read in the active file */
#else
signal(SIGALRM, SIG_IGN); /* Children don't deal with */
/* these things */
#endif
art_fp = NULL;
//.........这里部分代码省略.........
示例11: main
main()
{
#ifdef ALONE /* If no inetd */
int sockt, client, length;
struct sockaddr_in from;
extern int reaper();
disassoc();
/* fd 0-2 should be open and point to / now. */
#ifdef SYSLOG
#ifdef BSD_42
openlog("nntpd", LOG_PID); /* fd 3 */
#else
openlog("nntpd", LOG_PID, SYSLOG); /* fd 3 */
#endif
#endif
#ifdef FASTFORK
num_groups = read_groups(); /* Read active file now (fd 4) */
/* and then do it every */
set_timer(); /* so often later */
#endif
#ifndef EXCELAN
sockt = get_socket(); /* should be fd 4 or 5 */
#endif
#ifndef USG
(void) signal(SIGCHLD, reaper);
#endif
#ifndef EXCELAN
if (listen(sockt, SOMAXCONN) < 0) {
#ifdef SYSLOG
syslog(LOG_ERR, "main: listen: %m");
#endif
exit(1);
}
#endif
for (;;) {
#ifdef EXCELAN
int status;
sockt = get_socket();
if (sockt < 0)
continue;
client = accept(sockt, &from);
#else
length = sizeof (from);
client = accept(sockt, &from, &length);
#endif EXCELAN
if (client < 0) {
#ifdef SYSLOG
if (errno != EINTR)
syslog(LOG_ERR, "accept: %m\n");
#endif
#ifdef EXCELAN
close(sockt);
sleep(1);
#endif
continue;
}
switch (fork()) {
case -1:
#ifdef SYSLOG
syslog(LOG_ERR, "fork: %m\n");
#endif
#ifdef EXCELAN
(void) close(sockt);
#endif
(void) close(client);
break;
case 0:
#ifdef EXCELAN
if (fork())
exit(0);
bcopy(&from,¤t_peer,sizeof(from));
make_stdio(sockt);
#else
(void) close(sockt);
make_stdio(client);
#endif
serve();
break;
default:
#ifdef EXCELAN
(void) close(sockt);
(void) wait(&status);
#else
(void) close(client);
#endif
break;
}
//.........这里部分代码省略.........
示例12: main
//.........这里部分代码省略.........
/* LE UNITA' NATURALI GADGET LAVORANO IN 10^10 MSOL. SE SONO STATE
CAMBIATE, OCCORRE MODIFICARE QUI */
if (MassMin != -1 && MassMax != -1)
{
fprintf(stderr, "Mass range: [%2.2e,%2.2e]\n", MassMin, MassMax);
MassMin /= UdM; MassMax /= UdM;
}
else
{
fprintf(stderr, "Mass range: Unbounded\n");
MassMin = 0;
MassMax = 1e33;
}
switch (mode)
{
case MAKE_FOF:
fprintf(stderr, "Making FOFs.\n");
fof_(fEpsf,fPeriodf1,fPeriodf2,fPeriodf3,NumPart,P,pmap);
write_pmap(fof_fname, fEpsf,fPeriodf1,fPeriodf2,fPeriodf3,NumPart,pmap);
break;
case MAKE_GROUPS:
fprintf(stderr, "Making Groups.\n");
if (read_pmap(fof_fname, fEpsf,fPeriodf1,fPeriodf2,fPeriodf3,NumPart,pmap))
exit(1);
EvalGroups0(pmap,snapshot_fname);
break;
case MAKE_TREE:
fprintf(stderr, "Making Progenitor Trees.\n");
if (read_groups(groups_fname, &groups, &nGroups)) exit(1);
if (read_gmap(gmap_fname, &gmap, &nMapGroups)) exit(1);
/*=======================================================================
* Sanity check that the group files match up.
*=====================================================================*/
#if 0
if (nGroups != nMapGroups)
{
fprintf(stderr,
"Mismatched number of groups between group and map files (%i != %i).\n",
nGroups, nMapGroups);
exit(1);
}
#endif
#if 0
int nPartInGroups=0, nPartInMap=0;
for (i=0; i < nGroups; i++)
{
nPartInGroups += groups[i].npart;
nPartInMap += gmap[i].npart;
}
fprintf(stderr, "HERE 4\n");
if (nGroups != nMapGroups)
{
fprintf(stderr, "Mismatched number of particles between group and map files.\n");
exit(1);
}
#endif
示例13: read_content_features
ContentFeatures read_content_features(lua_State *L, int index)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
ContentFeatures f;
/* Cache existence of some callbacks */
lua_getfield(L, index, "on_construct");
if(!lua_isnil(L, -1)) f.has_on_construct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_destruct");
if(!lua_isnil(L, -1)) f.has_on_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "after_destruct");
if(!lua_isnil(L, -1)) f.has_after_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_rightclick");
f.rightclickable = lua_isfunction(L, -1);
lua_pop(L, 1);
/* Name */
getstringfield(L, index, "name", f.name);
/* Groups */
lua_getfield(L, index, "groups");
read_groups(L, -1, f.groups);
lua_pop(L, 1);
/* Visual definition */
f.drawtype = (NodeDrawType)getenumfield(L, index, "drawtype",
ScriptApiNode::es_DrawType,NDT_NORMAL);
getfloatfield(L, index, "visual_scale", f.visual_scale);
// tiles = {}
lua_getfield(L, index, "tiles");
// If nil, try the deprecated name "tile_images" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "tile_images",
"Deprecated; new name is \"tiles\".");
lua_getfield(L, index, "tile_images");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef[i] = read_tiledef(L, -1);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==6){
lua_pop(L, 1);
break;
}
}
// Copy last value to all remaining textures
if(i >= 1){
TileDef lasttile = f.tiledef[i-1];
while(i < 6){
f.tiledef[i] = lasttile;
i++;
}
}
}
lua_pop(L, 1);
// special_tiles = {}
lua_getfield(L, index, "special_tiles");
// If nil, try the deprecated name "special_materials" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "special_materials",
"Deprecated; new name is \"special_tiles\".");
lua_getfield(L, index, "special_materials");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef_special[i] = read_tiledef(L, -1);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==6){
lua_pop(L, 1);
break;
}
}
}
lua_pop(L, 1);
f.alpha = getintfield_default(L, index, "alpha", 255);
//.........这里部分代码省略.........
示例14: read_content_features
ContentFeatures read_content_features(lua_State *L, int index)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
ContentFeatures f;
/* Cache existence of some callbacks */
lua_getfield(L, index, "on_construct");
if(!lua_isnil(L, -1)) f.has_on_construct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_destruct");
if(!lua_isnil(L, -1)) f.has_on_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "after_destruct");
if(!lua_isnil(L, -1)) f.has_after_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_activate");
if(!lua_isnil(L, -1))
{
f.has_on_activate = true;
f.is_circuit_element = true;
}
lua_pop(L, 1);
lua_getfield(L, index, "on_deactivate");
if(!lua_isnil(L, -1))
{
f.has_on_deactivate = true;
f.is_circuit_element = true;
}
lua_pop(L, 1);
lua_getfield(L, index, "on_rightclick");
f.rightclickable = lua_isfunction(L, -1);
lua_pop(L, 1);
/* Name */
getstringfield(L, index, "name", f.name);
/* Groups */
lua_getfield(L, index, "groups");
read_groups(L, -1, f.groups);
lua_pop(L, 1);
/* Visual definition */
f.drawtype = (NodeDrawType)getenumfield(L, index, "drawtype",
ScriptApiNode::es_DrawType,NDT_NORMAL);
getfloatfield(L, index, "visual_scale", f.visual_scale);
/* Meshnode model filename */
getstringfield(L, index, "mesh", f.mesh);
// tiles = {}
lua_getfield(L, index, "tiles");
// If nil, try the deprecated name "tile_images" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "tile_images",
"Deprecated; new name is \"tiles\".");
lua_getfield(L, index, "tile_images");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef[i] = read_tiledef(L, -1);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==6){
lua_pop(L, 1);
break;
}
}
// Copy last value to all remaining textures
if(i >= 1){
TileDef lasttile = f.tiledef[i-1];
while(i < 6){
f.tiledef[i] = lasttile;
i++;
}
}
}
lua_pop(L, 1);
/* Circuit options */
lua_getfield(L, index, "is_wire");
if(!lua_isnil(L, -1)) {
f.is_wire = true;
}
lua_pop(L, 1);
lua_getfield(L, index, "is_wire_connector");
if(!lua_isnil(L, -1)) {
f.is_wire_connector = true;
}
lua_pop(L, 1);
//.........这里部分代码省略.........
示例15: read_content_features
ContentFeatures read_content_features(lua_State *L, int index)
{
if(index < 0)
index = lua_gettop(L) + 1 + index;
ContentFeatures f;
/* Cache existence of some callbacks */
lua_getfield(L, index, "on_construct");
if(!lua_isnil(L, -1)) f.has_on_construct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_destruct");
if(!lua_isnil(L, -1)) f.has_on_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "after_destruct");
if(!lua_isnil(L, -1)) f.has_after_destruct = true;
lua_pop(L, 1);
lua_getfield(L, index, "on_rightclick");
f.rightclickable = lua_isfunction(L, -1);
lua_pop(L, 1);
/* Name */
getstringfield(L, index, "name", f.name);
/* Groups */
lua_getfield(L, index, "groups");
read_groups(L, -1, f.groups);
lua_pop(L, 1);
/* Visual definition */
f.drawtype = (NodeDrawType)getenumfield(L, index, "drawtype",
ScriptApiNode::es_DrawType,NDT_NORMAL);
getfloatfield(L, index, "visual_scale", f.visual_scale);
/* Meshnode model filename */
getstringfield(L, index, "mesh", f.mesh);
// tiles = {}
lua_getfield(L, index, "tiles");
// If nil, try the deprecated name "tile_images" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "tile_images",
"Deprecated; new name is \"tiles\".");
lua_getfield(L, index, "tile_images");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef[i] = read_tiledef(L, -1, f.drawtype);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==6){
lua_pop(L, 1);
break;
}
}
// Copy last value to all remaining textures
if(i >= 1){
TileDef lasttile = f.tiledef[i-1];
while(i < 6){
f.tiledef[i] = lasttile;
i++;
}
}
}
lua_pop(L, 1);
// special_tiles = {}
lua_getfield(L, index, "special_tiles");
// If nil, try the deprecated name "special_materials" instead
if(lua_isnil(L, -1)){
lua_pop(L, 1);
warn_if_field_exists(L, index, "special_materials",
"Deprecated; new name is \"special_tiles\".");
lua_getfield(L, index, "special_materials");
}
if(lua_istable(L, -1)){
int table = lua_gettop(L);
lua_pushnil(L);
int i = 0;
while(lua_next(L, table) != 0){
// Read tiledef from value
f.tiledef_special[i] = read_tiledef(L, -1, f.drawtype);
// removes value, keeps key for next iteration
lua_pop(L, 1);
i++;
if(i==CF_SPECIAL_COUNT){
lua_pop(L, 1);
break;
}
}
}
lua_pop(L, 1);
//.........这里部分代码省略.........