/* * Prints the ISO date or time given a pointer to a time of day, * left-justfied in a 12-character expanding field with the * rightmost column always blank. * Includes a dcgettext() override in case a message catalog is needed. */ static void prtat(time_t *time) { struct tm *p; p = localtime(time); if (now - *time <= 18 * HR) { char timestr[50]; (void) strftime(timestr, sizeof (timestr), dcgettext(NULL, "%T", LC_TIME), p); PRINTF(("%-11s ", timestr)); } else if (now - *time <= 7 * DAY) { char weekdaytime[20]; (void) strftime(weekdaytime, sizeof (weekdaytime), dcgettext(NULL, "%a %H:%M", LC_TIME), p); PRINTF(("%-11s ", weekdaytime)); } else { char monthtime[20]; (void) strftime(monthtime, sizeof (monthtime), dcgettext(NULL, "%F", LC_TIME), p); PRINTF(("%-11s ", monthtime)); } }
void foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3, va_list v4, va_list v5, va_list v6, va_list v7) { fprintf (stdout, "%d", i); fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */ printf ("%d", i); printf ("%ld", i); /* { dg-warning "format" "printf" } */ /* The "unlocked" functions shouldn't warn in c99 mode. */ fprintf_unlocked (stdout, "%ld", i); /* { dg-bogus "format" "fprintf_unlocked" } */ printf_unlocked ("%ld", i); /* { dg-bogus "format" "printf_unlocked" } */ sprintf (s, "%d", i); sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */ snprintf (s, n, "%d", i); snprintf (s, n, "%ld", i); /* { dg-warning "format" "snprintf" } */ vfprintf (stdout, "%d", v0); vfprintf (stdout, "%Y", v1); /* { dg-warning "format" "vfprintf" } */ vprintf ("%d", v0); vprintf ("%Y", v1); /* { dg-warning "format" "vprintf" } */ vsprintf (s, "%d", v0); vsprintf (s, "%Y", v1); /* { dg-warning "format" "vsprintf" } */ vsnprintf (s, n, "%d", v0); vsnprintf (s, n, "%Y", v1); /* { dg-warning "format" "vsnprintf" } */ printf (gettext ("%d"), i); printf (gettext ("%ld"), i); printf (dgettext ("", "%d"), i); printf (dgettext ("", "%ld"), i); printf (dcgettext ("", "%d", 0), i); printf (dcgettext ("", "%ld", 0), i); }
int main (int argc, char **argv) { char *d1 = dgettext("test-domain", "dgettext1"); char *d2 = dgettext("some-other-domain", "dgettext2"); char *dc1 = dcgettext("test-domain", "dcgettext1", LC_MESSAGES); char *dc2 = dcgettext("some-other-domain", "dcgettext2", LC_MESSAGES); char *dc3 = dcgettext("test-domain", "dcgettext3", LC_TIME); return 0; }
static uim_lisp intl_dcgettext(uim_lisp domainname, uim_lisp msgid, uim_lisp category) { return MAKE_STR(dcgettext(REFER_C_STR(domainname), REFER_C_STR(msgid), C_INT(category))); }
static SeedValue seed_gettext_dcgettext (SeedContext ctx, SeedObject function, SeedObject this_object, gsize argument_count, const SeedValue args[], SeedException * exception) { gchar * domainname, * msgid; gint category; SeedValue ret; CHECK_ARG_COUNT("gettext.dcgettext", 3); domainname = seed_value_to_string (ctx, args[0], exception); msgid = seed_value_to_string (ctx, args[1], exception); category = seed_value_to_int (ctx, args[2], exception); ret = seed_value_from_string (ctx, dcgettext(domainname, msgid, category), exception); g_free(domainname); g_free(msgid); return ret; }
// address: 8048a30 void proc4(int param1) { __size32 eax; // r24 int edx; // r26 dcgettext(0, "Usage: %s [ignored command line arguments]\n or: %s OPTION\nExit with a status code indicating success.\n\nThese option names may not be abbreviated.\n\n", 5); printf(eax); dcgettext(0, " --help display this help and exit\n", 5); edx = *0x804b7e0; fputs_unlocked(eax, edx); dcgettext(0, " --version output version information and exit\n", 5); edx = *0x804b7e0; fputs_unlocked(eax, edx); dcgettext(0, "\nReport bugs to <%s>.\n", 5); printf(eax); exit(param1); return; }
static PyObject* PyIntl_dcgettext(PyObject *self, PyObject *args) { char *domain, *msgid; int category; if (!PyArg_ParseTuple(args, "zzi", &domain, &msgid, &category)) return 0; return PyString_FromString(dcgettext(domain,msgid,category)); }
static PyObject* PyIntl_dcgettext(PyObject *self, PyObject *args) { char *domain, *msgid; int category; if (!PyArg_ParseTuple(args, "zsi", &domain, &msgid, &category)) return 0; return PyUnicode_DecodeLocale(dcgettext(domain,msgid,category), NULL); }
/** * g_dcgettext: * @domain: (allow-none): the translation domain to use, or %NULL to use * the domain set with textdomain() * @msgid: message to translate * @category: a locale category * * This is a variant of g_dgettext() that allows specifying a locale * category instead of always using `LC_MESSAGES`. See g_dgettext() for * more information about how this functions differs from calling * dcgettext() directly. * * Returns: the translated string for the given locale category * * Since: 2.26 */ const gchar * g_dcgettext (const gchar *domain, const gchar *msgid, gint category) { if (domain && G_UNLIKELY (!_g_dgettext_should_translate ())) return msgid; return dcgettext (domain, msgid, category); }
void foo (int *ip, char *s, va_list v0, va_list v1, va_list v2, va_list v3, va_list v4, va_list v5) { fscanf (stdin, "%d", ip); fscanf (stdin, "%ld", ip); /* { dg-warning "format" "fscanf" } */ scanf ("%d", ip); scanf ("%ld", ip); /* { dg-warning "format" "scanf" } */ sscanf (s, "%d", ip); sscanf (s, "%ld", ip); /* { dg-warning "format" "sscanf" } */ vfscanf (stdin, "%d", v0); vscanf ("%d", v2); vsscanf (s, "%d", v4); scanf (gettext ("%d"), ip); scanf (gettext ("%ld"), ip); scanf (dgettext ("", "%d"), ip); scanf (dgettext ("", "%ld"), ip); scanf (dcgettext ("", "%d", 0), ip); scanf (dcgettext ("", "%ld", 0), ip); }
/*! @decl string dcgettext(string domain, string msg, int category) *! *! Return a translated version of @[msg] within the context of the *! specified @[domain] and current locale for the specified *! @[category]. Calling dcgettext with category @[Locale.Gettext.LC_MESSAGES] *! gives the same result as dgettext. *! *! If there is no translation available, @[msg] is returned. *! *! @note *! Obsoleted by @[gettext()] in Pike 7.3. *! *! @seealso *! @[bindtextdomain], @[textdomain], @[gettext], @[setlocale], @[localeconv] */ void f_dcgettext(INT32 args) { const char *domain, *msg; int category; get_all_args(NULL, args, "%c%c%d", &domain, &msg, &category); push_text(dcgettext(domain, msg, category)); stack_pop_n_elems_keep_top(args); }
static char * GETDATE() /* return date file was last modified */ { static char *now = NULL; static struct stat sbuf; static struct stat nbuf; if (Nfiles > 1 || Files->f_name == nulls) { if (now == NULL) { (void) time(&nbuf.st_mtime); (void) cftime(time_buf, dcgettext(NULL, FORMAT, LC_TIME), &nbuf.st_mtime); now = time_buf; } return (now); } else { (void) stat(Files->f_name, &sbuf); (void) cftime(time_buf, dcgettext(NULL, FORMAT, LC_TIME), &sbuf.st_mtime); return (time_buf); } }
const char *pgettext( const char *context, const char *msgid ) { // need to construct the string manually, // to correctly handle strings loaded from json. // could probably do this more efficiently without using std::string. std::string context_id( context ); context_id += '\004'; context_id += msgid; // null domain, uses global translation domain const char *msg_ctxt_id = context_id.c_str(); const char *translation = dcgettext( NULL, msg_ctxt_id, LC_MESSAGES ); if( translation == msg_ctxt_id ) { return msgid; } else { return translation; } }
static inline object do_gettext (const char* msgid, const char* domain, int category) { const char* translated_msg; if (msgid[0] == '\0') { translated_msg = ""; /* Don't return the catalog's header entry. */ } else { begin_system_call(); # ifdef CLISP_UNICODE if (domain != NULL) bind_textdomain_codeset(domain,"UTF-8"); # endif translated_msg = dcgettext(domain,msgid,category); end_system_call(); } return asciz_to_string(translated_msg,Symbol_value(S(utf_8))); }
/*! @decl string gettext(string msg) *! @decl string gettext(string msg, string domain) *! @decl string gettext(string msg, string domain, int category) *! *! @param msg *! Message to be translated. *! *! @param domain *! Domain from within the message should be translated. *! Defaults to the current domain. *! *! @param category *! Category from which the translation should be taken. *! Defaults to @[Locale.Gettext.LC_MESSAGES]. *! *! Return a translated version of @[msg] within the context *! of the specified @[domain] and current locale. If there is no *! translation available, @[msg] is returned. *! *! @seealso *! @[bindtextdomain], @[textdomain], @[setlocale], @[localeconv] */ void f_gettext(INT32 args) { const char *domain = NULL, *msg; int cat = 0; get_all_args(NULL, args, "%c.%C%D", &msg, &domain, &cat); if (domain) { if (args > 2 && SUBTYPEOF(Pike_sp[2-args]) == NUMBER_NUMBER) push_text(dcgettext(domain, msg, cat)); else push_text(dgettext(domain, msg)); } else push_text(gettext(msg)); stack_pop_n_elems_keep_top(args); }
// // Handler // INT_32 FnGetText_::Handler(CDT * aArguments, const UINT_32 iArgNum, CDT & oCDTRetVal, Logger & oLogger) { if (iArgNum == 1) { oCDTRetVal = gettext(aArguments[0].GetString().c_str()); return 0; } else if (iArgNum == 2) { oCDTRetVal = dgettext(aArguments[1].GetString().c_str(), aArguments[0].GetString().c_str()); return 0; } else if (iArgNum == 3) { oCDTRetVal = dcgettext(aArguments[2].GetString().c_str(), aArguments[1].GetString().c_str(), INT_32(aArguments[3].GetInt())); return 0; } oLogger.Emerg("Usage: _(message) or _(message, domain) or _(message, domain, category)"); return -1; }
static int intl_ctl(ErlDrvData drv_data, unsigned int command, char *buf, int len, char **rbuf, int rlen) { void* d = (void*)drv_data; char* aptr = buf; int alen = len; char* str1; char* str2; char* str3; int int1; int int2; unsigned int uint1; switch(command) { case INTL_GETTEXT: /* arguments: string msgid */ if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(gettext(str1), rbuf, rlen); case INTL_NGETTEXT: /* arguments: string msgid, string msgid_plural, int n */ if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str2) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_uinteger(&aptr, &alen, &uint1) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(ngettext(str1,str2,uint1), rbuf, rlen); case INTL_DGETTEXT: /* arguments: string domain, string msgid */ if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str2) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(dgettext(str1,str2), rbuf, rlen); case INTL_DNGETTEXT: /* arguments: string domain, string msgid, string msgid_plural, integer n */ if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str2) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str3) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_uinteger(&aptr, &alen, &uint1) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(dngettext(str1,str2,str3,uint1), rbuf, rlen); case INTL_DCGETTEXT: /* arguments: string domain, string msgid, int category */ if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str2) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_integer(&aptr,&alen, &int1) < 0) return ret_code(EINVAL, rbuf, rlen); if ((int1 = get_category(int1)) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(dcgettext(str1,str2,int1),rbuf,rlen); case INTL_DCNGETTEXT: /* arguments: string domain, string msgid, strinf msgid_plural, unsigned n, int category */ if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str2) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str3) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_uinteger(&aptr,&alen, &uint1) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_integer(&aptr,&alen, &int1) < 0) return ret_code(EINVAL, rbuf, rlen); if ((int1 = get_category(int1)) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(dcngettext(str1,str2,str3,uint1,int1),rbuf,rlen); case INTL_TEXTDOMAIN: /* arguments: string domainname */ if (len == 0) return ret_string(textdomain(NULL), rbuf, rlen); if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(textdomain(str1), rbuf, rlen); case INTL_BINDTEXTDOMAIN: /* arguments: string domainname, string dirname */ if (len == 0) return ret_string(textdomain(NULL), rbuf, rlen); if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str2) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(bindtextdomain(str1,str2), rbuf, rlen); case INTL_BIND_TEXTDOMAIN_CODESET: /* arguments: string domainname, string dirname */ if (len == 0) return ret_string(textdomain(NULL), rbuf, rlen); if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str2) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(bind_textdomain_codeset(str1,str2), rbuf, rlen); case INTL_SETLOCALE: if (get_integer(&aptr,&alen, &int1) < 0) return ret_code(EINVAL, rbuf, rlen); if ((int1 = get_category(int1)) < 0) return ret_code(EINVAL, rbuf, rlen); if (get_string(&aptr, &alen, &str1) < 0) return ret_code(EINVAL, rbuf, rlen); return ret_string(setlocale(int1,str1), rbuf, rlen); } return -1; }
int main(int argc, char *argv[]) { struct utmpx *ut; struct utmpx *utmpbegin; struct utmpx *utmpend; struct utmpx *utp; struct uproc *up, *parent, *pgrp; struct psinfo info; struct sigaction actinfo[ACTSIZE]; struct pstatus statinfo; size_t size; struct stat sbuf; DIR *dirp; struct dirent *dp; char pname[64]; char *fname; int procfd; char *cp; int i; int days, hrs, mins; int entries; double loadavg[3]; /* * This program needs the proc_owner privilege */ (void) __init_suid_priv(PU_CLEARLIMITSET, PRIV_PROC_OWNER, (char *)NULL); (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); login = (argv[0][0] == '-'); cp = strrchr(argv[0], '/'); firstchar = login ? argv[0][1] : (cp == 0) ? argv[0][0] : cp[1]; prog = argv[0]; while (argc > 1) { if (argv[1][0] == '-') { for (i = 1; argv[1][i]; i++) { switch (argv[1][i]) { case 'h': header = 0; break; case 'l': lflag++; break; case 's': lflag = 0; break; case 'u': case 'w': firstchar = argv[1][i]; break; default: (void) fprintf(stderr, gettext( "%s: bad flag %s\n"), prog, argv[1]); exit(1); } } } else { if (!isalnum(argv[1][0]) || argc > 2) { (void) fprintf(stderr, gettext( "usage: %s [ -hlsuw ] [ user ]\n"), prog); exit(1); } else sel_user = argv[1]; } argc--; argv++; } /* * read the UTMPX_FILE (contains information about each logged in user) */ if (stat(UTMPX_FILE, &sbuf) == ERR) { (void) fprintf(stderr, gettext("%s: stat error of %s: %s\n"), prog, UTMPX_FILE, strerror(errno)); exit(1); } entries = sbuf.st_size / sizeof (struct futmpx); size = sizeof (struct utmpx) * entries; if ((ut = malloc(size)) == NULL) { (void) fprintf(stderr, gettext("%s: malloc error of %s: %s\n"), prog, UTMPX_FILE, strerror(errno)); exit(1); } (void) utmpxname(UTMPX_FILE); utmpbegin = ut; utmpend = (struct utmpx *)((char *)utmpbegin + size); setutxent(); while ((ut < utmpend) && ((utp = getutxent()) != NULL)) (void) memcpy(ut++, utp, sizeof (*ut)); endutxent(); (void) time(&now); /* get current time */ if (header) { /* print a header */ prtat(&now); for (ut = utmpbegin; ut < utmpend; ut++) { if (ut->ut_type == USER_PROCESS) { if (!nonuserx(*ut)) nusers++; } else if (ut->ut_type == BOOT_TIME) { uptime = now - ut->ut_xtime; uptime += 30; days = uptime / (60*60*24); uptime %= (60*60*24); hrs = uptime / (60*60); uptime %= (60*60); mins = uptime / 60; PRINTF((gettext("up"))); if (days > 0) PRINTF((gettext( " %d day(s),"), days)); if (hrs > 0 && mins > 0) { PRINTF((" %2d:%02d,", hrs, mins)); } else { if (hrs > 0) PRINTF((gettext( " %d hr(s),"), hrs)); if (mins > 0) PRINTF((gettext( " %d min(s),"), mins)); } } } ut = utmpbegin; /* rewind utmp data */ PRINTF((((nusers == 1) ? gettext(" %d user") : gettext(" %d users")), nusers)); /* * Print 1, 5, and 15 minute load averages. */ (void) getloadavg(loadavg, 3); PRINTF((gettext(", load average: %.2f, %.2f, %.2f\n"), loadavg[LOADAVG_1MIN], loadavg[LOADAVG_5MIN], loadavg[LOADAVG_15MIN])); if (firstchar == 'u') /* uptime command */ exit(0); if (lflag) { PRINTF((dcgettext(NULL, "User tty " "login@ idle JCPU PCPU what\n", LC_TIME))); } else { PRINTF((dcgettext(NULL, "User tty idle what\n", LC_TIME))); } if (fflush(stdout) == EOF) { perror((gettext("%s: fflush failed\n"), prog)); exit(1); } } /* * loop through /proc, reading info about each process * and build the parent/child tree */ if (!(dirp = opendir(PROCDIR))) { (void) fprintf(stderr, gettext("%s: could not open %s: %s\n"), prog, PROCDIR, strerror(errno)); exit(1); } while ((dp = readdir(dirp)) != NULL) { if (dp->d_name[0] == '.') continue; retry: (void) sprintf(pname, "%s/%s/", PROCDIR, dp->d_name); fname = pname + strlen(pname); (void) strcpy(fname, "psinfo"); if ((procfd = open(pname, O_RDONLY)) < 0) continue; if (read(procfd, &info, sizeof (info)) != sizeof (info)) { int err = errno; (void) close(procfd); if (err == EAGAIN) goto retry; if (err != ENOENT) (void) fprintf(stderr, gettext( "%s: read() failed on %s: %s \n"), prog, pname, strerror(err)); continue; } (void) close(procfd); up = findhash(info.pr_pid); up->p_ttyd = info.pr_ttydev; up->p_state = (info.pr_nlwp == 0? ZOMBIE : RUNNING); up->p_time = 0; up->p_ctime = 0; up->p_igintr = 0; (void) strncpy(up->p_comm, info.pr_fname, sizeof (info.pr_fname)); up->p_args[0] = 0; if (up->p_state != NONE && up->p_state != ZOMBIE) { (void) strcpy(fname, "status"); /* now we need the proc_owner privilege */ (void) __priv_bracket(PRIV_ON); procfd = open(pname, O_RDONLY); /* drop proc_owner privilege after open */ (void) __priv_bracket(PRIV_OFF); if (procfd < 0) continue; if (read(procfd, &statinfo, sizeof (statinfo)) != sizeof (statinfo)) { int err = errno; (void) close(procfd); if (err == EAGAIN) goto retry; if (err != ENOENT) (void) fprintf(stderr, gettext( "%s: read() failed on %s: %s \n"), prog, pname, strerror(err)); continue; } (void) close(procfd); up->p_time = statinfo.pr_utime.tv_sec + statinfo.pr_stime.tv_sec; /* seconds */ up->p_ctime = statinfo.pr_cutime.tv_sec + statinfo.pr_cstime.tv_sec; (void) strcpy(fname, "sigact"); /* now we need the proc_owner privilege */ (void) __priv_bracket(PRIV_ON); procfd = open(pname, O_RDONLY); /* drop proc_owner privilege after open */ (void) __priv_bracket(PRIV_OFF); if (procfd < 0) continue; if (read(procfd, actinfo, sizeof (actinfo)) != sizeof (actinfo)) { int err = errno; (void) close(procfd); if (err == EAGAIN) goto retry; if (err != ENOENT) (void) fprintf(stderr, gettext( "%s: read() failed on %s: %s \n"), prog, pname, strerror(err)); continue; } (void) close(procfd); up->p_igintr = actinfo[SIGINT-1].sa_handler == SIG_IGN && actinfo[SIGQUIT-1].sa_handler == SIG_IGN; /* * Process args. */ up->p_args[0] = 0; clnarglist(info.pr_psargs); (void) strcat(up->p_args, info.pr_psargs); if (up->p_args[0] == 0 || up->p_args[0] == '-' && up->p_args[1] <= ' ' || up->p_args[0] == '?') { (void) strcat(up->p_args, " ("); (void) strcat(up->p_args, up->p_comm); (void) strcat(up->p_args, ")"); } } /* * link pgrp together in case parents go away * Pgrp chain is a single linked list originating * from the pgrp leader to its group member. */ if (info.pr_pgid != info.pr_pid) { /* not pgrp leader */ pgrp = findhash(info.pr_pgid); up->p_pgrpl = pgrp->p_pgrpl; pgrp->p_pgrpl = up; } parent = findhash(info.pr_ppid); /* if this is the new member, link it in */ if (parent->p_upid != INITPROCESS) { if (parent->p_child) { up->p_sibling = parent->p_child; up->p_child = 0; } parent->p_child = up; } } /* revert to non-privileged user after opening */ (void) __priv_relinquish(); (void) closedir(dirp); (void) time(&now); /* get current time */ /* * loop through utmpx file, printing process info * about each logged in user */ for (ut = utmpbegin; ut < utmpend; ut++) { if (ut->ut_type != USER_PROCESS) continue; if (sel_user && strncmp(ut->ut_name, sel_user, NMAX) != 0) continue; /* we're looking for somebody else */ /* print login name of the user */ PRINTF(("%-*.*s ", LOGIN_WIDTH, NMAX, ut->ut_name)); /* print tty user is on */ if (lflag) { PRINTF(("%-*.*s ", LINE_WIDTH, LMAX, ut->ut_line)); } else { if (ut->ut_line[0] == 'p' && ut->ut_line[1] == 't' && ut->ut_line[2] == 's' && ut->ut_line[3] == '/') { PRINTF(("%-*.*s ", LINE_WIDTH, LMAX, &ut->ut_line[4])); } else { PRINTF(("%-*.*s ", LINE_WIDTH, LMAX, ut->ut_line)); } } /* print when the user logged in */ if (lflag) { time_t tim = ut->ut_xtime; prtat(&tim); } /* print idle time */ idle = findidle(ut->ut_line); prttime(idle, 8); showtotals(findhash(ut->ut_pid)); } if (fclose(stdout) == EOF) { perror((gettext("%s: fclose failed"), prog)); exit(1); } return (0); }
int main(int argc, char *argv[]) { int y, i, j; int m; char *time_locale; char *ldayw; myname = argv[0]; (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); while (getopt(argc, argv, "") != EOF) usage(); argc -= optind; argv = &argv[optind]; time_locale = setlocale(LC_TIME, NULL); if ((time_locale[0] != 'C') || (time_locale[1] != '\0')) load_months(); /* * TRANSLATION_NOTE * This message is to be used for displaying * the names of the seven days, from Sunday to Saturday. * The length of the name of each one should be two or less. */ ldayw = dcgettext(NULL, DAYW, LC_TIME); switch (argc) { case 0: timbuf = time(&timbuf); thetime = localtime(&timbuf); m = thetime->tm_mon + 1; y = thetime->tm_year + 1900; break; case 1: goto xlong; case 2: m = number(argv[0]); y = number(argv[1]); break; default: usage(); } /* * print out just month */ if (m < 1 || m > 12) badmonth(); if (y < 1 || y > 9999) badyear(); /* * TRANSLATION_NOTE * This message is to be used for displaying * specified month and year. */ (void) printf(dcgettext(NULL, TITLE, LC_TIME), months[m-1], y); (void) printf("%s\n", ldayw); cal(m, y, string, 24); for (i = 0; i < 6*24; i += 24) pstr(string+i, 24); return (0); /* * print out complete year */ xlong: y = number(argv[0]); if (y < 1 || y > 9999) badyear(); /* * TRANSLATION_NOTE * This message is to be used for displaying * specified year. */ (void) printf(dcgettext(NULL, YEAR, LC_TIME), y); for (i = 0; i < 12; i += 3) { for (j = 0; j < 6*72; j++) string[j] = '\0'; /* * TRANSLATION_NOTE * This message is to be used for displaying * names of three months per a line and should be * correctly translated according to the display width * of the names of months. */ (void) printf( dcgettext(NULL, MONTH, LC_TIME), short_months[i], short_months[i+1], short_months[i+2]); (void) printf("%s %s %s\n", ldayw, ldayw, ldayw); cal(i+1, y, string, 72); cal(i+2, y, string+23, 72); cal(i+3, y, string+46, 72); for (j = 0; j < 6*72; j += 72) pstr(string+j, 72); } (void) printf("\n\n\n"); return (0); }
static void dump() { char device[sizeof (utmpp->ut_line) + 1]; time_t hr; time_t idle; time_t min; char path[sizeof (utmpp->ut_line) + 6]; int pexit; int pterm; int rc; char w; /* writeability indicator */ /* * Get and check user name */ if (utmpp->ut_user[0] == '\0') (void) strcpy(user, " ."); else { (void) strncpy(user, utmpp->ut_user, sizeof (user)); user[sizeof (user) - 1] = '\0'; } totlusrs++; /* * Do print in 'who -q' format */ if (qopt) { /* * XCU4 - Use non user macro for correct user count */ if (((totlusrs - 1) % number) == 0 && totlusrs > 1) (void) printf("\n"); (void) printf("%-*s ", NMAX, user); return; } pexit = (int)' '; pterm = (int)' '; /* * Get exit info if applicable */ if (utmpp->ut_type == RUN_LVL || utmpp->ut_type == DEAD_PROCESS) { pterm = utmpp->ut_exit.e_termination; pexit = utmpp->ut_exit.e_exit; } /* * Massage ut_xtime field */ lptr = localtime(&utmpp->ut_xtime); (void) strftime(time_buf, sizeof (time_buf), dcgettext(NULL, DATE_FMT, LC_TIME), lptr); /* * Get and massage device */ if (utmpp->ut_line[0] == '\0') (void) strcpy(device, " ."); else { (void) strncpy(device, utmpp->ut_line, sizeof (utmpp->ut_line)); device[sizeof (utmpp->ut_line)] = '\0'; } /* * Get writeability if requested * XCU4 - only print + or - for user processes */ if (Topt && (utmpp->ut_type == USER_PROCESS)) { w = '-'; (void) strcpy(path, "/dev/"); (void) strncpy(path + 5, utmpp->ut_line, sizeof (utmpp->ut_line)); path[5 + sizeof (utmpp->ut_line)] = '\0'; if ((rc = stat(path, stbufp)) == -1) w = '?'; else if ((stbufp->st_mode & S_IWOTH) || (stbufp->st_mode & S_IWGRP)) /* Check group & other */ w = '+'; } else w = ' '; /* * Print the TERSE portion of the output */ (void) printf("%-*s %c %-12s %s", NMAX, user, w, device, time_buf); if (!terse) { /* * Stat device for idle time * (Don't complain if you can't) */ rc = -1; if (utmpp->ut_type == USER_PROCESS) { (void) strcpy(path, "/dev/"); (void) strncpy(path + 5, utmpp->ut_line, sizeof (utmpp->ut_line)); path[5 + sizeof (utmpp->ut_line)] = '\0'; rc = stat(path, stbufp); } if (rc != -1) { idle = timnow - stbufp->st_mtime; hr = idle/3600; min = (unsigned)(idle/60)%60; if (hr == 0 && min == 0) (void) printf(gettext(" . ")); else { if (hr < 24) (void) printf(" %2d:%2.2d", (int)hr, (int)min); else (void) printf(gettext(" old ")); } } /* * Add PID for verbose output */ if (utmpp->ut_type != BOOT_TIME && utmpp->ut_type != RUN_LVL && utmpp->ut_type != ACCOUNTING) (void) printf(" %5ld", utmpp->ut_pid); /* * Handle /etc/inittab comment */ if (utmpp->ut_type == DEAD_PROCESS) { (void) printf(gettext(" id=%4.4s "), utmpp->ut_id); (void) printf(gettext("term=%-3d "), pterm); (void) printf(gettext("exit=%d "), pexit); } else if (utmpp->ut_type != INIT_PROCESS) { /* * Search for each entry in inittab * string. Keep our place from * search to search to try and * minimize the work. Wrap once if needed * for each entry. */ wrap = 0; /* * Look for a line beginning with * utmpp->ut_id */ while ((rc = strncmp(utmpp->ut_id, iinit, strcspn(iinit, ":"))) != 0) { for (; *iinit != '\n'; iinit++); iinit++; /* * Wrap once if necessary to * find entry in inittab */ if (*iinit == '\0') { if (!wrap) { iinit = inittab; wrap = 1; } } } if (*iinit != '\0') { /* * We found our entry */ for (iinit++; *iinit != '#' && *iinit != '\n'; iinit++); if (*iinit == '#') { for (iinit++; *iinit == ' ' || *iinit == '\t'; iinit++); for (rc = 0; *iinit != '\n'; iinit++) comment[rc++] = *iinit; comment[rc] = '\0'; } else (void) strcpy(comment, " "); (void) printf(" %s", comment); } else iinit = inittab; /* Reset pointer */ } if (utmpp->ut_type == INIT_PROCESS) (void) printf(gettext(" id=%4.4s"), utmpp->ut_id); } #ifdef XPG4 else if (dopt && utmpp->ut_type == DEAD_PROCESS) { (void) printf(gettext("\tterm=%-3d "), pterm); (void) printf(gettext("exit=%d "), pexit); } #endif /* XPG4 */ /* * Handle RUN_LVL process - If no alt. file - Only one! */ if (utmpp->ut_type == RUN_LVL) { (void) printf(" %c %5ld %c", pterm, utmpp->ut_pid, pexit); if (optcnt == 1 && !validtype[USER_PROCESS]) { (void) printf("\n"); exit(0); } } /* * Handle BOOT_TIME process - If no alt. file - Only one! */ if (utmpp->ut_type == BOOT_TIME) { if (optcnt == 1 && !validtype[USER_PROCESS]) { (void) printf("\n"); exit(0); } } /* * Get remote host from utmpx structure */ if (utmpp && utmpp->ut_host[0]) (void) printf("\t(%.*s)", sizeof (utmpp->ut_host), utmpp->ut_host); /* * Now, put on the trailing EOL */ (void) printf("\n"); }
Variant HHVM_FUNCTION(dcgettext, const String& domain, const String& msgid, int64_t category) { CHECK_DOMAIN_LENGTH(); CHECK_GETTEXT_LENGTH("msgid", msgid.length()); return String(dcgettext(domain.data(), msgid.data(), category), CopyString); }
// address: 80498b0 void proc5(char *param1, FILE *param2, char param3[], char param4[], char param5[], __size32 *param6) { __size32 eax; // r24 __size32 ebx; // r27 eax = *param6; if (eax != 0) { do { eax = *(param6 + 4); } while (eax != 0); } if (param3 == 0) { fprintf(param2, "%s %s\n", param4, param5); } else { fprintf(param2, "%s (%s) %s\n", param3, param4, param5); } switch(ebx) { case 0: case 1: L16: L15: dcgettext(0, param1, 5); vfprintf(); eax = *(param2 + 20); if (eax < *(param2 + 24)) { *(__size8*)eax = 10; *(__size32*)(param2 + 20)++; L9: eax = *0x804b7d0; fputs_unlocked(eax, param2); eax = *(param2 + 20); if (eax < *(param2 + 24)) { *(__size8*)eax = 10; *(__size32*)(param2 + 20)++; L4: dcgettext(0, "This is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", 5); fputs_unlocked(eax, param2); return; } __overflow(); goto L4; } __overflow(); goto L9; case 2: goto L15; case 3: goto L16; case 4: goto L16; case 5: goto L16; case 6: goto L15; case 7: goto L15; case 8: goto L16; case 9: goto L16; } abort(); return; }
/** Properly sets all locale information */ static void handle_locale() { const env_var_t lc_all = env_get_string( L"LC_ALL" ); int i; const wcstring old_locale = wsetlocale( LC_MESSAGES, NULL ); /* Array of locale constants corresponding to the local variable names defined in locale_variable */ static const int cat[] = { 0, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME } ; if( !lc_all.missing() ) { wsetlocale( LC_ALL, lc_all.c_str() ); } else { const env_var_t lang = env_get_string( L"LANG" ); if( !lang.missing() ) { wsetlocale( LC_ALL, lang.c_str() ); } for( i=2; locale_variable[i]; i++ ) { const env_var_t val = env_get_string( locale_variable[i] ); if( !val.missing() ) { wsetlocale( cat[i], val.c_str() ); } } } const wcstring new_locale = wsetlocale(LC_MESSAGES, NULL); if( old_locale != new_locale ) { /* Try to make change known to gettext. Both changing _nl_msg_cat_cntr and calling dcgettext might potentially tell some gettext implementation that the translation strings should be reloaded. We do both and hope for the best. */ extern int _nl_msg_cat_cntr; _nl_msg_cat_cntr++; dcgettext( "fish", "Changing language to English", LC_MESSAGES ); if( get_is_interactive() ) { debug( 0, _(L"Changing language to English") ); } } }
char *_p_CDCGetText (char *domainname, char *msgid, int category) { return dcgettext (domainname, msgid, category); }