Vector<String> PluginDatabase::defaultPluginDirectories() { Vector<String> paths; // Add paths specific to each platform #if defined(XP_UNIX) String userPluginPath = homeDirectoryPath(); userPluginPath.append(String("/.mozilla/plugins")); paths.append(userPluginPath); userPluginPath = homeDirectoryPath(); userPluginPath.append(String("/.netscape/plugins")); paths.append(userPluginPath); paths.append("/usr/lib/browser/plugins"); paths.append("/usr/local/lib/mozilla/plugins"); paths.append("/usr/lib/firefox/plugins"); paths.append("/usr/lib64/browser-plugins"); paths.append("/usr/lib/browser-plugins"); paths.append("/usr/lib/mozilla/plugins"); paths.append("/usr/local/netscape/plugins"); paths.append("/opt/mozilla/plugins"); paths.append("/opt/mozilla/lib/plugins"); paths.append("/opt/netscape/plugins"); paths.append("/opt/netscape/communicator/plugins"); paths.append("/usr/lib/netscape/plugins"); paths.append("/usr/lib/netscape/plugins-libc5"); paths.append("/usr/lib/netscape/plugins-libc6"); paths.append("/usr/lib64/netscape/plugins"); paths.append("/usr/lib64/mozilla/plugins"); String mozHome(getenv("MOZILLA_HOME")); mozHome.append("/plugins"); paths.append(mozHome); Vector<String> mozPaths; String mozPath(getenv("MOZ_PLUGIN_PATH")); mozPath.split(UChar(':'), /* allowEmptyEntries */ false, mozPaths); paths.append(mozPaths); #elif defined(XP_MACOSX) String userPluginPath = homeDirectoryPath(); userPluginPath.append(String("/Library/Internet Plug-Ins")); paths.append(userPluginPath); paths.append("/Library/Internet Plug-Ins"); #elif defined(XP_WIN) String userPluginPath = homeDirectoryPath(); userPluginPath.append(String("\\Application Data\\Mozilla\\plugins")); paths.append(userPluginPath); #endif // Add paths specific to each port #if PLATFORM(QT) Vector<String> qtPaths; String qtPath(getenv("QTWEBKIT_PLUGIN_PATH")); qtPath.split(UChar(':'), /* allowEmptyEntries */ false, qtPaths); paths.append(qtPaths); #endif return paths; }
_nc_msec_cost(const char *const cap, int affcnt) /* compute the cost of a given operation */ { if (cap == 0) return (INFINITY); else { const char *cp; float cum_cost = 0.0; for (cp = cap; *cp; cp++) { /* extract padding, either mandatory or required */ if (cp[0] == '$' && cp[1] == '<' && strchr(cp, '>')) { float number = 0.0; for (cp += 2; *cp != '>'; cp++) { if (isdigit(UChar(*cp))) number = number * 10 + (*cp - '0'); else if (*cp == '*') number *= affcnt; else if (*cp == '.' && (*++cp != '>') && isdigit(UChar(*cp))) number += (*cp - '0') / 10.0; } #if NCURSES_NO_PADDING if (!(SP->_no_padding)) #endif cum_cost += number * 10; } else cum_cost += SP->_char_padding; } return ((int) cum_cost); } }
/* * Check for an expression that corresponds to "%B" (BCD): * (parameter / 10) * 16 + (parameter % 10) */ static int bcd_expression(const char *str) { /* leave this non-const for HPUX */ static char fmt[] = "%%p%c%%{10}%%/%%{16}%%*%%p%c%%{10}%%m%%+"; int len = 0; char ch1, ch2; if (sscanf(str, fmt, &ch1, &ch2) == 2 && isdigit(UChar(ch1)) && isdigit(UChar(ch2)) && (ch1 == ch2)) { len = 28; #ifndef NDEBUG { char buffer[80]; int tst; _nc_SPRINTF(buffer, _nc_SLIMIT(sizeof(buffer)) fmt, ch1, ch2); tst = strlen(buffer) - 1; assert(len == tst); } #endif } return len; }
/*--------------------------------------------------------------------------- | Facility : libnmenu | Function : static bool Is_Sub_String( | bool IgnoreCaseFlag, | const char *part, | const char *string) | | Description : Checks whether or not part is a substring of string. | | Return Values : TRUE - if it is a substring | FALSE - if it is not a substring +--------------------------------------------------------------------------*/ static bool Is_Sub_String( bool IgnoreCaseFlag, const char *part, const char *string ) { assert(part && string); if (IgnoreCaseFlag) { while (*string && *part) { if (toupper(UChar(*string++)) != toupper(UChar(*part))) break; part++; } } else { while (*string && *part) if (*part != *string++) break; part++; } return ((*part) ? FALSE : TRUE); }
static void report(const char *name, int which, unsigned def) { unsigned older, newer; char *p; newer = mode.c_cc[which]; older = oldmode.c_cc[which]; if (older == newer && older == def) return; (void) fprintf(stderr, "%s %s ", name, older == newer ? "is" : "set to"); if (DISABLED(newer)) (void) fprintf(stderr, "undef.\n"); /* * Check 'delete' before 'backspace', since the key_backspace value * is ambiguous. */ else if (newer == 0177) (void) fprintf(stderr, "delete.\n"); else if ((p = key_backspace) != 0 && newer == (unsigned char) p[0] && p[1] == '\0') (void) fprintf(stderr, "backspace.\n"); else if (newer < 040) { newer ^= 0100; (void) fprintf(stderr, "control-%c (^%c).\n", UChar(newer), UChar(newer)); } else (void) fprintf(stderr, "%c.\n", UChar(newer)); }
bool PluginPackage::fetchInfo() { const char *errmsg; if (!load()) return false; NPP_GetValueProcPtr getValue = 0; NP_GetMIMEDescriptionFuncPtr getMIMEDescription = 0; getValue = reinterpret_cast<NPP_GetValueProcPtr>(dlsym(m_module, "NP_GetValue")); if ((errmsg = dlerror())) { EINA_LOG_ERR("Could not get symbol NP_GetValue: %s", errmsg); return false; } getMIMEDescription = reinterpret_cast<NP_GetMIMEDescriptionFuncPtr>(dlsym(m_module, "NP_GetMIMEDescription")); if ((errmsg = dlerror())) { EINA_LOG_ERR("Could not get symbol NP_GetMIMEDescription: %s", errmsg); return false; } char* buffer = 0; NPError err = getValue(0, NPPVpluginNameString, static_cast<void*>(&buffer)); if (err != NPERR_NO_ERROR) return false; m_name = buffer; buffer = 0; err = getValue(0, NPPVpluginDescriptionString, static_cast<void*>(&buffer)); if (err != NPERR_NO_ERROR) return false; m_description = buffer; determineModuleVersionFromDescription(); String description = getMIMEDescription(); Vector<String> types; description.split(UChar(';'), false, types); for (size_t i = 0; i < types.size(); ++i) { Vector<String> mime; types[i].split(UChar(':'), true, mime); if (!mime.isEmpty() > 0) { Vector<String> exts; if (mime.size() > 1) mime[1].split(UChar(','), false, exts); determineQuirks(mime[0]); m_mimeToExtensions.add(mime[0], exts); if (mime.size() > 2) m_mimeToDescriptions.add(mime[0], mime[2]); } } return true; }
void NetscapePluginModule::parseMIMEDescription(const String& mimeDescription, Vector<MimeClassInfo>& result) { ASSERT_ARG(result, result.isEmpty()); Vector<String> types; mimeDescription.lower().split(UChar(';'), false, types); result.reserveInitialCapacity(types.size()); size_t mimeInfoCount = 0; for (size_t i = 0; i < types.size(); ++i) { Vector<String> mimeTypeParts; types[i].split(UChar(':'), true, mimeTypeParts); if (mimeTypeParts.size() <= 0) continue; result.uncheckedAppend(MimeClassInfo()); MimeClassInfo& mimeInfo = result[mimeInfoCount++]; mimeInfo.type = mimeTypeParts[0]; if (mimeTypeParts.size() > 1) mimeTypeParts[1].split(UChar(','), false, mimeInfo.extensions); if (mimeTypeParts.size() > 2) mimeInfo.desc = mimeTypeParts[2]; } }
waddnstr(WINDOW *win, const char *astr, int n) { const char *str = astr; int code = ERR; T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbufn(astr, n), n)); if (win && (str != 0)) { TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); code = OK; if (n < 0) n = (int) strlen(astr); TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); while ((n-- > 0) && (*str != '\0')) { NCURSES_CH_T ch; TR(TRACE_VIRTPUT, ("*str = %#o", UChar(*str))); SetChar(ch, UChar(*str++), A_NORMAL); if (_nc_waddch_nosync(win, ch) == ERR) { code = ERR; break; } } _nc_synchook(win); } TR(TRACE_VIRTPUT, ("waddnstr returns %d", code)); returnCode(code); }
bool PluginPackage::fetchInfo() { if (!load()) return false; char* buf = 0; NPError err = m_pluginFuncs.getvalue(0, NPPVpluginNameString, (void *)&buf); m_name = buf; err = m_pluginFuncs.getvalue(0, NPPVpluginDescriptionString, (void *)&buf); m_description = buf; determineModuleVersionFromDescription(); String s = m_npInterface->NP_GetMIMEDescription(); Vector<String> types; s.split(UChar('|'), false, types); // <MIME1>;<ext1,ext2,ext3,...>;<Description>|<MIME2>|<MIME3>|... for (int i = 0; i < types.size(); ++i) { Vector<String> mime; types[i].split(UChar(';'), true, mime); // <MIME1>;<ext1,ext2,ext3,...>;<Description> if (mime.size() > 0) { Vector<String> exts; if (mime.size() > 1) mime[1].split(UChar(','), false, exts); // <ext1,ext2,ext3,...> m_mimeToExtensions.add(mime[0], exts); // <MIME>,<ext1,ext2,ext3> if (mime.size() > 2) m_mimeToDescriptions.add(mime[0], mime[2]); // <MIME>,<Description> } } unload(); return true; }
wadd_wch(WINDOW *win, const cchar_t *wch) { PUTC_DATA; int n; int code = ERR; TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), win, _tracech_t(wch))); if (win != 0) { PUTC_INIT; for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { attr_t attrs = (wch->attr & A_ATTRIBUTES); if ((PUTC_ch = wch->chars[PUTC_i]) == L'\0') break; if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) { code = ERR; if (is8bits(PUTC_ch)) code = waddch(win, UChar(PUTC_ch) | attrs); break; } for (n = 0; n < PUTC_n; n++) { if ((code = waddch(win, UChar(PUTC_buf[n]) | attrs)) == ERR) { break; } } if (code == ERR) break; } } TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
static char * _nc_vischar(char *tp, unsigned c) { if (c == '"' || c == '\\') { *tp++ = '\\'; *tp++ = (char) c; } else if (is7bits(c) && (isgraph(c) || c == ' ')) { *tp++ = (char) c; } else if (c == '\n') { *tp++ = '\\'; *tp++ = 'n'; } else if (c == '\r') { *tp++ = '\\'; *tp++ = 'r'; } else if (c == '\b') { *tp++ = '\\'; *tp++ = 'b'; } else if (c == '\033') { *tp++ = '\\'; *tp++ = 'e'; } else if (UChar(c) == 0x7f) { *tp++ = '\\'; *tp++ = '^'; *tp++ = '?'; } else if (is7bits(c) && iscntrl(UChar(c))) { *tp++ = '\\'; *tp++ = '^'; *tp++ = (char) ('@' + c); } else { sprintf(tp, "\\%03lo", (unsigned long) ChCharOf(c)); tp += strlen(tp); } *tp = 0; return tp; }
static void trim_suffix(const char *a, size_t *len) { const char ignore[] = SUFFIX_IGNORED; if (sizeof(ignore) != 0) { bool trim = FALSE; size_t need = (sizeof(ignore) - 1); if (*len > need) { size_t first = *len - need; size_t n; trim = TRUE; for (n = first; n < *len; ++n) { if (tolower(UChar(a[n])) != tolower(UChar(ignore[n - first]))) { trim = FALSE; break; } } if (trim) { *len -= need; } } } }
static chtype * ChStr(const char *source) { if (source != 0) { size_t need = ChLen(source) + 1; int n = 0; if (need > temp_length) { temp_length = need * 2; temp_buffer = typeRealloc(chtype, temp_length, temp_buffer); } do { const char *s; chtype ch = UChar(*source++); if (!pass_ctls && (s = unctrl(ch)) != 0) { while (*s != '\0') { temp_buffer[n++] = UChar(*s++); } } else { temp_buffer[n++] = ch; } } while (source[0] != 0); temp_buffer[n] = 0; } else if (temp_buffer != 0) { free(temp_buffer); temp_buffer = 0; temp_length = 0; } return temp_buffer; }
wecho_wchar(WINDOW *win, const cchar_t * wch) { PUTC_DATA; int n; int code = ERR; TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wecho_wchar(%p, %s)"), win, _tracech_t(wch))); if (win != 0) { PUTC_INIT; while (PUTC_i < CCHARW_MAX) { if ((PUTC_ch = wch->chars[PUTC_i++]) == L'\0') break; if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) { code = ERR; if (is8bits(PUTC_ch)) code = waddch(win, UChar(PUTC_ch) | wch->attr); break; } for (n = 0; n < PUTC_n; n++) { if ((code = waddch(win, UChar(PUTC_buf[n]) | wch->attr)) == ERR) { break; } } if (code == ERR) break; } wrefresh(win); } TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code)); return (code); }
_tracecchar_t2(int bufnum, const cchar_t *ch) { char *result = _nc_trace_buf(bufnum, BUFSIZ); attr_t attr; const char *found; if (result != 0) { strcpy(result, l_brace); if (ch != 0) { attr = AttrOfD(ch); if ((found = _nc_altcharset_name(attr, (chtype) CharOfD(ch))) != 0) { (void) _nc_trace_bufcat(bufnum, found); attr &= ~A_ALTCHARSET; } else if (isWidecExt(CHDEREF(ch))) { (void) _nc_trace_bufcat(bufnum, "{NAC}"); attr &= ~A_CHARTEXT; } else { PUTC_DATA; int n; PUTC_INIT; (void) _nc_trace_bufcat(bufnum, "{ "); for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) { PUTC_ch = ch->chars[PUTC_i]; if (PUTC_ch == L'\0') { if (PUTC_i == 0) result = _nc_trace_bufcat(bufnum, "\\000"); break; } PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st); if (PUTC_n <= 0) { if (PUTC_ch != L'\0') { /* it could not be a multibyte sequence */ (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, UChar(ch->chars[PUTC_i]))); } break; } for (n = 0; n < PUTC_n; n++) { if (n) (void) _nc_trace_bufcat(bufnum, ", "); (void) _nc_trace_bufcat(bufnum, _nc_tracechar(CURRENT_SCREEN, UChar(PUTC_buf[n]))); } } (void) _nc_trace_bufcat(bufnum, " }"); } if (attr != A_NORMAL) { (void) _nc_trace_bufcat(bufnum, " | "); (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); } } result = _nc_trace_bufcat(bufnum, r_brace); } return result; }
static char * decode_attr(char *source, attr_t *target, int *color) { bool found = FALSE; T(("decode_attr '%s'", source)); while (*source) { if (source[0] == MARKER && source[1] == L_CURL) { source += 2; found = TRUE; } else if (source[0] == R_CURL) { source++; found = FALSE; } else if (found) { size_t n; char *next = source; if (source[0] == GUTTER) { ++next; } else if (*next == 'C') { int value = 0; unsigned pair; next++; while (isdigit(UChar(*next))) { value = value * 10 + (*next++ - '0'); } *target &= ~A_COLOR; pair = (unsigned) ((value > 256) ? COLOR_PAIR(255) : COLOR_PAIR(value)); *target |= pair; *color = value; } else { while (isalnum(UChar(*next))) { ++next; } for (n = 0; n < SIZEOF(scr_attrs); ++n) { if ((size_t) (next - source) == strlen(scr_attrs[n].name)) { if (scr_attrs[n].attr) { *target |= scr_attrs[n].attr; } else { *target = A_NORMAL; } break; } } } source = next; } else { break; } } return source; }
_tracecchar_t2 (int bufnum, const cchar_t *ch) { char *buf = _nc_trace_buf(bufnum, BUFSIZ); attr_t attr; const char *found; strcpy(buf, l_brace); if (ch != 0) { attr = AttrOfD(ch); if ((found = _nc_altcharset_name(attr, CharOfD(ch))) != 0) { (void) _nc_trace_bufcat(bufnum, found); attr &= ~A_ALTCHARSET; } else if (isWidecExt(CHDEREF(ch))) { (void) _nc_trace_bufcat(bufnum, "{NAC}"); attr &= ~A_CHARTEXT; } else { PUTC_DATA; int n; PUTC_INIT; (void) _nc_trace_bufcat(bufnum, "{ "); do { PUTC_ch = PUTC_i < CCHARW_MAX ? ch->chars[PUTC_i] : L'\0'; PUTC_n = wcrtomb(PUTC_buf, ch->chars[PUTC_i], &PUT_st); if (PUTC_ch == L'\0') --PUTC_n; if (PUTC_n <= 0) { if (PUTC_ch != L'\0') { /* it could not be a multibyte sequence */ (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(ch->chars[PUTC_i]))); } break; } for (n = 0; n < PUTC_n; n++) { if (n) (void) _nc_trace_bufcat(bufnum, ", "); (void) _nc_trace_bufcat(bufnum, _tracechar(UChar(PUTC_buf[n]))); } ++PUTC_i; } while (PUTC_ch != L'\0'); (void) _nc_trace_bufcat(bufnum, " }"); } if (attr != A_NORMAL) { (void) _nc_trace_bufcat(bufnum, " | "); (void) _nc_trace_bufcat(bufnum, _traceattr2(bufnum + 20, attr)); } } return (_nc_trace_bufcat(bufnum, r_brace)); }
/* Discards null codepoints */ static void outbufUTF8(Iso2022Ptr is, int fd, unsigned c) { if (c == 0) return; if (c <= 0x7F) { OUTBUF_MAKE_FREE(is, fd, 1); is->outbuf[is->outbuf_count++] = UChar(c); } else if (c <= 0x7FF) { OUTBUF_MAKE_FREE(is, fd, 2); is->outbuf[is->outbuf_count++] = UChar(0xC0 | ((c >> 6) & 0x1F)); is->outbuf[is->outbuf_count++] = UChar(0x80 | (c & 0x3F)); } else {
bool PluginPackage::fetchInfo() { if (!load()) return false; // FIXME: Find a better way to get around the fetchinfo load. // We are fetching the info. Technically we have not loaded the plugin. PluginView::Init will load the plugin so decrement the counter m_loadCount--; NP_GetMIMEDescriptionFuncPtr getDescription = (NP_GetMIMEDescriptionFuncPtr) dlsym(m_module, "NP_GetMIMEDescription"); NPP_GetValueProcPtr getValue = (NPP_GetValueProcPtr) dlsym(m_module, "NP_GetValue"); if (!getDescription || !getValue) return false; char* buf = 0; NPError err = getValue(0, NPPVpluginNameString, (void *) &buf); if (err != NPERR_NO_ERROR) return false; m_name = buf; err = getValue(0, NPPVpluginDescriptionString, (void *) &buf); if (err != NPERR_NO_ERROR) return false; m_description = buf; determineModuleVersionFromDescription(); String s = getDescription(); Vector<String> types; s.split(UChar(';'), false, types); for (unsigned i = 0; i < types.size(); ++i) { Vector<String> mime; types[i].split(UChar(':'), true, mime); if (mime.size() > 0) { Vector<String> extensions; if (mime.size() > 1) mime[1].split(UChar(','), false, extensions); determineQuirks(mime[0]); m_mimeToExtensions.add(mime[0], extensions); if (mime.size() > 2) m_mimeToDescriptions.add(mime[0], mime[2]); } } return true; }
static void trim(char *buffer) { size_t n = strlen(buffer); while (n-- && isspace(UChar(buffer[n]))) buffer[n] = 0; }
static const char * _nc_visbuf2n(int bufnum, const char *buf, int len) { char *vbuf; char *tp; int c; if (buf == 0) return ("(null)"); if (buf == CANCELLED_STRING) return ("(cancelled)"); if (len < 0) len = strlen(buf); #ifdef TRACE tp = vbuf = _nc_trace_buf(bufnum, (unsigned) (len * 4) + 5); #else { static char *mybuf[2]; mybuf[bufnum] = typeRealloc(char, (unsigned) (len * 4) + 5, mybuf[bufnum]); tp = vbuf = mybuf[bufnum]; } #endif *tp++ = D_QUOTE; while ((--len >= 0) && (c = *buf++) != '\0') { tp = _nc_vischar(tp, UChar(c)); } *tp++ = D_QUOTE; *tp++ = '\0'; return (vbuf); }
bool WebKitTestBus::run() { // FIXME: Use GTestDBus when we bump glib to 2.34. GUniquePtr<char> dbusLaunch(g_find_program_in_path("dbus-launch")); if (!dbusLaunch) { g_warning("Error starting DBUS daemon: dbus-launch not found in path"); return false; } GUniqueOutPtr<char> output; GUniqueOutPtr<GError> error; if (!g_spawn_command_line_sync(dbusLaunch.get(), &output.outPtr(), 0, 0, &error.outPtr())) { g_warning("Error starting DBUS daemon: %s", error->message); return false; } String outputString = String::fromUTF8(output.get()); Vector<String> lines; outputString.split(UChar('\n'), /* allowEmptyEntries */ false, lines); for (size_t i = 0; i < lines.size(); ++i) { char** keyValue = g_strsplit(lines[i].utf8().data(), "=", 2); g_assert_cmpuint(g_strv_length(keyValue), ==, 2); if (!g_strcmp0(keyValue[0], "DBUS_SESSION_BUS_ADDRESS")) { m_address = keyValue[1]; g_setenv("DBUS_SESSION_BUS_ADDRESS", keyValue[1], TRUE); } else if (!g_strcmp0(keyValue[0], "DBUS_SESSION_BUS_PID")) m_pid = g_ascii_strtoll(keyValue[1], 0, 10); g_strfreev(keyValue); } return m_pid > 0; }
form_request_by_name(const char *str) { /* because the table is so small, it doesn't really hurt to run sequentially through it. */ size_t i = 0; char buf[16]; /* longest name is 10 chars */ T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str))); if (str != 0 && (i = strlen(str)) != 0) { if (i > sizeof(buf) - 2) i = sizeof(buf) - 2; memcpy(buf, str, i); buf[i] = '\0'; for (i = 0; buf[i] != '\0'; ++i) { buf[i] = (char)toupper(UChar(buf[i])); } for (i = 0; i < A_SIZE; i++) { if (strcmp(request_names[i], buf) == 0) returnCode(MIN_FORM_COMMAND + (int)i); } } RETURN(E_NO_MATCH); }
/* * Log the most recently-written line to our logfile */ static void log_last_line(WINDOW *win) { FILE *fp; int y, x, n; char temp[256]; if ((fp = fopen(MY_LOGFILE, "a")) != 0) { int need = sizeof(temp) - 1; if (need > COLS) need = COLS; getyx(win, y, x); wmove(win, y - 1, 0); n = winnstr(win, temp, need); while (n-- > 0) { if (isspace(UChar(temp[n]))) temp[n] = '\0'; else break; } wmove(win, y, x); fprintf(fp, "%s\n", temp); fclose(fp); } }
_nc_tracechar(SCREEN *sp, int ch) { NCURSES_CONST char *name; char *MyBuffer = ((sp != 0) ? sp->tracechr_buf : _nc_globals.tracechr_buf); size_t len = ((sp != 0) ? _nc_screen_tracechr_buf_size : _nc_globals_traceatr_color_buf_size); if (ch > KEY_MIN || ch < 0) { name = _nc_keyname(sp, ch); if (name == 0 || *name == '\0') name = "NULL"; (void) snprintf(MyBuffer, len, "'%.30s' = %#03o", name, ch); } else if (!is8bits(ch) || !isprint(UChar(ch))) { /* * workaround for glibc bug: * sprintf changes the result from unctrl() to an empty string if it * does not correspond to a valid multibyte sequence. */ (void) snprintf(MyBuffer, len, "%#03o", ch); } else { name = _nc_unctrl(sp, (chtype) ch); if (name == 0 || *name == 0) name = "null"; /* shouldn't happen */ (void) snprintf(MyBuffer, len, "'%.30s' = %#03o", name, ch); } return (MyBuffer); }
int main(int argc, char *argv[]) { long badanswer = 1; long *response = &badanswer; setlocale(LC_ALL, ""); initscr(); scrollok(stdscr, TRUE); idlok(stdscr, TRUE); echo(); #if 0 trace(TRACE_UPDATE | TRACE_CALLS); #endif while (argc > 1) { if (isdigit(UChar(*argv[1]))) move(atoi(argv[1]), 0); else if (!strcmp(argv[1], "-k")) keypad(stdscr, TRUE); argc--, argv++; } while (badanswer) { printw("Enter a number (0 to quit):\n"); printw("--> "); scanw("%20ld", response); /* yes, it's a pointer */ } endwin(); ExitProgram(EXIT_SUCCESS); }
bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData& result) { CString binaryPath = fileSystemRepresentation(executablePathOfPluginProcess()); CString pluginPathCString = fileSystemRepresentation(pluginPath); char* argv[4]; argv[0] = const_cast<char*>(binaryPath.data()); argv[1] = const_cast<char*>("-scanPlugin"); argv[2] = const_cast<char*>(pluginPathCString.data()); argv[3] = 0; gint status; gchar* stdOut; if (!g_spawn_sync(0, argv, 0, G_SPAWN_STDERR_TO_DEV_NULL, 0, 0, &stdOut, 0, &status, 0)) return false; if (!WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS) return false; const unsigned kNumLinesExpected = 3; String lines[kNumLinesExpected]; unsigned lineIndex = 0; const UChar* current = reinterpret_cast<const UChar*>(stdOut); while (lineIndex < kNumLinesExpected) { const UChar* start = current; while (*current++ != UChar('\n')) { } lines[lineIndex++] = String(start, current - start - 1); } result.name.swap(lines[0]); result.description.swap(lines[1]); result.mimeDescription.swap(lines[2]); return !result.mimeDescription.isEmpty(); }
form_request_by_name(const char *str) { /* because the table is so small, it doesn't really hurt to run sequentially through it. */ unsigned int i = 0; char buf[16]; T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str))); if (str) { strncpy(buf, str, sizeof(buf)); while ((i < sizeof(buf)) && (buf[i] != '\0')) { buf[i] = toupper(UChar(buf[i])); i++; } for (i = 0; i < A_SIZE; i++) { if (strncmp(request_names[i], buf, sizeof(buf)) == 0) returnCode(MIN_FORM_COMMAND + (int) i); } } RETURN(E_NO_MATCH); }
static int cvtchar(register const char *sp) /* convert a character to a terminfo push */ { unsigned char c = 0; int len; switch (*sp) { case '\\': switch (*++sp) { case '\'': case '$': case '\\': case '%': c = *sp; len = 2; break; case '\0': c = '\\'; len = 1; break; case '0': case '1': case '2': case '3': len = 1; while (isdigit(UChar(*sp))) { c = 8 * c + (*sp++ - '0'); len++; } break; default: c = *sp; len = 2; break; } break; case '^': c = (*++sp & 0x1f); len = 2; break; default: c = *sp; len = 1; } if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') { dp = save_string(dp, "%\'"); dp = save_char(dp, c); dp = save_char(dp, '\''); } else { dp = save_string(dp, "%{"); if (c > 99) dp = save_char(dp, c / 100 + '0'); if (c > 9) dp = save_char(dp, ((int) (c / 10)) % 10 + '0'); dp = save_char(dp, c % 10 + '0'); dp = save_char(dp, '}'); } return len; }
static const char * skip(const char *buffer) { while (isspace(UChar(*buffer))) buffer++; return buffer; }