int main (int argc, char *argv[]) { int i; int res; if (argc == 1) { /* No arg => local host */ if ( (res = soc_get_local_host_name (host_name, sizeof(host_name)) ) == SOC_OK) { do_one (host_name); } else { fprintf (stderr, "soc_get_local_host_name -> %d\n", res); exit (1); } } else if (strcmp (argv[1], "-h") == 0) { printf ("Usage: %s [ { <host_name> | <host_ip> | <host_id> } ]\n", basename(argv[0])); exit (2); } else { /* Dump each argument */ for (i = 1; i < argc; i++) { do_one (argv[i]); } } exit (0); }
int main(void) { do_one("freeradius",80); do_one("anton-laptop",81); do_one("127.0.0.1",80); do_one("tiger",80); do_one("www.google.com",80); return 0; } /* main() */
SEXP attribute_hidden do_rapply(SEXP call, SEXP op, SEXP args, SEXP rho) { SEXP X, FUN, classes, deflt, how, ans, names; int i, n; Rboolean replace; checkArity(op, args); X = CAR(args); args = CDR(args); FUN = CAR(args); args = CDR(args); if(!isFunction(FUN)) error(_("invalid '%s' argument"), "f"); classes = CAR(args); args = CDR(args); if(!isString(classes)) error(_("invalid '%s' argument"), "classes"); deflt = CAR(args); args = CDR(args); how = CAR(args); if(!isString(how)) error(_("invalid '%s' argument"), "how"); replace = strcmp(CHAR(STRING_ELT(how, 0)), "replace") == 0; /* ASCII */ n = length(X); if (replace) { PROTECT(ans = shallow_duplicate(X)); } else { PROTECT(ans = allocVector(VECSXP, n)); names = getAttrib(X, R_NamesSymbol); if(!isNull(names)) setAttrib(ans, R_NamesSymbol, names); } for(i = 0; i < n; i++) SET_VECTOR_ELT(ans, i, do_one(VECTOR_ELT(X, i), FUN, classes, deflt, replace, rho)); UNPROTECT(1); return ans; }
/* * Set up the NFS service over all the available transports. * Returns -1 for failure, 0 for success. */ int do_all(struct protob *protobp, int (*svc)(int, struct netbuf, struct netconfig *)) { struct netconfig *nconf; NCONF_HANDLE *nc; int l; if ((nc = setnetconfig()) == (NCONF_HANDLE *)NULL) { syslog(LOG_ERR, "setnetconfig failed: %m"); return (-1); } l = strlen(NC_UDP); while (nconf = getnetconfig(nc)) { if ((nconf->nc_flag & NC_VISIBLE) && strcmp(nconf->nc_protofmly, NC_LOOPBACK) != 0 && OK_TPI_TYPE(nconf) && (protobp->program != NFS4_CALLBACK || strncasecmp(nconf->nc_proto, NC_UDP, l) != 0)) do_one(nconf->nc_device, nconf->nc_proto, protobp, svc); } (void) endnetconfig(nc); return (0); }
/* * Fire off a detached thread for each host in the list, if the thread * create fails simply run synchronously. */ static void doit(char *hostname) { thread_t tid; char *thread_hostname; (void) mutex_lock(&thr_mtx); while (thread_count >= MAX_THREADS) { (void) mutex_unlock(&thr_mtx); (void) sleep(PATIENCE/2); (void) mutex_lock(&thr_mtx); } thread_count++; (void) mutex_unlock(&thr_mtx); thread_hostname = strdup(hostname); if (thread_hostname == (char *)NULL) { (void) mutex_lock(&tty); (void) fprintf(stderr, "Ran out of memory\n"); (void) mutex_unlock(&tty); exit(1); } if (thr_create(NULL, 0, do_one, thread_hostname, THR_DETACHED, &tid) != 0) { (void) do_one(thread_hostname); } }
void run(worker_group& wg) { while (!done()) { do_one(wg); } }
int test_copy_loop(void) { char *src, *dst, *redzone, *fill; unsigned long len, src_off, dst_off; unsigned long i; src = memalign(BUFLEN, BUFLEN); dst = memalign(BUFLEN, BUFLEN); redzone = malloc(BUFLEN); fill = malloc(BUFLEN); if (!src || !dst || !redzone || !fill) { fprintf(stderr, "malloc failed\n"); exit(1); } memset(redzone, POISON, BUFLEN); /* Fill with sequential bytes */ for (i = 0; i < BUFLEN; i++) fill[i] = i & 0xff; for (len = 1; len < MAX_LEN; len++) { for (src_off = 0; src_off < MAX_OFFSET; src_off++) { for (dst_off = 0; dst_off < MAX_OFFSET; dst_off++) { do_one(src, dst, src_off, dst_off, len, redzone, fill); } } } return 0; }
int main(void) { unsigned long i; for (i = 0; i < 1000000; i++) do_one(); return 0; }
void __bsd_iconvlist(int (*do_one) (unsigned int, const char * const *, void *), void *data) { char **list, **names; const char * const *np; char *curitem, *curkey, *slashpos; size_t sz; unsigned int i, j, n; i = 0; names = NULL; if (__bsd___iconv_get_list(&list, &sz, true)) { list = NULL; goto out; } qsort((void *)list, sz, sizeof(char *), qsort_helper); while (i < sz) { j = 0; slashpos = strchr(list[i], '/'); names = malloc(sz * sizeof(char *)); if (names == NULL) goto out; curkey = strndup(list[i], slashpos - list[i]); if (curkey == NULL) goto out; names[j++] = curkey; for (; (i < sz) && (memcmp(curkey, list[i], strlen(curkey)) == 0); i++) { slashpos = strchr(list[i], '/'); if (strcmp(curkey, &slashpos[1]) == 0) continue; curitem = strdup(&slashpos[1]); if (curitem == NULL) goto out; names[j++] = curitem; } np = (const char * const *)names; do_one(j, np, data); for (n = 0; n < j; n++) free(names[n]); free(names); names = NULL; } out: if (names != NULL) { for (n = 0; n < j; n++) free(names[n]); free(names); } if (list != NULL) __bsd___iconv_free_list(list, sz); }
static SEXP do_one(SEXP X, SEXP FUN, SEXP classes, SEXP deflt, Rboolean replace, SEXP rho) { SEXP ans, names, klass; int i, j, n; Rboolean matched = FALSE; /* if X is a list, recurse. Otherwise if it matches classes call f */ if(isNewList(X)) { n = length(X); if (replace) { PROTECT(ans = shallow_duplicate(X)); } else { PROTECT(ans = allocVector(VECSXP, n)); names = getAttrib(X, R_NamesSymbol); if(!isNull(names)) setAttrib(ans, R_NamesSymbol, names); } for(i = 0; i < n; i++) SET_VECTOR_ELT(ans, i, do_one(VECTOR_ELT(X, i), FUN, classes, deflt, replace, rho)); UNPROTECT(1); return ans; } if(strcmp(CHAR(STRING_ELT(classes, 0)), "ANY") == 0) /* ASCII */ matched = TRUE; else { PROTECT(klass = R_data_class(X, FALSE)); for(i = 0; i < LENGTH(klass); i++) for(j = 0; j < length(classes); j++) if(Seql(STRING_ELT(klass, i), STRING_ELT(classes, j))) matched = TRUE; UNPROTECT(1); } if(matched) { /* This stores value to which the function is to be applied in a variable X in the environment of the rapply closure call that calls into the rapply .Internal. */ SEXP R_fcall; /* could allocate once and preserve for re-use */ SEXP Xsym = install("X"); defineVar(Xsym, X, rho); INCREMENT_NAMED(X); /* PROTECT(R_fcall = lang2(FUN, Xsym)); */ PROTECT(R_fcall = lang3(FUN, Xsym, R_DotsSymbol)); ans = R_forceAndCall(R_fcall, 1, rho); if (MAYBE_REFERENCED(ans)) ans = lazy_duplicate(ans); UNPROTECT(1); return(ans); } else if(replace) return lazy_duplicate(X); else return lazy_duplicate(deflt); }
int main(int argc, char *argv[]) { argc = argc; argv = argv; bool end; do { end = !do_one(); } while (!end); return 0; }
void active_server::run(){ while(1){ if (!do_one()){ if (_run_flag.load() == false){ break; } if (_active_pool.size() == 0){ _empty_flag.store(false); boost::mutex::scoped_lock lock(_mu); _cond.timed_wait(lock, boost::get_system_time() + boost::posix_time::seconds(3)); } } } }
void iconvlist(int (*do_one) (unsigned int, const char * const *, void *), void *data) { char **list, **names; const char * const *np; char *curitem, *curkey, *slashpos; size_t sz; unsigned int i, j; i = 0; if (__iconv_get_list(&list, &sz, true)) list = NULL; qsort((void *)list, sz, sizeof(char *), qsort_helper); while (i < sz) { j = 0; slashpos = strchr(list[i], '/'); curkey = (char *)malloc(slashpos - list[i] + 2); names = (char **)malloc(sz * sizeof(char *)); if ((curkey == NULL) || (names == NULL)) { __iconv_free_list(list, sz); return; } strlcpy(curkey, list[i], slashpos - list[i] + 1); names[j++] = curkey; for (; (i < sz) && (memcmp(curkey, list[i], strlen(curkey)) == 0); i++) { slashpos = strchr(list[i], '/'); curitem = (char *)malloc(strlen(slashpos) + 1); if (curitem == NULL) { __iconv_free_list(list, sz); return; } strlcpy(curitem, &slashpos[1], strlen(slashpos) + 1); if (strcmp(curkey, curitem) == 0) { continue; } names[j++] = curitem; } np = (const char * const *)names; do_one(j, np, data); free(names); } __iconv_free_list(list, sz); }
static SEXP do_one(SEXP X, SEXP FUN, SEXP classes, SEXP deflt, Rboolean replace, SEXP rho) { SEXP ans, names, klass, R_fcall; int i, j, n; Rboolean matched = FALSE; /* if X is a list, recurse. Otherwise if it matches classes call f */ if(isNewList(X)) { n = length(X); PROTECT(ans = allocVector(VECSXP, n)); names = getAttrib(X, R_NamesSymbol); /* or copy attributes if replace = TRUE? */ if(!isNull(names)) setAttrib(ans, R_NamesSymbol, names); for(i = 0; i < n; i++) SET_VECTOR_ELT(ans, i, do_one(VECTOR_ELT(X, i), FUN, classes, deflt, replace, rho)); UNPROTECT(1); return ans; } if(strcmp(CHAR(STRING_ELT(classes, 0)), "ANY") == 0) /* ASCII */ matched = TRUE; else { PROTECT(klass = R_data_class(X, FALSE)); for(i = 0; i < LENGTH(klass); i++) for(j = 0; j < length(classes); j++) if(Seql(STRING_ELT(klass, i), STRING_ELT(classes, j))) matched = TRUE; UNPROTECT(1); } if(matched) { /* PROTECT(R_fcall = lang2(FUN, X)); */ PROTECT(R_fcall = lang3(FUN, X, R_DotsSymbol)); ans = eval(R_fcall, rho); if (NAMED(ans)) ans = duplicate(ans); UNPROTECT(1); return(ans); } else if(replace) return duplicate(X); else return duplicate(deflt); }
int main(int ac, char *av[]) { char *dir = "/"; int allflag = 0; int df_allflag = 0; int opt_cnt = 0; int maxservers = 1; /* zero allows inifinte number of threads */ int maxservers_set = 0; int logmaxservers = 0; int pid; int i; char *provider = (char *)NULL; char *df_provider = (char *)NULL; struct protob *protobp0, *protobp; NETSELDECL(proto) = NULL; NETSELDECL(df_proto) = NULL; NETSELPDECL(providerp); char *defval; boolean_t can_do_mlp; uint_t dss_npaths = 0; char **dss_pathnames = NULL; sigset_t sgset; char name[PATH_MAX], value[PATH_MAX]; int ret, bufsz; int pipe_fd = -1; MyName = *av; /* * Initializations that require more privileges than we need to run. */ (void) _create_daemon_lock(NFSD, DAEMON_UID, DAEMON_GID); svcsetprio(); can_do_mlp = priv_ineffect(PRIV_NET_BINDMLP); if (__init_daemon_priv(PU_RESETGROUPS|PU_CLEARLIMITSET, DAEMON_UID, DAEMON_GID, PRIV_SYS_NFS, can_do_mlp ? PRIV_NET_BINDMLP : NULL, NULL) == -1) { (void) fprintf(stderr, "%s should be run with" " sufficient privileges\n", av[0]); exit(1); } (void) enable_extended_FILE_stdio(-1, -1); /* * Read in the values from SMF first before we check * command line options so the options override SMF values. */ bufsz = PATH_MAX; ret = nfs_smf_get_prop("max_connections", value, DEFAULT_INSTANCE, SCF_TYPE_INTEGER, NFSD, &bufsz); if (ret == SA_OK) { errno = 0; max_conns_allowed = strtol(value, (char **)NULL, 10); if (errno != 0) max_conns_allowed = -1; } bufsz = PATH_MAX; ret = nfs_smf_get_prop("listen_backlog", value, DEFAULT_INSTANCE, SCF_TYPE_INTEGER, NFSD, &bufsz); if (ret == SA_OK) { errno = 0; listen_backlog = strtol(value, (char **)NULL, 10); if (errno != 0) { listen_backlog = 32; } } bufsz = PATH_MAX; ret = nfs_smf_get_prop("protocol", value, DEFAULT_INSTANCE, SCF_TYPE_ASTRING, NFSD, &bufsz); if ((ret == SA_OK) && strlen(value) > 0) { df_proto = strdup(value); opt_cnt++; if (strncasecmp("ALL", value, 3) == 0) { free(df_proto); df_proto = NULL; df_allflag = 1; } } bufsz = PATH_MAX; ret = nfs_smf_get_prop("device", value, DEFAULT_INSTANCE, SCF_TYPE_ASTRING, NFSD, &bufsz); if ((ret == SA_OK) && strlen(value) > 0) { df_provider = strdup(value); opt_cnt++; } bufsz = PATH_MAX; ret = nfs_smf_get_prop("servers", value, DEFAULT_INSTANCE, SCF_TYPE_INTEGER, NFSD, &bufsz); if (ret == SA_OK) { errno = 0; maxservers = strtol(value, (char **)NULL, 10); if (errno != 0) maxservers = 1; else maxservers_set = 1; } bufsz = 4; ret = nfs_smf_get_prop("server_versmin", value, DEFAULT_INSTANCE, SCF_TYPE_INTEGER, NFSD, &bufsz); if (ret == SA_OK) nfs_server_vers_min = strtol(value, (char **)NULL, 10); bufsz = 4; ret = nfs_smf_get_prop("server_versmax", value, DEFAULT_INSTANCE, SCF_TYPE_INTEGER, NFSD, &bufsz); if (ret == SA_OK) nfs_server_vers_max = strtol(value, (char **)NULL, 10); bufsz = PATH_MAX; ret = nfs_smf_get_prop("server_delegation", value, DEFAULT_INSTANCE, SCF_TYPE_ASTRING, NFSD, &bufsz); if (ret == SA_OK) if (strncasecmp(value, "off", 3) == 0) nfs_server_delegation = FALSE; /* * Conflict options error messages. */ if (opt_cnt > 1) { (void) fprintf(stderr, "\nConflicting options, only one of " "the following options can be specified\n" "in SMF:\n" "\tprotocol=ALL\n" "\tprotocol=protocol\n" "\tdevice=devicename\n\n"); usage(); } opt_cnt = 0; while ((i = getopt(ac, av, "ac:p:s:t:l:")) != EOF) { switch (i) { case 'a': free(df_proto); df_proto = NULL; free(df_provider); df_provider = NULL; allflag = 1; opt_cnt++; break; case 'c': max_conns_allowed = atoi(optarg); break; case 'p': proto = optarg; df_allflag = 0; opt_cnt++; break; /* * DSS: NFSv4 distributed stable storage. * * This is a Contracted Project Private interface, for * the sole use of Sun Cluster HA-NFS. See PSARC/2006/313. */ case 's': if (strlen(optarg) < MAXPATHLEN) { /* first "-s" option encountered? */ if (dss_pathnames == NULL) { /* * Allocate maximum possible space * required given cmdline arg count; * "-s <path>" consumes two args. */ size_t sz = (ac / 2) * sizeof (char *); dss_pathnames = (char **)malloc(sz); if (dss_pathnames == NULL) { (void) fprintf(stderr, "%s: " "dss paths malloc failed\n", av[0]); exit(1); } (void) memset(dss_pathnames, 0, sz); } dss_pathnames[dss_npaths] = optarg; dss_npaths++; } else { (void) fprintf(stderr, "%s: -s pathname too long.\n", av[0]); } break; case 't': provider = optarg; df_allflag = 0; opt_cnt++; break; case 'l': listen_backlog = atoi(optarg); break; case '?': usage(); /* NOTREACHED */ } } allflag = df_allflag; if (proto == NULL) proto = df_proto; if (provider == NULL) provider = df_provider; /* * Conflict options error messages. */ if (opt_cnt > 1) { (void) fprintf(stderr, "\nConflicting options, only one of " "the following options can be specified\n" "on the command line:\n" "\t-a\n" "\t-p protocol\n" "\t-t transport\n\n"); usage(); } if (proto != NULL && strncasecmp(proto, NC_UDP, strlen(NC_UDP)) == 0) { if (nfs_server_vers_max == NFS_V4) { if (nfs_server_vers_min == NFS_V4) { fprintf(stderr, "NFS version 4 is not supported " "with the UDP protocol. Exiting\n"); exit(3); } else { fprintf(stderr, "NFS version 4 is not supported " "with the UDP protocol.\n"); } } } /* * If there is exactly one more argument, it is the number of * servers. */ if (optind == ac - 1) { maxservers = atoi(av[optind]); maxservers_set = 1; } /* * If there are two or more arguments, then this is a usage error. */ else if (optind < ac - 1) usage(); /* * Check the ranges for min/max version specified */ else if ((nfs_server_vers_min > nfs_server_vers_max) || (nfs_server_vers_min < NFS_VERSMIN) || (nfs_server_vers_max > NFS_VERSMAX)) usage(); /* * There are no additional arguments, and we haven't set maxservers * explicitly via the config file, we use a default number of * servers. We will log this. */ else if (maxservers_set == 0) logmaxservers = 1; /* * Basic Sanity checks on options * * max_conns_allowed must be positive, except for the special * value of -1 which is used internally to mean unlimited, -1 isn't * documented but we allow it anyway. * * maxservers must be positive * listen_backlog must be positive or zero */ if (((max_conns_allowed != -1) && (max_conns_allowed <= 0)) || (listen_backlog < 0) || (maxservers <= 0)) { usage(); } /* * Set current dir to server root */ if (chdir(dir) < 0) { (void) fprintf(stderr, "%s: ", MyName); perror(dir); exit(1); } #ifndef DEBUG pipe_fd = daemonize_init(); #endif openlog(MyName, LOG_PID | LOG_NDELAY, LOG_DAEMON); /* * establish our lock on the lock file and write our pid to it. * exit if some other process holds the lock, or if there's any * error in writing/locking the file. */ pid = _enter_daemon_lock(NFSD); switch (pid) { case 0: break; case -1: fprintf(stderr, "error locking for %s: %s\n", NFSD, strerror(errno)); exit(2); default: /* daemon was already running */ exit(0); } /* * If we've been given a list of paths to be used for distributed * stable storage, and provided we're going to run a version * that supports it, setup the DSS paths. */ if (dss_pathnames != NULL && nfs_server_vers_max >= DSS_VERSMIN) { if (dss_init(dss_npaths, dss_pathnames) != 0) { fprintf(stderr, "%s", "dss_init failed. Exiting.\n"); exit(1); } } /* * Block all signals till we spawn other * threads. */ (void) sigfillset(&sgset); (void) thr_sigsetmask(SIG_BLOCK, &sgset, NULL); if (logmaxservers) { fprintf(stderr, "Number of servers not specified. Using default of %d.\n", maxservers); } /* * Make sure to unregister any previous versions in case the * user is reconfiguring the server in interesting ways. */ svc_unreg(NFS_PROGRAM, NFS_VERSION); svc_unreg(NFS_PROGRAM, NFS_V3); svc_unreg(NFS_PROGRAM, NFS_V4); svc_unreg(NFS_ACL_PROGRAM, NFS_ACL_V2); svc_unreg(NFS_ACL_PROGRAM, NFS_ACL_V3); /* * Set up kernel RPC thread pool for the NFS server. */ if (nfssvcpool(maxservers)) { fprintf(stderr, "Can't set up kernel NFS service: %s. " "Exiting.\n", strerror(errno)); exit(1); } /* * Set up blocked thread to do LWP creation on behalf of the kernel. */ if (svcwait(NFS_SVCPOOL_ID)) { fprintf(stderr, "Can't set up NFS pool creator: %s. Exiting.\n", strerror(errno)); exit(1); } /* * RDMA start and stop thread. * Per pool RDMA listener creation and * destructor thread. * * start rdma services and block in the kernel. * (only if proto or provider is not set to TCP or UDP) */ if ((proto == NULL) && (provider == NULL)) { if (svcrdma(NFS_SVCPOOL_ID, nfs_server_vers_min, nfs_server_vers_max, nfs_server_delegation)) { fprintf(stderr, "Can't set up RDMA creator thread : %s\n", strerror(errno)); } } /* * Now open up for signal delivery */ (void) thr_sigsetmask(SIG_UNBLOCK, &sgset, NULL); sigset(SIGTERM, sigflush); sigset(SIGUSR1, quiesce); /* * Build a protocol block list for registration. */ protobp0 = protobp = (struct protob *)malloc(sizeof (struct protob)); protobp->serv = "NFS"; protobp->versmin = nfs_server_vers_min; protobp->versmax = nfs_server_vers_max; protobp->program = NFS_PROGRAM; protobp->next = (struct protob *)malloc(sizeof (struct protob)); protobp = protobp->next; protobp->serv = "NFS_ACL"; /* not used */ protobp->versmin = nfs_server_vers_min; /* XXX - this needs work to get the version just right */ protobp->versmax = (nfs_server_vers_max > NFS_ACL_V3) ? NFS_ACL_V3 : nfs_server_vers_max; protobp->program = NFS_ACL_PROGRAM; protobp->next = (struct protob *)NULL; if (allflag) { if (do_all(protobp0, nfssvc) == -1) { fprintf(stderr, "setnetconfig failed : %s\n", strerror(errno)); exit(1); } } else if (proto) { /* there's more than one match for the same protocol */ struct netconfig *nconf; NCONF_HANDLE *nc; bool_t protoFound = FALSE; if ((nc = setnetconfig()) == (NCONF_HANDLE *) NULL) { fprintf(stderr, "setnetconfig failed : %s\n", strerror(errno)); goto done; } while (nconf = getnetconfig(nc)) { if (strcmp(nconf->nc_proto, proto) == 0) { protoFound = TRUE; do_one(nconf->nc_device, NULL, protobp0, nfssvc); } } (void) endnetconfig(nc); if (protoFound == FALSE) { fprintf(stderr, "couldn't find netconfig entry for protocol %s\n", proto); } } else if (provider) do_one(provider, proto, protobp0, nfssvc); else { for (providerp = defaultproviders; *providerp != NULL; providerp++) { provider = *providerp; do_one(provider, NULL, protobp0, nfssvc); } } done: free(protobp); free(protobp0); if (num_fds == 0) { fprintf(stderr, "Could not start NFS service for any protocol." " Exiting.\n"); exit(1); } end_listen_fds = num_fds; /* * nfsd is up and running as far as we are concerned. */ daemonize_fini(pipe_fd); /* * Get rid of unneeded privileges. */ __fini_daemon_priv(PRIV_PROC_FORK, PRIV_PROC_EXEC, PRIV_PROC_SESSION, PRIV_FILE_LINK_ANY, PRIV_PROC_INFO, (char *)NULL); /* * Poll for non-data control events on the transport descriptors. */ poll_for_action(); /* * If we get here, something failed in poll_for_action(). */ return (1); }
void iconvlist (int (*do_one) (unsigned int namescount, const char * const * names, void* data), void* data) { #define aliascount1 sizeof(aliases)/sizeof(aliases[0]) #ifndef aliases2_lookup #define aliascount2 sizeof(sysdep_aliases)/sizeof(sysdep_aliases[0]) #else #define aliascount2 0 #endif #define aliascount (aliascount1+aliascount2) struct nalias aliasbuf[aliascount]; const char * namesbuf[aliascount]; size_t num_aliases; { /* Put all existing aliases into a buffer. */ size_t i; size_t j; j = 0; for (i = 0; i < aliascount1; i++) { const struct alias * p = &aliases[i]; if (p->name >= 0 && p->encoding_index != ei_local_char && p->encoding_index != ei_local_wchar_t) { aliasbuf[j].name = stringpool + p->name; aliasbuf[j].encoding_index = p->encoding_index; j++; } } #ifndef aliases2_lookup for (i = 0; i < aliascount2; i++) { aliasbuf[j].name = stringpool2 + sysdep_aliases[i].name; aliasbuf[j].encoding_index = sysdep_aliases[i].encoding_index; j++; } #endif num_aliases = j; } /* Sort by encoding_index. */ if (num_aliases > 1) qsort(aliasbuf, num_aliases, sizeof(struct nalias), compare_by_index); { /* Process all aliases with the same encoding_index together. */ size_t j; j = 0; while (j < num_aliases) { unsigned int ei = aliasbuf[j].encoding_index; size_t i = 0; do namesbuf[i++] = aliasbuf[j++].name; while (j < num_aliases && aliasbuf[j].encoding_index == ei); if (i > 1) qsort((void *)namesbuf, i, sizeof(const char *), compare_by_name); /* Call the callback. */ if (do_one((unsigned int)i,namesbuf,data)) break; } } #undef aliascount #undef aliascount2 #undef aliascount1 }