hexsha
stringlengths
40
40
repo
stringlengths
5
105
path
stringlengths
3
173
license
sequence
language
stringclasses
1 value
identifier
stringlengths
1
438
return_type
stringlengths
1
106
original_string
stringlengths
21
40.7k
original_docstring
stringlengths
18
13.4k
docstring
stringlengths
11
3.24k
docstring_tokens
sequence
code
stringlengths
14
20.4k
code_tokens
sequence
short_docstring
stringlengths
0
4.36k
short_docstring_tokens
sequence
comment
sequence
parameters
list
docstring_params
dict
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
acc_char_cmp
word_type
static inline word_type acc_char_cmp (word_type val, word_type c) { #if defined(__GNUC__) && defined(__alpha__) /* We can get exact results using a compare-bytes instruction. Get (val == c) via (0 >= (val ^ c)). */ return __builtin_alpha_cmpbge (0, val ^ c); #else word_type magic = 0x7efefefeU; if (sizeof(word_type) == 8) magic = (magic << 16 << 16) | 0xfefefefeU; magic |= 1; val ^= c; return ((val + magic) ^ ~val) & ~magic; #endif }
/* Return non-zero if some byte of VAL is (probably) C. */
Return non-zero if some byte of VAL is (probably) C.
[ "Return", "non", "-", "zero", "if", "some", "byte", "of", "VAL", "is", "(", "probably", ")", "C", "." ]
static inline word_type acc_char_cmp (word_type val, word_type c) { #if defined(__GNUC__) && defined(__alpha__) return __builtin_alpha_cmpbge (0, val ^ c); #else word_type magic = 0x7efefefeU; if (sizeof(word_type) == 8) magic = (magic << 16 << 16) | 0xfefefefeU; magic |= 1; val ^= c; return ((val + magic) ^ ~val) & ~magic; #endif }
[ "static", "inline", "word_type", "acc_char_cmp", "(", "word_type", "val", ",", "word_type", "c", ")", "{", "#if", "defined", "(", "__GNUC__", ")", "&&", "defined", "(", "__alpha__", ")", "\n", "return", "__builtin_alpha_cmpbge", "(", "0", ",", "val", "^", "c", ")", ";", "#else", "word_type", "magic", "=", "0x7efefefeU", ";", "if", "(", "sizeof", "(", "word_type", ")", "==", "8", ")", "magic", "=", "(", "magic", "<<", "16", "<<", "16", ")", "|", "0xfefefefeU", ";", "magic", "|=", "1", ";", "val", "^=", "c", ";", "return", "(", "(", "val", "+", "magic", ")", "^", "~", "val", ")", "&", "~", "magic", ";", "#endif", "}" ]
Return non-zero if some byte of VAL is (probably) C.
[ "Return", "non", "-", "zero", "if", "some", "byte", "of", "VAL", "is", "(", "probably", ")", "C", "." ]
[ "/* We can get exact results using a compare-bytes instruction. \n Get (val == c) via (0 >= (val ^ c)). */" ]
[ { "param": "val", "type": "word_type" }, { "param": "c", "type": "word_type" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "val", "type": "word_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "c", "type": "word_type", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
_cpp_init_lexer
void
void _cpp_init_lexer (void) { #ifdef HAVE_init_vectorized_lexer init_vectorized_lexer (); #endif }
/* Initialize the lexer if needed. */
Initialize the lexer if needed.
[ "Initialize", "the", "lexer", "if", "needed", "." ]
void _cpp_init_lexer (void) { #ifdef HAVE_init_vectorized_lexer init_vectorized_lexer (); #endif }
[ "void", "_cpp_init_lexer", "(", "void", ")", "{", "#ifdef", "HAVE_init_vectorized_lexer", "init_vectorized_lexer", "(", ")", ";", "#endif", "}" ]
Initialize the lexer if needed.
[ "Initialize", "the", "lexer", "if", "needed", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
_cpp_clean_line
void
void _cpp_clean_line (cpp_reader *pfile) { cpp_buffer *buffer; const uchar *s; uchar c, *d, *p; buffer = pfile->buffer; buffer->cur_note = buffer->notes_used = 0; buffer->cur = buffer->line_base = buffer->next_line; buffer->need_line = false; s = buffer->next_line; if (!buffer->from_stage3) { const uchar *pbackslash = NULL; /* Fast path. This is the common case of an un-escaped line with no trigraphs. The primary win here is by not writing any data back to memory until we have to. */ while (1) { /* Perform an optimized search for \n, \r, \\, ?. */ s = search_line_fast (s, buffer->rlimit); c = *s; if (c == '\\') { /* Record the location of the backslash and continue. */ pbackslash = s++; } else if (__builtin_expect (c == '?', 0)) { if (__builtin_expect (s[1] == '?', false) && _cpp_trigraph_map[s[2]]) { /* Have a trigraph. We may or may not have to convert it. Add a line note regardless, for -Wtrigraphs. */ add_line_note (buffer, s, s[2]); if (CPP_OPTION (pfile, trigraphs)) { /* We do, and that means we have to switch to the slow path. */ d = (uchar *) s; *d = _cpp_trigraph_map[s[2]]; s += 2; goto slow_path; } } /* Not a trigraph. Continue on fast-path. */ s++; } else break; } /* This must be \r or \n. We're either done, or we'll be forced to write back to the buffer and continue on the slow path. */ d = (uchar *) s; if (__builtin_expect (s == buffer->rlimit, false)) goto done; /* DOS line ending? */ if (__builtin_expect (c == '\r', false) && s[1] == '\n') { s++; if (s == buffer->rlimit) goto done; } if (__builtin_expect (pbackslash == NULL, true)) goto done; /* Check for escaped newline. */ p = d; while (is_nvspace (p[-1])) p--; if (p - 1 != pbackslash) goto done; /* Have an escaped newline; process it and proceed to the slow path. */ add_line_note (buffer, p - 1, p != d ? ' ' : '\\'); d = p - 2; buffer->next_line = p - 1; slow_path: while (1) { c = *++s; *++d = c; if (c == '\n' || c == '\r') { /* Handle DOS line endings. */ if (c == '\r' && s != buffer->rlimit && s[1] == '\n') s++; if (s == buffer->rlimit) break; /* Escaped? */ p = d; while (p != buffer->next_line && is_nvspace (p[-1])) p--; if (p == buffer->next_line || p[-1] != '\\') break; add_line_note (buffer, p - 1, p != d ? ' ': '\\'); d = p - 2; buffer->next_line = p - 1; } else if (c == '?' && s[1] == '?' && _cpp_trigraph_map[s[2]]) { /* Add a note regardless, for the benefit of -Wtrigraphs. */ add_line_note (buffer, d, s[2]); if (CPP_OPTION (pfile, trigraphs)) { *d = _cpp_trigraph_map[s[2]]; s += 2; } } } } else { while (*s != '\n' && *s != '\r') s++; d = (uchar *) s; /* Handle DOS line endings. */ if (*s == '\r' && s != buffer->rlimit && s[1] == '\n') s++; } done: *d = '\n'; /* A sentinel note that should never be processed. */ add_line_note (buffer, d + 1, '\n'); buffer->next_line = s + 1; }
/* Returns with a logical line that contains no escaped newlines or trigraphs. This is a time-critical inner loop. */
Returns with a logical line that contains no escaped newlines or trigraphs. This is a time-critical inner loop.
[ "Returns", "with", "a", "logical", "line", "that", "contains", "no", "escaped", "newlines", "or", "trigraphs", ".", "This", "is", "a", "time", "-", "critical", "inner", "loop", "." ]
void _cpp_clean_line (cpp_reader *pfile) { cpp_buffer *buffer; const uchar *s; uchar c, *d, *p; buffer = pfile->buffer; buffer->cur_note = buffer->notes_used = 0; buffer->cur = buffer->line_base = buffer->next_line; buffer->need_line = false; s = buffer->next_line; if (!buffer->from_stage3) { const uchar *pbackslash = NULL; while (1) { s = search_line_fast (s, buffer->rlimit); c = *s; if (c == '\\') { pbackslash = s++; } else if (__builtin_expect (c == '?', 0)) { if (__builtin_expect (s[1] == '?', false) && _cpp_trigraph_map[s[2]]) { add_line_note (buffer, s, s[2]); if (CPP_OPTION (pfile, trigraphs)) { d = (uchar *) s; *d = _cpp_trigraph_map[s[2]]; s += 2; goto slow_path; } } s++; } else break; } d = (uchar *) s; if (__builtin_expect (s == buffer->rlimit, false)) goto done; if (__builtin_expect (c == '\r', false) && s[1] == '\n') { s++; if (s == buffer->rlimit) goto done; } if (__builtin_expect (pbackslash == NULL, true)) goto done; p = d; while (is_nvspace (p[-1])) p--; if (p - 1 != pbackslash) goto done; add_line_note (buffer, p - 1, p != d ? ' ' : '\\'); d = p - 2; buffer->next_line = p - 1; slow_path: while (1) { c = *++s; *++d = c; if (c == '\n' || c == '\r') { if (c == '\r' && s != buffer->rlimit && s[1] == '\n') s++; if (s == buffer->rlimit) break; p = d; while (p != buffer->next_line && is_nvspace (p[-1])) p--; if (p == buffer->next_line || p[-1] != '\\') break; add_line_note (buffer, p - 1, p != d ? ' ': '\\'); d = p - 2; buffer->next_line = p - 1; } else if (c == '?' && s[1] == '?' && _cpp_trigraph_map[s[2]]) { add_line_note (buffer, d, s[2]); if (CPP_OPTION (pfile, trigraphs)) { *d = _cpp_trigraph_map[s[2]]; s += 2; } } } } else { while (*s != '\n' && *s != '\r') s++; d = (uchar *) s; if (*s == '\r' && s != buffer->rlimit && s[1] == '\n') s++; } done: *d = '\n'; add_line_note (buffer, d + 1, '\n'); buffer->next_line = s + 1; }
[ "void", "_cpp_clean_line", "(", "cpp_reader", "*", "pfile", ")", "{", "cpp_buffer", "*", "buffer", ";", "const", "uchar", "*", "s", ";", "uchar", "c", ",", "*", "d", ",", "*", "p", ";", "buffer", "=", "pfile", "->", "buffer", ";", "buffer", "->", "cur_note", "=", "buffer", "->", "notes_used", "=", "0", ";", "buffer", "->", "cur", "=", "buffer", "->", "line_base", "=", "buffer", "->", "next_line", ";", "buffer", "->", "need_line", "=", "false", ";", "s", "=", "buffer", "->", "next_line", ";", "if", "(", "!", "buffer", "->", "from_stage3", ")", "{", "const", "uchar", "*", "pbackslash", "=", "NULL", ";", "while", "(", "1", ")", "{", "s", "=", "search_line_fast", "(", "s", ",", "buffer", "->", "rlimit", ")", ";", "c", "=", "*", "s", ";", "if", "(", "c", "==", "'", "\\\\", "'", ")", "{", "pbackslash", "=", "s", "++", ";", "}", "else", "if", "(", "__builtin_expect", "(", "c", "==", "'", "'", ",", "0", ")", ")", "{", "if", "(", "__builtin_expect", "(", "s", "[", "1", "]", "==", "'", "'", ",", "false", ")", "&&", "_cpp_trigraph_map", "[", "s", "[", "2", "]", "]", ")", "{", "add_line_note", "(", "buffer", ",", "s", ",", "s", "[", "2", "]", ")", ";", "if", "(", "CPP_OPTION", "(", "pfile", ",", "trigraphs", ")", ")", "{", "d", "=", "(", "uchar", "*", ")", "s", ";", "*", "d", "=", "_cpp_trigraph_map", "[", "s", "[", "2", "]", "]", ";", "s", "+=", "2", ";", "goto", "slow_path", ";", "}", "}", "s", "++", ";", "}", "else", "break", ";", "}", "d", "=", "(", "uchar", "*", ")", "s", ";", "if", "(", "__builtin_expect", "(", "s", "==", "buffer", "->", "rlimit", ",", "false", ")", ")", "goto", "done", ";", "if", "(", "__builtin_expect", "(", "c", "==", "'", "\\r", "'", ",", "false", ")", "&&", "s", "[", "1", "]", "==", "'", "\\n", "'", ")", "{", "s", "++", ";", "if", "(", "s", "==", "buffer", "->", "rlimit", ")", "goto", "done", ";", "}", "if", "(", "__builtin_expect", "(", "pbackslash", "==", "NULL", ",", "true", ")", ")", "goto", "done", ";", "p", "=", "d", ";", "while", "(", "is_nvspace", "(", "p", "[", "-1", "]", ")", ")", "p", "--", ";", "if", "(", "p", "-", "1", "!=", "pbackslash", ")", "goto", "done", ";", "add_line_note", "(", "buffer", ",", "p", "-", "1", ",", "p", "!=", "d", "?", "'", "'", ":", "'", "\\\\", "'", ")", ";", "d", "=", "p", "-", "2", ";", "buffer", "->", "next_line", "=", "p", "-", "1", ";", "slow_path", ":", "while", "(", "1", ")", "{", "c", "=", "*", "++", "s", ";", "*", "++", "d", "=", "c", ";", "if", "(", "c", "==", "'", "\\n", "'", "||", "c", "==", "'", "\\r", "'", ")", "{", "if", "(", "c", "==", "'", "\\r", "'", "&&", "s", "!=", "buffer", "->", "rlimit", "&&", "s", "[", "1", "]", "==", "'", "\\n", "'", ")", "s", "++", ";", "if", "(", "s", "==", "buffer", "->", "rlimit", ")", "break", ";", "p", "=", "d", ";", "while", "(", "p", "!=", "buffer", "->", "next_line", "&&", "is_nvspace", "(", "p", "[", "-1", "]", ")", ")", "p", "--", ";", "if", "(", "p", "==", "buffer", "->", "next_line", "||", "p", "[", "-1", "]", "!=", "'", "\\\\", "'", ")", "break", ";", "add_line_note", "(", "buffer", ",", "p", "-", "1", ",", "p", "!=", "d", "?", "'", "'", ":", "'", "\\\\", "'", ")", ";", "d", "=", "p", "-", "2", ";", "buffer", "->", "next_line", "=", "p", "-", "1", ";", "}", "else", "if", "(", "c", "==", "'", "'", "&&", "s", "[", "1", "]", "==", "'", "'", "&&", "_cpp_trigraph_map", "[", "s", "[", "2", "]", "]", ")", "{", "add_line_note", "(", "buffer", ",", "d", ",", "s", "[", "2", "]", ")", ";", "if", "(", "CPP_OPTION", "(", "pfile", ",", "trigraphs", ")", ")", "{", "*", "d", "=", "_cpp_trigraph_map", "[", "s", "[", "2", "]", "]", ";", "s", "+=", "2", ";", "}", "}", "}", "}", "else", "{", "while", "(", "*", "s", "!=", "'", "\\n", "'", "&&", "*", "s", "!=", "'", "\\r", "'", ")", "s", "++", ";", "d", "=", "(", "uchar", "*", ")", "s", ";", "if", "(", "*", "s", "==", "'", "\\r", "'", "&&", "s", "!=", "buffer", "->", "rlimit", "&&", "s", "[", "1", "]", "==", "'", "\\n", "'", ")", "s", "++", ";", "}", "done", ":", "*", "d", "=", "'", "\\n", "'", ";", "add_line_note", "(", "buffer", ",", "d", "+", "1", ",", "'", "\\n", "'", ")", ";", "buffer", "->", "next_line", "=", "s", "+", "1", ";", "}" ]
Returns with a logical line that contains no escaped newlines or trigraphs.
[ "Returns", "with", "a", "logical", "line", "that", "contains", "no", "escaped", "newlines", "or", "trigraphs", "." ]
[ "/* Fast path. This is the common case of an un-escaped line with\n\t no trigraphs. The primary win here is by not writing any\n\t data back to memory until we have to. */", "/* Perform an optimized search for \\n, \\r, \\\\, ?. */", "/* Record the location of the backslash and continue. */", "/* Have a trigraph. We may or may not have to convert\n\t\t it. Add a line note regardless, for -Wtrigraphs. */", "/* We do, and that means we have to switch to the\n\t\t slow path. */", "/* Not a trigraph. Continue on fast-path. */", "/* This must be \\r or \\n. We're either done, or we'll be forced\n\t to write back to the buffer and continue on the slow path. */", "/* DOS line ending? */", "/* Check for escaped newline. */", "/* Have an escaped newline; process it and proceed to\n\t the slow path. */", "/* Handle DOS line endings. */", "/* Escaped? */", "/* Add a note regardless, for the benefit of -Wtrigraphs. */", "/* Handle DOS line endings. */", "/* A sentinel note that should never be processed. */" ]
[ { "param": "pfile", "type": "cpp_reader" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfile", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
_cpp_process_line_notes
void
void _cpp_process_line_notes (cpp_reader *pfile, int in_comment) { cpp_buffer *buffer = pfile->buffer; for (;;) { _cpp_line_note *note = &buffer->notes[buffer->cur_note]; unsigned int col; if (note->pos > buffer->cur) break; buffer->cur_note++; col = CPP_BUF_COLUMN (buffer, note->pos + 1); if (note->type == '\\' || note->type == ' ') { if (note->type == ' ' && !in_comment) cpp_error_with_line (pfile, CPP_DL_WARNING, pfile->line_table->highest_line, col, "backslash and newline separated by space"); if (buffer->next_line > buffer->rlimit) { cpp_error_with_line (pfile, CPP_DL_PEDWARN, pfile->line_table->highest_line, col, "backslash-newline at end of file"); /* Prevent "no newline at end of file" warning. */ buffer->next_line = buffer->rlimit; } buffer->line_base = note->pos; CPP_INCREMENT_LINE (pfile, 0); } else if (_cpp_trigraph_map[note->type]) { if (CPP_OPTION (pfile, warn_trigraphs) && (!in_comment || warn_in_comment (pfile, note))) { if (CPP_OPTION (pfile, trigraphs)) cpp_warning_with_line (pfile, CPP_W_TRIGRAPHS, pfile->line_table->highest_line, col, "trigraph ??%c converted to %c", note->type, (int) _cpp_trigraph_map[note->type]); else { cpp_warning_with_line (pfile, CPP_W_TRIGRAPHS, pfile->line_table->highest_line, col, "trigraph ??%c ignored, use -trigraphs to enable", note->type); } } } else if (note->type == 0) /* Already processed in lex_raw_string. */; else abort (); } }
/* Process the notes created by add_line_note as far as the current location. */
Process the notes created by add_line_note as far as the current location.
[ "Process", "the", "notes", "created", "by", "add_line_note", "as", "far", "as", "the", "current", "location", "." ]
void _cpp_process_line_notes (cpp_reader *pfile, int in_comment) { cpp_buffer *buffer = pfile->buffer; for (;;) { _cpp_line_note *note = &buffer->notes[buffer->cur_note]; unsigned int col; if (note->pos > buffer->cur) break; buffer->cur_note++; col = CPP_BUF_COLUMN (buffer, note->pos + 1); if (note->type == '\\' || note->type == ' ') { if (note->type == ' ' && !in_comment) cpp_error_with_line (pfile, CPP_DL_WARNING, pfile->line_table->highest_line, col, "backslash and newline separated by space"); if (buffer->next_line > buffer->rlimit) { cpp_error_with_line (pfile, CPP_DL_PEDWARN, pfile->line_table->highest_line, col, "backslash-newline at end of file"); buffer->next_line = buffer->rlimit; } buffer->line_base = note->pos; CPP_INCREMENT_LINE (pfile, 0); } else if (_cpp_trigraph_map[note->type]) { if (CPP_OPTION (pfile, warn_trigraphs) && (!in_comment || warn_in_comment (pfile, note))) { if (CPP_OPTION (pfile, trigraphs)) cpp_warning_with_line (pfile, CPP_W_TRIGRAPHS, pfile->line_table->highest_line, col, "trigraph ??%c converted to %c", note->type, (int) _cpp_trigraph_map[note->type]); else { cpp_warning_with_line (pfile, CPP_W_TRIGRAPHS, pfile->line_table->highest_line, col, "trigraph ??%c ignored, use -trigraphs to enable", note->type); } } } else if (note->type == 0) ; else abort (); } }
[ "void", "_cpp_process_line_notes", "(", "cpp_reader", "*", "pfile", ",", "int", "in_comment", ")", "{", "cpp_buffer", "*", "buffer", "=", "pfile", "->", "buffer", ";", "for", "(", ";", ";", ")", "{", "_cpp_line_note", "*", "note", "=", "&", "buffer", "->", "notes", "[", "buffer", "->", "cur_note", "]", ";", "unsigned", "int", "col", ";", "if", "(", "note", "->", "pos", ">", "buffer", "->", "cur", ")", "break", ";", "buffer", "->", "cur_note", "++", ";", "col", "=", "CPP_BUF_COLUMN", "(", "buffer", ",", "note", "->", "pos", "+", "1", ")", ";", "if", "(", "note", "->", "type", "==", "'", "\\\\", "'", "||", "note", "->", "type", "==", "'", "'", ")", "{", "if", "(", "note", "->", "type", "==", "'", "'", "&&", "!", "in_comment", ")", "cpp_error_with_line", "(", "pfile", ",", "CPP_DL_WARNING", ",", "pfile", "->", "line_table", "->", "highest_line", ",", "col", ",", "\"", "\"", ")", ";", "if", "(", "buffer", "->", "next_line", ">", "buffer", "->", "rlimit", ")", "{", "cpp_error_with_line", "(", "pfile", ",", "CPP_DL_PEDWARN", ",", "pfile", "->", "line_table", "->", "highest_line", ",", "col", ",", "\"", "\"", ")", ";", "buffer", "->", "next_line", "=", "buffer", "->", "rlimit", ";", "}", "buffer", "->", "line_base", "=", "note", "->", "pos", ";", "CPP_INCREMENT_LINE", "(", "pfile", ",", "0", ")", ";", "}", "else", "if", "(", "_cpp_trigraph_map", "[", "note", "->", "type", "]", ")", "{", "if", "(", "CPP_OPTION", "(", "pfile", ",", "warn_trigraphs", ")", "&&", "(", "!", "in_comment", "||", "warn_in_comment", "(", "pfile", ",", "note", ")", ")", ")", "{", "if", "(", "CPP_OPTION", "(", "pfile", ",", "trigraphs", ")", ")", "cpp_warning_with_line", "(", "pfile", ",", "CPP_W_TRIGRAPHS", ",", "pfile", "->", "line_table", "->", "highest_line", ",", "col", ",", "\"", "\"", ",", "note", "->", "type", ",", "(", "int", ")", "_cpp_trigraph_map", "[", "note", "->", "type", "]", ")", ";", "else", "{", "cpp_warning_with_line", "(", "pfile", ",", "CPP_W_TRIGRAPHS", ",", "pfile", "->", "line_table", "->", "highest_line", ",", "col", ",", "\"", "\"", ",", "note", "->", "type", ")", ";", "}", "}", "}", "else", "if", "(", "note", "->", "type", "==", "0", ")", ";", "else", "abort", "(", ")", ";", "}", "}" ]
Process the notes created by add_line_note as far as the current location.
[ "Process", "the", "notes", "created", "by", "add_line_note", "as", "far", "as", "the", "current", "location", "." ]
[ "/* Prevent \"no newline at end of file\" warning. */", "/* Already processed in lex_raw_string. */" ]
[ { "param": "pfile", "type": "cpp_reader" }, { "param": "in_comment", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfile", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "in_comment", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
_cpp_skip_block_comment
bool
bool _cpp_skip_block_comment (cpp_reader *pfile) { cpp_buffer *buffer = pfile->buffer; const uchar *cur = buffer->cur; uchar c; cur++; if (*cur == '/') cur++; for (;;) { /* People like decorating comments with '*', so check for '/' instead for efficiency. */ c = *cur++; if (c == '/') { if (cur[-2] == '*') break; /* Warn about potential nested comments, but not if the '/' comes immediately before the true comment delimiter. Don't bother to get it right across escaped newlines. */ if (CPP_OPTION (pfile, warn_comments) && cur[0] == '*' && cur[1] != '/') { buffer->cur = cur; cpp_warning_with_line (pfile, CPP_W_COMMENTS, pfile->line_table->highest_line, CPP_BUF_COL (buffer), "\"/*\" within comment"); } } else if (c == '\n') { unsigned int cols; buffer->cur = cur - 1; _cpp_process_line_notes (pfile, true); if (buffer->next_line >= buffer->rlimit) return true; _cpp_clean_line (pfile); cols = buffer->next_line - buffer->line_base; CPP_INCREMENT_LINE (pfile, cols); cur = buffer->cur; } } buffer->cur = cur; _cpp_process_line_notes (pfile, true); return false; }
/* Skip a C-style block comment. We find the end of the comment by seeing if an asterisk is before every '/' we encounter. Returns nonzero if comment terminated by EOF, zero otherwise. Buffer->cur points to the initial asterisk of the comment. */
Skip a C-style block comment. We find the end of the comment by seeing if an asterisk is before every '/' we encounter. Returns nonzero if comment terminated by EOF, zero otherwise. Buffer->cur points to the initial asterisk of the comment.
[ "Skip", "a", "C", "-", "style", "block", "comment", ".", "We", "find", "the", "end", "of", "the", "comment", "by", "seeing", "if", "an", "asterisk", "is", "before", "every", "'", "/", "'", "we", "encounter", ".", "Returns", "nonzero", "if", "comment", "terminated", "by", "EOF", "zero", "otherwise", ".", "Buffer", "-", ">", "cur", "points", "to", "the", "initial", "asterisk", "of", "the", "comment", "." ]
bool _cpp_skip_block_comment (cpp_reader *pfile) { cpp_buffer *buffer = pfile->buffer; const uchar *cur = buffer->cur; uchar c; cur++; if (*cur == '/') cur++; for (;;) { c = *cur++; if (c == '/') { if (cur[-2] == '*') break; if (CPP_OPTION (pfile, warn_comments) && cur[0] == '*' && cur[1] != '/') { buffer->cur = cur; cpp_warning_with_line (pfile, CPP_W_COMMENTS, pfile->line_table->highest_line, CPP_BUF_COL (buffer), "\"/*\" within comment"); } } else if (c == '\n') { unsigned int cols; buffer->cur = cur - 1; _cpp_process_line_notes (pfile, true); if (buffer->next_line >= buffer->rlimit) return true; _cpp_clean_line (pfile); cols = buffer->next_line - buffer->line_base; CPP_INCREMENT_LINE (pfile, cols); cur = buffer->cur; } } buffer->cur = cur; _cpp_process_line_notes (pfile, true); return false; }
[ "bool", "_cpp_skip_block_comment", "(", "cpp_reader", "*", "pfile", ")", "{", "cpp_buffer", "*", "buffer", "=", "pfile", "->", "buffer", ";", "const", "uchar", "*", "cur", "=", "buffer", "->", "cur", ";", "uchar", "c", ";", "cur", "++", ";", "if", "(", "*", "cur", "==", "'", "'", ")", "cur", "++", ";", "for", "(", ";", ";", ")", "{", "c", "=", "*", "cur", "++", ";", "if", "(", "c", "==", "'", "'", ")", "{", "if", "(", "cur", "[", "-2", "]", "==", "'", "'", ")", "break", ";", "if", "(", "CPP_OPTION", "(", "pfile", ",", "warn_comments", ")", "&&", "cur", "[", "0", "]", "==", "'", "'", "&&", "cur", "[", "1", "]", "!=", "'", "'", ")", "{", "buffer", "->", "cur", "=", "cur", ";", "cpp_warning_with_line", "(", "pfile", ",", "CPP_W_COMMENTS", ",", "pfile", "->", "line_table", "->", "highest_line", ",", "CPP_BUF_COL", "(", "buffer", ")", ",", "\"", "\\\"", "\\\"", "\"", ")", ";", "}", "}", "else", "if", "(", "c", "==", "'", "\\n", "'", ")", "{", "unsigned", "int", "cols", ";", "buffer", "->", "cur", "=", "cur", "-", "1", ";", "_cpp_process_line_notes", "(", "pfile", ",", "true", ")", ";", "if", "(", "buffer", "->", "next_line", ">=", "buffer", "->", "rlimit", ")", "return", "true", ";", "_cpp_clean_line", "(", "pfile", ")", ";", "cols", "=", "buffer", "->", "next_line", "-", "buffer", "->", "line_base", ";", "CPP_INCREMENT_LINE", "(", "pfile", ",", "cols", ")", ";", "cur", "=", "buffer", "->", "cur", ";", "}", "}", "buffer", "->", "cur", "=", "cur", ";", "_cpp_process_line_notes", "(", "pfile", ",", "true", ")", ";", "return", "false", ";", "}" ]
Skip a C-style block comment.
[ "Skip", "a", "C", "-", "style", "block", "comment", "." ]
[ "/* People like decorating comments with '*', so check for '/'\n\t instead for efficiency. */", "/* Warn about potential nested comments, but not if the '/'\n\t comes immediately before the true comment delimiter.\n\t Don't bother to get it right across escaped newlines. */" ]
[ { "param": "pfile", "type": "cpp_reader" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfile", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
lex_identifier_intern
cpp_hashnode
static cpp_hashnode * lex_identifier_intern (cpp_reader *pfile, const uchar *base) { cpp_hashnode *result; const uchar *cur; unsigned int len; unsigned int hash = HT_HASHSTEP (0, *base); cur = base + 1; while (ISIDNUM (*cur)) { hash = HT_HASHSTEP (hash, *cur); cur++; } len = cur - base; hash = HT_HASHFINISH (hash, len); result = CPP_HASHNODE (ht_lookup_with_hash (pfile->hash_table, base, len, hash, HT_ALLOC)); /* Rarely, identifiers require diagnostics when lexed. */ if (__builtin_expect ((result->flags & NODE_DIAGNOSTIC) && !pfile->state.skipping, 0)) { /* It is allowed to poison the same identifier twice. */ if ((result->flags & NODE_POISONED) && !pfile->state.poisoned_ok) cpp_error (pfile, CPP_DL_ERROR, "attempt to use poisoned \"%s\"", NODE_NAME (result)); /* Constraint 6.10.3.5: __VA_ARGS__ should only appear in the replacement list of a variadic macro. */ if (result == pfile->spec_nodes.n__VA_ARGS__ && !pfile->state.va_args_ok) cpp_error (pfile, CPP_DL_PEDWARN, "__VA_ARGS__ can only appear in the expansion" " of a C99 variadic macro"); /* For -Wc++-compat, warn about use of C++ named operators. */ if (result->flags & NODE_WARN_OPERATOR) cpp_warning (pfile, CPP_W_CXX_OPERATOR_NAMES, "identifier \"%s\" is a special operator name in C++", NODE_NAME (result)); } return result; }
/* Helper function to get the cpp_hashnode of the identifier BASE. */
Helper function to get the cpp_hashnode of the identifier BASE.
[ "Helper", "function", "to", "get", "the", "cpp_hashnode", "of", "the", "identifier", "BASE", "." ]
static cpp_hashnode * lex_identifier_intern (cpp_reader *pfile, const uchar *base) { cpp_hashnode *result; const uchar *cur; unsigned int len; unsigned int hash = HT_HASHSTEP (0, *base); cur = base + 1; while (ISIDNUM (*cur)) { hash = HT_HASHSTEP (hash, *cur); cur++; } len = cur - base; hash = HT_HASHFINISH (hash, len); result = CPP_HASHNODE (ht_lookup_with_hash (pfile->hash_table, base, len, hash, HT_ALLOC)); if (__builtin_expect ((result->flags & NODE_DIAGNOSTIC) && !pfile->state.skipping, 0)) { if ((result->flags & NODE_POISONED) && !pfile->state.poisoned_ok) cpp_error (pfile, CPP_DL_ERROR, "attempt to use poisoned \"%s\"", NODE_NAME (result)); if (result == pfile->spec_nodes.n__VA_ARGS__ && !pfile->state.va_args_ok) cpp_error (pfile, CPP_DL_PEDWARN, "__VA_ARGS__ can only appear in the expansion" " of a C99 variadic macro"); if (result->flags & NODE_WARN_OPERATOR) cpp_warning (pfile, CPP_W_CXX_OPERATOR_NAMES, "identifier \"%s\" is a special operator name in C++", NODE_NAME (result)); } return result; }
[ "static", "cpp_hashnode", "*", "lex_identifier_intern", "(", "cpp_reader", "*", "pfile", ",", "const", "uchar", "*", "base", ")", "{", "cpp_hashnode", "*", "result", ";", "const", "uchar", "*", "cur", ";", "unsigned", "int", "len", ";", "unsigned", "int", "hash", "=", "HT_HASHSTEP", "(", "0", ",", "*", "base", ")", ";", "cur", "=", "base", "+", "1", ";", "while", "(", "ISIDNUM", "(", "*", "cur", ")", ")", "{", "hash", "=", "HT_HASHSTEP", "(", "hash", ",", "*", "cur", ")", ";", "cur", "++", ";", "}", "len", "=", "cur", "-", "base", ";", "hash", "=", "HT_HASHFINISH", "(", "hash", ",", "len", ")", ";", "result", "=", "CPP_HASHNODE", "(", "ht_lookup_with_hash", "(", "pfile", "->", "hash_table", ",", "base", ",", "len", ",", "hash", ",", "HT_ALLOC", ")", ")", ";", "if", "(", "__builtin_expect", "(", "(", "result", "->", "flags", "&", "NODE_DIAGNOSTIC", ")", "&&", "!", "pfile", "->", "state", ".", "skipping", ",", "0", ")", ")", "{", "if", "(", "(", "result", "->", "flags", "&", "NODE_POISONED", ")", "&&", "!", "pfile", "->", "state", ".", "poisoned_ok", ")", "cpp_error", "(", "pfile", ",", "CPP_DL_ERROR", ",", "\"", "\\\"", "\\\"", "\"", ",", "NODE_NAME", "(", "result", ")", ")", ";", "if", "(", "result", "==", "pfile", "->", "spec_nodes", ".", "n__VA_ARGS__", "&&", "!", "pfile", "->", "state", ".", "va_args_ok", ")", "cpp_error", "(", "pfile", ",", "CPP_DL_PEDWARN", ",", "\"", "\"", "\"", "\"", ")", ";", "if", "(", "result", "->", "flags", "&", "NODE_WARN_OPERATOR", ")", "cpp_warning", "(", "pfile", ",", "CPP_W_CXX_OPERATOR_NAMES", ",", "\"", "\\\"", "\\\"", "\"", ",", "NODE_NAME", "(", "result", ")", ")", ";", "}", "return", "result", ";", "}" ]
Helper function to get the cpp_hashnode of the identifier BASE.
[ "Helper", "function", "to", "get", "the", "cpp_hashnode", "of", "the", "identifier", "BASE", "." ]
[ "/* Rarely, identifiers require diagnostics when lexed. */", "/* It is allowed to poison the same identifier twice. */", "/* Constraint 6.10.3.5: __VA_ARGS__ should only appear in the\n\t replacement list of a variadic macro. */", "/* For -Wc++-compat, warn about use of C++ named operators. */" ]
[ { "param": "pfile", "type": "cpp_reader" }, { "param": "base", "type": "uchar" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfile", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "base", "type": "uchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
lex_string
void
static void lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base) { bool saw_NUL = false; const uchar *cur; cppchar_t terminator; enum cpp_ttype type; cur = base; terminator = *cur++; if (terminator == 'L' || terminator == 'U') terminator = *cur++; else if (terminator == 'u') { terminator = *cur++; if (terminator == '8') terminator = *cur++; } if (terminator == 'R') { lex_raw_string (pfile, token, base, cur); return; } if (terminator == '"') type = (*base == 'L' ? CPP_WSTRING : *base == 'U' ? CPP_STRING32 : *base == 'u' ? (base[1] == '8' ? CPP_UTF8STRING : CPP_STRING16) : CPP_STRING); else if (terminator == '\'') type = (*base == 'L' ? CPP_WCHAR : *base == 'U' ? CPP_CHAR32 : *base == 'u' ? CPP_CHAR16 : CPP_CHAR); else terminator = '>', type = CPP_HEADER_NAME; for (;;) { cppchar_t c = *cur++; /* In #include-style directives, terminators are not escapable. */ if (c == '\\' && !pfile->state.angled_headers && *cur != '\n') cur++; else if (c == terminator) break; else if (c == '\n') { cur--; /* Unmatched quotes always yield undefined behavior, but greedy lexing means that what appears to be an unterminated header name may actually be a legitimate sequence of tokens. */ if (terminator == '>') { token->type = CPP_LESS; return; } type = CPP_OTHER; break; } else if (c == '\0') saw_NUL = true; } if (saw_NUL && !pfile->state.skipping) cpp_error (pfile, CPP_DL_WARNING, "null character(s) preserved in literal"); if (type == CPP_OTHER && CPP_OPTION (pfile, lang) != CLK_ASM) cpp_error (pfile, CPP_DL_PEDWARN, "missing terminating %c character", (int) terminator); if (CPP_OPTION (pfile, user_literals)) { /* Grab user defined literal suffix. */ if (ISIDST (*cur)) { type = cpp_userdef_char_add_type (type); type = cpp_userdef_string_add_type (type); ++cur; } while (ISIDNUM (*cur)) ++cur; } pfile->buffer->cur = cur; create_literal (pfile, token, base, cur - base, type); }
/* Lexes a string, character constant, or angle-bracketed header file name. The stored string contains the spelling, including opening quote and any leading 'L', 'u', 'U' or 'u8' and optional 'R' modifier. It returns the type of the literal, or CPP_OTHER if it was not properly terminated, or CPP_LESS for an unterminated header name which must be relexed as normal tokens. The spelling is NUL-terminated, but it is not guaranteed that this is the first NUL since embedded NULs are preserved. */
Lexes a string, character constant, or angle-bracketed header file name. The spelling is NUL-terminated, but it is not guaranteed that this is the first NUL since embedded NULs are preserved.
[ "Lexes", "a", "string", "character", "constant", "or", "angle", "-", "bracketed", "header", "file", "name", ".", "The", "spelling", "is", "NUL", "-", "terminated", "but", "it", "is", "not", "guaranteed", "that", "this", "is", "the", "first", "NUL", "since", "embedded", "NULs", "are", "preserved", "." ]
static void lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base) { bool saw_NUL = false; const uchar *cur; cppchar_t terminator; enum cpp_ttype type; cur = base; terminator = *cur++; if (terminator == 'L' || terminator == 'U') terminator = *cur++; else if (terminator == 'u') { terminator = *cur++; if (terminator == '8') terminator = *cur++; } if (terminator == 'R') { lex_raw_string (pfile, token, base, cur); return; } if (terminator == '"') type = (*base == 'L' ? CPP_WSTRING : *base == 'U' ? CPP_STRING32 : *base == 'u' ? (base[1] == '8' ? CPP_UTF8STRING : CPP_STRING16) : CPP_STRING); else if (terminator == '\'') type = (*base == 'L' ? CPP_WCHAR : *base == 'U' ? CPP_CHAR32 : *base == 'u' ? CPP_CHAR16 : CPP_CHAR); else terminator = '>', type = CPP_HEADER_NAME; for (;;) { cppchar_t c = *cur++; if (c == '\\' && !pfile->state.angled_headers && *cur != '\n') cur++; else if (c == terminator) break; else if (c == '\n') { cur--; if (terminator == '>') { token->type = CPP_LESS; return; } type = CPP_OTHER; break; } else if (c == '\0') saw_NUL = true; } if (saw_NUL && !pfile->state.skipping) cpp_error (pfile, CPP_DL_WARNING, "null character(s) preserved in literal"); if (type == CPP_OTHER && CPP_OPTION (pfile, lang) != CLK_ASM) cpp_error (pfile, CPP_DL_PEDWARN, "missing terminating %c character", (int) terminator); if (CPP_OPTION (pfile, user_literals)) { if (ISIDST (*cur)) { type = cpp_userdef_char_add_type (type); type = cpp_userdef_string_add_type (type); ++cur; } while (ISIDNUM (*cur)) ++cur; } pfile->buffer->cur = cur; create_literal (pfile, token, base, cur - base, type); }
[ "static", "void", "lex_string", "(", "cpp_reader", "*", "pfile", ",", "cpp_token", "*", "token", ",", "const", "uchar", "*", "base", ")", "{", "bool", "saw_NUL", "=", "false", ";", "const", "uchar", "*", "cur", ";", "cppchar_t", "terminator", ";", "enum", "cpp_ttype", "type", ";", "cur", "=", "base", ";", "terminator", "=", "*", "cur", "++", ";", "if", "(", "terminator", "==", "'", "'", "||", "terminator", "==", "'", "'", ")", "terminator", "=", "*", "cur", "++", ";", "else", "if", "(", "terminator", "==", "'", "'", ")", "{", "terminator", "=", "*", "cur", "++", ";", "if", "(", "terminator", "==", "'", "'", ")", "terminator", "=", "*", "cur", "++", ";", "}", "if", "(", "terminator", "==", "'", "'", ")", "{", "lex_raw_string", "(", "pfile", ",", "token", ",", "base", ",", "cur", ")", ";", "return", ";", "}", "if", "(", "terminator", "==", "'", "'", ")", "type", "=", "(", "*", "base", "==", "'", "'", "?", "CPP_WSTRING", ":", "*", "base", "==", "'", "'", "?", "CPP_STRING32", ":", "*", "base", "==", "'", "'", "?", "(", "base", "[", "1", "]", "==", "'", "'", "?", "CPP_UTF8STRING", ":", "CPP_STRING16", ")", ":", "CPP_STRING", ")", ";", "else", "if", "(", "terminator", "==", "'", "\\'", "'", ")", "type", "=", "(", "*", "base", "==", "'", "'", "?", "CPP_WCHAR", ":", "*", "base", "==", "'", "'", "?", "CPP_CHAR32", ":", "*", "base", "==", "'", "'", "?", "CPP_CHAR16", ":", "CPP_CHAR", ")", ";", "else", "terminator", "=", "'", "'", ",", "type", "=", "CPP_HEADER_NAME", ";", "for", "(", ";", ";", ")", "{", "cppchar_t", "c", "=", "*", "cur", "++", ";", "if", "(", "c", "==", "'", "\\\\", "'", "&&", "!", "pfile", "->", "state", ".", "angled_headers", "&&", "*", "cur", "!=", "'", "\\n", "'", ")", "cur", "++", ";", "else", "if", "(", "c", "==", "terminator", ")", "break", ";", "else", "if", "(", "c", "==", "'", "\\n", "'", ")", "{", "cur", "--", ";", "if", "(", "terminator", "==", "'", "'", ")", "{", "token", "->", "type", "=", "CPP_LESS", ";", "return", ";", "}", "type", "=", "CPP_OTHER", ";", "break", ";", "}", "else", "if", "(", "c", "==", "'", "\\0", "'", ")", "saw_NUL", "=", "true", ";", "}", "if", "(", "saw_NUL", "&&", "!", "pfile", "->", "state", ".", "skipping", ")", "cpp_error", "(", "pfile", ",", "CPP_DL_WARNING", ",", "\"", "\"", ")", ";", "if", "(", "type", "==", "CPP_OTHER", "&&", "CPP_OPTION", "(", "pfile", ",", "lang", ")", "!=", "CLK_ASM", ")", "cpp_error", "(", "pfile", ",", "CPP_DL_PEDWARN", ",", "\"", "\"", ",", "(", "int", ")", "terminator", ")", ";", "if", "(", "CPP_OPTION", "(", "pfile", ",", "user_literals", ")", ")", "{", "if", "(", "ISIDST", "(", "*", "cur", ")", ")", "{", "type", "=", "cpp_userdef_char_add_type", "(", "type", ")", ";", "type", "=", "cpp_userdef_string_add_type", "(", "type", ")", ";", "++", "cur", ";", "}", "while", "(", "ISIDNUM", "(", "*", "cur", ")", ")", "++", "cur", ";", "}", "pfile", "->", "buffer", "->", "cur", "=", "cur", ";", "create_literal", "(", "pfile", ",", "token", ",", "base", ",", "cur", "-", "base", ",", "type", ")", ";", "}" ]
Lexes a string, character constant, or angle-bracketed header file name.
[ "Lexes", "a", "string", "character", "constant", "or", "angle", "-", "bracketed", "header", "file", "name", "." ]
[ "/* In #include-style directives, terminators are not escapable. */", "/* Unmatched quotes always yield undefined behavior, but\n\t greedy lexing means that what appears to be an unterminated\n\t header name may actually be a legitimate sequence of tokens. */", "/* Grab user defined literal suffix. */" ]
[ { "param": "pfile", "type": "cpp_reader" }, { "param": "token", "type": "cpp_token" }, { "param": "base", "type": "uchar" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfile", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "token", "type": "cpp_token", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "base", "type": "uchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
save_comment
void
static void save_comment (cpp_reader *pfile, cpp_token *token, const unsigned char *from, cppchar_t type) { unsigned char *buffer; unsigned int len, clen, i; len = pfile->buffer->cur - from + 1; /* + 1 for the initial '/'. */ /* C++ comments probably (not definitely) have moved past a new line, which we don't want to save in the comment. */ if (is_vspace (pfile->buffer->cur[-1])) len--; /* If we are currently in a directive or in argument parsing, then we need to store all C++ comments as C comments internally, and so we need to allocate a little extra space in that case. Note that the only time we encounter a directive here is when we are saving comments in a "#define". */ clen = ((pfile->state.in_directive || pfile->state.parsing_args) && type == '/') ? len + 2 : len; buffer = _cpp_unaligned_alloc (pfile, clen); token->type = CPP_COMMENT; token->val.str.len = clen; token->val.str.text = buffer; buffer[0] = '/'; memcpy (buffer + 1, from, len - 1); /* Finish conversion to a C comment, if necessary. */ if ((pfile->state.in_directive || pfile->state.parsing_args) && type == '/') { buffer[1] = '*'; buffer[clen - 2] = '*'; buffer[clen - 1] = '/'; /* As there can be in a C++ comments illegal sequences for C comments we need to filter them out. */ for (i = 2; i < (clen - 2); i++) if (buffer[i] == '/' && (buffer[i - 1] == '*' || buffer[i + 1] == '*')) buffer[i] = '|'; } /* Finally store this comment for use by clients of libcpp. */ store_comment (pfile, token); }
/* The stored comment includes the comment start and any terminator. */
The stored comment includes the comment start and any terminator.
[ "The", "stored", "comment", "includes", "the", "comment", "start", "and", "any", "terminator", "." ]
static void save_comment (cpp_reader *pfile, cpp_token *token, const unsigned char *from, cppchar_t type) { unsigned char *buffer; unsigned int len, clen, i; len = pfile->buffer->cur - from + 1; if (is_vspace (pfile->buffer->cur[-1])) len--; clen = ((pfile->state.in_directive || pfile->state.parsing_args) && type == '/') ? len + 2 : len; buffer = _cpp_unaligned_alloc (pfile, clen); token->type = CPP_COMMENT; token->val.str.len = clen; token->val.str.text = buffer; buffer[0] = '/'; memcpy (buffer + 1, from, len - 1); if ((pfile->state.in_directive || pfile->state.parsing_args) && type == '/') { buffer[1] = '*'; buffer[clen - 2] = '*'; buffer[clen - 1] = '/'; for (i = 2; i < (clen - 2); i++) if (buffer[i] == '/' && (buffer[i - 1] == '*' || buffer[i + 1] == '*')) buffer[i] = '|'; } store_comment (pfile, token); }
[ "static", "void", "save_comment", "(", "cpp_reader", "*", "pfile", ",", "cpp_token", "*", "token", ",", "const", "unsigned", "char", "*", "from", ",", "cppchar_t", "type", ")", "{", "unsigned", "char", "*", "buffer", ";", "unsigned", "int", "len", ",", "clen", ",", "i", ";", "len", "=", "pfile", "->", "buffer", "->", "cur", "-", "from", "+", "1", ";", "if", "(", "is_vspace", "(", "pfile", "->", "buffer", "->", "cur", "[", "-1", "]", ")", ")", "len", "--", ";", "clen", "=", "(", "(", "pfile", "->", "state", ".", "in_directive", "||", "pfile", "->", "state", ".", "parsing_args", ")", "&&", "type", "==", "'", "'", ")", "?", "len", "+", "2", ":", "len", ";", "buffer", "=", "_cpp_unaligned_alloc", "(", "pfile", ",", "clen", ")", ";", "token", "->", "type", "=", "CPP_COMMENT", ";", "token", "->", "val", ".", "str", ".", "len", "=", "clen", ";", "token", "->", "val", ".", "str", ".", "text", "=", "buffer", ";", "buffer", "[", "0", "]", "=", "'", "'", ";", "memcpy", "(", "buffer", "+", "1", ",", "from", ",", "len", "-", "1", ")", ";", "if", "(", "(", "pfile", "->", "state", ".", "in_directive", "||", "pfile", "->", "state", ".", "parsing_args", ")", "&&", "type", "==", "'", "'", ")", "{", "buffer", "[", "1", "]", "=", "'", "'", ";", "buffer", "[", "clen", "-", "2", "]", "=", "'", "'", ";", "buffer", "[", "clen", "-", "1", "]", "=", "'", "'", ";", "for", "(", "i", "=", "2", ";", "i", "<", "(", "clen", "-", "2", ")", ";", "i", "++", ")", "if", "(", "buffer", "[", "i", "]", "==", "'", "'", "&&", "(", "buffer", "[", "i", "-", "1", "]", "==", "'", "'", "||", "buffer", "[", "i", "+", "1", "]", "==", "'", "'", ")", ")", "buffer", "[", "i", "]", "=", "'", "'", ";", "}", "store_comment", "(", "pfile", ",", "token", ")", ";", "}" ]
The stored comment includes the comment start and any terminator.
[ "The", "stored", "comment", "includes", "the", "comment", "start", "and", "any", "terminator", "." ]
[ "/* + 1 for the initial '/'. */", "/* C++ comments probably (not definitely) have moved past a new\n line, which we don't want to save in the comment. */", "/* If we are currently in a directive or in argument parsing, then\n we need to store all C++ comments as C comments internally, and\n so we need to allocate a little extra space in that case.\n\n Note that the only time we encounter a directive here is\n when we are saving comments in a \"#define\". */", "/* Finish conversion to a C comment, if necessary. */", "/* As there can be in a C++ comments illegal sequences for C comments\n we need to filter them out. */", "/* Finally store this comment for use by clients of libcpp. */" ]
[ { "param": "pfile", "type": "cpp_reader" }, { "param": "token", "type": "cpp_token" }, { "param": "from", "type": "unsigned char" }, { "param": "type", "type": "cppchar_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfile", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "token", "type": "cpp_token", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "from", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "type", "type": "cppchar_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
_cpp_token_from_context_at
cpp_token
static const cpp_token* _cpp_token_from_context_at (cpp_context *context, int index) { if (context->tokens_kind == TOKENS_KIND_DIRECT) return &(FIRST (context).token[index]); else if (context->tokens_kind == TOKENS_KIND_INDIRECT || context->tokens_kind == TOKENS_KIND_EXTENDED) return FIRST (context).ptoken[index]; else abort (); }
/* Returns the token present at index INDEX in a given context. If INDEX is zero, the next token to be processed is returned. */
Returns the token present at index INDEX in a given context. If INDEX is zero, the next token to be processed is returned.
[ "Returns", "the", "token", "present", "at", "index", "INDEX", "in", "a", "given", "context", ".", "If", "INDEX", "is", "zero", "the", "next", "token", "to", "be", "processed", "is", "returned", "." ]
static const cpp_token* _cpp_token_from_context_at (cpp_context *context, int index) { if (context->tokens_kind == TOKENS_KIND_DIRECT) return &(FIRST (context).token[index]); else if (context->tokens_kind == TOKENS_KIND_INDIRECT || context->tokens_kind == TOKENS_KIND_EXTENDED) return FIRST (context).ptoken[index]; else abort (); }
[ "static", "const", "cpp_token", "*", "_cpp_token_from_context_at", "(", "cpp_context", "*", "context", ",", "int", "index", ")", "{", "if", "(", "context", "->", "tokens_kind", "==", "TOKENS_KIND_DIRECT", ")", "return", "&", "(", "FIRST", "(", "context", ")", ".", "token", "[", "index", "]", ")", ";", "else", "if", "(", "context", "->", "tokens_kind", "==", "TOKENS_KIND_INDIRECT", "||", "context", "->", "tokens_kind", "==", "TOKENS_KIND_EXTENDED", ")", "return", "FIRST", "(", "context", ")", ".", "ptoken", "[", "index", "]", ";", "else", "abort", "(", ")", ";", "}" ]
Returns the token present at index INDEX in a given context.
[ "Returns", "the", "token", "present", "at", "index", "INDEX", "in", "a", "given", "context", "." ]
[]
[ { "param": "context", "type": "cpp_context" }, { "param": "index", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "context", "type": "cpp_context", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
cpp_peek_token
cpp_token
const cpp_token * cpp_peek_token (cpp_reader *pfile, int index) { cpp_context *context = pfile->context; const cpp_token *peektok; int count; /* First, scan through any pending cpp_context objects. */ while (context->prev) { ptrdiff_t sz = _cpp_remaining_tokens_num_in_context (context); if (index < (int) sz) return _cpp_token_from_context_at (context, index); index -= (int) sz; context = context->prev; } /* We will have to read some new tokens after all (and do so without invalidating preceding tokens). */ count = index; pfile->keep_tokens++; do { peektok = _cpp_lex_token (pfile); if (peektok->type == CPP_EOF) return peektok; } while (index--); _cpp_backup_tokens_direct (pfile, count + 1); pfile->keep_tokens--; return peektok; }
/* Look ahead in the input stream. */
Look ahead in the input stream.
[ "Look", "ahead", "in", "the", "input", "stream", "." ]
const cpp_token * cpp_peek_token (cpp_reader *pfile, int index) { cpp_context *context = pfile->context; const cpp_token *peektok; int count; while (context->prev) { ptrdiff_t sz = _cpp_remaining_tokens_num_in_context (context); if (index < (int) sz) return _cpp_token_from_context_at (context, index); index -= (int) sz; context = context->prev; } count = index; pfile->keep_tokens++; do { peektok = _cpp_lex_token (pfile); if (peektok->type == CPP_EOF) return peektok; } while (index--); _cpp_backup_tokens_direct (pfile, count + 1); pfile->keep_tokens--; return peektok; }
[ "const", "cpp_token", "*", "cpp_peek_token", "(", "cpp_reader", "*", "pfile", ",", "int", "index", ")", "{", "cpp_context", "*", "context", "=", "pfile", "->", "context", ";", "const", "cpp_token", "*", "peektok", ";", "int", "count", ";", "while", "(", "context", "->", "prev", ")", "{", "ptrdiff_t", "sz", "=", "_cpp_remaining_tokens_num_in_context", "(", "context", ")", ";", "if", "(", "index", "<", "(", "int", ")", "sz", ")", "return", "_cpp_token_from_context_at", "(", "context", ",", "index", ")", ";", "index", "-=", "(", "int", ")", "sz", ";", "context", "=", "context", "->", "prev", ";", "}", "count", "=", "index", ";", "pfile", "->", "keep_tokens", "++", ";", "do", "{", "peektok", "=", "_cpp_lex_token", "(", "pfile", ")", ";", "if", "(", "peektok", "->", "type", "==", "CPP_EOF", ")", "return", "peektok", ";", "}", "while", "(", "index", "--", ")", ";", "_cpp_backup_tokens_direct", "(", "pfile", ",", "count", "+", "1", ")", ";", "pfile", "->", "keep_tokens", "--", ";", "return", "peektok", ";", "}" ]
Look ahead in the input stream.
[ "Look", "ahead", "in", "the", "input", "stream", "." ]
[ "/* First, scan through any pending cpp_context objects. */", "/* We will have to read some new tokens after all (and do so\n without invalidating preceding tokens). */" ]
[ { "param": "pfile", "type": "cpp_reader" }, { "param": "index", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfile", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
cpp_token_len
null
unsigned int cpp_token_len (const cpp_token *token) { unsigned int len; switch (TOKEN_SPELL (token)) { default: len = 6; break; case SPELL_LITERAL: len = token->val.str.len; break; case SPELL_IDENT: len = NODE_LEN (token->val.node.node) * 10; break; } return len; }
/* An upper bound on the number of bytes needed to spell TOKEN. Does not include preceding whitespace. */
An upper bound on the number of bytes needed to spell TOKEN. Does not include preceding whitespace.
[ "An", "upper", "bound", "on", "the", "number", "of", "bytes", "needed", "to", "spell", "TOKEN", ".", "Does", "not", "include", "preceding", "whitespace", "." ]
unsigned int cpp_token_len (const cpp_token *token) { unsigned int len; switch (TOKEN_SPELL (token)) { default: len = 6; break; case SPELL_LITERAL: len = token->val.str.len; break; case SPELL_IDENT: len = NODE_LEN (token->val.node.node) * 10; break; } return len; }
[ "unsigned", "int", "cpp_token_len", "(", "const", "cpp_token", "*", "token", ")", "{", "unsigned", "int", "len", ";", "switch", "(", "TOKEN_SPELL", "(", "token", ")", ")", "{", "default", ":", "len", "=", "6", ";", "break", ";", "case", "SPELL_LITERAL", ":", "len", "=", "token", "->", "val", ".", "str", ".", "len", ";", "break", ";", "case", "SPELL_IDENT", ":", "len", "=", "NODE_LEN", "(", "token", "->", "val", ".", "node", ".", "node", ")", "*", "10", ";", "break", ";", "}", "return", "len", ";", "}" ]
An upper bound on the number of bytes needed to spell TOKEN.
[ "An", "upper", "bound", "on", "the", "number", "of", "bytes", "needed", "to", "spell", "TOKEN", "." ]
[]
[ { "param": "token", "type": "cpp_token" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "token", "type": "cpp_token", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
cpp_digraph2name
null
static const unsigned char * cpp_digraph2name (enum cpp_ttype type) { return digraph_spellings[(int) type - (int) CPP_FIRST_DIGRAPH]; }
/* Given a token TYPE corresponding to a digraph, return a pointer to the spelling of the digraph. */
Given a token TYPE corresponding to a digraph, return a pointer to the spelling of the digraph.
[ "Given", "a", "token", "TYPE", "corresponding", "to", "a", "digraph", "return", "a", "pointer", "to", "the", "spelling", "of", "the", "digraph", "." ]
static const unsigned char * cpp_digraph2name (enum cpp_ttype type) { return digraph_spellings[(int) type - (int) CPP_FIRST_DIGRAPH]; }
[ "static", "const", "unsigned", "char", "*", "cpp_digraph2name", "(", "enum", "cpp_ttype", "type", ")", "{", "return", "digraph_spellings", "[", "(", "int", ")", "type", "-", "(", "int", ")", "CPP_FIRST_DIGRAPH", "]", ";", "}" ]
Given a token TYPE corresponding to a digraph, return a pointer to the spelling of the digraph.
[ "Given", "a", "token", "TYPE", "corresponding", "to", "a", "digraph", "return", "a", "pointer", "to", "the", "spelling", "of", "the", "digraph", "." ]
[]
[ { "param": "type", "type": "enum cpp_ttype" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "enum cpp_ttype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
cpp_spell_token
null
unsigned char * cpp_spell_token (cpp_reader *pfile, const cpp_token *token, unsigned char *buffer, bool forstring) { switch (TOKEN_SPELL (token)) { case SPELL_OPERATOR: { const unsigned char *spelling; unsigned char c; if (token->flags & DIGRAPH) spelling = cpp_digraph2name (token->type); else if (token->flags & NAMED_OP) goto spell_ident; else spelling = TOKEN_NAME (token); while ((c = *spelling++) != '\0') *buffer++ = c; } break; spell_ident: case SPELL_IDENT: if (forstring) { memcpy (buffer, NODE_NAME (token->val.node.node), NODE_LEN (token->val.node.node)); buffer += NODE_LEN (token->val.node.node); } else { size_t i; const unsigned char * name = NODE_NAME (token->val.node.node); for (i = 0; i < NODE_LEN (token->val.node.node); i++) if (name[i] & ~0x7F) { i += utf8_to_ucn (buffer, name + i) - 1; buffer += 10; } else *buffer++ = NODE_NAME (token->val.node.node)[i]; } break; case SPELL_LITERAL: memcpy (buffer, token->val.str.text, token->val.str.len); buffer += token->val.str.len; break; case SPELL_NONE: cpp_error (pfile, CPP_DL_ICE, "unspellable token %s", TOKEN_NAME (token)); break; } return buffer; }
/* Write the spelling of a token TOKEN to BUFFER. The buffer must already contain the enough space to hold the token's spelling. Returns a pointer to the character after the last character written. FORSTRING is true if this is to be the spelling after translation phase 1 (this is different for UCNs). FIXME: Would be nice if we didn't need the PFILE argument. */
Write the spelling of a token TOKEN to BUFFER. The buffer must already contain the enough space to hold the token's spelling. Returns a pointer to the character after the last character written. FORSTRING is true if this is to be the spelling after translation phase 1 (this is different for UCNs). FIXME: Would be nice if we didn't need the PFILE argument.
[ "Write", "the", "spelling", "of", "a", "token", "TOKEN", "to", "BUFFER", ".", "The", "buffer", "must", "already", "contain", "the", "enough", "space", "to", "hold", "the", "token", "'", "s", "spelling", ".", "Returns", "a", "pointer", "to", "the", "character", "after", "the", "last", "character", "written", ".", "FORSTRING", "is", "true", "if", "this", "is", "to", "be", "the", "spelling", "after", "translation", "phase", "1", "(", "this", "is", "different", "for", "UCNs", ")", ".", "FIXME", ":", "Would", "be", "nice", "if", "we", "didn", "'", "t", "need", "the", "PFILE", "argument", "." ]
unsigned char * cpp_spell_token (cpp_reader *pfile, const cpp_token *token, unsigned char *buffer, bool forstring) { switch (TOKEN_SPELL (token)) { case SPELL_OPERATOR: { const unsigned char *spelling; unsigned char c; if (token->flags & DIGRAPH) spelling = cpp_digraph2name (token->type); else if (token->flags & NAMED_OP) goto spell_ident; else spelling = TOKEN_NAME (token); while ((c = *spelling++) != '\0') *buffer++ = c; } break; spell_ident: case SPELL_IDENT: if (forstring) { memcpy (buffer, NODE_NAME (token->val.node.node), NODE_LEN (token->val.node.node)); buffer += NODE_LEN (token->val.node.node); } else { size_t i; const unsigned char * name = NODE_NAME (token->val.node.node); for (i = 0; i < NODE_LEN (token->val.node.node); i++) if (name[i] & ~0x7F) { i += utf8_to_ucn (buffer, name + i) - 1; buffer += 10; } else *buffer++ = NODE_NAME (token->val.node.node)[i]; } break; case SPELL_LITERAL: memcpy (buffer, token->val.str.text, token->val.str.len); buffer += token->val.str.len; break; case SPELL_NONE: cpp_error (pfile, CPP_DL_ICE, "unspellable token %s", TOKEN_NAME (token)); break; } return buffer; }
[ "unsigned", "char", "*", "cpp_spell_token", "(", "cpp_reader", "*", "pfile", ",", "const", "cpp_token", "*", "token", ",", "unsigned", "char", "*", "buffer", ",", "bool", "forstring", ")", "{", "switch", "(", "TOKEN_SPELL", "(", "token", ")", ")", "{", "case", "SPELL_OPERATOR", ":", "{", "const", "unsigned", "char", "*", "spelling", ";", "unsigned", "char", "c", ";", "if", "(", "token", "->", "flags", "&", "DIGRAPH", ")", "spelling", "=", "cpp_digraph2name", "(", "token", "->", "type", ")", ";", "else", "if", "(", "token", "->", "flags", "&", "NAMED_OP", ")", "goto", "spell_ident", ";", "else", "spelling", "=", "TOKEN_NAME", "(", "token", ")", ";", "while", "(", "(", "c", "=", "*", "spelling", "++", ")", "!=", "'", "\\0", "'", ")", "*", "buffer", "++", "=", "c", ";", "}", "break", ";", "spell_ident", ":", "case", "SPELL_IDENT", ":", "if", "(", "forstring", ")", "{", "memcpy", "(", "buffer", ",", "NODE_NAME", "(", "token", "->", "val", ".", "node", ".", "node", ")", ",", "NODE_LEN", "(", "token", "->", "val", ".", "node", ".", "node", ")", ")", ";", "buffer", "+=", "NODE_LEN", "(", "token", "->", "val", ".", "node", ".", "node", ")", ";", "}", "else", "{", "size_t", "i", ";", "const", "unsigned", "char", "*", "name", "=", "NODE_NAME", "(", "token", "->", "val", ".", "node", ".", "node", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NODE_LEN", "(", "token", "->", "val", ".", "node", ".", "node", ")", ";", "i", "++", ")", "if", "(", "name", "[", "i", "]", "&", "~", "0x7F", ")", "{", "i", "+=", "utf8_to_ucn", "(", "buffer", ",", "name", "+", "i", ")", "-", "1", ";", "buffer", "+=", "10", ";", "}", "else", "*", "buffer", "++", "=", "NODE_NAME", "(", "token", "->", "val", ".", "node", ".", "node", ")", "[", "i", "]", ";", "}", "break", ";", "case", "SPELL_LITERAL", ":", "memcpy", "(", "buffer", ",", "token", "->", "val", ".", "str", ".", "text", ",", "token", "->", "val", ".", "str", ".", "len", ")", ";", "buffer", "+=", "token", "->", "val", ".", "str", ".", "len", ";", "break", ";", "case", "SPELL_NONE", ":", "cpp_error", "(", "pfile", ",", "CPP_DL_ICE", ",", "\"", "\"", ",", "TOKEN_NAME", "(", "token", ")", ")", ";", "break", ";", "}", "return", "buffer", ";", "}" ]
Write the spelling of a token TOKEN to BUFFER.
[ "Write", "the", "spelling", "of", "a", "token", "TOKEN", "to", "BUFFER", "." ]
[]
[ { "param": "pfile", "type": "cpp_reader" }, { "param": "token", "type": "cpp_token" }, { "param": "buffer", "type": "unsigned char" }, { "param": "forstring", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pfile", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "token", "type": "cpp_token", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buffer", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "forstring", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
cpp_type2name
char
const char * cpp_type2name (enum cpp_ttype type, unsigned char flags) { if (flags & DIGRAPH) return (const char *) cpp_digraph2name (type); else if (flags & NAMED_OP) return cpp_named_operator2name (type); return (const char *) token_spellings[type].name; }
/* Returns a pointer to a string which spells the token defined by TYPE and FLAGS. Used by C front ends, which really should move to using cpp_token_as_text. */
Returns a pointer to a string which spells the token defined by TYPE and FLAGS. Used by C front ends, which really should move to using cpp_token_as_text.
[ "Returns", "a", "pointer", "to", "a", "string", "which", "spells", "the", "token", "defined", "by", "TYPE", "and", "FLAGS", ".", "Used", "by", "C", "front", "ends", "which", "really", "should", "move", "to", "using", "cpp_token_as_text", "." ]
const char * cpp_type2name (enum cpp_ttype type, unsigned char flags) { if (flags & DIGRAPH) return (const char *) cpp_digraph2name (type); else if (flags & NAMED_OP) return cpp_named_operator2name (type); return (const char *) token_spellings[type].name; }
[ "const", "char", "*", "cpp_type2name", "(", "enum", "cpp_ttype", "type", ",", "unsigned", "char", "flags", ")", "{", "if", "(", "flags", "&", "DIGRAPH", ")", "return", "(", "const", "char", "*", ")", "cpp_digraph2name", "(", "type", ")", ";", "else", "if", "(", "flags", "&", "NAMED_OP", ")", "return", "cpp_named_operator2name", "(", "type", ")", ";", "return", "(", "const", "char", "*", ")", "token_spellings", "[", "type", "]", ".", "name", ";", "}" ]
Returns a pointer to a string which spells the token defined by TYPE and FLAGS.
[ "Returns", "a", "pointer", "to", "a", "string", "which", "spells", "the", "token", "defined", "by", "TYPE", "and", "FLAGS", "." ]
[]
[ { "param": "type", "type": "enum cpp_ttype" }, { "param": "flags", "type": "unsigned char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "enum cpp_ttype", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": "unsigned char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
cpp_output_token
void
void cpp_output_token (const cpp_token *token, FILE *fp) { switch (TOKEN_SPELL (token)) { case SPELL_OPERATOR: { const unsigned char *spelling; int c; if (token->flags & DIGRAPH) spelling = cpp_digraph2name (token->type); else if (token->flags & NAMED_OP) goto spell_ident; else spelling = TOKEN_NAME (token); c = *spelling; do putc (c, fp); while ((c = *++spelling) != '\0'); } break; spell_ident: case SPELL_IDENT: { size_t i; const unsigned char * name = NODE_NAME (token->val.node.node); for (i = 0; i < NODE_LEN (token->val.node.node); i++) if (name[i] & ~0x7F) { unsigned char buffer[10]; i += utf8_to_ucn (buffer, name + i) - 1; fwrite (buffer, 1, 10, fp); } else fputc (NODE_NAME (token->val.node.node)[i], fp); } break; case SPELL_LITERAL: fwrite (token->val.str.text, 1, token->val.str.len, fp); break; case SPELL_NONE: /* An error, most probably. */ break; } }
/* Writes the spelling of token to FP, without any preceding space. Separated from cpp_spell_token for efficiency - to avoid stdio double-buffering. */
Writes the spelling of token to FP, without any preceding space. Separated from cpp_spell_token for efficiency - to avoid stdio double-buffering.
[ "Writes", "the", "spelling", "of", "token", "to", "FP", "without", "any", "preceding", "space", ".", "Separated", "from", "cpp_spell_token", "for", "efficiency", "-", "to", "avoid", "stdio", "double", "-", "buffering", "." ]
void cpp_output_token (const cpp_token *token, FILE *fp) { switch (TOKEN_SPELL (token)) { case SPELL_OPERATOR: { const unsigned char *spelling; int c; if (token->flags & DIGRAPH) spelling = cpp_digraph2name (token->type); else if (token->flags & NAMED_OP) goto spell_ident; else spelling = TOKEN_NAME (token); c = *spelling; do putc (c, fp); while ((c = *++spelling) != '\0'); } break; spell_ident: case SPELL_IDENT: { size_t i; const unsigned char * name = NODE_NAME (token->val.node.node); for (i = 0; i < NODE_LEN (token->val.node.node); i++) if (name[i] & ~0x7F) { unsigned char buffer[10]; i += utf8_to_ucn (buffer, name + i) - 1; fwrite (buffer, 1, 10, fp); } else fputc (NODE_NAME (token->val.node.node)[i], fp); } break; case SPELL_LITERAL: fwrite (token->val.str.text, 1, token->val.str.len, fp); break; case SPELL_NONE: break; } }
[ "void", "cpp_output_token", "(", "const", "cpp_token", "*", "token", ",", "FILE", "*", "fp", ")", "{", "switch", "(", "TOKEN_SPELL", "(", "token", ")", ")", "{", "case", "SPELL_OPERATOR", ":", "{", "const", "unsigned", "char", "*", "spelling", ";", "int", "c", ";", "if", "(", "token", "->", "flags", "&", "DIGRAPH", ")", "spelling", "=", "cpp_digraph2name", "(", "token", "->", "type", ")", ";", "else", "if", "(", "token", "->", "flags", "&", "NAMED_OP", ")", "goto", "spell_ident", ";", "else", "spelling", "=", "TOKEN_NAME", "(", "token", ")", ";", "c", "=", "*", "spelling", ";", "do", "putc", "(", "c", ",", "fp", ")", ";", "while", "(", "(", "c", "=", "*", "++", "spelling", ")", "!=", "'", "\\0", "'", ")", ";", "}", "break", ";", "spell_ident", ":", "case", "SPELL_IDENT", ":", "{", "size_t", "i", ";", "const", "unsigned", "char", "*", "name", "=", "NODE_NAME", "(", "token", "->", "val", ".", "node", ".", "node", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "NODE_LEN", "(", "token", "->", "val", ".", "node", ".", "node", ")", ";", "i", "++", ")", "if", "(", "name", "[", "i", "]", "&", "~", "0x7F", ")", "{", "unsigned", "char", "buffer", "[", "10", "]", ";", "i", "+=", "utf8_to_ucn", "(", "buffer", ",", "name", "+", "i", ")", "-", "1", ";", "fwrite", "(", "buffer", ",", "1", ",", "10", ",", "fp", ")", ";", "}", "else", "fputc", "(", "NODE_NAME", "(", "token", "->", "val", ".", "node", ".", "node", ")", "[", "i", "]", ",", "fp", ")", ";", "}", "break", ";", "case", "SPELL_LITERAL", ":", "fwrite", "(", "token", "->", "val", ".", "str", ".", "text", ",", "1", ",", "token", "->", "val", ".", "str", ".", "len", ",", "fp", ")", ";", "break", ";", "case", "SPELL_NONE", ":", "break", ";", "}", "}" ]
Writes the spelling of token to FP, without any preceding space.
[ "Writes", "the", "spelling", "of", "token", "to", "FP", "without", "any", "preceding", "space", "." ]
[ "/* An error, most probably. */" ]
[ { "param": "token", "type": "cpp_token" }, { "param": "fp", "type": "FILE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "token", "type": "cpp_token", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fp", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
cpp_token_val_index
null
enum cpp_token_fld_kind cpp_token_val_index (cpp_token *tok) { switch (TOKEN_SPELL (tok)) { case SPELL_IDENT: return CPP_TOKEN_FLD_NODE; case SPELL_LITERAL: return CPP_TOKEN_FLD_STR; case SPELL_OPERATOR: if (tok->type == CPP_PASTE) return CPP_TOKEN_FLD_TOKEN_NO; else return CPP_TOKEN_FLD_NONE; case SPELL_NONE: if (tok->type == CPP_MACRO_ARG) return CPP_TOKEN_FLD_ARG_NO; else if (tok->type == CPP_PADDING) return CPP_TOKEN_FLD_SOURCE; else if (tok->type == CPP_PRAGMA) return CPP_TOKEN_FLD_PRAGMA; /* else fall through */ default: return CPP_TOKEN_FLD_NONE; } }
/* Say which field of TOK is in use. */
Say which field of TOK is in use.
[ "Say", "which", "field", "of", "TOK", "is", "in", "use", "." ]
enum cpp_token_fld_kind cpp_token_val_index (cpp_token *tok) { switch (TOKEN_SPELL (tok)) { case SPELL_IDENT: return CPP_TOKEN_FLD_NODE; case SPELL_LITERAL: return CPP_TOKEN_FLD_STR; case SPELL_OPERATOR: if (tok->type == CPP_PASTE) return CPP_TOKEN_FLD_TOKEN_NO; else return CPP_TOKEN_FLD_NONE; case SPELL_NONE: if (tok->type == CPP_MACRO_ARG) return CPP_TOKEN_FLD_ARG_NO; else if (tok->type == CPP_PADDING) return CPP_TOKEN_FLD_SOURCE; else if (tok->type == CPP_PRAGMA) return CPP_TOKEN_FLD_PRAGMA; default: return CPP_TOKEN_FLD_NONE; } }
[ "enum", "cpp_token_fld_kind", "cpp_token_val_index", "(", "cpp_token", "*", "tok", ")", "{", "switch", "(", "TOKEN_SPELL", "(", "tok", ")", ")", "{", "case", "SPELL_IDENT", ":", "return", "CPP_TOKEN_FLD_NODE", ";", "case", "SPELL_LITERAL", ":", "return", "CPP_TOKEN_FLD_STR", ";", "case", "SPELL_OPERATOR", ":", "if", "(", "tok", "->", "type", "==", "CPP_PASTE", ")", "return", "CPP_TOKEN_FLD_TOKEN_NO", ";", "else", "return", "CPP_TOKEN_FLD_NONE", ";", "case", "SPELL_NONE", ":", "if", "(", "tok", "->", "type", "==", "CPP_MACRO_ARG", ")", "return", "CPP_TOKEN_FLD_ARG_NO", ";", "else", "if", "(", "tok", "->", "type", "==", "CPP_PADDING", ")", "return", "CPP_TOKEN_FLD_SOURCE", ";", "else", "if", "(", "tok", "->", "type", "==", "CPP_PRAGMA", ")", "return", "CPP_TOKEN_FLD_PRAGMA", ";", "default", ":", "return", "CPP_TOKEN_FLD_NONE", ";", "}", "}" ]
Say which field of TOK is in use.
[ "Say", "which", "field", "of", "TOK", "is", "in", "use", "." ]
[ "/* else fall through */" ]
[ { "param": "tok", "type": "cpp_token" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tok", "type": "cpp_token", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
cpp_force_token_locations
void
void cpp_force_token_locations (cpp_reader *r, source_location *p) { r->forced_token_location_p = p; }
/* All tokens lexed in R after calling this function will be forced to have their source_location the same as the location referenced by P, until cpp_stop_forcing_token_locations is called for R. */
All tokens lexed in R after calling this function will be forced to have their source_location the same as the location referenced by P, until cpp_stop_forcing_token_locations is called for R.
[ "All", "tokens", "lexed", "in", "R", "after", "calling", "this", "function", "will", "be", "forced", "to", "have", "their", "source_location", "the", "same", "as", "the", "location", "referenced", "by", "P", "until", "cpp_stop_forcing_token_locations", "is", "called", "for", "R", "." ]
void cpp_force_token_locations (cpp_reader *r, source_location *p) { r->forced_token_location_p = p; }
[ "void", "cpp_force_token_locations", "(", "cpp_reader", "*", "r", ",", "source_location", "*", "p", ")", "{", "r", "->", "forced_token_location_p", "=", "p", ";", "}" ]
All tokens lexed in R after calling this function will be forced to have their source_location the same as the location referenced by P, until cpp_stop_forcing_token_locations is called for R.
[ "All", "tokens", "lexed", "in", "R", "after", "calling", "this", "function", "will", "be", "forced", "to", "have", "their", "source_location", "the", "same", "as", "the", "location", "referenced", "by", "P", "until", "cpp_stop_forcing_token_locations", "is", "called", "for", "R", "." ]
[]
[ { "param": "r", "type": "cpp_reader" }, { "param": "p", "type": "source_location" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "r", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "source_location", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ad9660a76ba7a174d603466e81b76f6769a3c97
atrens/DragonFlyBSD-src
contrib/gcc-4.7/libcpp/lex.c
[ "BSD-3-Clause" ]
C
cpp_stop_forcing_token_locations
void
void cpp_stop_forcing_token_locations (cpp_reader *r) { r->forced_token_location_p = NULL; }
/* Go back to assigning locations naturally for lexed tokens. */
Go back to assigning locations naturally for lexed tokens.
[ "Go", "back", "to", "assigning", "locations", "naturally", "for", "lexed", "tokens", "." ]
void cpp_stop_forcing_token_locations (cpp_reader *r) { r->forced_token_location_p = NULL; }
[ "void", "cpp_stop_forcing_token_locations", "(", "cpp_reader", "*", "r", ")", "{", "r", "->", "forced_token_location_p", "=", "NULL", ";", "}" ]
Go back to assigning locations naturally for lexed tokens.
[ "Go", "back", "to", "assigning", "locations", "naturally", "for", "lexed", "tokens", "." ]
[]
[ { "param": "r", "type": "cpp_reader" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "r", "type": "cpp_reader", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24dfd241f668a533dd82e3e8b48125ba9ed2747b
atrens/DragonFlyBSD-src
usr.bin/last/last.c
[ "BSD-3-Clause" ]
C
addarg
void
static void addarg(int type, char *arg) { ARG *cur; if (!(cur = (ARG *)malloc((u_int)sizeof(ARG)))) err(1, "malloc failure"); cur->next = arglist; cur->type = type; cur->name = arg; arglist = cur; }
/* * addarg -- * add an entry to a linked list of arguments */
addarg add an entry to a linked list of arguments
[ "addarg", "add", "an", "entry", "to", "a", "linked", "list", "of", "arguments" ]
static void addarg(int type, char *arg) { ARG *cur; if (!(cur = (ARG *)malloc((u_int)sizeof(ARG)))) err(1, "malloc failure"); cur->next = arglist; cur->type = type; cur->name = arg; arglist = cur; }
[ "static", "void", "addarg", "(", "int", "type", ",", "char", "*", "arg", ")", "{", "ARG", "*", "cur", ";", "if", "(", "!", "(", "cur", "=", "(", "ARG", "*", ")", "malloc", "(", "(", "u_int", ")", "sizeof", "(", "ARG", ")", ")", ")", ")", "err", "(", "1", ",", "\"", "\"", ")", ";", "cur", "->", "next", "=", "arglist", ";", "cur", "->", "type", "=", "type", ";", "cur", "->", "name", "=", "arg", ";", "arglist", "=", "cur", ";", "}" ]
addarg add an entry to a linked list of arguments
[ "addarg", "add", "an", "entry", "to", "a", "linked", "list", "of", "arguments" ]
[]
[ { "param": "type", "type": "int" }, { "param": "arg", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24dfd241f668a533dd82e3e8b48125ba9ed2747b
atrens/DragonFlyBSD-src
usr.bin/last/last.c
[ "BSD-3-Clause" ]
C
addtty
TTY
static TTY * addtty(const char *tty) { TTY *cur; if (!(cur = (TTY *)malloc((u_int)sizeof(TTY)))) err(1, "malloc failure"); cur->next = ttylist; cur->logout = currentout; memmove(cur->tty, tty, sizeof(cur->tty)); return (ttylist = cur); }
/* * addtty -- * add an entry to a linked list of ttys */
addtty add an entry to a linked list of ttys
[ "addtty", "add", "an", "entry", "to", "a", "linked", "list", "of", "ttys" ]
static TTY * addtty(const char *tty) { TTY *cur; if (!(cur = (TTY *)malloc((u_int)sizeof(TTY)))) err(1, "malloc failure"); cur->next = ttylist; cur->logout = currentout; memmove(cur->tty, tty, sizeof(cur->tty)); return (ttylist = cur); }
[ "static", "TTY", "*", "addtty", "(", "const", "char", "*", "tty", ")", "{", "TTY", "*", "cur", ";", "if", "(", "!", "(", "cur", "=", "(", "TTY", "*", ")", "malloc", "(", "(", "u_int", ")", "sizeof", "(", "TTY", ")", ")", ")", ")", "err", "(", "1", ",", "\"", "\"", ")", ";", "cur", "->", "next", "=", "ttylist", ";", "cur", "->", "logout", "=", "currentout", ";", "memmove", "(", "cur", "->", "tty", ",", "tty", ",", "sizeof", "(", "cur", "->", "tty", ")", ")", ";", "return", "(", "ttylist", "=", "cur", ")", ";", "}" ]
addtty add an entry to a linked list of ttys
[ "addtty", "add", "an", "entry", "to", "a", "linked", "list", "of", "ttys" ]
[]
[ { "param": "tty", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tty", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24dfd241f668a533dd82e3e8b48125ba9ed2747b
atrens/DragonFlyBSD-src
usr.bin/last/last.c
[ "BSD-3-Clause" ]
C
hostconv
void
static void hostconv(char *arg) { static int first = 1; static char *hostdot, name[MAXHOSTNAMELEN + 1]; char *argdot; if (!(argdot = strchr(arg, '.'))) return; if (first) { first = 0; if (gethostname(name, sizeof(name))) err(1, "gethostname"); name[sizeof(name) - 1] = '\0'; hostdot = strchr(name, '.'); } if (hostdot && !strcasecmp(hostdot, argdot)) *argdot = '\0'; }
/* * hostconv -- * convert the hostname to search pattern; if the supplied host name * has a domain attached that is the same as the current domain, rip * off the domain suffix since that's what login(1) does. */
hostconv convert the hostname to search pattern; if the supplied host name has a domain attached that is the same as the current domain, rip off the domain suffix since that's what login(1) does.
[ "hostconv", "convert", "the", "hostname", "to", "search", "pattern", ";", "if", "the", "supplied", "host", "name", "has", "a", "domain", "attached", "that", "is", "the", "same", "as", "the", "current", "domain", "rip", "off", "the", "domain", "suffix", "since", "that", "'", "s", "what", "login", "(", "1", ")", "does", "." ]
static void hostconv(char *arg) { static int first = 1; static char *hostdot, name[MAXHOSTNAMELEN + 1]; char *argdot; if (!(argdot = strchr(arg, '.'))) return; if (first) { first = 0; if (gethostname(name, sizeof(name))) err(1, "gethostname"); name[sizeof(name) - 1] = '\0'; hostdot = strchr(name, '.'); } if (hostdot && !strcasecmp(hostdot, argdot)) *argdot = '\0'; }
[ "static", "void", "hostconv", "(", "char", "*", "arg", ")", "{", "static", "int", "first", "=", "1", ";", "static", "char", "*", "hostdot", ",", "name", "[", "MAXHOSTNAMELEN", "+", "1", "]", ";", "char", "*", "argdot", ";", "if", "(", "!", "(", "argdot", "=", "strchr", "(", "arg", ",", "'", "'", ")", ")", ")", "return", ";", "if", "(", "first", ")", "{", "first", "=", "0", ";", "if", "(", "gethostname", "(", "name", ",", "sizeof", "(", "name", ")", ")", ")", "err", "(", "1", ",", "\"", "\"", ")", ";", "name", "[", "sizeof", "(", "name", ")", "-", "1", "]", "=", "'", "\\0", "'", ";", "hostdot", "=", "strchr", "(", "name", ",", "'", "'", ")", ";", "}", "if", "(", "hostdot", "&&", "!", "strcasecmp", "(", "hostdot", ",", "argdot", ")", ")", "*", "argdot", "=", "'", "\\0", "'", ";", "}" ]
hostconv convert the hostname to search pattern; if the supplied host name has a domain attached that is the same as the current domain, rip off the domain suffix since that's what login(1) does.
[ "hostconv", "convert", "the", "hostname", "to", "search", "pattern", ";", "if", "the", "supplied", "host", "name", "has", "a", "domain", "attached", "that", "is", "the", "same", "as", "the", "current", "domain", "rip", "off", "the", "domain", "suffix", "since", "that", "'", "s", "what", "login", "(", "1", ")", "does", "." ]
[]
[ { "param": "arg", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arg", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24dfd241f668a533dd82e3e8b48125ba9ed2747b
atrens/DragonFlyBSD-src
usr.bin/last/last.c
[ "BSD-3-Clause" ]
C
ttyconv
char
static char * ttyconv(char *arg) { char *mval; /* * kludge -- we assume that all tty's end with * a two character suffix. */ if (strlen(arg) == 2) { /* either 6 for "ttyxx" or 8 for "console" */ if (!(mval = malloc((u_int)8))) err(1, "malloc failure"); if (!strcmp(arg, "co")) strcpy(mval, "console"); else { strcpy(mval, "tty"); strcpy(mval + 3, arg); } return (mval); } if (!strncmp(arg, _PATH_DEV, sizeof(_PATH_DEV) - 1)) return (arg + 5); return (arg); }
/* * ttyconv -- * convert tty to correct name. */
ttyconv convert tty to correct name.
[ "ttyconv", "convert", "tty", "to", "correct", "name", "." ]
static char * ttyconv(char *arg) { char *mval; if (strlen(arg) == 2) { if (!(mval = malloc((u_int)8))) err(1, "malloc failure"); if (!strcmp(arg, "co")) strcpy(mval, "console"); else { strcpy(mval, "tty"); strcpy(mval + 3, arg); } return (mval); } if (!strncmp(arg, _PATH_DEV, sizeof(_PATH_DEV) - 1)) return (arg + 5); return (arg); }
[ "static", "char", "*", "ttyconv", "(", "char", "*", "arg", ")", "{", "char", "*", "mval", ";", "if", "(", "strlen", "(", "arg", ")", "==", "2", ")", "{", "if", "(", "!", "(", "mval", "=", "malloc", "(", "(", "u_int", ")", "8", ")", ")", ")", "err", "(", "1", ",", "\"", "\"", ")", ";", "if", "(", "!", "strcmp", "(", "arg", ",", "\"", "\"", ")", ")", "strcpy", "(", "mval", ",", "\"", "\"", ")", ";", "else", "{", "strcpy", "(", "mval", ",", "\"", "\"", ")", ";", "strcpy", "(", "mval", "+", "3", ",", "arg", ")", ";", "}", "return", "(", "mval", ")", ";", "}", "if", "(", "!", "strncmp", "(", "arg", ",", "_PATH_DEV", ",", "sizeof", "(", "_PATH_DEV", ")", "-", "1", ")", ")", "return", "(", "arg", "+", "5", ")", ";", "return", "(", "arg", ")", ";", "}" ]
ttyconv convert tty to correct name.
[ "ttyconv", "convert", "tty", "to", "correct", "name", "." ]
[ "/*\n\t * kludge -- we assume that all tty's end with\n\t * a two character suffix.\n\t */", "/* either 6 for \"ttyxx\" or 8 for \"console\" */" ]
[ { "param": "arg", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arg", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24dfd241f668a533dd82e3e8b48125ba9ed2747b
atrens/DragonFlyBSD-src
usr.bin/last/last.c
[ "BSD-3-Clause" ]
C
fmttime
char
static char * fmttime(time_t t, int flags) { struct tm *tm; static char tbuf[TBUFLEN]; tm = (flags & GMT) ? gmtime(&t) : localtime(&t); strftime(tbuf, sizeof(tbuf), (flags & TIMEONLY) ? (flags & FULLTIME ? LTFMTS : TFMTS) : (flags & FULLTIME ? LTFMT : TFMT), tm); return (tbuf); }
/* * fmttime -- * return pointer to (static) formatted time string. */
fmttime return pointer to (static) formatted time string.
[ "fmttime", "return", "pointer", "to", "(", "static", ")", "formatted", "time", "string", "." ]
static char * fmttime(time_t t, int flags) { struct tm *tm; static char tbuf[TBUFLEN]; tm = (flags & GMT) ? gmtime(&t) : localtime(&t); strftime(tbuf, sizeof(tbuf), (flags & TIMEONLY) ? (flags & FULLTIME ? LTFMTS : TFMTS) : (flags & FULLTIME ? LTFMT : TFMT), tm); return (tbuf); }
[ "static", "char", "*", "fmttime", "(", "time_t", "t", ",", "int", "flags", ")", "{", "struct", "tm", "*", "tm", ";", "static", "char", "tbuf", "[", "TBUFLEN", "]", ";", "tm", "=", "(", "flags", "&", "GMT", ")", "?", "gmtime", "(", "&", "t", ")", ":", "localtime", "(", "&", "t", ")", ";", "strftime", "(", "tbuf", ",", "sizeof", "(", "tbuf", ")", ",", "(", "flags", "&", "TIMEONLY", ")", "?", "(", "flags", "&", "FULLTIME", "?", "LTFMTS", ":", "TFMTS", ")", ":", "(", "flags", "&", "FULLTIME", "?", "LTFMT", ":", "TFMT", ")", ",", "tm", ")", ";", "return", "(", "tbuf", ")", ";", "}" ]
fmttime return pointer to (static) formatted time string.
[ "fmttime", "return", "pointer", "to", "(", "static", ")", "formatted", "time", "string", "." ]
[]
[ { "param": "t", "type": "time_t" }, { "param": "flags", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "t", "type": "time_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24dfd241f668a533dd82e3e8b48125ba9ed2747b
atrens/DragonFlyBSD-src
usr.bin/last/last.c
[ "BSD-3-Clause" ]
C
wtmpx
void
static void wtmpx(const char *file, int namesz, int linesz, int hostsz) { struct utmpx *bp; /* current structure */ TTY *T; /* tty list entry */ struct stat stb; /* stat of file for sz */ time_t delta; /* time difference */ off_t bl; int bytes, wfd; char *ct; const char *crmsg; size_t len = sizeof(*bufx) * MAXUTMP; if ((bufx = malloc(len)) == NULL) err(1, "Cannot allocate utmpx buffer"); crmsg = NULL; if ((wfd = open(file, O_RDONLY, 0)) < 0 || fstat(wfd, &stb) == -1) err(1, "%s", file); bl = (stb.st_size + len - 1) / len; bufx[1].ut_xtime = time(NULL); (void)signal(SIGINT, onintrx); (void)signal(SIGQUIT, onintrx); while (--bl >= 0) { if (lseek(wfd, bl * len, SEEK_SET) == -1 || (bytes = read(wfd, bufx, len)) == -1) err(1, "%s", file); for (bp = &bufx[bytes / sizeof(*bufx) - 1]; bp >= bufx; --bp) { /* * if the terminal line is '~', the machine stopped. * see utmpx(5) for more info. */ if (bp->ut_line[0] == '~' && !bp->ut_line[1]) { /* everybody just logged out */ for (T = ttylist; T; T = T->next) T->logout = -bp->ut_xtime; currentout = -bp->ut_xtime; #ifdef __DragonFly__ /* XXX swildner: this should not be needed afaict */ if (!strncmp(bp->ut_name, "shutdown", namesz)) crmsg = "shutdown"; else if (!strncmp(bp->ut_name, "reboot", namesz)) crmsg = "reboot"; else crmsg = "crash"; #else crmsg = strncmp(bp->ut_name, "shutdown", namesz) ? "crash" : "shutdown"; #endif if (wantx(bp, NO)) { ct = fmttime(bp->ut_xtime, fulltime); printf("%-*.*s %-*.*s %-*.*s %s\n", namesz, namesz, bp->ut_name, linesz, linesz, bp->ut_line, hostsz, hostsz, bp->ut_host, ct); if (maxrec != -1 && !--maxrec) return; } continue; } /* * if the line is '{' or '|', date got set; see * utmpx(5) for more info. */ if ((bp->ut_line[0] == '{' || bp->ut_line[0] == '|') && !bp->ut_line[1]) { if (wantx(bp, NO)) { ct = fmttime(bp->ut_xtime, fulltime); printf("%-*.*s %-*.*s %-*.*s %s\n", namesz, namesz, bp->ut_name, linesz, linesz, bp->ut_line, hostsz, hostsz, bp->ut_host, ct); if (maxrec && !--maxrec) return; } continue; } /* find associated tty */ for (T = ttylist;; T = T->next) { if (!T) { /* add new one */ T = addtty(bp->ut_line); break; } if (!strncmp(T->tty, bp->ut_line, UTX_LINESIZE)) break; } if (bp->ut_type == SIGNATURE) continue; if (bp->ut_name[0] && wantx(bp, YES)) { ct = fmttime(bp->ut_xtime, fulltime); printf("%-*.*s %-*.*s %-*.*s %s ", namesz, namesz, bp->ut_name, linesz, linesz, bp->ut_line, hostsz, hostsz, bp->ut_host, ct); if (!T->logout) puts(" still logged in"); else { if (T->logout < 0) { T->logout = -T->logout; printf("- %s", crmsg); } else printf("- %s", fmttime(T->logout, fulltime | TIMEONLY)); delta = T->logout - bp->ut_xtime; if (delta < SECSPERDAY) printf(" (%s)\n", fmttime(delta, fulltime | TIMEONLY | GMT)); else printf(" (%ld+%s)\n", delta / SECSPERDAY, fmttime(delta, fulltime | TIMEONLY | GMT)); } if (maxrec != -1 && !--maxrec) return; } T->logout = bp->ut_xtime; } } fulltime = 1; /* show full time */ crmsg = fmttime(bufx[1].ut_xtime, FULLTIME); if ((ct = strrchr(file, '/')) != NULL) ct++; printf("\n%s begins %s\n", ct ? ct : file, crmsg); }
/* * wtmpx -- * read through the wtmpx file */
wtmpx read through the wtmpx file
[ "wtmpx", "read", "through", "the", "wtmpx", "file" ]
static void wtmpx(const char *file, int namesz, int linesz, int hostsz) { struct utmpx *bp; TTY *T; struct stat stb; time_t delta; off_t bl; int bytes, wfd; char *ct; const char *crmsg; size_t len = sizeof(*bufx) * MAXUTMP; if ((bufx = malloc(len)) == NULL) err(1, "Cannot allocate utmpx buffer"); crmsg = NULL; if ((wfd = open(file, O_RDONLY, 0)) < 0 || fstat(wfd, &stb) == -1) err(1, "%s", file); bl = (stb.st_size + len - 1) / len; bufx[1].ut_xtime = time(NULL); (void)signal(SIGINT, onintrx); (void)signal(SIGQUIT, onintrx); while (--bl >= 0) { if (lseek(wfd, bl * len, SEEK_SET) == -1 || (bytes = read(wfd, bufx, len)) == -1) err(1, "%s", file); for (bp = &bufx[bytes / sizeof(*bufx) - 1]; bp >= bufx; --bp) { if (bp->ut_line[0] == '~' && !bp->ut_line[1]) { for (T = ttylist; T; T = T->next) T->logout = -bp->ut_xtime; currentout = -bp->ut_xtime; #ifdef __DragonFly__ if (!strncmp(bp->ut_name, "shutdown", namesz)) crmsg = "shutdown"; else if (!strncmp(bp->ut_name, "reboot", namesz)) crmsg = "reboot"; else crmsg = "crash"; #else crmsg = strncmp(bp->ut_name, "shutdown", namesz) ? "crash" : "shutdown"; #endif if (wantx(bp, NO)) { ct = fmttime(bp->ut_xtime, fulltime); printf("%-*.*s %-*.*s %-*.*s %s\n", namesz, namesz, bp->ut_name, linesz, linesz, bp->ut_line, hostsz, hostsz, bp->ut_host, ct); if (maxrec != -1 && !--maxrec) return; } continue; } if ((bp->ut_line[0] == '{' || bp->ut_line[0] == '|') && !bp->ut_line[1]) { if (wantx(bp, NO)) { ct = fmttime(bp->ut_xtime, fulltime); printf("%-*.*s %-*.*s %-*.*s %s\n", namesz, namesz, bp->ut_name, linesz, linesz, bp->ut_line, hostsz, hostsz, bp->ut_host, ct); if (maxrec && !--maxrec) return; } continue; } for (T = ttylist;; T = T->next) { if (!T) { T = addtty(bp->ut_line); break; } if (!strncmp(T->tty, bp->ut_line, UTX_LINESIZE)) break; } if (bp->ut_type == SIGNATURE) continue; if (bp->ut_name[0] && wantx(bp, YES)) { ct = fmttime(bp->ut_xtime, fulltime); printf("%-*.*s %-*.*s %-*.*s %s ", namesz, namesz, bp->ut_name, linesz, linesz, bp->ut_line, hostsz, hostsz, bp->ut_host, ct); if (!T->logout) puts(" still logged in"); else { if (T->logout < 0) { T->logout = -T->logout; printf("- %s", crmsg); } else printf("- %s", fmttime(T->logout, fulltime | TIMEONLY)); delta = T->logout - bp->ut_xtime; if (delta < SECSPERDAY) printf(" (%s)\n", fmttime(delta, fulltime | TIMEONLY | GMT)); else printf(" (%ld+%s)\n", delta / SECSPERDAY, fmttime(delta, fulltime | TIMEONLY | GMT)); } if (maxrec != -1 && !--maxrec) return; } T->logout = bp->ut_xtime; } } fulltime = 1; crmsg = fmttime(bufx[1].ut_xtime, FULLTIME); if ((ct = strrchr(file, '/')) != NULL) ct++; printf("\n%s begins %s\n", ct ? ct : file, crmsg); }
[ "static", "void", "wtmpx", "(", "const", "char", "*", "file", ",", "int", "namesz", ",", "int", "linesz", ",", "int", "hostsz", ")", "{", "struct", "utmpx", "*", "bp", ";", "TTY", "*", "T", ";", "struct", "stat", "stb", ";", "time_t", "delta", ";", "off_t", "bl", ";", "int", "bytes", ",", "wfd", ";", "char", "*", "ct", ";", "const", "char", "*", "crmsg", ";", "size_t", "len", "=", "sizeof", "(", "*", "bufx", ")", "*", "MAXUTMP", ";", "if", "(", "(", "bufx", "=", "malloc", "(", "len", ")", ")", "==", "NULL", ")", "err", "(", "1", ",", "\"", "\"", ")", ";", "crmsg", "=", "NULL", ";", "if", "(", "(", "wfd", "=", "open", "(", "file", ",", "O_RDONLY", ",", "0", ")", ")", "<", "0", "||", "fstat", "(", "wfd", ",", "&", "stb", ")", "==", "-1", ")", "err", "(", "1", ",", "\"", "\"", ",", "file", ")", ";", "bl", "=", "(", "stb", ".", "st_size", "+", "len", "-", "1", ")", "/", "len", ";", "bufx", "[", "1", "]", ".", "ut_xtime", "=", "time", "(", "NULL", ")", ";", "(", "void", ")", "signal", "(", "SIGINT", ",", "onintrx", ")", ";", "(", "void", ")", "signal", "(", "SIGQUIT", ",", "onintrx", ")", ";", "while", "(", "--", "bl", ">=", "0", ")", "{", "if", "(", "lseek", "(", "wfd", ",", "bl", "*", "len", ",", "SEEK_SET", ")", "==", "-1", "||", "(", "bytes", "=", "read", "(", "wfd", ",", "bufx", ",", "len", ")", ")", "==", "-1", ")", "err", "(", "1", ",", "\"", "\"", ",", "file", ")", ";", "for", "(", "bp", "=", "&", "bufx", "[", "bytes", "/", "sizeof", "(", "*", "bufx", ")", "-", "1", "]", ";", "bp", ">=", "bufx", ";", "--", "bp", ")", "{", "if", "(", "bp", "->", "ut_line", "[", "0", "]", "==", "'", "'", "&&", "!", "bp", "->", "ut_line", "[", "1", "]", ")", "{", "for", "(", "T", "=", "ttylist", ";", "T", ";", "T", "=", "T", "->", "next", ")", "T", "->", "logout", "=", "-", "bp", "->", "ut_xtime", ";", "currentout", "=", "-", "bp", "->", "ut_xtime", ";", "#ifdef", "__DragonFly__", "if", "(", "!", "strncmp", "(", "bp", "->", "ut_name", ",", "\"", "\"", ",", "namesz", ")", ")", "crmsg", "=", "\"", "\"", ";", "else", "if", "(", "!", "strncmp", "(", "bp", "->", "ut_name", ",", "\"", "\"", ",", "namesz", ")", ")", "crmsg", "=", "\"", "\"", ";", "else", "crmsg", "=", "\"", "\"", ";", "#else", "crmsg", "=", "strncmp", "(", "bp", "->", "ut_name", ",", "\"", "\"", ",", "namesz", ")", "?", "\"", "\"", ":", "\"", "\"", ";", "#endif", "if", "(", "wantx", "(", "bp", ",", "NO", ")", ")", "{", "ct", "=", "fmttime", "(", "bp", "->", "ut_xtime", ",", "fulltime", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "namesz", ",", "namesz", ",", "bp", "->", "ut_name", ",", "linesz", ",", "linesz", ",", "bp", "->", "ut_line", ",", "hostsz", ",", "hostsz", ",", "bp", "->", "ut_host", ",", "ct", ")", ";", "if", "(", "maxrec", "!=", "-1", "&&", "!", "--", "maxrec", ")", "return", ";", "}", "continue", ";", "}", "if", "(", "(", "bp", "->", "ut_line", "[", "0", "]", "==", "'", "'", "||", "bp", "->", "ut_line", "[", "0", "]", "==", "'", "'", ")", "&&", "!", "bp", "->", "ut_line", "[", "1", "]", ")", "{", "if", "(", "wantx", "(", "bp", ",", "NO", ")", ")", "{", "ct", "=", "fmttime", "(", "bp", "->", "ut_xtime", ",", "fulltime", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "namesz", ",", "namesz", ",", "bp", "->", "ut_name", ",", "linesz", ",", "linesz", ",", "bp", "->", "ut_line", ",", "hostsz", ",", "hostsz", ",", "bp", "->", "ut_host", ",", "ct", ")", ";", "if", "(", "maxrec", "&&", "!", "--", "maxrec", ")", "return", ";", "}", "continue", ";", "}", "for", "(", "T", "=", "ttylist", ";", ";", "T", "=", "T", "->", "next", ")", "{", "if", "(", "!", "T", ")", "{", "T", "=", "addtty", "(", "bp", "->", "ut_line", ")", ";", "break", ";", "}", "if", "(", "!", "strncmp", "(", "T", "->", "tty", ",", "bp", "->", "ut_line", ",", "UTX_LINESIZE", ")", ")", "break", ";", "}", "if", "(", "bp", "->", "ut_type", "==", "SIGNATURE", ")", "continue", ";", "if", "(", "bp", "->", "ut_name", "[", "0", "]", "&&", "wantx", "(", "bp", ",", "YES", ")", ")", "{", "ct", "=", "fmttime", "(", "bp", "->", "ut_xtime", ",", "fulltime", ")", ";", "printf", "(", "\"", "\"", ",", "namesz", ",", "namesz", ",", "bp", "->", "ut_name", ",", "linesz", ",", "linesz", ",", "bp", "->", "ut_line", ",", "hostsz", ",", "hostsz", ",", "bp", "->", "ut_host", ",", "ct", ")", ";", "if", "(", "!", "T", "->", "logout", ")", "puts", "(", "\"", "\"", ")", ";", "else", "{", "if", "(", "T", "->", "logout", "<", "0", ")", "{", "T", "->", "logout", "=", "-", "T", "->", "logout", ";", "printf", "(", "\"", "\"", ",", "crmsg", ")", ";", "}", "else", "printf", "(", "\"", "\"", ",", "fmttime", "(", "T", "->", "logout", ",", "fulltime", "|", "TIMEONLY", ")", ")", ";", "delta", "=", "T", "->", "logout", "-", "bp", "->", "ut_xtime", ";", "if", "(", "delta", "<", "SECSPERDAY", ")", "printf", "(", "\"", "\\n", "\"", ",", "fmttime", "(", "delta", ",", "fulltime", "|", "TIMEONLY", "|", "GMT", ")", ")", ";", "else", "printf", "(", "\"", "\\n", "\"", ",", "delta", "/", "SECSPERDAY", ",", "fmttime", "(", "delta", ",", "fulltime", "|", "TIMEONLY", "|", "GMT", ")", ")", ";", "}", "if", "(", "maxrec", "!=", "-1", "&&", "!", "--", "maxrec", ")", "return", ";", "}", "T", "->", "logout", "=", "bp", "->", "ut_xtime", ";", "}", "}", "fulltime", "=", "1", ";", "crmsg", "=", "fmttime", "(", "bufx", "[", "1", "]", ".", "ut_xtime", ",", "FULLTIME", ")", ";", "if", "(", "(", "ct", "=", "strrchr", "(", "file", ",", "'", "'", ")", ")", "!=", "NULL", ")", "ct", "++", ";", "printf", "(", "\"", "\\n", "\\n", "\"", ",", "ct", "?", "ct", ":", "file", ",", "crmsg", ")", ";", "}" ]
wtmpx read through the wtmpx file
[ "wtmpx", "read", "through", "the", "wtmpx", "file" ]
[ "/* current structure */", "/* tty list entry */", "/* stat of file for sz */", "/* time difference */", "/*\n\t\t\t * if the terminal line is '~', the machine stopped.\n\t\t\t * see utmpx(5) for more info.\n\t\t\t */", "/* everybody just logged out */", "/* XXX swildner: this should not be needed afaict */", "/*\n\t\t\t * if the line is '{' or '|', date got set; see\n\t\t\t * utmpx(5) for more info.\n\t\t\t */", "/* find associated tty */", "/* add new one */", "/* show full time */" ]
[ { "param": "file", "type": "char" }, { "param": "namesz", "type": "int" }, { "param": "linesz", "type": "int" }, { "param": "hostsz", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "namesz", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "linesz", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "hostsz", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24dfd241f668a533dd82e3e8b48125ba9ed2747b
atrens/DragonFlyBSD-src
usr.bin/last/last.c
[ "BSD-3-Clause" ]
C
wantx
int
static int wantx(struct utmpx *bp, int check) { ARG *step; if (check) { /* * when uucp and ftp log in over a network, the entry in * the utmpx file is the name plus their process id. See * etc/ftpd.c and usr.bin/uucp/uucpd.c for more information. */ if (!strncmp(bp->ut_line, "ftp", sizeof("ftp") - 1)) bp->ut_line[3] = '\0'; else if (!strncmp(bp->ut_line, "uucp", sizeof("uucp") - 1)) bp->ut_line[4] = '\0'; } if (!arglist) return (YES); for (step = arglist; step; step = step->next) switch(step->type) { case HOST_TYPE: if (!strncasecmp(step->name, bp->ut_host, UTX_HOSTSIZE)) return (YES); break; case TTY_TYPE: if (!strncmp(step->name, bp->ut_line, UTX_LINESIZE)) return (YES); break; case USER_TYPE: if (!strncmp(step->name, bp->ut_name, UTX_USERSIZE)) return (YES); break; } return (NO); }
/* * wantx -- * see if want this entry */
wantx see if want this entry
[ "wantx", "see", "if", "want", "this", "entry" ]
static int wantx(struct utmpx *bp, int check) { ARG *step; if (check) { if (!strncmp(bp->ut_line, "ftp", sizeof("ftp") - 1)) bp->ut_line[3] = '\0'; else if (!strncmp(bp->ut_line, "uucp", sizeof("uucp") - 1)) bp->ut_line[4] = '\0'; } if (!arglist) return (YES); for (step = arglist; step; step = step->next) switch(step->type) { case HOST_TYPE: if (!strncasecmp(step->name, bp->ut_host, UTX_HOSTSIZE)) return (YES); break; case TTY_TYPE: if (!strncmp(step->name, bp->ut_line, UTX_LINESIZE)) return (YES); break; case USER_TYPE: if (!strncmp(step->name, bp->ut_name, UTX_USERSIZE)) return (YES); break; } return (NO); }
[ "static", "int", "wantx", "(", "struct", "utmpx", "*", "bp", ",", "int", "check", ")", "{", "ARG", "*", "step", ";", "if", "(", "check", ")", "{", "if", "(", "!", "strncmp", "(", "bp", "->", "ut_line", ",", "\"", "\"", ",", "sizeof", "(", "\"", "\"", ")", "-", "1", ")", ")", "bp", "->", "ut_line", "[", "3", "]", "=", "'", "\\0", "'", ";", "else", "if", "(", "!", "strncmp", "(", "bp", "->", "ut_line", ",", "\"", "\"", ",", "sizeof", "(", "\"", "\"", ")", "-", "1", ")", ")", "bp", "->", "ut_line", "[", "4", "]", "=", "'", "\\0", "'", ";", "}", "if", "(", "!", "arglist", ")", "return", "(", "YES", ")", ";", "for", "(", "step", "=", "arglist", ";", "step", ";", "step", "=", "step", "->", "next", ")", "switch", "(", "step", "->", "type", ")", "{", "case", "HOST_TYPE", ":", "if", "(", "!", "strncasecmp", "(", "step", "->", "name", ",", "bp", "->", "ut_host", ",", "UTX_HOSTSIZE", ")", ")", "return", "(", "YES", ")", ";", "break", ";", "case", "TTY_TYPE", ":", "if", "(", "!", "strncmp", "(", "step", "->", "name", ",", "bp", "->", "ut_line", ",", "UTX_LINESIZE", ")", ")", "return", "(", "YES", ")", ";", "break", ";", "case", "USER_TYPE", ":", "if", "(", "!", "strncmp", "(", "step", "->", "name", ",", "bp", "->", "ut_name", ",", "UTX_USERSIZE", ")", ")", "return", "(", "YES", ")", ";", "break", ";", "}", "return", "(", "NO", ")", ";", "}" ]
wantx see if want this entry
[ "wantx", "see", "if", "want", "this", "entry" ]
[ "/*\n\t\t * when uucp and ftp log in over a network, the entry in\n\t\t * the utmpx file is the name plus their process id. See\n\t\t * etc/ftpd.c and usr.bin/uucp/uucpd.c for more information.\n\t\t */" ]
[ { "param": "bp", "type": "struct utmpx" }, { "param": "check", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bp", "type": "struct utmpx", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "check", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24dfd241f668a533dd82e3e8b48125ba9ed2747b
atrens/DragonFlyBSD-src
usr.bin/last/last.c
[ "BSD-3-Clause" ]
C
onintrx
void
static void onintrx(int signo) { printf("\ninterrupted %s\n", fmttime(bufx[1].ut_xtime, FULLTIME)); if (signo == SIGINT) exit(1); (void)fflush(stdout); /* fix required for rsh */ }
/* * onintrx -- * on interrupt, we inform the user how far we've gotten */
onintrx on interrupt, we inform the user how far we've gotten
[ "onintrx", "on", "interrupt", "we", "inform", "the", "user", "how", "far", "we", "'", "ve", "gotten" ]
static void onintrx(int signo) { printf("\ninterrupted %s\n", fmttime(bufx[1].ut_xtime, FULLTIME)); if (signo == SIGINT) exit(1); (void)fflush(stdout); }
[ "static", "void", "onintrx", "(", "int", "signo", ")", "{", "printf", "(", "\"", "\\n", "\\n", "\"", ",", "fmttime", "(", "bufx", "[", "1", "]", ".", "ut_xtime", ",", "FULLTIME", ")", ")", ";", "if", "(", "signo", "==", "SIGINT", ")", "exit", "(", "1", ")", ";", "(", "void", ")", "fflush", "(", "stdout", ")", ";", "}" ]
onintrx on interrupt, we inform the user how far we've gotten
[ "onintrx", "on", "interrupt", "we", "inform", "the", "user", "how", "far", "we", "'", "ve", "gotten" ]
[ "/* fix required for rsh */" ]
[ { "param": "signo", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "signo", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
match_token
int
static int match_token(struct _s_x *table, char *string) { struct _s_x *pt; int i = strlen(string); for (pt = table ; i && pt->s != NULL ; pt++) if ((int)strlen(pt->s) == i && !bcmp(string, pt->s, i)) return pt->x; return -1; }
/** * match_token takes a table and a string, returns the value associated * with the string (0 meaning an error in most cases) */
match_token takes a table and a string, returns the value associated with the string (0 meaning an error in most cases)
[ "match_token", "takes", "a", "table", "and", "a", "string", "returns", "the", "value", "associated", "with", "the", "string", "(", "0", "meaning", "an", "error", "in", "most", "cases", ")" ]
static int match_token(struct _s_x *table, char *string) { struct _s_x *pt; int i = strlen(string); for (pt = table ; i && pt->s != NULL ; pt++) if ((int)strlen(pt->s) == i && !bcmp(string, pt->s, i)) return pt->x; return -1; }
[ "static", "int", "match_token", "(", "struct", "_s_x", "*", "table", ",", "char", "*", "string", ")", "{", "struct", "_s_x", "*", "pt", ";", "int", "i", "=", "strlen", "(", "string", ")", ";", "for", "(", "pt", "=", "table", ";", "i", "&&", "pt", "->", "s", "!=", "NULL", ";", "pt", "++", ")", "if", "(", "(", "int", ")", "strlen", "(", "pt", "->", "s", ")", "==", "i", "&&", "!", "bcmp", "(", "string", ",", "pt", "->", "s", ",", "i", ")", ")", "return", "pt", "->", "x", ";", "return", "-1", ";", "}" ]
match_token takes a table and a string, returns the value associated with the string (0 meaning an error in most cases)
[ "match_token", "takes", "a", "table", "and", "a", "string", "returns", "the", "value", "associated", "with", "the", "string", "(", "0", "meaning", "an", "error", "in", "most", "cases", ")" ]
[]
[ { "param": "table", "type": "struct _s_x" }, { "param": "string", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "table", "type": "struct _s_x", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "string", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
print_port
void
static void print_port(int proto, u_int16_t port) { if (proto == IPPROTO_ETHERTYPE) { const char *str; if (do_resolv && (str = match_value(ether_types, port)) ) printf("%s", str); else printf("0x%04x", port); } else { struct servent *se = NULL; if (do_resolv) { struct protoent *pe = getprotobynumber(proto); se = getservbyport(htons(port), pe ? pe->p_name : NULL); } if (se) printf("%s", se->s_name); else printf("%d", port); } }
/* * prints one port, symbolic or numeric */
prints one port, symbolic or numeric
[ "prints", "one", "port", "symbolic", "or", "numeric" ]
static void print_port(int proto, u_int16_t port) { if (proto == IPPROTO_ETHERTYPE) { const char *str; if (do_resolv && (str = match_value(ether_types, port)) ) printf("%s", str); else printf("0x%04x", port); } else { struct servent *se = NULL; if (do_resolv) { struct protoent *pe = getprotobynumber(proto); se = getservbyport(htons(port), pe ? pe->p_name : NULL); } if (se) printf("%s", se->s_name); else printf("%d", port); } }
[ "static", "void", "print_port", "(", "int", "proto", ",", "u_int16_t", "port", ")", "{", "if", "(", "proto", "==", "IPPROTO_ETHERTYPE", ")", "{", "const", "char", "*", "str", ";", "if", "(", "do_resolv", "&&", "(", "str", "=", "match_value", "(", "ether_types", ",", "port", ")", ")", ")", "printf", "(", "\"", "\"", ",", "str", ")", ";", "else", "printf", "(", "\"", "\"", ",", "port", ")", ";", "}", "else", "{", "struct", "servent", "*", "se", "=", "NULL", ";", "if", "(", "do_resolv", ")", "{", "struct", "protoent", "*", "pe", "=", "getprotobynumber", "(", "proto", ")", ";", "se", "=", "getservbyport", "(", "htons", "(", "port", ")", ",", "pe", "?", "pe", "->", "p_name", ":", "NULL", ")", ";", "}", "if", "(", "se", ")", "printf", "(", "\"", "\"", ",", "se", "->", "s_name", ")", ";", "else", "printf", "(", "\"", "\"", ",", "port", ")", ";", "}", "}" ]
prints one port, symbolic or numeric
[ "prints", "one", "port", "symbolic", "or", "numeric" ]
[]
[ { "param": "proto", "type": "int" }, { "param": "port", "type": "u_int16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "proto", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "port", "type": "u_int16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
print_newports
void
static void print_newports(ipfw_insn_u16 *cmd, int proto, int opcode) { u_int16_t *p = cmd->ports; int i; const char *sep= " "; if (cmd->o.len & F_NOT) printf(" not"); if (opcode != 0) printf ("%s", opcode == O_MAC_TYPE ? " mac-type" : (opcode == O_IP_DSTPORT ? " dst-port" : " src-port")); for (i = F_LEN((ipfw_insn *)cmd) - 1; i > 0; i--, p += 2) { printf("%s", sep); print_port(proto, p[0]); if (p[0] != p[1]) { printf("-"); print_port(proto, p[1]); } sep = ","; } }
/* * print the values in a list of ports * XXX todo: add support for mask. */
print the values in a list of ports XXX todo: add support for mask.
[ "print", "the", "values", "in", "a", "list", "of", "ports", "XXX", "todo", ":", "add", "support", "for", "mask", "." ]
static void print_newports(ipfw_insn_u16 *cmd, int proto, int opcode) { u_int16_t *p = cmd->ports; int i; const char *sep= " "; if (cmd->o.len & F_NOT) printf(" not"); if (opcode != 0) printf ("%s", opcode == O_MAC_TYPE ? " mac-type" : (opcode == O_IP_DSTPORT ? " dst-port" : " src-port")); for (i = F_LEN((ipfw_insn *)cmd) - 1; i > 0; i--, p += 2) { printf("%s", sep); print_port(proto, p[0]); if (p[0] != p[1]) { printf("-"); print_port(proto, p[1]); } sep = ","; } }
[ "static", "void", "print_newports", "(", "ipfw_insn_u16", "*", "cmd", ",", "int", "proto", ",", "int", "opcode", ")", "{", "u_int16_t", "*", "p", "=", "cmd", "->", "ports", ";", "int", "i", ";", "const", "char", "*", "sep", "=", "\"", "\"", ";", "if", "(", "cmd", "->", "o", ".", "len", "&", "F_NOT", ")", "printf", "(", "\"", "\"", ")", ";", "if", "(", "opcode", "!=", "0", ")", "printf", "(", "\"", "\"", ",", "opcode", "==", "O_MAC_TYPE", "?", "\"", "\"", ":", "(", "opcode", "==", "O_IP_DSTPORT", "?", "\"", "\"", ":", "\"", "\"", ")", ")", ";", "for", "(", "i", "=", "F_LEN", "(", "(", "ipfw_insn", "*", ")", "cmd", ")", "-", "1", ";", "i", ">", "0", ";", "i", "--", ",", "p", "+=", "2", ")", "{", "printf", "(", "\"", "\"", ",", "sep", ")", ";", "print_port", "(", "proto", ",", "p", "[", "0", "]", ")", ";", "if", "(", "p", "[", "0", "]", "!=", "p", "[", "1", "]", ")", "{", "printf", "(", "\"", "\"", ")", ";", "print_port", "(", "proto", ",", "p", "[", "1", "]", ")", ";", "}", "sep", "=", "\"", "\"", ";", "}", "}" ]
print the values in a list of ports XXX todo: add support for mask.
[ "print", "the", "values", "in", "a", "list", "of", "ports", "XXX", "todo", ":", "add", "support", "for", "mask", "." ]
[]
[ { "param": "cmd", "type": "ipfw_insn_u16" }, { "param": "proto", "type": "int" }, { "param": "opcode", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "ipfw_insn_u16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "proto", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "opcode", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
strtoport
int
static int strtoport(char *str, char **end, int base, int proto) { char *p, *buf; char *s1; int i; *end = str; /* default - not found */ if (*str == '\0') return 0; /* not found */ if (isdigit(*str)) return strtol(str, end, base); /* * find separator. '\\' escapes the next char. */ for (s1 = str; *s1 && (isalnum(*s1) || *s1 == '\\') ; s1++) if (*s1 == '\\' && s1[1] != '\0') s1++; buf = malloc(s1 - str + 1); if (buf == NULL) return 0; /* * copy into a buffer skipping backslashes */ for (p = str, i = 0; p != s1 ; p++) if ( *p != '\\') buf[i++] = *p; buf[i++] = '\0'; if (proto == IPPROTO_ETHERTYPE) { i = match_token(ether_types, buf); free(buf); if (i != -1) { /* found */ *end = s1; return i; } } else { struct protoent *pe = NULL; struct servent *se; if (proto != 0) pe = getprotobynumber(proto); setservent(1); se = getservbyname(buf, pe ? pe->p_name : NULL); free(buf); if (se != NULL) { *end = s1; return ntohs(se->s_port); } } return 0; /* not found */ }
/* * Like strtol, but also translates service names into port numbers * for some protocols. * In particular: * proto == -1 disables the protocol check; * proto == IPPROTO_ETHERTYPE looks up an internal table * proto == <some value in /etc/protocols> matches the values there. * Returns *end == s in case the parameter is not found. */
Like strtol, but also translates service names into port numbers for some protocols.
[ "Like", "strtol", "but", "also", "translates", "service", "names", "into", "port", "numbers", "for", "some", "protocols", "." ]
static int strtoport(char *str, char **end, int base, int proto) { char *p, *buf; char *s1; int i; *end = str; if (*str == '\0') return 0; if (isdigit(*str)) return strtol(str, end, base); for (s1 = str; *s1 && (isalnum(*s1) || *s1 == '\\') ; s1++) if (*s1 == '\\' && s1[1] != '\0') s1++; buf = malloc(s1 - str + 1); if (buf == NULL) return 0; for (p = str, i = 0; p != s1 ; p++) if ( *p != '\\') buf[i++] = *p; buf[i++] = '\0'; if (proto == IPPROTO_ETHERTYPE) { i = match_token(ether_types, buf); free(buf); if (i != -1) { *end = s1; return i; } } else { struct protoent *pe = NULL; struct servent *se; if (proto != 0) pe = getprotobynumber(proto); setservent(1); se = getservbyname(buf, pe ? pe->p_name : NULL); free(buf); if (se != NULL) { *end = s1; return ntohs(se->s_port); } } return 0; }
[ "static", "int", "strtoport", "(", "char", "*", "str", ",", "char", "*", "*", "end", ",", "int", "base", ",", "int", "proto", ")", "{", "char", "*", "p", ",", "*", "buf", ";", "char", "*", "s1", ";", "int", "i", ";", "*", "end", "=", "str", ";", "if", "(", "*", "str", "==", "'", "\\0", "'", ")", "return", "0", ";", "if", "(", "isdigit", "(", "*", "str", ")", ")", "return", "strtol", "(", "str", ",", "end", ",", "base", ")", ";", "for", "(", "s1", "=", "str", ";", "*", "s1", "&&", "(", "isalnum", "(", "*", "s1", ")", "||", "*", "s1", "==", "'", "\\\\", "'", ")", ";", "s1", "++", ")", "if", "(", "*", "s1", "==", "'", "\\\\", "'", "&&", "s1", "[", "1", "]", "!=", "'", "\\0", "'", ")", "s1", "++", ";", "buf", "=", "malloc", "(", "s1", "-", "str", "+", "1", ")", ";", "if", "(", "buf", "==", "NULL", ")", "return", "0", ";", "for", "(", "p", "=", "str", ",", "i", "=", "0", ";", "p", "!=", "s1", ";", "p", "++", ")", "if", "(", "*", "p", "!=", "'", "\\\\", "'", ")", "buf", "[", "i", "++", "]", "=", "*", "p", ";", "buf", "[", "i", "++", "]", "=", "'", "\\0", "'", ";", "if", "(", "proto", "==", "IPPROTO_ETHERTYPE", ")", "{", "i", "=", "match_token", "(", "ether_types", ",", "buf", ")", ";", "free", "(", "buf", ")", ";", "if", "(", "i", "!=", "-1", ")", "{", "*", "end", "=", "s1", ";", "return", "i", ";", "}", "}", "else", "{", "struct", "protoent", "*", "pe", "=", "NULL", ";", "struct", "servent", "*", "se", ";", "if", "(", "proto", "!=", "0", ")", "pe", "=", "getprotobynumber", "(", "proto", ")", ";", "setservent", "(", "1", ")", ";", "se", "=", "getservbyname", "(", "buf", ",", "pe", "?", "pe", "->", "p_name", ":", "NULL", ")", ";", "free", "(", "buf", ")", ";", "if", "(", "se", "!=", "NULL", ")", "{", "*", "end", "=", "s1", ";", "return", "ntohs", "(", "se", "->", "s_port", ")", ";", "}", "}", "return", "0", ";", "}" ]
Like strtol, but also translates service names into port numbers for some protocols.
[ "Like", "strtol", "but", "also", "translates", "service", "names", "into", "port", "numbers", "for", "some", "protocols", "." ]
[ "/* default - not found */", "/* not found */", "/*\n\t * find separator. '\\\\' escapes the next char.\n\t */", "/*\n\t * copy into a buffer skipping backslashes\n\t */", "/* found */", "/* not found */" ]
[ { "param": "str", "type": "char" }, { "param": "end", "type": "char" }, { "param": "base", "type": "int" }, { "param": "proto", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "end", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "base", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "proto", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
fill_newports
int
static int fill_newports(ipfw_insn_u16 *cmd, char *av, int proto) { u_int16_t *p = cmd->ports; int i = 0; char *str = av; while (*str) { u_int16_t a, b; a = strtoport(av, &str, 0, proto); if (str == av) /* no parameter */ break; if (*str == '-') { /* a range */ av = str+1; b = strtoport(av, &str, 0, proto); if (str == av) /* no parameter */ break; p[0] = a; p[1] = b; } else if (*str == ',' || *str == '\0' ) { p[0] = p[1] = a; } else { /* invalid separator */ errx(EX_DATAERR, "invalid separator <%c> in <%s>\n", *str, av); } i++; p += 2; av = str+1; } if (i > 0) { if (i+1 > F_LEN_MASK) errx(EX_DATAERR, "too many ports/ranges\n"); cmd->o.len |= i+1; /* leave F_NOT and F_OR untouched */ } return i; }
/* * fill the body of the command with the list of port ranges. * At the moment it only understands numeric ranges. */
fill the body of the command with the list of port ranges. At the moment it only understands numeric ranges.
[ "fill", "the", "body", "of", "the", "command", "with", "the", "list", "of", "port", "ranges", ".", "At", "the", "moment", "it", "only", "understands", "numeric", "ranges", "." ]
static int fill_newports(ipfw_insn_u16 *cmd, char *av, int proto) { u_int16_t *p = cmd->ports; int i = 0; char *str = av; while (*str) { u_int16_t a, b; a = strtoport(av, &str, 0, proto); if (str == av) break; if (*str == '-') { av = str+1; b = strtoport(av, &str, 0, proto); if (str == av) break; p[0] = a; p[1] = b; } else if (*str == ',' || *str == '\0' ) { p[0] = p[1] = a; } else { errx(EX_DATAERR, "invalid separator <%c> in <%s>\n", *str, av); } i++; p += 2; av = str+1; } if (i > 0) { if (i+1 > F_LEN_MASK) errx(EX_DATAERR, "too many ports/ranges\n"); cmd->o.len |= i+1; } return i; }
[ "static", "int", "fill_newports", "(", "ipfw_insn_u16", "*", "cmd", ",", "char", "*", "av", ",", "int", "proto", ")", "{", "u_int16_t", "*", "p", "=", "cmd", "->", "ports", ";", "int", "i", "=", "0", ";", "char", "*", "str", "=", "av", ";", "while", "(", "*", "str", ")", "{", "u_int16_t", "a", ",", "b", ";", "a", "=", "strtoport", "(", "av", ",", "&", "str", ",", "0", ",", "proto", ")", ";", "if", "(", "str", "==", "av", ")", "break", ";", "if", "(", "*", "str", "==", "'", "'", ")", "{", "av", "=", "str", "+", "1", ";", "b", "=", "strtoport", "(", "av", ",", "&", "str", ",", "0", ",", "proto", ")", ";", "if", "(", "str", "==", "av", ")", "break", ";", "p", "[", "0", "]", "=", "a", ";", "p", "[", "1", "]", "=", "b", ";", "}", "else", "if", "(", "*", "str", "==", "'", "'", "||", "*", "str", "==", "'", "\\0", "'", ")", "{", "p", "[", "0", "]", "=", "p", "[", "1", "]", "=", "a", ";", "}", "else", "{", "errx", "(", "EX_DATAERR", ",", "\"", "\\n", "\"", ",", "*", "str", ",", "av", ")", ";", "}", "i", "++", ";", "p", "+=", "2", ";", "av", "=", "str", "+", "1", ";", "}", "if", "(", "i", ">", "0", ")", "{", "if", "(", "i", "+", "1", ">", "F_LEN_MASK", ")", "errx", "(", "EX_DATAERR", ",", "\"", "\\n", "\"", ")", ";", "cmd", "->", "o", ".", "len", "|=", "i", "+", "1", ";", "}", "return", "i", ";", "}" ]
fill the body of the command with the list of port ranges.
[ "fill", "the", "body", "of", "the", "command", "with", "the", "list", "of", "port", "ranges", "." ]
[ "/* no parameter */", "/* a range */", "/* no parameter */", "/* invalid separator */", "/* leave F_NOT and F_OR untouched */" ]
[ { "param": "cmd", "type": "ipfw_insn_u16" }, { "param": "av", "type": "char" }, { "param": "proto", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "ipfw_insn_u16", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "av", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "proto", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
contigmask
int
static int contigmask(u_char *p, int len) { int i, n; for (i=0; i<len ; i++) if ( (p[i/8] & (1 << (7 - (i%8)))) == 0) /* first bit unset */ break; for (n=i+1; n < len; n++) if ( (p[n/8] & (1 << (7 - (n%8)))) != 0) return -1; /* mask not contiguous */ return i; }
/* * Returns the number of bits set (from left) in a contiguous bitmask, * or -1 if the mask is not contiguous. * XXX this needs a proper fix. * This effectively works on masks in big-endian (network) format. * when compiled on little endian architectures. * * First bit is bit 7 of the first byte -- note, for MAC addresses, * the first bit on the wire is bit 0 of the first byte. * len is the max length in bits. */
Returns the number of bits set (from left) in a contiguous bitmask, or -1 if the mask is not contiguous. XXX this needs a proper fix. This effectively works on masks in big-endian (network) format. when compiled on little endian architectures. First bit is bit 7 of the first byte -- note, for MAC addresses, the first bit on the wire is bit 0 of the first byte. len is the max length in bits.
[ "Returns", "the", "number", "of", "bits", "set", "(", "from", "left", ")", "in", "a", "contiguous", "bitmask", "or", "-", "1", "if", "the", "mask", "is", "not", "contiguous", ".", "XXX", "this", "needs", "a", "proper", "fix", ".", "This", "effectively", "works", "on", "masks", "in", "big", "-", "endian", "(", "network", ")", "format", ".", "when", "compiled", "on", "little", "endian", "architectures", ".", "First", "bit", "is", "bit", "7", "of", "the", "first", "byte", "--", "note", "for", "MAC", "addresses", "the", "first", "bit", "on", "the", "wire", "is", "bit", "0", "of", "the", "first", "byte", ".", "len", "is", "the", "max", "length", "in", "bits", "." ]
static int contigmask(u_char *p, int len) { int i, n; for (i=0; i<len ; i++) if ( (p[i/8] & (1 << (7 - (i%8)))) == 0) break; for (n=i+1; n < len; n++) if ( (p[n/8] & (1 << (7 - (n%8)))) != 0) return -1; return i; }
[ "static", "int", "contigmask", "(", "u_char", "*", "p", ",", "int", "len", ")", "{", "int", "i", ",", "n", ";", "for", "(", "i", "=", "0", ";", "i", "<", "len", ";", "i", "++", ")", "if", "(", "(", "p", "[", "i", "/", "8", "]", "&", "(", "1", "<<", "(", "7", "-", "(", "i", "%", "8", ")", ")", ")", ")", "==", "0", ")", "break", ";", "for", "(", "n", "=", "i", "+", "1", ";", "n", "<", "len", ";", "n", "++", ")", "if", "(", "(", "p", "[", "n", "/", "8", "]", "&", "(", "1", "<<", "(", "7", "-", "(", "n", "%", "8", ")", ")", ")", ")", "!=", "0", ")", "return", "-1", ";", "return", "i", ";", "}" ]
Returns the number of bits set (from left) in a contiguous bitmask, or -1 if the mask is not contiguous.
[ "Returns", "the", "number", "of", "bits", "set", "(", "from", "left", ")", "in", "a", "contiguous", "bitmask", "or", "-", "1", "if", "the", "mask", "is", "not", "contiguous", "." ]
[ "/* first bit unset */", "/* mask not contiguous */" ]
[ { "param": "p", "type": "u_char" }, { "param": "len", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
print_flags
void
static void print_flags(const char *name, ipfw_insn *cmd, struct _s_x *list) { const char *comma=""; int i; u_char set = cmd->arg1 & 0xff; u_char clear = (cmd->arg1 >> 8) & 0xff; if (list == f_tcpflags && set == TH_SYN && clear == TH_ACK) { printf(" setup"); return; } printf(" %s ", name); for (i=0; list[i].x != 0; i++) { if (set & list[i].x) { set &= ~list[i].x; printf("%s%s", comma, list[i].s); comma = ","; } if (clear & list[i].x) { clear &= ~list[i].x; printf("%s!%s", comma, list[i].s); comma = ","; } } }
/* * print flags set/clear in the two bitmasks passed as parameters. * There is a specialized check for f_tcpflags. */
print flags set/clear in the two bitmasks passed as parameters. There is a specialized check for f_tcpflags.
[ "print", "flags", "set", "/", "clear", "in", "the", "two", "bitmasks", "passed", "as", "parameters", ".", "There", "is", "a", "specialized", "check", "for", "f_tcpflags", "." ]
static void print_flags(const char *name, ipfw_insn *cmd, struct _s_x *list) { const char *comma=""; int i; u_char set = cmd->arg1 & 0xff; u_char clear = (cmd->arg1 >> 8) & 0xff; if (list == f_tcpflags && set == TH_SYN && clear == TH_ACK) { printf(" setup"); return; } printf(" %s ", name); for (i=0; list[i].x != 0; i++) { if (set & list[i].x) { set &= ~list[i].x; printf("%s%s", comma, list[i].s); comma = ","; } if (clear & list[i].x) { clear &= ~list[i].x; printf("%s!%s", comma, list[i].s); comma = ","; } } }
[ "static", "void", "print_flags", "(", "const", "char", "*", "name", ",", "ipfw_insn", "*", "cmd", ",", "struct", "_s_x", "*", "list", ")", "{", "const", "char", "*", "comma", "=", "\"", "\"", ";", "int", "i", ";", "u_char", "set", "=", "cmd", "->", "arg1", "&", "0xff", ";", "u_char", "clear", "=", "(", "cmd", "->", "arg1", ">>", "8", ")", "&", "0xff", ";", "if", "(", "list", "==", "f_tcpflags", "&&", "set", "==", "TH_SYN", "&&", "clear", "==", "TH_ACK", ")", "{", "printf", "(", "\"", "\"", ")", ";", "return", ";", "}", "printf", "(", "\"", "\"", ",", "name", ")", ";", "for", "(", "i", "=", "0", ";", "list", "[", "i", "]", ".", "x", "!=", "0", ";", "i", "++", ")", "{", "if", "(", "set", "&", "list", "[", "i", "]", ".", "x", ")", "{", "set", "&=", "~", "list", "[", "i", "]", ".", "x", ";", "printf", "(", "\"", "\"", ",", "comma", ",", "list", "[", "i", "]", ".", "s", ")", ";", "comma", "=", "\"", "\"", ";", "}", "if", "(", "clear", "&", "list", "[", "i", "]", ".", "x", ")", "{", "clear", "&=", "~", "list", "[", "i", "]", ".", "x", ";", "printf", "(", "\"", "\"", ",", "comma", ",", "list", "[", "i", "]", ".", "s", ")", ";", "comma", "=", "\"", "\"", ";", "}", "}", "}" ]
print flags set/clear in the two bitmasks passed as parameters.
[ "print", "flags", "set", "/", "clear", "in", "the", "two", "bitmasks", "passed", "as", "parameters", "." ]
[]
[ { "param": "name", "type": "char" }, { "param": "cmd", "type": "ipfw_insn" }, { "param": "list", "type": "struct _s_x" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cmd", "type": "ipfw_insn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "list", "type": "struct _s_x", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
print_ip
void
static void print_ip(ipfw_insn_ip *cmd, const char *str) { struct hostent *he = NULL; int mb; printf("%s%s ", cmd->o.len & F_NOT ? " not": "", str); if (cmd->o.opcode == O_IP_SRC_ME || cmd->o.opcode == O_IP_DST_ME) { printf("me"); return; } if (cmd->o.opcode == O_IP_SRC_TABLE || cmd->o.opcode == O_IP_DST_TABLE) { printf("<%u>", cmd->o.arg1); return; } if (cmd->o.opcode == O_IP_SRC_IFIP || cmd->o.opcode == O_IP_DST_IFIP) { printf("[%s%s]", ((ipfw_insn_ifip *)cmd)->ifname, (cmd->o.arg1 & IPFW_IFIP_NET) ? ":net" : ""); return; } if (cmd->o.opcode == O_IP_SRC_SET || cmd->o.opcode == O_IP_DST_SET) { u_int32_t x, *d; int i; char comma = '{'; x = cmd->o.arg1 - 1; x = htonl( ~x ); cmd->addr.s_addr = htonl(cmd->addr.s_addr); printf("%s/%d", inet_ntoa(cmd->addr), contigmask((u_char *)&x, 32)); x = cmd->addr.s_addr = htonl(cmd->addr.s_addr); x &= 0xff; /* base */ d = (u_int32_t *)&(cmd->mask); for (i=0; i < cmd->o.arg1; i++) if (d[ i/32] & (1<<(i & 31))) { printf("%c%d", comma, i+x); comma = ','; } printf("}"); return; } if (cmd->o.opcode == O_IP_SRC || cmd->o.opcode == O_IP_DST) mb = 32; else mb = contigmask((u_char *)&(cmd->mask.s_addr), 32); if (mb == 32 && do_resolv) he = gethostbyaddr(&(cmd->addr.s_addr), sizeof(u_long), AF_INET); if (he != NULL) /* resolved to name */ printf("%s", he->h_name); else if (mb == 0) /* any */ printf("any"); else { /* numeric IP followed by some kind of mask */ printf("%s", inet_ntoa(cmd->addr)); if (mb < 0) printf(":%s", inet_ntoa(cmd->mask)); else if (mb < 32) printf("/%d", mb); } }
/* * Print the ip address contained in a command. */
Print the ip address contained in a command.
[ "Print", "the", "ip", "address", "contained", "in", "a", "command", "." ]
static void print_ip(ipfw_insn_ip *cmd, const char *str) { struct hostent *he = NULL; int mb; printf("%s%s ", cmd->o.len & F_NOT ? " not": "", str); if (cmd->o.opcode == O_IP_SRC_ME || cmd->o.opcode == O_IP_DST_ME) { printf("me"); return; } if (cmd->o.opcode == O_IP_SRC_TABLE || cmd->o.opcode == O_IP_DST_TABLE) { printf("<%u>", cmd->o.arg1); return; } if (cmd->o.opcode == O_IP_SRC_IFIP || cmd->o.opcode == O_IP_DST_IFIP) { printf("[%s%s]", ((ipfw_insn_ifip *)cmd)->ifname, (cmd->o.arg1 & IPFW_IFIP_NET) ? ":net" : ""); return; } if (cmd->o.opcode == O_IP_SRC_SET || cmd->o.opcode == O_IP_DST_SET) { u_int32_t x, *d; int i; char comma = '{'; x = cmd->o.arg1 - 1; x = htonl( ~x ); cmd->addr.s_addr = htonl(cmd->addr.s_addr); printf("%s/%d", inet_ntoa(cmd->addr), contigmask((u_char *)&x, 32)); x = cmd->addr.s_addr = htonl(cmd->addr.s_addr); x &= 0xff; d = (u_int32_t *)&(cmd->mask); for (i=0; i < cmd->o.arg1; i++) if (d[ i/32] & (1<<(i & 31))) { printf("%c%d", comma, i+x); comma = ','; } printf("}"); return; } if (cmd->o.opcode == O_IP_SRC || cmd->o.opcode == O_IP_DST) mb = 32; else mb = contigmask((u_char *)&(cmd->mask.s_addr), 32); if (mb == 32 && do_resolv) he = gethostbyaddr(&(cmd->addr.s_addr), sizeof(u_long), AF_INET); if (he != NULL) printf("%s", he->h_name); else if (mb == 0) printf("any"); else { printf("%s", inet_ntoa(cmd->addr)); if (mb < 0) printf(":%s", inet_ntoa(cmd->mask)); else if (mb < 32) printf("/%d", mb); } }
[ "static", "void", "print_ip", "(", "ipfw_insn_ip", "*", "cmd", ",", "const", "char", "*", "str", ")", "{", "struct", "hostent", "*", "he", "=", "NULL", ";", "int", "mb", ";", "printf", "(", "\"", "\"", ",", "cmd", "->", "o", ".", "len", "&", "F_NOT", "?", "\"", "\"", ":", "\"", "\"", ",", "str", ")", ";", "if", "(", "cmd", "->", "o", ".", "opcode", "==", "O_IP_SRC_ME", "||", "cmd", "->", "o", ".", "opcode", "==", "O_IP_DST_ME", ")", "{", "printf", "(", "\"", "\"", ")", ";", "return", ";", "}", "if", "(", "cmd", "->", "o", ".", "opcode", "==", "O_IP_SRC_TABLE", "||", "cmd", "->", "o", ".", "opcode", "==", "O_IP_DST_TABLE", ")", "{", "printf", "(", "\"", "\"", ",", "cmd", "->", "o", ".", "arg1", ")", ";", "return", ";", "}", "if", "(", "cmd", "->", "o", ".", "opcode", "==", "O_IP_SRC_IFIP", "||", "cmd", "->", "o", ".", "opcode", "==", "O_IP_DST_IFIP", ")", "{", "printf", "(", "\"", "\"", ",", "(", "(", "ipfw_insn_ifip", "*", ")", "cmd", ")", "->", "ifname", ",", "(", "cmd", "->", "o", ".", "arg1", "&", "IPFW_IFIP_NET", ")", "?", "\"", "\"", ":", "\"", "\"", ")", ";", "return", ";", "}", "if", "(", "cmd", "->", "o", ".", "opcode", "==", "O_IP_SRC_SET", "||", "cmd", "->", "o", ".", "opcode", "==", "O_IP_DST_SET", ")", "{", "u_int32_t", "x", ",", "*", "d", ";", "int", "i", ";", "char", "comma", "=", "'", "'", ";", "x", "=", "cmd", "->", "o", ".", "arg1", "-", "1", ";", "x", "=", "htonl", "(", "~", "x", ")", ";", "cmd", "->", "addr", ".", "s_addr", "=", "htonl", "(", "cmd", "->", "addr", ".", "s_addr", ")", ";", "printf", "(", "\"", "\"", ",", "inet_ntoa", "(", "cmd", "->", "addr", ")", ",", "contigmask", "(", "(", "u_char", "*", ")", "&", "x", ",", "32", ")", ")", ";", "x", "=", "cmd", "->", "addr", ".", "s_addr", "=", "htonl", "(", "cmd", "->", "addr", ".", "s_addr", ")", ";", "x", "&=", "0xff", ";", "d", "=", "(", "u_int32_t", "*", ")", "&", "(", "cmd", "->", "mask", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "cmd", "->", "o", ".", "arg1", ";", "i", "++", ")", "if", "(", "d", "[", "i", "/", "32", "]", "&", "(", "1", "<<", "(", "i", "&", "31", ")", ")", ")", "{", "printf", "(", "\"", "\"", ",", "comma", ",", "i", "+", "x", ")", ";", "comma", "=", "'", "'", ";", "}", "printf", "(", "\"", "\"", ")", ";", "return", ";", "}", "if", "(", "cmd", "->", "o", ".", "opcode", "==", "O_IP_SRC", "||", "cmd", "->", "o", ".", "opcode", "==", "O_IP_DST", ")", "mb", "=", "32", ";", "else", "mb", "=", "contigmask", "(", "(", "u_char", "*", ")", "&", "(", "cmd", "->", "mask", ".", "s_addr", ")", ",", "32", ")", ";", "if", "(", "mb", "==", "32", "&&", "do_resolv", ")", "he", "=", "gethostbyaddr", "(", "&", "(", "cmd", "->", "addr", ".", "s_addr", ")", ",", "sizeof", "(", "u_long", ")", ",", "AF_INET", ")", ";", "if", "(", "he", "!=", "NULL", ")", "printf", "(", "\"", "\"", ",", "he", "->", "h_name", ")", ";", "else", "if", "(", "mb", "==", "0", ")", "printf", "(", "\"", "\"", ")", ";", "else", "{", "printf", "(", "\"", "\"", ",", "inet_ntoa", "(", "cmd", "->", "addr", ")", ")", ";", "if", "(", "mb", "<", "0", ")", "printf", "(", "\"", "\"", ",", "inet_ntoa", "(", "cmd", "->", "mask", ")", ")", ";", "else", "if", "(", "mb", "<", "32", ")", "printf", "(", "\"", "\"", ",", "mb", ")", ";", "}", "}" ]
Print the ip address contained in a command.
[ "Print", "the", "ip", "address", "contained", "in", "a", "command", "." ]
[ "/* base */", "/* resolved to name */", "/* any */", "/* numeric IP followed by some kind of mask */" ]
[ { "param": "cmd", "type": "ipfw_insn_ip" }, { "param": "str", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "ipfw_insn_ip", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
print_mac
void
static void print_mac(u_char *addr, u_char *mask) { int l = contigmask(mask, 48); if (l == 0) printf(" any"); else { printf(" %02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); if (l == -1) printf("&%02x:%02x:%02x:%02x:%02x:%02x", mask[0], mask[1], mask[2], mask[3], mask[4], mask[5]); else if (l < 48) printf("/%d", l); } }
/* * prints a MAC address/mask pair */
prints a MAC address/mask pair
[ "prints", "a", "MAC", "address", "/", "mask", "pair" ]
static void print_mac(u_char *addr, u_char *mask) { int l = contigmask(mask, 48); if (l == 0) printf(" any"); else { printf(" %02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); if (l == -1) printf("&%02x:%02x:%02x:%02x:%02x:%02x", mask[0], mask[1], mask[2], mask[3], mask[4], mask[5]); else if (l < 48) printf("/%d", l); } }
[ "static", "void", "print_mac", "(", "u_char", "*", "addr", ",", "u_char", "*", "mask", ")", "{", "int", "l", "=", "contigmask", "(", "mask", ",", "48", ")", ";", "if", "(", "l", "==", "0", ")", "printf", "(", "\"", "\"", ")", ";", "else", "{", "printf", "(", "\"", "\"", ",", "addr", "[", "0", "]", ",", "addr", "[", "1", "]", ",", "addr", "[", "2", "]", ",", "addr", "[", "3", "]", ",", "addr", "[", "4", "]", ",", "addr", "[", "5", "]", ")", ";", "if", "(", "l", "==", "-1", ")", "printf", "(", "\"", "\"", ",", "mask", "[", "0", "]", ",", "mask", "[", "1", "]", ",", "mask", "[", "2", "]", ",", "mask", "[", "3", "]", ",", "mask", "[", "4", "]", ",", "mask", "[", "5", "]", ")", ";", "else", "if", "(", "l", "<", "48", ")", "printf", "(", "\"", "\"", ",", "l", ")", ";", "}", "}" ]
prints a MAC address/mask pair
[ "prints", "a", "MAC", "address", "/", "mask", "pair" ]
[]
[ { "param": "addr", "type": "u_char" }, { "param": "mask", "type": "u_char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "addr", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mask", "type": "u_char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
fill_flags
void
static void fill_flags(ipfw_insn *cmd, enum ipfw_opcodes opcode, struct _s_x *flags, char *p) { u_int8_t set=0, clear=0; while (p && *p) { char *q; /* points to the separator */ int val; u_int8_t *which; /* mask we are working on */ if (*p == '!') { p++; which = &clear; } else which = &set; q = strchr(p, ','); if (q) *q++ = '\0'; val = match_token(flags, p); if (val <= 0) errx(EX_DATAERR, "invalid flag %s", p); *which |= (u_int8_t)val; p = q; } cmd->opcode = opcode; cmd->len = (cmd->len & (F_NOT | F_OR)) | 1; cmd->arg1 = (set & 0xff) | ( (clear & 0xff) << 8); }
/* * helper function to process a set of flags and set bits in the * appropriate masks. */
helper function to process a set of flags and set bits in the appropriate masks.
[ "helper", "function", "to", "process", "a", "set", "of", "flags", "and", "set", "bits", "in", "the", "appropriate", "masks", "." ]
static void fill_flags(ipfw_insn *cmd, enum ipfw_opcodes opcode, struct _s_x *flags, char *p) { u_int8_t set=0, clear=0; while (p && *p) { char *q; int val; u_int8_t *which; if (*p == '!') { p++; which = &clear; } else which = &set; q = strchr(p, ','); if (q) *q++ = '\0'; val = match_token(flags, p); if (val <= 0) errx(EX_DATAERR, "invalid flag %s", p); *which |= (u_int8_t)val; p = q; } cmd->opcode = opcode; cmd->len = (cmd->len & (F_NOT | F_OR)) | 1; cmd->arg1 = (set & 0xff) | ( (clear & 0xff) << 8); }
[ "static", "void", "fill_flags", "(", "ipfw_insn", "*", "cmd", ",", "enum", "ipfw_opcodes", "opcode", ",", "struct", "_s_x", "*", "flags", ",", "char", "*", "p", ")", "{", "u_int8_t", "set", "=", "0", ",", "clear", "=", "0", ";", "while", "(", "p", "&&", "*", "p", ")", "{", "char", "*", "q", ";", "int", "val", ";", "u_int8_t", "*", "which", ";", "if", "(", "*", "p", "==", "'", "'", ")", "{", "p", "++", ";", "which", "=", "&", "clear", ";", "}", "else", "which", "=", "&", "set", ";", "q", "=", "strchr", "(", "p", ",", "'", "'", ")", ";", "if", "(", "q", ")", "*", "q", "++", "=", "'", "\\0", "'", ";", "val", "=", "match_token", "(", "flags", ",", "p", ")", ";", "if", "(", "val", "<=", "0", ")", "errx", "(", "EX_DATAERR", ",", "\"", "\"", ",", "p", ")", ";", "*", "which", "|=", "(", "u_int8_t", ")", "val", ";", "p", "=", "q", ";", "}", "cmd", "->", "opcode", "=", "opcode", ";", "cmd", "->", "len", "=", "(", "cmd", "->", "len", "&", "(", "F_NOT", "|", "F_OR", ")", ")", "|", "1", ";", "cmd", "->", "arg1", "=", "(", "set", "&", "0xff", ")", "|", "(", "(", "clear", "&", "0xff", ")", "<<", "8", ")", ";", "}" ]
helper function to process a set of flags and set bits in the appropriate masks.
[ "helper", "function", "to", "process", "a", "set", "of", "flags", "and", "set", "bits", "in", "the", "appropriate", "masks", "." ]
[ "/* points to the separator */", "/* mask we are working on */" ]
[ { "param": "cmd", "type": "ipfw_insn" }, { "param": "opcode", "type": "enum ipfw_opcodes" }, { "param": "flags", "type": "struct _s_x" }, { "param": "p", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "ipfw_insn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "opcode", "type": "enum ipfw_opcodes", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": "struct _s_x", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
fill_iface
void
static void fill_iface(ipfw_insn_if *cmd, char *arg) { cmd->name[0] = '\0'; cmd->o.len |= F_INSN_SIZE(ipfw_insn_if); /* Parse the interface or address */ if (!strcmp(arg, "any")) cmd->o.len = 0; /* effectively ignore this command */ else if (!isdigit(*arg)) { strlcpy(cmd->name, arg, sizeof(cmd->name)); cmd->p.glob = strpbrk(arg, "*?[") != NULL ? 1 : 0; } else if (!inet_aton(arg, &cmd->p.ip)) errx(EX_DATAERR, "bad ip address ``%s''", arg); }
/* * fill the interface structure. We do not check the name as we can * create interfaces dynamically, so checking them at insert time * makes relatively little sense. * Interface names containing '*', '?', or '[' are assumed to be shell * patterns which match interfaces. */
fill the interface structure. We do not check the name as we can create interfaces dynamically, so checking them at insert time makes relatively little sense.
[ "fill", "the", "interface", "structure", ".", "We", "do", "not", "check", "the", "name", "as", "we", "can", "create", "interfaces", "dynamically", "so", "checking", "them", "at", "insert", "time", "makes", "relatively", "little", "sense", "." ]
static void fill_iface(ipfw_insn_if *cmd, char *arg) { cmd->name[0] = '\0'; cmd->o.len |= F_INSN_SIZE(ipfw_insn_if); if (!strcmp(arg, "any")) cmd->o.len = 0; else if (!isdigit(*arg)) { strlcpy(cmd->name, arg, sizeof(cmd->name)); cmd->p.glob = strpbrk(arg, "*?[") != NULL ? 1 : 0; } else if (!inet_aton(arg, &cmd->p.ip)) errx(EX_DATAERR, "bad ip address ``%s''", arg); }
[ "static", "void", "fill_iface", "(", "ipfw_insn_if", "*", "cmd", ",", "char", "*", "arg", ")", "{", "cmd", "->", "name", "[", "0", "]", "=", "'", "\\0", "'", ";", "cmd", "->", "o", ".", "len", "|=", "F_INSN_SIZE", "(", "ipfw_insn_if", ")", ";", "if", "(", "!", "strcmp", "(", "arg", ",", "\"", "\"", ")", ")", "cmd", "->", "o", ".", "len", "=", "0", ";", "else", "if", "(", "!", "isdigit", "(", "*", "arg", ")", ")", "{", "strlcpy", "(", "cmd", "->", "name", ",", "arg", ",", "sizeof", "(", "cmd", "->", "name", ")", ")", ";", "cmd", "->", "p", ".", "glob", "=", "strpbrk", "(", "arg", ",", "\"", "\"", ")", "!=", "NULL", "?", "1", ":", "0", ";", "}", "else", "if", "(", "!", "inet_aton", "(", "arg", ",", "&", "cmd", "->", "p", ".", "ip", ")", ")", "errx", "(", "EX_DATAERR", ",", "\"", "\"", ",", "arg", ")", ";", "}" ]
fill the interface structure.
[ "fill", "the", "interface", "structure", "." ]
[ "/* Parse the interface or address */", "/* effectively ignore this command */" ]
[ { "param": "cmd", "type": "ipfw_insn_if" }, { "param": "arg", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "ipfw_insn_if", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
next_cmd
ipfw_insn
static ipfw_insn * next_cmd(ipfw_insn *cmd) { cmd += F_LEN(cmd); bzero(cmd, sizeof(*cmd)); return cmd; }
/* * helper function, updates the pointer to cmd with the length * of the current command, and also cleans up the first word of * the new command in case it has been clobbered before. */
helper function, updates the pointer to cmd with the length of the current command, and also cleans up the first word of the new command in case it has been clobbered before.
[ "helper", "function", "updates", "the", "pointer", "to", "cmd", "with", "the", "length", "of", "the", "current", "command", "and", "also", "cleans", "up", "the", "first", "word", "of", "the", "new", "command", "in", "case", "it", "has", "been", "clobbered", "before", "." ]
static ipfw_insn * next_cmd(ipfw_insn *cmd) { cmd += F_LEN(cmd); bzero(cmd, sizeof(*cmd)); return cmd; }
[ "static", "ipfw_insn", "*", "next_cmd", "(", "ipfw_insn", "*", "cmd", ")", "{", "cmd", "+=", "F_LEN", "(", "cmd", ")", ";", "bzero", "(", "cmd", ",", "sizeof", "(", "*", "cmd", ")", ")", ";", "return", "cmd", ";", "}" ]
helper function, updates the pointer to cmd with the length of the current command, and also cleans up the first word of the new command in case it has been clobbered before.
[ "helper", "function", "updates", "the", "pointer", "to", "cmd", "with", "the", "length", "of", "the", "current", "command", "and", "also", "cleans", "up", "the", "first", "word", "of", "the", "new", "command", "in", "case", "it", "has", "been", "clobbered", "before", "." ]
[]
[ { "param": "cmd", "type": "ipfw_insn" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "ipfw_insn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
fill_cmd
void
static void fill_cmd(ipfw_insn *cmd, enum ipfw_opcodes opcode, int flags, u_int16_t arg) { cmd->opcode = opcode; cmd->len = ((cmd->len | flags) & (F_NOT | F_OR)) | 1; cmd->arg1 = arg; }
/* * A function to fill simple commands of size 1. * Existing flags are preserved. */
A function to fill simple commands of size 1. Existing flags are preserved.
[ "A", "function", "to", "fill", "simple", "commands", "of", "size", "1", ".", "Existing", "flags", "are", "preserved", "." ]
static void fill_cmd(ipfw_insn *cmd, enum ipfw_opcodes opcode, int flags, u_int16_t arg) { cmd->opcode = opcode; cmd->len = ((cmd->len | flags) & (F_NOT | F_OR)) | 1; cmd->arg1 = arg; }
[ "static", "void", "fill_cmd", "(", "ipfw_insn", "*", "cmd", ",", "enum", "ipfw_opcodes", "opcode", ",", "int", "flags", ",", "u_int16_t", "arg", ")", "{", "cmd", "->", "opcode", "=", "opcode", ";", "cmd", "->", "len", "=", "(", "(", "cmd", "->", "len", "|", "flags", ")", "&", "(", "F_NOT", "|", "F_OR", ")", ")", "|", "1", ";", "cmd", "->", "arg1", "=", "arg", ";", "}" ]
A function to fill simple commands of size 1.
[ "A", "function", "to", "fill", "simple", "commands", "of", "size", "1", "." ]
[]
[ { "param": "cmd", "type": "ipfw_insn" }, { "param": "opcode", "type": "enum ipfw_opcodes" }, { "param": "flags", "type": "int" }, { "param": "arg", "type": "u_int16_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "ipfw_insn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "opcode", "type": "enum ipfw_opcodes", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flags", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg", "type": "u_int16_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6f63564d297b9b9fa9469ad650a4cfefc448d405
atrens/DragonFlyBSD-src
sbin/ipfw/ipfw2.c
[ "BSD-3-Clause" ]
C
add_mac
ipfw_insn
static ipfw_insn * add_mac(ipfw_insn *cmd, int ac, char *av[]) { ipfw_insn_mac *mac; if (ac < 2) errx(EX_DATAERR, "MAC dst src"); cmd->opcode = O_MACADDR2; cmd->len = (cmd->len & (F_NOT | F_OR)) | F_INSN_SIZE(ipfw_insn_mac); mac = (ipfw_insn_mac *)cmd; get_mac_addr_mask(av[0], mac->addr, mac->mask); /* dst */ get_mac_addr_mask(av[1], &(mac->addr[6]), &(mac->mask[6])); /* src */ return cmd; }
/* * Fetch and add the MAC address and type, with masks. This generates one or * two microinstructions, and returns the pointer to the last one. */
Fetch and add the MAC address and type, with masks. This generates one or two microinstructions, and returns the pointer to the last one.
[ "Fetch", "and", "add", "the", "MAC", "address", "and", "type", "with", "masks", ".", "This", "generates", "one", "or", "two", "microinstructions", "and", "returns", "the", "pointer", "to", "the", "last", "one", "." ]
static ipfw_insn * add_mac(ipfw_insn *cmd, int ac, char *av[]) { ipfw_insn_mac *mac; if (ac < 2) errx(EX_DATAERR, "MAC dst src"); cmd->opcode = O_MACADDR2; cmd->len = (cmd->len & (F_NOT | F_OR)) | F_INSN_SIZE(ipfw_insn_mac); mac = (ipfw_insn_mac *)cmd; get_mac_addr_mask(av[0], mac->addr, mac->mask); get_mac_addr_mask(av[1], &(mac->addr[6]), &(mac->mask[6])); return cmd; }
[ "static", "ipfw_insn", "*", "add_mac", "(", "ipfw_insn", "*", "cmd", ",", "int", "ac", ",", "char", "*", "av", "[", "]", ")", "{", "ipfw_insn_mac", "*", "mac", ";", "if", "(", "ac", "<", "2", ")", "errx", "(", "EX_DATAERR", ",", "\"", "\"", ")", ";", "cmd", "->", "opcode", "=", "O_MACADDR2", ";", "cmd", "->", "len", "=", "(", "cmd", "->", "len", "&", "(", "F_NOT", "|", "F_OR", ")", ")", "|", "F_INSN_SIZE", "(", "ipfw_insn_mac", ")", ";", "mac", "=", "(", "ipfw_insn_mac", "*", ")", "cmd", ";", "get_mac_addr_mask", "(", "av", "[", "0", "]", ",", "mac", "->", "addr", ",", "mac", "->", "mask", ")", ";", "get_mac_addr_mask", "(", "av", "[", "1", "]", ",", "&", "(", "mac", "->", "addr", "[", "6", "]", ")", ",", "&", "(", "mac", "->", "mask", "[", "6", "]", ")", ")", ";", "return", "cmd", ";", "}" ]
Fetch and add the MAC address and type, with masks.
[ "Fetch", "and", "add", "the", "MAC", "address", "and", "type", "with", "masks", "." ]
[ "/* dst */", "/* src */" ]
[ { "param": "cmd", "type": "ipfw_insn" }, { "param": "ac", "type": "int" }, { "param": "av", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "ipfw_insn", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ac", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "av", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
find_referenced_vars
null
static unsigned int find_referenced_vars (void) { basic_block bb; gimple_stmt_iterator si; FOR_EACH_BB (bb) { for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) { gimple stmt = gsi_stmt (si); if (is_gimple_debug (stmt)) continue; find_referenced_vars_in (gsi_stmt (si)); } for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) find_referenced_vars_in (gsi_stmt (si)); } return 0; }
/* Find all the variables referenced in the function. This function builds the global arrays REFERENCED_VARS and CALL_CLOBBERED_VARS. Note that this function does not look for statement operands, it simply determines what variables are referenced in the program and detects various attributes for each variable used by alias analysis and the optimizer. */
Find all the variables referenced in the function. This function builds the global arrays REFERENCED_VARS and CALL_CLOBBERED_VARS. Note that this function does not look for statement operands, it simply determines what variables are referenced in the program and detects various attributes for each variable used by alias analysis and the optimizer.
[ "Find", "all", "the", "variables", "referenced", "in", "the", "function", ".", "This", "function", "builds", "the", "global", "arrays", "REFERENCED_VARS", "and", "CALL_CLOBBERED_VARS", ".", "Note", "that", "this", "function", "does", "not", "look", "for", "statement", "operands", "it", "simply", "determines", "what", "variables", "are", "referenced", "in", "the", "program", "and", "detects", "various", "attributes", "for", "each", "variable", "used", "by", "alias", "analysis", "and", "the", "optimizer", "." ]
static unsigned int find_referenced_vars (void) { basic_block bb; gimple_stmt_iterator si; FOR_EACH_BB (bb) { for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) { gimple stmt = gsi_stmt (si); if (is_gimple_debug (stmt)) continue; find_referenced_vars_in (gsi_stmt (si)); } for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si)) find_referenced_vars_in (gsi_stmt (si)); } return 0; }
[ "static", "unsigned", "int", "find_referenced_vars", "(", "void", ")", "{", "basic_block", "bb", ";", "gimple_stmt_iterator", "si", ";", "FOR_EACH_BB", "(", "bb", ")", "{", "for", "(", "si", "=", "gsi_start_bb", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "si", ")", ";", "gsi_next", "(", "&", "si", ")", ")", "{", "gimple", "stmt", "=", "gsi_stmt", "(", "si", ")", ";", "if", "(", "is_gimple_debug", "(", "stmt", ")", ")", "continue", ";", "find_referenced_vars_in", "(", "gsi_stmt", "(", "si", ")", ")", ";", "}", "for", "(", "si", "=", "gsi_start_phis", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "si", ")", ";", "gsi_next", "(", "&", "si", ")", ")", "find_referenced_vars_in", "(", "gsi_stmt", "(", "si", ")", ")", ";", "}", "return", "0", ";", "}" ]
Find all the variables referenced in the function.
[ "Find", "all", "the", "variables", "referenced", "in", "the", "function", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
create_var_ann
var_ann_t
var_ann_t create_var_ann (tree t) { var_ann_t ann; gcc_assert (t); gcc_assert (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL); ann = ggc_alloc_cleared_var_ann_d (); *DECL_VAR_ANN_PTR (t) = ann; return ann; }
/* Create a new annotation for a _DECL node T. */
Create a new annotation for a _DECL node T.
[ "Create", "a", "new", "annotation", "for", "a", "_DECL", "node", "T", "." ]
var_ann_t create_var_ann (tree t) { var_ann_t ann; gcc_assert (t); gcc_assert (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL); ann = ggc_alloc_cleared_var_ann_d (); *DECL_VAR_ANN_PTR (t) = ann; return ann; }
[ "var_ann_t", "create_var_ann", "(", "tree", "t", ")", "{", "var_ann_t", "ann", ";", "gcc_assert", "(", "t", ")", ";", "gcc_assert", "(", "TREE_CODE", "(", "t", ")", "==", "VAR_DECL", "||", "TREE_CODE", "(", "t", ")", "==", "PARM_DECL", "||", "TREE_CODE", "(", "t", ")", "==", "RESULT_DECL", ")", ";", "ann", "=", "ggc_alloc_cleared_var_ann_d", "(", ")", ";", "*", "DECL_VAR_ANN_PTR", "(", "t", ")", "=", "ann", ";", "return", "ann", ";", "}" ]
Create a new annotation for a _DECL node T.
[ "Create", "a", "new", "annotation", "for", "a", "_DECL", "node", "T", "." ]
[]
[ { "param": "t", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "t", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
renumber_gimple_stmt_uids
void
void renumber_gimple_stmt_uids (void) { basic_block bb; set_gimple_stmt_max_uid (cfun, 0); FOR_ALL_BB (bb) { gimple_stmt_iterator bsi; for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } } }
/* Renumber all of the gimple stmt uids. */
Renumber all of the gimple stmt uids.
[ "Renumber", "all", "of", "the", "gimple", "stmt", "uids", "." ]
void renumber_gimple_stmt_uids (void) { basic_block bb; set_gimple_stmt_max_uid (cfun, 0); FOR_ALL_BB (bb) { gimple_stmt_iterator bsi; for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } } }
[ "void", "renumber_gimple_stmt_uids", "(", "void", ")", "{", "basic_block", "bb", ";", "set_gimple_stmt_max_uid", "(", "cfun", ",", "0", ")", ";", "FOR_ALL_BB", "(", "bb", ")", "{", "gimple_stmt_iterator", "bsi", ";", "for", "(", "bsi", "=", "gsi_start_phis", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "bsi", ")", ";", "gsi_next", "(", "&", "bsi", ")", ")", "{", "gimple", "stmt", "=", "gsi_stmt", "(", "bsi", ")", ";", "gimple_set_uid", "(", "stmt", ",", "inc_gimple_stmt_max_uid", "(", "cfun", ")", ")", ";", "}", "for", "(", "bsi", "=", "gsi_start_bb", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "bsi", ")", ";", "gsi_next", "(", "&", "bsi", ")", ")", "{", "gimple", "stmt", "=", "gsi_stmt", "(", "bsi", ")", ";", "gimple_set_uid", "(", "stmt", ",", "inc_gimple_stmt_max_uid", "(", "cfun", ")", ")", ";", "}", "}", "}" ]
Renumber all of the gimple stmt uids.
[ "Renumber", "all", "of", "the", "gimple", "stmt", "uids", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
renumber_gimple_stmt_uids_in_blocks
void
void renumber_gimple_stmt_uids_in_blocks (basic_block *blocks, int n_blocks) { int i; set_gimple_stmt_max_uid (cfun, 0); for (i = 0; i < n_blocks; i++) { basic_block bb = blocks[i]; gimple_stmt_iterator bsi; for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } } }
/* Like renumber_gimple_stmt_uids, but only do work on the basic blocks in BLOCKS, of which there are N_BLOCKS. Also renumbers PHIs. */
Like renumber_gimple_stmt_uids, but only do work on the basic blocks in BLOCKS, of which there are N_BLOCKS.
[ "Like", "renumber_gimple_stmt_uids", "but", "only", "do", "work", "on", "the", "basic", "blocks", "in", "BLOCKS", "of", "which", "there", "are", "N_BLOCKS", "." ]
void renumber_gimple_stmt_uids_in_blocks (basic_block *blocks, int n_blocks) { int i; set_gimple_stmt_max_uid (cfun, 0); for (i = 0; i < n_blocks; i++) { basic_block bb = blocks[i]; gimple_stmt_iterator bsi; for (bsi = gsi_start_phis (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) { gimple stmt = gsi_stmt (bsi); gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun)); } } }
[ "void", "renumber_gimple_stmt_uids_in_blocks", "(", "basic_block", "*", "blocks", ",", "int", "n_blocks", ")", "{", "int", "i", ";", "set_gimple_stmt_max_uid", "(", "cfun", ",", "0", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "n_blocks", ";", "i", "++", ")", "{", "basic_block", "bb", "=", "blocks", "[", "i", "]", ";", "gimple_stmt_iterator", "bsi", ";", "for", "(", "bsi", "=", "gsi_start_phis", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "bsi", ")", ";", "gsi_next", "(", "&", "bsi", ")", ")", "{", "gimple", "stmt", "=", "gsi_stmt", "(", "bsi", ")", ";", "gimple_set_uid", "(", "stmt", ",", "inc_gimple_stmt_max_uid", "(", "cfun", ")", ")", ";", "}", "for", "(", "bsi", "=", "gsi_start_bb", "(", "bb", ")", ";", "!", "gsi_end_p", "(", "bsi", ")", ";", "gsi_next", "(", "&", "bsi", ")", ")", "{", "gimple", "stmt", "=", "gsi_stmt", "(", "bsi", ")", ";", "gimple_set_uid", "(", "stmt", ",", "inc_gimple_stmt_max_uid", "(", "cfun", ")", ")", ";", "}", "}", "}" ]
Like renumber_gimple_stmt_uids, but only do work on the basic blocks in BLOCKS, of which there are N_BLOCKS.
[ "Like", "renumber_gimple_stmt_uids", "but", "only", "do", "work", "on", "the", "basic", "blocks", "in", "BLOCKS", "of", "which", "there", "are", "N_BLOCKS", "." ]
[]
[ { "param": "blocks", "type": "basic_block" }, { "param": "n_blocks", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "blocks", "type": "basic_block", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n_blocks", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
make_rename_temp
tree
tree make_rename_temp (tree type, const char *prefix) { tree t = create_tmp_reg (type, prefix); if (gimple_referenced_vars (cfun)) { add_referenced_var (t); mark_sym_for_renaming (t); } return t; }
/* Build a temporary. Make sure and register it to be renamed. */
Build a temporary. Make sure and register it to be renamed.
[ "Build", "a", "temporary", ".", "Make", "sure", "and", "register", "it", "to", "be", "renamed", "." ]
tree make_rename_temp (tree type, const char *prefix) { tree t = create_tmp_reg (type, prefix); if (gimple_referenced_vars (cfun)) { add_referenced_var (t); mark_sym_for_renaming (t); } return t; }
[ "tree", "make_rename_temp", "(", "tree", "type", ",", "const", "char", "*", "prefix", ")", "{", "tree", "t", "=", "create_tmp_reg", "(", "type", ",", "prefix", ")", ";", "if", "(", "gimple_referenced_vars", "(", "cfun", ")", ")", "{", "add_referenced_var", "(", "t", ")", ";", "mark_sym_for_renaming", "(", "t", ")", ";", "}", "return", "t", ";", "}" ]
Build a temporary.
[ "Build", "a", "temporary", "." ]
[]
[ { "param": "type", "type": "tree" }, { "param": "prefix", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prefix", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
dump_referenced_vars
void
void dump_referenced_vars (FILE *file) { tree var; referenced_var_iterator rvi; fprintf (file, "\nReferenced variables in %s: %u\n\n", get_name (current_function_decl), (unsigned) num_referenced_vars); FOR_EACH_REFERENCED_VAR (cfun, var, rvi) { fprintf (file, "Variable: "); dump_variable (file, var); } fprintf (file, "\n"); }
/* Dump the list of all the referenced variables in the current function to FILE. */
Dump the list of all the referenced variables in the current function to FILE.
[ "Dump", "the", "list", "of", "all", "the", "referenced", "variables", "in", "the", "current", "function", "to", "FILE", "." ]
void dump_referenced_vars (FILE *file) { tree var; referenced_var_iterator rvi; fprintf (file, "\nReferenced variables in %s: %u\n\n", get_name (current_function_decl), (unsigned) num_referenced_vars); FOR_EACH_REFERENCED_VAR (cfun, var, rvi) { fprintf (file, "Variable: "); dump_variable (file, var); } fprintf (file, "\n"); }
[ "void", "dump_referenced_vars", "(", "FILE", "*", "file", ")", "{", "tree", "var", ";", "referenced_var_iterator", "rvi", ";", "fprintf", "(", "file", ",", "\"", "\\n", "\\n", "\\n", "\"", ",", "get_name", "(", "current_function_decl", ")", ",", "(", "unsigned", ")", "num_referenced_vars", ")", ";", "FOR_EACH_REFERENCED_VAR", "(", "cfun", ",", "var", ",", "rvi", ")", "", "{", "fprintf", "(", "file", ",", "\"", "\"", ")", ";", "dump_variable", "(", "file", ",", "var", ")", ";", "}", "fprintf", "(", "file", ",", "\"", "\\n", "\"", ")", ";", "}" ]
Dump the list of all the referenced variables in the current function to FILE.
[ "Dump", "the", "list", "of", "all", "the", "referenced", "variables", "in", "the", "current", "function", "to", "FILE", "." ]
[]
[ { "param": "file", "type": "FILE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
dump_variable
void
void dump_variable (FILE *file, tree var) { if (TREE_CODE (var) == SSA_NAME) { if (POINTER_TYPE_P (TREE_TYPE (var))) dump_points_to_info_for (file, var); var = SSA_NAME_VAR (var); } if (var == NULL_TREE) { fprintf (file, "<nil>"); return; } print_generic_expr (file, var, dump_flags); fprintf (file, ", UID D.%u", (unsigned) DECL_UID (var)); if (DECL_PT_UID (var) != DECL_UID (var)) fprintf (file, ", PT-UID D.%u", (unsigned) DECL_PT_UID (var)); fprintf (file, ", "); print_generic_expr (file, TREE_TYPE (var), dump_flags); if (TREE_ADDRESSABLE (var)) fprintf (file, ", is addressable"); if (is_global_var (var)) fprintf (file, ", is global"); if (TREE_THIS_VOLATILE (var)) fprintf (file, ", is volatile"); if (cfun && gimple_default_def (cfun, var)) { fprintf (file, ", default def: "); print_generic_expr (file, gimple_default_def (cfun, var), dump_flags); } if (DECL_INITIAL (var)) { fprintf (file, ", initial: "); print_generic_expr (file, DECL_INITIAL (var), dump_flags); } fprintf (file, "\n"); }
/* Dump variable VAR and its may-aliases to FILE. */
Dump variable VAR and its may-aliases to FILE.
[ "Dump", "variable", "VAR", "and", "its", "may", "-", "aliases", "to", "FILE", "." ]
void dump_variable (FILE *file, tree var) { if (TREE_CODE (var) == SSA_NAME) { if (POINTER_TYPE_P (TREE_TYPE (var))) dump_points_to_info_for (file, var); var = SSA_NAME_VAR (var); } if (var == NULL_TREE) { fprintf (file, "<nil>"); return; } print_generic_expr (file, var, dump_flags); fprintf (file, ", UID D.%u", (unsigned) DECL_UID (var)); if (DECL_PT_UID (var) != DECL_UID (var)) fprintf (file, ", PT-UID D.%u", (unsigned) DECL_PT_UID (var)); fprintf (file, ", "); print_generic_expr (file, TREE_TYPE (var), dump_flags); if (TREE_ADDRESSABLE (var)) fprintf (file, ", is addressable"); if (is_global_var (var)) fprintf (file, ", is global"); if (TREE_THIS_VOLATILE (var)) fprintf (file, ", is volatile"); if (cfun && gimple_default_def (cfun, var)) { fprintf (file, ", default def: "); print_generic_expr (file, gimple_default_def (cfun, var), dump_flags); } if (DECL_INITIAL (var)) { fprintf (file, ", initial: "); print_generic_expr (file, DECL_INITIAL (var), dump_flags); } fprintf (file, "\n"); }
[ "void", "dump_variable", "(", "FILE", "*", "file", ",", "tree", "var", ")", "{", "if", "(", "TREE_CODE", "(", "var", ")", "==", "SSA_NAME", ")", "{", "if", "(", "POINTER_TYPE_P", "(", "TREE_TYPE", "(", "var", ")", ")", ")", "dump_points_to_info_for", "(", "file", ",", "var", ")", ";", "var", "=", "SSA_NAME_VAR", "(", "var", ")", ";", "}", "if", "(", "var", "==", "NULL_TREE", ")", "{", "fprintf", "(", "file", ",", "\"", "\"", ")", ";", "return", ";", "}", "print_generic_expr", "(", "file", ",", "var", ",", "dump_flags", ")", ";", "fprintf", "(", "file", ",", "\"", "\"", ",", "(", "unsigned", ")", "DECL_UID", "(", "var", ")", ")", ";", "if", "(", "DECL_PT_UID", "(", "var", ")", "!=", "DECL_UID", "(", "var", ")", ")", "fprintf", "(", "file", ",", "\"", "\"", ",", "(", "unsigned", ")", "DECL_PT_UID", "(", "var", ")", ")", ";", "fprintf", "(", "file", ",", "\"", "\"", ")", ";", "print_generic_expr", "(", "file", ",", "TREE_TYPE", "(", "var", ")", ",", "dump_flags", ")", ";", "if", "(", "TREE_ADDRESSABLE", "(", "var", ")", ")", "fprintf", "(", "file", ",", "\"", "\"", ")", ";", "if", "(", "is_global_var", "(", "var", ")", ")", "fprintf", "(", "file", ",", "\"", "\"", ")", ";", "if", "(", "TREE_THIS_VOLATILE", "(", "var", ")", ")", "fprintf", "(", "file", ",", "\"", "\"", ")", ";", "if", "(", "cfun", "&&", "gimple_default_def", "(", "cfun", ",", "var", ")", ")", "{", "fprintf", "(", "file", ",", "\"", "\"", ")", ";", "print_generic_expr", "(", "file", ",", "gimple_default_def", "(", "cfun", ",", "var", ")", ",", "dump_flags", ")", ";", "}", "if", "(", "DECL_INITIAL", "(", "var", ")", ")", "{", "fprintf", "(", "file", ",", "\"", "\"", ")", ";", "print_generic_expr", "(", "file", ",", "DECL_INITIAL", "(", "var", ")", ",", "dump_flags", ")", ";", "}", "fprintf", "(", "file", ",", "\"", "\\n", "\"", ")", ";", "}" ]
Dump variable VAR and its may-aliases to FILE.
[ "Dump", "variable", "VAR", "and", "its", "may", "-", "aliases", "to", "FILE", "." ]
[]
[ { "param": "file", "type": "FILE" }, { "param": "var", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "var", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
dump_dfa_stats
void
void dump_dfa_stats (FILE *file) { struct dfa_stats_d dfa_stats; unsigned long size, total = 0; const char * const fmt_str = "%-30s%-13s%12s\n"; const char * const fmt_str_1 = "%-30s%13lu%11lu%c\n"; const char * const fmt_str_3 = "%-43s%11lu%c\n"; const char *funcname = lang_hooks.decl_printable_name (current_function_decl, 2); collect_dfa_stats (&dfa_stats); fprintf (file, "\nDFA Statistics for %s\n\n", funcname); fprintf (file, "---------------------------------------------------------\n"); fprintf (file, fmt_str, "", " Number of ", "Memory"); fprintf (file, fmt_str, "", " instances ", "used "); fprintf (file, "---------------------------------------------------------\n"); size = num_referenced_vars * sizeof (tree); total += size; fprintf (file, fmt_str_1, "Referenced variables", (unsigned long)num_referenced_vars, SCALE (size), LABEL (size)); size = dfa_stats.num_var_anns * sizeof (struct var_ann_d); total += size; fprintf (file, fmt_str_1, "Variables annotated", dfa_stats.num_var_anns, SCALE (size), LABEL (size)); size = dfa_stats.num_uses * sizeof (tree *); total += size; fprintf (file, fmt_str_1, "USE operands", dfa_stats.num_uses, SCALE (size), LABEL (size)); size = dfa_stats.num_defs * sizeof (tree *); total += size; fprintf (file, fmt_str_1, "DEF operands", dfa_stats.num_defs, SCALE (size), LABEL (size)); size = dfa_stats.num_vuses * sizeof (tree *); total += size; fprintf (file, fmt_str_1, "VUSE operands", dfa_stats.num_vuses, SCALE (size), LABEL (size)); size = dfa_stats.num_vdefs * sizeof (tree *); total += size; fprintf (file, fmt_str_1, "VDEF operands", dfa_stats.num_vdefs, SCALE (size), LABEL (size)); size = dfa_stats.num_phis * sizeof (struct gimple_statement_phi); total += size; fprintf (file, fmt_str_1, "PHI nodes", dfa_stats.num_phis, SCALE (size), LABEL (size)); size = dfa_stats.num_phi_args * sizeof (struct phi_arg_d); total += size; fprintf (file, fmt_str_1, "PHI arguments", dfa_stats.num_phi_args, SCALE (size), LABEL (size)); fprintf (file, "---------------------------------------------------------\n"); fprintf (file, fmt_str_3, "Total memory used by DFA/SSA data", SCALE (total), LABEL (total)); fprintf (file, "---------------------------------------------------------\n"); fprintf (file, "\n"); if (dfa_stats.num_phis) fprintf (file, "Average number of arguments per PHI node: %.1f (max: %ld)\n", (float) dfa_stats.num_phi_args / (float) dfa_stats.num_phis, (long) dfa_stats.max_num_phi_args); fprintf (file, "\n"); }
/* Dump various DFA statistics to FILE. */
Dump various DFA statistics to FILE.
[ "Dump", "various", "DFA", "statistics", "to", "FILE", "." ]
void dump_dfa_stats (FILE *file) { struct dfa_stats_d dfa_stats; unsigned long size, total = 0; const char * const fmt_str = "%-30s%-13s%12s\n"; const char * const fmt_str_1 = "%-30s%13lu%11lu%c\n"; const char * const fmt_str_3 = "%-43s%11lu%c\n"; const char *funcname = lang_hooks.decl_printable_name (current_function_decl, 2); collect_dfa_stats (&dfa_stats); fprintf (file, "\nDFA Statistics for %s\n\n", funcname); fprintf (file, "---------------------------------------------------------\n"); fprintf (file, fmt_str, "", " Number of ", "Memory"); fprintf (file, fmt_str, "", " instances ", "used "); fprintf (file, "---------------------------------------------------------\n"); size = num_referenced_vars * sizeof (tree); total += size; fprintf (file, fmt_str_1, "Referenced variables", (unsigned long)num_referenced_vars, SCALE (size), LABEL (size)); size = dfa_stats.num_var_anns * sizeof (struct var_ann_d); total += size; fprintf (file, fmt_str_1, "Variables annotated", dfa_stats.num_var_anns, SCALE (size), LABEL (size)); size = dfa_stats.num_uses * sizeof (tree *); total += size; fprintf (file, fmt_str_1, "USE operands", dfa_stats.num_uses, SCALE (size), LABEL (size)); size = dfa_stats.num_defs * sizeof (tree *); total += size; fprintf (file, fmt_str_1, "DEF operands", dfa_stats.num_defs, SCALE (size), LABEL (size)); size = dfa_stats.num_vuses * sizeof (tree *); total += size; fprintf (file, fmt_str_1, "VUSE operands", dfa_stats.num_vuses, SCALE (size), LABEL (size)); size = dfa_stats.num_vdefs * sizeof (tree *); total += size; fprintf (file, fmt_str_1, "VDEF operands", dfa_stats.num_vdefs, SCALE (size), LABEL (size)); size = dfa_stats.num_phis * sizeof (struct gimple_statement_phi); total += size; fprintf (file, fmt_str_1, "PHI nodes", dfa_stats.num_phis, SCALE (size), LABEL (size)); size = dfa_stats.num_phi_args * sizeof (struct phi_arg_d); total += size; fprintf (file, fmt_str_1, "PHI arguments", dfa_stats.num_phi_args, SCALE (size), LABEL (size)); fprintf (file, "---------------------------------------------------------\n"); fprintf (file, fmt_str_3, "Total memory used by DFA/SSA data", SCALE (total), LABEL (total)); fprintf (file, "---------------------------------------------------------\n"); fprintf (file, "\n"); if (dfa_stats.num_phis) fprintf (file, "Average number of arguments per PHI node: %.1f (max: %ld)\n", (float) dfa_stats.num_phi_args / (float) dfa_stats.num_phis, (long) dfa_stats.max_num_phi_args); fprintf (file, "\n"); }
[ "void", "dump_dfa_stats", "(", "FILE", "*", "file", ")", "{", "struct", "dfa_stats_d", "dfa_stats", ";", "unsigned", "long", "size", ",", "total", "=", "0", ";", "const", "char", "*", "const", "fmt_str", "=", "\"", "\\n", "\"", ";", "const", "char", "*", "const", "fmt_str_1", "=", "\"", "\\n", "\"", ";", "const", "char", "*", "const", "fmt_str_3", "=", "\"", "\\n", "\"", ";", "const", "char", "*", "funcname", "=", "lang_hooks", ".", "decl_printable_name", "(", "current_function_decl", ",", "2", ")", ";", "collect_dfa_stats", "(", "&", "dfa_stats", ")", ";", "fprintf", "(", "file", ",", "\"", "\\n", "\\n", "\\n", "\"", ",", "funcname", ")", ";", "fprintf", "(", "file", ",", "\"", "\\n", "\"", ")", ";", "fprintf", "(", "file", ",", "fmt_str", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "fprintf", "(", "file", ",", "fmt_str", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ")", ";", "fprintf", "(", "file", ",", "\"", "\\n", "\"", ")", ";", "size", "=", "num_referenced_vars", "*", "sizeof", "(", "tree", ")", ";", "total", "+=", "size", ";", "fprintf", "(", "file", ",", "fmt_str_1", ",", "\"", "\"", ",", "(", "unsigned", "long", ")", "num_referenced_vars", ",", "SCALE", "(", "size", ")", ",", "LABEL", "(", "size", ")", ")", ";", "size", "=", "dfa_stats", ".", "num_var_anns", "*", "sizeof", "(", "struct", "var_ann_d", ")", ";", "total", "+=", "size", ";", "fprintf", "(", "file", ",", "fmt_str_1", ",", "\"", "\"", ",", "dfa_stats", ".", "num_var_anns", ",", "SCALE", "(", "size", ")", ",", "LABEL", "(", "size", ")", ")", ";", "size", "=", "dfa_stats", ".", "num_uses", "*", "sizeof", "(", "tree", "*", ")", ";", "total", "+=", "size", ";", "fprintf", "(", "file", ",", "fmt_str_1", ",", "\"", "\"", ",", "dfa_stats", ".", "num_uses", ",", "SCALE", "(", "size", ")", ",", "LABEL", "(", "size", ")", ")", ";", "size", "=", "dfa_stats", ".", "num_defs", "*", "sizeof", "(", "tree", "*", ")", ";", "total", "+=", "size", ";", "fprintf", "(", "file", ",", "fmt_str_1", ",", "\"", "\"", ",", "dfa_stats", ".", "num_defs", ",", "SCALE", "(", "size", ")", ",", "LABEL", "(", "size", ")", ")", ";", "size", "=", "dfa_stats", ".", "num_vuses", "*", "sizeof", "(", "tree", "*", ")", ";", "total", "+=", "size", ";", "fprintf", "(", "file", ",", "fmt_str_1", ",", "\"", "\"", ",", "dfa_stats", ".", "num_vuses", ",", "SCALE", "(", "size", ")", ",", "LABEL", "(", "size", ")", ")", ";", "size", "=", "dfa_stats", ".", "num_vdefs", "*", "sizeof", "(", "tree", "*", ")", ";", "total", "+=", "size", ";", "fprintf", "(", "file", ",", "fmt_str_1", ",", "\"", "\"", ",", "dfa_stats", ".", "num_vdefs", ",", "SCALE", "(", "size", ")", ",", "LABEL", "(", "size", ")", ")", ";", "size", "=", "dfa_stats", ".", "num_phis", "*", "sizeof", "(", "struct", "gimple_statement_phi", ")", ";", "total", "+=", "size", ";", "fprintf", "(", "file", ",", "fmt_str_1", ",", "\"", "\"", ",", "dfa_stats", ".", "num_phis", ",", "SCALE", "(", "size", ")", ",", "LABEL", "(", "size", ")", ")", ";", "size", "=", "dfa_stats", ".", "num_phi_args", "*", "sizeof", "(", "struct", "phi_arg_d", ")", ";", "total", "+=", "size", ";", "fprintf", "(", "file", ",", "fmt_str_1", ",", "\"", "\"", ",", "dfa_stats", ".", "num_phi_args", ",", "SCALE", "(", "size", ")", ",", "LABEL", "(", "size", ")", ")", ";", "fprintf", "(", "file", ",", "\"", "\\n", "\"", ")", ";", "fprintf", "(", "file", ",", "fmt_str_3", ",", "\"", "\"", ",", "SCALE", "(", "total", ")", ",", "LABEL", "(", "total", ")", ")", ";", "fprintf", "(", "file", ",", "\"", "\\n", "\"", ")", ";", "fprintf", "(", "file", ",", "\"", "\\n", "\"", ")", ";", "if", "(", "dfa_stats", ".", "num_phis", ")", "fprintf", "(", "file", ",", "\"", "\\n", "\"", ",", "(", "float", ")", "dfa_stats", ".", "num_phi_args", "/", "(", "float", ")", "dfa_stats", ".", "num_phis", ",", "(", "long", ")", "dfa_stats", ".", "max_num_phi_args", ")", ";", "fprintf", "(", "file", ",", "\"", "\\n", "\"", ")", ";", "}" ]
Dump various DFA statistics to FILE.
[ "Dump", "various", "DFA", "statistics", "to", "FILE", "." ]
[]
[ { "param": "file", "type": "FILE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
find_referenced_vars_in
void
void find_referenced_vars_in (gimple stmt) { size_t i; if (gimple_code (stmt) != GIMPLE_PHI) { for (i = 0; i < gimple_num_ops (stmt); i++) walk_tree (gimple_op_ptr (stmt, i), find_vars_r, NULL, NULL); } else { walk_tree (gimple_phi_result_ptr (stmt), find_vars_r, NULL, NULL); for (i = 0; i < gimple_phi_num_args (stmt); i++) { tree arg = gimple_phi_arg_def (stmt, i); walk_tree (&arg, find_vars_r, NULL, NULL); } } }
/* Find referenced variables in STMT. In contrast with find_new_referenced_vars, this function will not mark newly found variables for renaming. */
Find referenced variables in STMT. In contrast with find_new_referenced_vars, this function will not mark newly found variables for renaming.
[ "Find", "referenced", "variables", "in", "STMT", ".", "In", "contrast", "with", "find_new_referenced_vars", "this", "function", "will", "not", "mark", "newly", "found", "variables", "for", "renaming", "." ]
void find_referenced_vars_in (gimple stmt) { size_t i; if (gimple_code (stmt) != GIMPLE_PHI) { for (i = 0; i < gimple_num_ops (stmt); i++) walk_tree (gimple_op_ptr (stmt, i), find_vars_r, NULL, NULL); } else { walk_tree (gimple_phi_result_ptr (stmt), find_vars_r, NULL, NULL); for (i = 0; i < gimple_phi_num_args (stmt); i++) { tree arg = gimple_phi_arg_def (stmt, i); walk_tree (&arg, find_vars_r, NULL, NULL); } } }
[ "void", "find_referenced_vars_in", "(", "gimple", "stmt", ")", "{", "size_t", "i", ";", "if", "(", "gimple_code", "(", "stmt", ")", "!=", "GIMPLE_PHI", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "gimple_num_ops", "(", "stmt", ")", ";", "i", "++", ")", "walk_tree", "(", "gimple_op_ptr", "(", "stmt", ",", "i", ")", ",", "find_vars_r", ",", "NULL", ",", "NULL", ")", ";", "}", "else", "{", "walk_tree", "(", "gimple_phi_result_ptr", "(", "stmt", ")", ",", "find_vars_r", ",", "NULL", ",", "NULL", ")", ";", "for", "(", "i", "=", "0", ";", "i", "<", "gimple_phi_num_args", "(", "stmt", ")", ";", "i", "++", ")", "{", "tree", "arg", "=", "gimple_phi_arg_def", "(", "stmt", ",", "i", ")", ";", "walk_tree", "(", "&", "arg", ",", "find_vars_r", ",", "NULL", ",", "NULL", ")", ";", "}", "}", "}" ]
Find referenced variables in STMT.
[ "Find", "referenced", "variables", "in", "STMT", "." ]
[]
[ { "param": "stmt", "type": "gimple" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stmt", "type": "gimple", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
referenced_var_lookup
tree
tree referenced_var_lookup (struct function *fn, unsigned int uid) { tree h; struct tree_decl_minimal in; in.uid = uid; h = (tree) htab_find_with_hash (gimple_referenced_vars (fn), &in, uid); return h; }
/* Lookup UID in the referenced_vars hashtable and return the associated variable. */
Lookup UID in the referenced_vars hashtable and return the associated variable.
[ "Lookup", "UID", "in", "the", "referenced_vars", "hashtable", "and", "return", "the", "associated", "variable", "." ]
tree referenced_var_lookup (struct function *fn, unsigned int uid) { tree h; struct tree_decl_minimal in; in.uid = uid; h = (tree) htab_find_with_hash (gimple_referenced_vars (fn), &in, uid); return h; }
[ "tree", "referenced_var_lookup", "(", "struct", "function", "*", "fn", ",", "unsigned", "int", "uid", ")", "{", "tree", "h", ";", "struct", "tree_decl_minimal", "in", ";", "in", ".", "uid", "=", "uid", ";", "h", "=", "(", "tree", ")", "htab_find_with_hash", "(", "gimple_referenced_vars", "(", "fn", ")", ",", "&", "in", ",", "uid", ")", ";", "return", "h", ";", "}" ]
Lookup UID in the referenced_vars hashtable and return the associated variable.
[ "Lookup", "UID", "in", "the", "referenced_vars", "hashtable", "and", "return", "the", "associated", "variable", "." ]
[]
[ { "param": "fn", "type": "struct function" }, { "param": "uid", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fn", "type": "struct function", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "uid", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
referenced_var_check_and_insert
bool
bool referenced_var_check_and_insert (tree to) { tree h, *loc; struct tree_decl_minimal in; unsigned int uid = DECL_UID (to); in.uid = uid; h = (tree) htab_find_with_hash (gimple_referenced_vars (cfun), &in, uid); if (h) { /* DECL_UID has already been entered in the table. Verify that it is the same entry as TO. See PR 27793. */ gcc_assert (h == to); return false; } loc = (tree *) htab_find_slot_with_hash (gimple_referenced_vars (cfun), &in, uid, INSERT); *loc = to; return true; }
/* Check if TO is in the referenced_vars hash table and insert it if not. Return true if it required insertion. */
Check if TO is in the referenced_vars hash table and insert it if not. Return true if it required insertion.
[ "Check", "if", "TO", "is", "in", "the", "referenced_vars", "hash", "table", "and", "insert", "it", "if", "not", ".", "Return", "true", "if", "it", "required", "insertion", "." ]
bool referenced_var_check_and_insert (tree to) { tree h, *loc; struct tree_decl_minimal in; unsigned int uid = DECL_UID (to); in.uid = uid; h = (tree) htab_find_with_hash (gimple_referenced_vars (cfun), &in, uid); if (h) { gcc_assert (h == to); return false; } loc = (tree *) htab_find_slot_with_hash (gimple_referenced_vars (cfun), &in, uid, INSERT); *loc = to; return true; }
[ "bool", "referenced_var_check_and_insert", "(", "tree", "to", ")", "{", "tree", "h", ",", "*", "loc", ";", "struct", "tree_decl_minimal", "in", ";", "unsigned", "int", "uid", "=", "DECL_UID", "(", "to", ")", ";", "in", ".", "uid", "=", "uid", ";", "h", "=", "(", "tree", ")", "htab_find_with_hash", "(", "gimple_referenced_vars", "(", "cfun", ")", ",", "&", "in", ",", "uid", ")", ";", "if", "(", "h", ")", "{", "gcc_assert", "(", "h", "==", "to", ")", ";", "return", "false", ";", "}", "loc", "=", "(", "tree", "*", ")", "htab_find_slot_with_hash", "(", "gimple_referenced_vars", "(", "cfun", ")", ",", "&", "in", ",", "uid", ",", "INSERT", ")", ";", "*", "loc", "=", "to", ";", "return", "true", ";", "}" ]
Check if TO is in the referenced_vars hash table and insert it if not.
[ "Check", "if", "TO", "is", "in", "the", "referenced_vars", "hash", "table", "and", "insert", "it", "if", "not", "." ]
[ "/* DECL_UID has already been entered in the table. Verify that it is\n\t the same entry as TO. See PR 27793. */" ]
[ { "param": "to", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "to", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
gimple_default_def
tree
tree gimple_default_def (struct function *fn, tree var) { struct tree_decl_minimal ind; struct tree_ssa_name in; gcc_assert (SSA_VAR_P (var)); in.var = (tree)&ind; ind.uid = DECL_UID (var); return (tree) htab_find_with_hash (DEFAULT_DEFS (fn), &in, DECL_UID (var)); }
/* Lookup VAR UID in the default_defs hashtable and return the associated variable. */
Lookup VAR UID in the default_defs hashtable and return the associated variable.
[ "Lookup", "VAR", "UID", "in", "the", "default_defs", "hashtable", "and", "return", "the", "associated", "variable", "." ]
tree gimple_default_def (struct function *fn, tree var) { struct tree_decl_minimal ind; struct tree_ssa_name in; gcc_assert (SSA_VAR_P (var)); in.var = (tree)&ind; ind.uid = DECL_UID (var); return (tree) htab_find_with_hash (DEFAULT_DEFS (fn), &in, DECL_UID (var)); }
[ "tree", "gimple_default_def", "(", "struct", "function", "*", "fn", ",", "tree", "var", ")", "{", "struct", "tree_decl_minimal", "ind", ";", "struct", "tree_ssa_name", "in", ";", "gcc_assert", "(", "SSA_VAR_P", "(", "var", ")", ")", ";", "in", ".", "var", "=", "(", "tree", ")", "&", "ind", ";", "ind", ".", "uid", "=", "DECL_UID", "(", "var", ")", ";", "return", "(", "tree", ")", "htab_find_with_hash", "(", "DEFAULT_DEFS", "(", "fn", ")", ",", "&", "in", ",", "DECL_UID", "(", "var", ")", ")", ";", "}" ]
Lookup VAR UID in the default_defs hashtable and return the associated variable.
[ "Lookup", "VAR", "UID", "in", "the", "default_defs", "hashtable", "and", "return", "the", "associated", "variable", "." ]
[]
[ { "param": "fn", "type": "struct function" }, { "param": "var", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fn", "type": "struct function", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "var", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
add_referenced_var
bool
bool add_referenced_var (tree var) { gcc_assert (DECL_P (var)); if (!*DECL_VAR_ANN_PTR (var)) create_var_ann (var); /* Insert VAR into the referenced_vars hash table if it isn't present. */ if (referenced_var_check_and_insert (var)) { /* Scan DECL_INITIAL for pointer variables as they may contain address arithmetic referencing the address of other variables. As we are only interested in directly referenced globals or referenced locals restrict this to initializers than can refer to local variables. */ if (DECL_INITIAL (var) && DECL_CONTEXT (var) == current_function_decl) walk_tree (&DECL_INITIAL (var), find_vars_r, NULL, 0); return true; } return false; }
/* Add VAR to the list of referenced variables if it isn't already there. */
Add VAR to the list of referenced variables if it isn't already there.
[ "Add", "VAR", "to", "the", "list", "of", "referenced", "variables", "if", "it", "isn", "'", "t", "already", "there", "." ]
bool add_referenced_var (tree var) { gcc_assert (DECL_P (var)); if (!*DECL_VAR_ANN_PTR (var)) create_var_ann (var); if (referenced_var_check_and_insert (var)) { if (DECL_INITIAL (var) && DECL_CONTEXT (var) == current_function_decl) walk_tree (&DECL_INITIAL (var), find_vars_r, NULL, 0); return true; } return false; }
[ "bool", "add_referenced_var", "(", "tree", "var", ")", "{", "gcc_assert", "(", "DECL_P", "(", "var", ")", ")", ";", "if", "(", "!", "*", "DECL_VAR_ANN_PTR", "(", "var", ")", ")", "create_var_ann", "(", "var", ")", ";", "if", "(", "referenced_var_check_and_insert", "(", "var", ")", ")", "{", "if", "(", "DECL_INITIAL", "(", "var", ")", "&&", "DECL_CONTEXT", "(", "var", ")", "==", "current_function_decl", ")", "walk_tree", "(", "&", "DECL_INITIAL", "(", "var", ")", ",", "find_vars_r", ",", "NULL", ",", "0", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add VAR to the list of referenced variables if it isn't already there.
[ "Add", "VAR", "to", "the", "list", "of", "referenced", "variables", "if", "it", "isn", "'", "t", "already", "there", "." ]
[ "/* Insert VAR into the referenced_vars hash table if it isn't present. */", "/* Scan DECL_INITIAL for pointer variables as they may contain\n\t address arithmetic referencing the address of other\n\t variables. As we are only interested in directly referenced\n\t globals or referenced locals restrict this to initializers\n\t than can refer to local variables. */" ]
[ { "param": "var", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "var", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
remove_referenced_var
void
void remove_referenced_var (tree var) { var_ann_t v_ann; struct tree_decl_minimal in; void **loc; unsigned int uid = DECL_UID (var); /* Preserve var_anns of globals. */ if (!is_global_var (var) && (v_ann = var_ann (var))) { ggc_free (v_ann); *DECL_VAR_ANN_PTR (var) = NULL; } gcc_assert (DECL_P (var)); in.uid = uid; loc = htab_find_slot_with_hash (gimple_referenced_vars (cfun), &in, uid, NO_INSERT); htab_clear_slot (gimple_referenced_vars (cfun), loc); }
/* Remove VAR from the list. */
Remove VAR from the list.
[ "Remove", "VAR", "from", "the", "list", "." ]
void remove_referenced_var (tree var) { var_ann_t v_ann; struct tree_decl_minimal in; void **loc; unsigned int uid = DECL_UID (var); if (!is_global_var (var) && (v_ann = var_ann (var))) { ggc_free (v_ann); *DECL_VAR_ANN_PTR (var) = NULL; } gcc_assert (DECL_P (var)); in.uid = uid; loc = htab_find_slot_with_hash (gimple_referenced_vars (cfun), &in, uid, NO_INSERT); htab_clear_slot (gimple_referenced_vars (cfun), loc); }
[ "void", "remove_referenced_var", "(", "tree", "var", ")", "{", "var_ann_t", "v_ann", ";", "struct", "tree_decl_minimal", "in", ";", "void", "*", "*", "loc", ";", "unsigned", "int", "uid", "=", "DECL_UID", "(", "var", ")", ";", "if", "(", "!", "is_global_var", "(", "var", ")", "&&", "(", "v_ann", "=", "var_ann", "(", "var", ")", ")", ")", "{", "ggc_free", "(", "v_ann", ")", ";", "*", "DECL_VAR_ANN_PTR", "(", "var", ")", "=", "NULL", ";", "}", "gcc_assert", "(", "DECL_P", "(", "var", ")", ")", ";", "in", ".", "uid", "=", "uid", ";", "loc", "=", "htab_find_slot_with_hash", "(", "gimple_referenced_vars", "(", "cfun", ")", ",", "&", "in", ",", "uid", ",", "NO_INSERT", ")", ";", "htab_clear_slot", "(", "gimple_referenced_vars", "(", "cfun", ")", ",", "loc", ")", ";", "}" ]
Remove VAR from the list.
[ "Remove", "VAR", "from", "the", "list", "." ]
[ "/* Preserve var_anns of globals. */" ]
[ { "param": "var", "type": "tree" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "var", "type": "tree", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
mark_symbols_for_renaming
void
void mark_symbols_for_renaming (gimple stmt) { tree op; ssa_op_iter iter; update_stmt (stmt); /* Mark all the operands for renaming. */ FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_ALL_OPERANDS) if (DECL_P (op)) mark_sym_for_renaming (op); }
/* Mark all the naked symbols in STMT for SSA renaming. */
Mark all the naked symbols in STMT for SSA renaming.
[ "Mark", "all", "the", "naked", "symbols", "in", "STMT", "for", "SSA", "renaming", "." ]
void mark_symbols_for_renaming (gimple stmt) { tree op; ssa_op_iter iter; update_stmt (stmt); FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_ALL_OPERANDS) if (DECL_P (op)) mark_sym_for_renaming (op); }
[ "void", "mark_symbols_for_renaming", "(", "gimple", "stmt", ")", "{", "tree", "op", ";", "ssa_op_iter", "iter", ";", "update_stmt", "(", "stmt", ")", ";", "FOR_EACH_SSA_TREE_OPERAND", "(", "op", ",", "stmt", ",", "iter", ",", "SSA_OP_ALL_OPERANDS", ")", "", "if", "(", "DECL_P", "(", "op", ")", ")", "mark_sym_for_renaming", "(", "op", ")", ";", "}" ]
Mark all the naked symbols in STMT for SSA renaming.
[ "Mark", "all", "the", "naked", "symbols", "in", "STMT", "for", "SSA", "renaming", "." ]
[ "/* Mark all the operands for renaming. */" ]
[ { "param": "stmt", "type": "gimple" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stmt", "type": "gimple", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
find_new_referenced_vars
void
void find_new_referenced_vars (gimple stmt) { walk_gimple_op (stmt, find_new_referenced_vars_1, NULL); }
/* Find any new referenced variables in STMT. */
Find any new referenced variables in STMT.
[ "Find", "any", "new", "referenced", "variables", "in", "STMT", "." ]
void find_new_referenced_vars (gimple stmt) { walk_gimple_op (stmt, find_new_referenced_vars_1, NULL); }
[ "void", "find_new_referenced_vars", "(", "gimple", "stmt", ")", "{", "walk_gimple_op", "(", "stmt", ",", "find_new_referenced_vars_1", ",", "NULL", ")", ";", "}" ]
Find any new referenced variables in STMT.
[ "Find", "any", "new", "referenced", "variables", "in", "STMT", "." ]
[]
[ { "param": "stmt", "type": "gimple" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stmt", "type": "gimple", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3bcca2b31f3be850bb3dd30535b2202fbc4a1b3c
atrens/DragonFlyBSD-src
contrib/gcc-4.7/gcc/tree-dfa.c
[ "BSD-3-Clause" ]
C
stmt_references_abnormal_ssa_name
bool
bool stmt_references_abnormal_ssa_name (gimple stmt) { ssa_op_iter oi; use_operand_p use_p; FOR_EACH_SSA_USE_OPERAND (use_p, stmt, oi, SSA_OP_USE) { if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (USE_FROM_PTR (use_p))) return true; } return false; }
/* Returns true if STMT references an SSA_NAME that has SSA_NAME_OCCURS_IN_ABNORMAL_PHI set, otherwise false. */
Returns true if STMT references an SSA_NAME that has SSA_NAME_OCCURS_IN_ABNORMAL_PHI set, otherwise false.
[ "Returns", "true", "if", "STMT", "references", "an", "SSA_NAME", "that", "has", "SSA_NAME_OCCURS_IN_ABNORMAL_PHI", "set", "otherwise", "false", "." ]
bool stmt_references_abnormal_ssa_name (gimple stmt) { ssa_op_iter oi; use_operand_p use_p; FOR_EACH_SSA_USE_OPERAND (use_p, stmt, oi, SSA_OP_USE) { if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (USE_FROM_PTR (use_p))) return true; } return false; }
[ "bool", "stmt_references_abnormal_ssa_name", "(", "gimple", "stmt", ")", "{", "ssa_op_iter", "oi", ";", "use_operand_p", "use_p", ";", "FOR_EACH_SSA_USE_OPERAND", "(", "use_p", ",", "stmt", ",", "oi", ",", "SSA_OP_USE", ")", "", "{", "if", "(", "SSA_NAME_OCCURS_IN_ABNORMAL_PHI", "(", "USE_FROM_PTR", "(", "use_p", ")", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if STMT references an SSA_NAME that has SSA_NAME_OCCURS_IN_ABNORMAL_PHI set, otherwise false.
[ "Returns", "true", "if", "STMT", "references", "an", "SSA_NAME", "that", "has", "SSA_NAME_OCCURS_IN_ABNORMAL_PHI", "set", "otherwise", "false", "." ]
[]
[ { "param": "stmt", "type": "gimple" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "stmt", "type": "gimple", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a7c67f4961aedc74be4e1e9c3b144adeb70682e2
atrens/DragonFlyBSD-src
sys/vfs/ufs/ufs_bmap.c
[ "BSD-3-Clause" ]
C
ufs_bmap
int
int ufs_bmap(struct vop_bmap_args *ap) { struct fs *fs; ufs_daddr_t lbn; ufs_daddr_t dbn; int error; /* * Check for underlying vnode requests and ensure that logical * to physical mapping is requested. */ if (ap->a_doffsetp == NULL) return (0); fs = VTOI(ap->a_vp)->i_fs; KKASSERT(((int)ap->a_loffset & ((1 << fs->fs_bshift) - 1)) == 0); lbn = ap->a_loffset >> fs->fs_bshift; error = ufs_bmaparray(ap->a_vp, lbn, &dbn, NULL, NULL, ap->a_runp, ap->a_runb); if (error || dbn == (ufs_daddr_t)-1) { *ap->a_doffsetp = NOOFFSET; } else { *ap->a_doffsetp = dbtodoff(fs, dbn); if (ap->a_runp) *ap->a_runp = (*ap->a_runp + 1) << fs->fs_bshift; if (ap->a_runb) *ap->a_runb = *ap->a_runb << fs->fs_bshift; } return (error); }
/* * Bmap converts the logical block number of a file to its physical block * number on the disk. The conversion is done by using the logical block * number to index into the array of block pointers described by the dinode. * * BMAP must return the contiguous before and after run in bytes, inclusive * of the returned block. * * ufs_bmap(struct vnode *a_vp, off_t a_loffset, * off_t *a_doffsetp, int *a_runp, int *a_runb) */
Bmap converts the logical block number of a file to its physical block number on the disk. The conversion is done by using the logical block number to index into the array of block pointers described by the dinode. BMAP must return the contiguous before and after run in bytes, inclusive of the returned block.
[ "Bmap", "converts", "the", "logical", "block", "number", "of", "a", "file", "to", "its", "physical", "block", "number", "on", "the", "disk", ".", "The", "conversion", "is", "done", "by", "using", "the", "logical", "block", "number", "to", "index", "into", "the", "array", "of", "block", "pointers", "described", "by", "the", "dinode", ".", "BMAP", "must", "return", "the", "contiguous", "before", "and", "after", "run", "in", "bytes", "inclusive", "of", "the", "returned", "block", "." ]
int ufs_bmap(struct vop_bmap_args *ap) { struct fs *fs; ufs_daddr_t lbn; ufs_daddr_t dbn; int error; if (ap->a_doffsetp == NULL) return (0); fs = VTOI(ap->a_vp)->i_fs; KKASSERT(((int)ap->a_loffset & ((1 << fs->fs_bshift) - 1)) == 0); lbn = ap->a_loffset >> fs->fs_bshift; error = ufs_bmaparray(ap->a_vp, lbn, &dbn, NULL, NULL, ap->a_runp, ap->a_runb); if (error || dbn == (ufs_daddr_t)-1) { *ap->a_doffsetp = NOOFFSET; } else { *ap->a_doffsetp = dbtodoff(fs, dbn); if (ap->a_runp) *ap->a_runp = (*ap->a_runp + 1) << fs->fs_bshift; if (ap->a_runb) *ap->a_runb = *ap->a_runb << fs->fs_bshift; } return (error); }
[ "int", "ufs_bmap", "(", "struct", "vop_bmap_args", "*", "ap", ")", "{", "struct", "fs", "*", "fs", ";", "ufs_daddr_t", "lbn", ";", "ufs_daddr_t", "dbn", ";", "int", "error", ";", "if", "(", "ap", "->", "a_doffsetp", "==", "NULL", ")", "return", "(", "0", ")", ";", "fs", "=", "VTOI", "(", "ap", "->", "a_vp", ")", "->", "i_fs", ";", "KKASSERT", "(", "(", "(", "int", ")", "ap", "->", "a_loffset", "&", "(", "(", "1", "<<", "fs", "->", "fs_bshift", ")", "-", "1", ")", ")", "==", "0", ")", ";", "lbn", "=", "ap", "->", "a_loffset", ">>", "fs", "->", "fs_bshift", ";", "error", "=", "ufs_bmaparray", "(", "ap", "->", "a_vp", ",", "lbn", ",", "&", "dbn", ",", "NULL", ",", "NULL", ",", "ap", "->", "a_runp", ",", "ap", "->", "a_runb", ")", ";", "if", "(", "error", "||", "dbn", "==", "(", "ufs_daddr_t", ")", "-", "1", ")", "{", "*", "ap", "->", "a_doffsetp", "=", "NOOFFSET", ";", "}", "else", "{", "*", "ap", "->", "a_doffsetp", "=", "dbtodoff", "(", "fs", ",", "dbn", ")", ";", "if", "(", "ap", "->", "a_runp", ")", "*", "ap", "->", "a_runp", "=", "(", "*", "ap", "->", "a_runp", "+", "1", ")", "<<", "fs", "->", "fs_bshift", ";", "if", "(", "ap", "->", "a_runb", ")", "*", "ap", "->", "a_runb", "=", "*", "ap", "->", "a_runb", "<<", "fs", "->", "fs_bshift", ";", "}", "return", "(", "error", ")", ";", "}" ]
Bmap converts the logical block number of a file to its physical block number on the disk.
[ "Bmap", "converts", "the", "logical", "block", "number", "of", "a", "file", "to", "its", "physical", "block", "number", "on", "the", "disk", "." ]
[ "/*\n\t * Check for underlying vnode requests and ensure that logical\n\t * to physical mapping is requested.\n\t */" ]
[ { "param": "ap", "type": "struct vop_bmap_args" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ap", "type": "struct vop_bmap_args", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a7c67f4961aedc74be4e1e9c3b144adeb70682e2
atrens/DragonFlyBSD-src
sys/vfs/ufs/ufs_bmap.c
[ "BSD-3-Clause" ]
C
ufs_bmaparray
int
int ufs_bmaparray(struct vnode *vp, ufs_daddr_t bn, ufs_daddr_t *bnp, struct indir *ap, int *nump, int *runp, int *runb) { struct inode *ip; struct buf *bp; struct ufsmount *ump; struct mount *mp; struct fs *fs; struct indir a[UFS_NIADDR+1], *xap; ufs_daddr_t daddr; long metalbn; int error, maxrun, num; ip = VTOI(vp); mp = vp->v_mount; ump = VFSTOUFS(mp); fs = ip->i_fs; #ifdef DIAGNOSTIC if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL)) panic("ufs_bmaparray: invalid arguments"); #endif if (runp) { *runp = 0; } if (runb) { *runb = 0; } maxrun = mp->mnt_iosize_max / mp->mnt_stat.f_iosize - 1; xap = ap == NULL ? a : ap; if (!nump) nump = &num; error = ufs_getlbns(vp, bn, xap, nump); if (error) return (error); num = *nump; if (num == 0) { *bnp = blkptrtodb(ump, ip->i_db[bn]); if (*bnp == 0) *bnp = -1; else if (runp) { daddr_t bnb = bn; for (++bn; bn < UFS_NDADDR && *runp < maxrun && is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]); ++bn, ++*runp); bn = bnb; if (runb && (bn > 0)) { for (--bn; (bn >= 0) && (*runb < maxrun) && is_sequential(ump, ip->i_db[bn], ip->i_db[bn+1]); --bn, ++*runb); } } return (0); } /* Get disk address out of indirect block array */ daddr = ip->i_ib[xap->in_off]; for (bp = NULL, ++xap; --num; ++xap) { /* * Exit the loop if there is no disk address assigned yet and * the indirect block isn't in the cache, or if we were * looking for an indirect block and we've found it. */ metalbn = xap->in_lbn; if ((daddr == 0 && !findblk(vp, dbtodoff(fs, metalbn), FINDBLK_TEST)) || metalbn == bn) { break; } /* * If we get here, we've either got the block in the cache * or we have a disk address for it, go fetch it. */ if (bp) bqrelse(bp); bp = getblk(vp, lblktodoff(fs, metalbn), mp->mnt_stat.f_iosize, 0, 0); if ((bp->b_flags & B_CACHE) == 0) { #ifdef DIAGNOSTIC if (!daddr) panic("ufs_bmaparray: indirect block not in cache"); #endif /* * cached disk addr in bio2, do I/O on bio1. It * will probably hit the vfs's strategy function * which will then use the cached offset in bio2. */ bp->b_bio1.bio_done = biodone_sync; bp->b_bio1.bio_flags |= BIO_SYNC; bp->b_bio2.bio_offset = fsbtodoff(fs, daddr); bp->b_flags &= ~(B_INVAL|B_ERROR); bp->b_cmd = BUF_CMD_READ; vfs_busy_pages(bp->b_vp, bp); vn_strategy(bp->b_vp, &bp->b_bio1); error = biowait(&bp->b_bio1, "biord"); if (error) { brelse(bp); return (error); } } daddr = ((ufs_daddr_t *)bp->b_data)[xap->in_off]; if (num == 1 && daddr && runp) { for (bn = xap->in_off + 1; bn < MNINDIR(ump) && *runp < maxrun && is_sequential(ump, ((ufs_daddr_t *)bp->b_data)[bn - 1], ((ufs_daddr_t *)bp->b_data)[bn]); ++bn, ++*runp); bn = xap->in_off; if (runb && bn) { for(--bn; bn >= 0 && *runb < maxrun && is_sequential(ump, ((daddr_t *)bp->b_data)[bn], ((daddr_t *)bp->b_data)[bn+1]); --bn, ++*runb); } } } if (bp) bqrelse(bp); daddr = blkptrtodb(ump, daddr); *bnp = daddr == 0 ? -1 : daddr; return (0); }
/* * Indirect blocks are now on the vnode for the file. They are given negative * logical block numbers. Indirect blocks are addressed by the negative * address of the first data block to which they point. Double indirect blocks * are addressed by one less than the address of the first indirect block to * which they point. Triple indirect blocks are addressed by one less than * the address of the first double indirect block to which they point. * * ufs_bmaparray does the bmap conversion, and if requested returns the * array of logical blocks which must be traversed to get to a block. * Each entry contains the offset into that block that gets you to the * next block and the disk address of the block (if it is assigned). */
Indirect blocks are now on the vnode for the file. They are given negative logical block numbers. Indirect blocks are addressed by the negative address of the first data block to which they point. Double indirect blocks are addressed by one less than the address of the first indirect block to which they point. Triple indirect blocks are addressed by one less than the address of the first double indirect block to which they point. ufs_bmaparray does the bmap conversion, and if requested returns the array of logical blocks which must be traversed to get to a block. Each entry contains the offset into that block that gets you to the next block and the disk address of the block (if it is assigned).
[ "Indirect", "blocks", "are", "now", "on", "the", "vnode", "for", "the", "file", ".", "They", "are", "given", "negative", "logical", "block", "numbers", ".", "Indirect", "blocks", "are", "addressed", "by", "the", "negative", "address", "of", "the", "first", "data", "block", "to", "which", "they", "point", ".", "Double", "indirect", "blocks", "are", "addressed", "by", "one", "less", "than", "the", "address", "of", "the", "first", "indirect", "block", "to", "which", "they", "point", ".", "Triple", "indirect", "blocks", "are", "addressed", "by", "one", "less", "than", "the", "address", "of", "the", "first", "double", "indirect", "block", "to", "which", "they", "point", ".", "ufs_bmaparray", "does", "the", "bmap", "conversion", "and", "if", "requested", "returns", "the", "array", "of", "logical", "blocks", "which", "must", "be", "traversed", "to", "get", "to", "a", "block", ".", "Each", "entry", "contains", "the", "offset", "into", "that", "block", "that", "gets", "you", "to", "the", "next", "block", "and", "the", "disk", "address", "of", "the", "block", "(", "if", "it", "is", "assigned", ")", "." ]
int ufs_bmaparray(struct vnode *vp, ufs_daddr_t bn, ufs_daddr_t *bnp, struct indir *ap, int *nump, int *runp, int *runb) { struct inode *ip; struct buf *bp; struct ufsmount *ump; struct mount *mp; struct fs *fs; struct indir a[UFS_NIADDR+1], *xap; ufs_daddr_t daddr; long metalbn; int error, maxrun, num; ip = VTOI(vp); mp = vp->v_mount; ump = VFSTOUFS(mp); fs = ip->i_fs; #ifdef DIAGNOSTIC if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL)) panic("ufs_bmaparray: invalid arguments"); #endif if (runp) { *runp = 0; } if (runb) { *runb = 0; } maxrun = mp->mnt_iosize_max / mp->mnt_stat.f_iosize - 1; xap = ap == NULL ? a : ap; if (!nump) nump = &num; error = ufs_getlbns(vp, bn, xap, nump); if (error) return (error); num = *nump; if (num == 0) { *bnp = blkptrtodb(ump, ip->i_db[bn]); if (*bnp == 0) *bnp = -1; else if (runp) { daddr_t bnb = bn; for (++bn; bn < UFS_NDADDR && *runp < maxrun && is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]); ++bn, ++*runp); bn = bnb; if (runb && (bn > 0)) { for (--bn; (bn >= 0) && (*runb < maxrun) && is_sequential(ump, ip->i_db[bn], ip->i_db[bn+1]); --bn, ++*runb); } } return (0); } daddr = ip->i_ib[xap->in_off]; for (bp = NULL, ++xap; --num; ++xap) { metalbn = xap->in_lbn; if ((daddr == 0 && !findblk(vp, dbtodoff(fs, metalbn), FINDBLK_TEST)) || metalbn == bn) { break; } if (bp) bqrelse(bp); bp = getblk(vp, lblktodoff(fs, metalbn), mp->mnt_stat.f_iosize, 0, 0); if ((bp->b_flags & B_CACHE) == 0) { #ifdef DIAGNOSTIC if (!daddr) panic("ufs_bmaparray: indirect block not in cache"); #endif bp->b_bio1.bio_done = biodone_sync; bp->b_bio1.bio_flags |= BIO_SYNC; bp->b_bio2.bio_offset = fsbtodoff(fs, daddr); bp->b_flags &= ~(B_INVAL|B_ERROR); bp->b_cmd = BUF_CMD_READ; vfs_busy_pages(bp->b_vp, bp); vn_strategy(bp->b_vp, &bp->b_bio1); error = biowait(&bp->b_bio1, "biord"); if (error) { brelse(bp); return (error); } } daddr = ((ufs_daddr_t *)bp->b_data)[xap->in_off]; if (num == 1 && daddr && runp) { for (bn = xap->in_off + 1; bn < MNINDIR(ump) && *runp < maxrun && is_sequential(ump, ((ufs_daddr_t *)bp->b_data)[bn - 1], ((ufs_daddr_t *)bp->b_data)[bn]); ++bn, ++*runp); bn = xap->in_off; if (runb && bn) { for(--bn; bn >= 0 && *runb < maxrun && is_sequential(ump, ((daddr_t *)bp->b_data)[bn], ((daddr_t *)bp->b_data)[bn+1]); --bn, ++*runb); } } } if (bp) bqrelse(bp); daddr = blkptrtodb(ump, daddr); *bnp = daddr == 0 ? -1 : daddr; return (0); }
[ "int", "ufs_bmaparray", "(", "struct", "vnode", "*", "vp", ",", "ufs_daddr_t", "bn", ",", "ufs_daddr_t", "*", "bnp", ",", "struct", "indir", "*", "ap", ",", "int", "*", "nump", ",", "int", "*", "runp", ",", "int", "*", "runb", ")", "{", "struct", "inode", "*", "ip", ";", "struct", "buf", "*", "bp", ";", "struct", "ufsmount", "*", "ump", ";", "struct", "mount", "*", "mp", ";", "struct", "fs", "*", "fs", ";", "struct", "indir", "a", "[", "UFS_NIADDR", "+", "1", "]", ",", "*", "xap", ";", "ufs_daddr_t", "daddr", ";", "long", "metalbn", ";", "int", "error", ",", "maxrun", ",", "num", ";", "ip", "=", "VTOI", "(", "vp", ")", ";", "mp", "=", "vp", "->", "v_mount", ";", "ump", "=", "VFSTOUFS", "(", "mp", ")", ";", "fs", "=", "ip", "->", "i_fs", ";", "#ifdef", "DIAGNOSTIC", "if", "(", "(", "ap", "!=", "NULL", "&&", "nump", "==", "NULL", ")", "||", "(", "ap", "==", "NULL", "&&", "nump", "!=", "NULL", ")", ")", "panic", "(", "\"", "\"", ")", ";", "#endif", "if", "(", "runp", ")", "{", "*", "runp", "=", "0", ";", "}", "if", "(", "runb", ")", "{", "*", "runb", "=", "0", ";", "}", "maxrun", "=", "mp", "->", "mnt_iosize_max", "/", "mp", "->", "mnt_stat", ".", "f_iosize", "-", "1", ";", "xap", "=", "ap", "==", "NULL", "?", "a", ":", "ap", ";", "if", "(", "!", "nump", ")", "nump", "=", "&", "num", ";", "error", "=", "ufs_getlbns", "(", "vp", ",", "bn", ",", "xap", ",", "nump", ")", ";", "if", "(", "error", ")", "return", "(", "error", ")", ";", "num", "=", "*", "nump", ";", "if", "(", "num", "==", "0", ")", "{", "*", "bnp", "=", "blkptrtodb", "(", "ump", ",", "ip", "->", "i_db", "[", "bn", "]", ")", ";", "if", "(", "*", "bnp", "==", "0", ")", "*", "bnp", "=", "-1", ";", "else", "if", "(", "runp", ")", "{", "daddr_t", "bnb", "=", "bn", ";", "for", "(", "++", "bn", ";", "bn", "<", "UFS_NDADDR", "&&", "*", "runp", "<", "maxrun", "&&", "is_sequential", "(", "ump", ",", "ip", "->", "i_db", "[", "bn", "-", "1", "]", ",", "ip", "->", "i_db", "[", "bn", "]", ")", ";", "++", "bn", ",", "++", "*", "runp", ")", ";", "bn", "=", "bnb", ";", "if", "(", "runb", "&&", "(", "bn", ">", "0", ")", ")", "{", "for", "(", "--", "bn", ";", "(", "bn", ">=", "0", ")", "&&", "(", "*", "runb", "<", "maxrun", ")", "&&", "is_sequential", "(", "ump", ",", "ip", "->", "i_db", "[", "bn", "]", ",", "ip", "->", "i_db", "[", "bn", "+", "1", "]", ")", ";", "--", "bn", ",", "++", "*", "runb", ")", ";", "}", "}", "return", "(", "0", ")", ";", "}", "daddr", "=", "ip", "->", "i_ib", "[", "xap", "->", "in_off", "]", ";", "for", "(", "bp", "=", "NULL", ",", "++", "xap", ";", "--", "num", ";", "++", "xap", ")", "{", "metalbn", "=", "xap", "->", "in_lbn", ";", "if", "(", "(", "daddr", "==", "0", "&&", "!", "findblk", "(", "vp", ",", "dbtodoff", "(", "fs", ",", "metalbn", ")", ",", "FINDBLK_TEST", ")", ")", "||", "metalbn", "==", "bn", ")", "{", "break", ";", "}", "if", "(", "bp", ")", "bqrelse", "(", "bp", ")", ";", "bp", "=", "getblk", "(", "vp", ",", "lblktodoff", "(", "fs", ",", "metalbn", ")", ",", "mp", "->", "mnt_stat", ".", "f_iosize", ",", "0", ",", "0", ")", ";", "if", "(", "(", "bp", "->", "b_flags", "&", "B_CACHE", ")", "==", "0", ")", "{", "#ifdef", "DIAGNOSTIC", "if", "(", "!", "daddr", ")", "panic", "(", "\"", "\"", ")", ";", "#endif", "bp", "->", "b_bio1", ".", "bio_done", "=", "biodone_sync", ";", "bp", "->", "b_bio1", ".", "bio_flags", "|=", "BIO_SYNC", ";", "bp", "->", "b_bio2", ".", "bio_offset", "=", "fsbtodoff", "(", "fs", ",", "daddr", ")", ";", "bp", "->", "b_flags", "&=", "~", "(", "B_INVAL", "|", "B_ERROR", ")", ";", "bp", "->", "b_cmd", "=", "BUF_CMD_READ", ";", "vfs_busy_pages", "(", "bp", "->", "b_vp", ",", "bp", ")", ";", "vn_strategy", "(", "bp", "->", "b_vp", ",", "&", "bp", "->", "b_bio1", ")", ";", "error", "=", "biowait", "(", "&", "bp", "->", "b_bio1", ",", "\"", "\"", ")", ";", "if", "(", "error", ")", "{", "brelse", "(", "bp", ")", ";", "return", "(", "error", ")", ";", "}", "}", "daddr", "=", "(", "(", "ufs_daddr_t", "*", ")", "bp", "->", "b_data", ")", "[", "xap", "->", "in_off", "]", ";", "if", "(", "num", "==", "1", "&&", "daddr", "&&", "runp", ")", "{", "for", "(", "bn", "=", "xap", "->", "in_off", "+", "1", ";", "bn", "<", "MNINDIR", "(", "ump", ")", "&&", "*", "runp", "<", "maxrun", "&&", "is_sequential", "(", "ump", ",", "(", "(", "ufs_daddr_t", "*", ")", "bp", "->", "b_data", ")", "[", "bn", "-", "1", "]", ",", "(", "(", "ufs_daddr_t", "*", ")", "bp", "->", "b_data", ")", "[", "bn", "]", ")", ";", "++", "bn", ",", "++", "*", "runp", ")", ";", "bn", "=", "xap", "->", "in_off", ";", "if", "(", "runb", "&&", "bn", ")", "{", "for", "(", "--", "bn", ";", "bn", ">=", "0", "&&", "*", "runb", "<", "maxrun", "&&", "is_sequential", "(", "ump", ",", "(", "(", "daddr_t", "*", ")", "bp", "->", "b_data", ")", "[", "bn", "]", ",", "(", "(", "daddr_t", "*", ")", "bp", "->", "b_data", ")", "[", "bn", "+", "1", "]", ")", ";", "--", "bn", ",", "++", "*", "runb", ")", ";", "}", "}", "}", "if", "(", "bp", ")", "bqrelse", "(", "bp", ")", ";", "daddr", "=", "blkptrtodb", "(", "ump", ",", "daddr", ")", ";", "*", "bnp", "=", "daddr", "==", "0", "?", "-1", ":", "daddr", ";", "return", "(", "0", ")", ";", "}" ]
Indirect blocks are now on the vnode for the file.
[ "Indirect", "blocks", "are", "now", "on", "the", "vnode", "for", "the", "file", "." ]
[ "/* Get disk address out of indirect block array */", "/*\n\t\t * Exit the loop if there is no disk address assigned yet and\n\t\t * the indirect block isn't in the cache, or if we were\n\t\t * looking for an indirect block and we've found it.\n\t\t */", "/*\n\t\t * If we get here, we've either got the block in the cache\n\t\t * or we have a disk address for it, go fetch it.\n\t\t */", "/*\n\t\t\t * cached disk addr in bio2, do I/O on bio1. It\n\t\t\t * will probably hit the vfs's strategy function\n\t\t\t * which will then use the cached offset in bio2.\n\t\t\t */" ]
[ { "param": "vp", "type": "struct vnode" }, { "param": "bn", "type": "ufs_daddr_t" }, { "param": "bnp", "type": "ufs_daddr_t" }, { "param": "ap", "type": "struct indir" }, { "param": "nump", "type": "int" }, { "param": "runp", "type": "int" }, { "param": "runb", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "vp", "type": "struct vnode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bn", "type": "ufs_daddr_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bnp", "type": "ufs_daddr_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ap", "type": "struct indir", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nump", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "runp", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "runb", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a7c67f4961aedc74be4e1e9c3b144adeb70682e2
atrens/DragonFlyBSD-src
sys/vfs/ufs/ufs_bmap.c
[ "BSD-3-Clause" ]
C
ufs_getlbns
int
int ufs_getlbns(struct vnode *vp, ufs_daddr_t bn, struct indir *ap, int *nump) { long blockcnt, metalbn, realbn; struct ufsmount *ump; int i, numlevels, off; int64_t qblockcnt; ump = VFSTOUFS(vp->v_mount); if (nump) *nump = 0; numlevels = 0; realbn = bn; if ((long)bn < 0) bn = -(long)bn; /* The first UFS_NDADDR blocks are direct blocks. */ if (bn < UFS_NDADDR) return (0); /* * Determine the number of levels of indirection. After this loop * is done, blockcnt indicates the number of data blocks possible * at the previous level of indirection, and UFS_NIADDR-i is the number * of levels of indirection needed to locate the requested block. */ for (blockcnt = 1, i = UFS_NIADDR, bn -= UFS_NDADDR;; i--, bn -= blockcnt) { if (i == 0) return (EFBIG); /* * Use int64_t's here to avoid overflow for triple indirect * blocks when longs have 32 bits and the block size is more * than 4K. */ qblockcnt = (int64_t)blockcnt * MNINDIR(ump); if (bn < qblockcnt) break; blockcnt = qblockcnt; } /* Calculate the address of the first meta-block. */ if (realbn >= 0) metalbn = -(realbn - bn + UFS_NIADDR - i); else metalbn = -(-realbn - bn + UFS_NIADDR - i); /* * At each iteration, off is the offset into the bap array which is * an array of disk addresses at the current level of indirection. * The logical block number and the offset in that block are stored * into the argument array. */ ap->in_lbn = metalbn; ap->in_off = off = UFS_NIADDR - i; ap++; for (++numlevels; i <= UFS_NIADDR; i++) { /* If searching for a meta-data block, quit when found. */ if (metalbn == realbn) break; off = (bn / blockcnt) % MNINDIR(ump); ++numlevels; ap->in_lbn = metalbn; ap->in_off = off; ++ap; metalbn -= -1 + off * blockcnt; blockcnt /= MNINDIR(ump); } if (nump) *nump = numlevels; return (0); }
/* * Create an array of logical block number/offset pairs which represent the * path of indirect blocks required to access a data block. The first "pair" * contains the logical block number of the appropriate single, double or * triple indirect block and the offset into the inode indirect block array. * Note, the logical block number of the inode single/double/triple indirect * block appears twice in the array, once with the offset into the i_ib and * once with the offset into the page itself. */
Create an array of logical block number/offset pairs which represent the path of indirect blocks required to access a data block. The first "pair" contains the logical block number of the appropriate single, double or triple indirect block and the offset into the inode indirect block array. Note, the logical block number of the inode single/double/triple indirect block appears twice in the array, once with the offset into the i_ib and once with the offset into the page itself.
[ "Create", "an", "array", "of", "logical", "block", "number", "/", "offset", "pairs", "which", "represent", "the", "path", "of", "indirect", "blocks", "required", "to", "access", "a", "data", "block", ".", "The", "first", "\"", "pair", "\"", "contains", "the", "logical", "block", "number", "of", "the", "appropriate", "single", "double", "or", "triple", "indirect", "block", "and", "the", "offset", "into", "the", "inode", "indirect", "block", "array", ".", "Note", "the", "logical", "block", "number", "of", "the", "inode", "single", "/", "double", "/", "triple", "indirect", "block", "appears", "twice", "in", "the", "array", "once", "with", "the", "offset", "into", "the", "i_ib", "and", "once", "with", "the", "offset", "into", "the", "page", "itself", "." ]
int ufs_getlbns(struct vnode *vp, ufs_daddr_t bn, struct indir *ap, int *nump) { long blockcnt, metalbn, realbn; struct ufsmount *ump; int i, numlevels, off; int64_t qblockcnt; ump = VFSTOUFS(vp->v_mount); if (nump) *nump = 0; numlevels = 0; realbn = bn; if ((long)bn < 0) bn = -(long)bn; if (bn < UFS_NDADDR) return (0); for (blockcnt = 1, i = UFS_NIADDR, bn -= UFS_NDADDR;; i--, bn -= blockcnt) { if (i == 0) return (EFBIG); qblockcnt = (int64_t)blockcnt * MNINDIR(ump); if (bn < qblockcnt) break; blockcnt = qblockcnt; } if (realbn >= 0) metalbn = -(realbn - bn + UFS_NIADDR - i); else metalbn = -(-realbn - bn + UFS_NIADDR - i); ap->in_lbn = metalbn; ap->in_off = off = UFS_NIADDR - i; ap++; for (++numlevels; i <= UFS_NIADDR; i++) { if (metalbn == realbn) break; off = (bn / blockcnt) % MNINDIR(ump); ++numlevels; ap->in_lbn = metalbn; ap->in_off = off; ++ap; metalbn -= -1 + off * blockcnt; blockcnt /= MNINDIR(ump); } if (nump) *nump = numlevels; return (0); }
[ "int", "ufs_getlbns", "(", "struct", "vnode", "*", "vp", ",", "ufs_daddr_t", "bn", ",", "struct", "indir", "*", "ap", ",", "int", "*", "nump", ")", "{", "long", "blockcnt", ",", "metalbn", ",", "realbn", ";", "struct", "ufsmount", "*", "ump", ";", "int", "i", ",", "numlevels", ",", "off", ";", "int64_t", "qblockcnt", ";", "ump", "=", "VFSTOUFS", "(", "vp", "->", "v_mount", ")", ";", "if", "(", "nump", ")", "*", "nump", "=", "0", ";", "numlevels", "=", "0", ";", "realbn", "=", "bn", ";", "if", "(", "(", "long", ")", "bn", "<", "0", ")", "bn", "=", "-", "(", "long", ")", "bn", ";", "if", "(", "bn", "<", "UFS_NDADDR", ")", "return", "(", "0", ")", ";", "for", "(", "blockcnt", "=", "1", ",", "i", "=", "UFS_NIADDR", ",", "bn", "-=", "UFS_NDADDR", ";", ";", "i", "--", ",", "bn", "-=", "blockcnt", ")", "{", "if", "(", "i", "==", "0", ")", "return", "(", "EFBIG", ")", ";", "qblockcnt", "=", "(", "int64_t", ")", "blockcnt", "*", "MNINDIR", "(", "ump", ")", ";", "if", "(", "bn", "<", "qblockcnt", ")", "break", ";", "blockcnt", "=", "qblockcnt", ";", "}", "if", "(", "realbn", ">=", "0", ")", "metalbn", "=", "-", "(", "realbn", "-", "bn", "+", "UFS_NIADDR", "-", "i", ")", ";", "else", "metalbn", "=", "-", "(", "-", "realbn", "-", "bn", "+", "UFS_NIADDR", "-", "i", ")", ";", "ap", "->", "in_lbn", "=", "metalbn", ";", "ap", "->", "in_off", "=", "off", "=", "UFS_NIADDR", "-", "i", ";", "ap", "++", ";", "for", "(", "++", "numlevels", ";", "i", "<=", "UFS_NIADDR", ";", "i", "++", ")", "{", "if", "(", "metalbn", "==", "realbn", ")", "break", ";", "off", "=", "(", "bn", "/", "blockcnt", ")", "%", "MNINDIR", "(", "ump", ")", ";", "++", "numlevels", ";", "ap", "->", "in_lbn", "=", "metalbn", ";", "ap", "->", "in_off", "=", "off", ";", "++", "ap", ";", "metalbn", "-=", "-1", "+", "off", "*", "blockcnt", ";", "blockcnt", "/=", "MNINDIR", "(", "ump", ")", ";", "}", "if", "(", "nump", ")", "*", "nump", "=", "numlevels", ";", "return", "(", "0", ")", ";", "}" ]
Create an array of logical block number/offset pairs which represent the path of indirect blocks required to access a data block.
[ "Create", "an", "array", "of", "logical", "block", "number", "/", "offset", "pairs", "which", "represent", "the", "path", "of", "indirect", "blocks", "required", "to", "access", "a", "data", "block", "." ]
[ "/* The first UFS_NDADDR blocks are direct blocks. */", "/*\n\t * Determine the number of levels of indirection. After this loop\n\t * is done, blockcnt indicates the number of data blocks possible\n\t * at the previous level of indirection, and UFS_NIADDR-i is the number\n\t * of levels of indirection needed to locate the requested block.\n\t */", "/*\n\t\t * Use int64_t's here to avoid overflow for triple indirect\n\t\t * blocks when longs have 32 bits and the block size is more\n\t\t * than 4K.\n\t\t */", "/* Calculate the address of the first meta-block. */", "/*\n\t * At each iteration, off is the offset into the bap array which is\n\t * an array of disk addresses at the current level of indirection.\n\t * The logical block number and the offset in that block are stored\n\t * into the argument array.\n\t */", "/* If searching for a meta-data block, quit when found. */" ]
[ { "param": "vp", "type": "struct vnode" }, { "param": "bn", "type": "ufs_daddr_t" }, { "param": "ap", "type": "struct indir" }, { "param": "nump", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "vp", "type": "struct vnode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bn", "type": "ufs_daddr_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ap", "type": "struct indir", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "nump", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
args2line
char
static char * args2line(int argc, char **argv) { char *cp1, *cend; const char *cp2; char buf[1024]; if (argc <= 0) return strdup("\n"); cp1 = buf; cend = buf + sizeof(buf) - 1; /* save room for '\0' */ while (--argc >= 0) { cp2 = *argv++; while ((cp1 < cend) && (*cp1++ = *cp2++)) ; cp1[-1] = ' '; } cp1[-1] = '\n'; *cp1 = '\0'; return strdup(buf); }
/* * Convert an argv-array of character strings into a single string. */
Convert an argv-array of character strings into a single string.
[ "Convert", "an", "argv", "-", "array", "of", "character", "strings", "into", "a", "single", "string", "." ]
static char * args2line(int argc, char **argv) { char *cp1, *cend; const char *cp2; char buf[1024]; if (argc <= 0) return strdup("\n"); cp1 = buf; cend = buf + sizeof(buf) - 1; while (--argc >= 0) { cp2 = *argv++; while ((cp1 < cend) && (*cp1++ = *cp2++)) ; cp1[-1] = ' '; } cp1[-1] = '\n'; *cp1 = '\0'; return strdup(buf); }
[ "static", "char", "*", "args2line", "(", "int", "argc", ",", "char", "*", "*", "argv", ")", "{", "char", "*", "cp1", ",", "*", "cend", ";", "const", "char", "*", "cp2", ";", "char", "buf", "[", "1024", "]", ";", "if", "(", "argc", "<=", "0", ")", "return", "strdup", "(", "\"", "\\n", "\"", ")", ";", "cp1", "=", "buf", ";", "cend", "=", "buf", "+", "sizeof", "(", "buf", ")", "-", "1", ";", "while", "(", "--", "argc", ">=", "0", ")", "{", "cp2", "=", "*", "argv", "++", ";", "while", "(", "(", "cp1", "<", "cend", ")", "&&", "(", "*", "cp1", "++", "=", "*", "cp2", "++", ")", ")", ";", "cp1", "[", "-1", "]", "=", "'", "'", ";", "}", "cp1", "[", "-1", "]", "=", "'", "\\n", "'", ";", "*", "cp1", "=", "'", "\\0", "'", ";", "return", "strdup", "(", "buf", ")", ";", "}" ]
Convert an argv-array of character strings into a single string.
[ "Convert", "an", "argv", "-", "array", "of", "character", "strings", "into", "a", "single", "string", "." ]
[ "/* save room for '\\0' */" ]
[ { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
kill_qtask
int
static int kill_qtask(const char *lf) { FILE *fp; pid_t pid; int errsav, killres, lockres, res; seteuid(euid); fp = fopen(lf, "r"); errsav = errno; seteuid(uid); res = KQT_NODAEMON; if (fp == NULL) { /* * If there is no lock file, then there is no daemon to * kill. Any other error return means there is some * kind of problem with the lock file. */ if (errsav != ENOENT) res = KQT_LFERROR; goto killdone; } /* If the lock file is empty, then there is no daemon to kill */ if (get_line(fp) == 0) goto killdone; /* * If the file can be locked without blocking, then there * no daemon to kill, or we should not try to kill it. * * XXX - not sure I understand the reasoning behind this... */ lockres = flock(fileno(fp), LOCK_SH|LOCK_NB); fclose(fp); if (lockres == 0) goto killdone; pid = atoi(line); if (pid < 0) { /* * If we got a negative pid, then the contents of the * lock file is not valid. */ res = KQT_LFERROR; goto killdone; } seteuid(uid); killres = kill(pid, SIGTERM); errsav = errno; seteuid(uid); if (killres == 0) { res = KQT_KILLOK; printf("\tdaemon (pid %d) killed\n", pid); } else if (errno == ESRCH) { res = KQT_NODAEMON; } else { res = KQT_KILLFAIL; printf("\tWarning: daemon (pid %d) not killed:\n", pid); printf("\t %s\n", strerror(errsav)); } killdone: switch (res) { case KQT_LFERROR: printf("\tcannot open lock file: %s\n", strerror(errsav)); break; case KQT_NODAEMON: printf("\tno daemon to abort\n"); break; case KQT_KILLFAIL: case KQT_KILLOK: /* These two already printed messages to the user. */ break; default: printf("\t<internal error in kill_qtask>\n"); break; } return (res); }
/* * Kill the current daemon, to stop printing of the active job. */
Kill the current daemon, to stop printing of the active job.
[ "Kill", "the", "current", "daemon", "to", "stop", "printing", "of", "the", "active", "job", "." ]
static int kill_qtask(const char *lf) { FILE *fp; pid_t pid; int errsav, killres, lockres, res; seteuid(euid); fp = fopen(lf, "r"); errsav = errno; seteuid(uid); res = KQT_NODAEMON; if (fp == NULL) { if (errsav != ENOENT) res = KQT_LFERROR; goto killdone; } if (get_line(fp) == 0) goto killdone; lockres = flock(fileno(fp), LOCK_SH|LOCK_NB); fclose(fp); if (lockres == 0) goto killdone; pid = atoi(line); if (pid < 0) { res = KQT_LFERROR; goto killdone; } seteuid(uid); killres = kill(pid, SIGTERM); errsav = errno; seteuid(uid); if (killres == 0) { res = KQT_KILLOK; printf("\tdaemon (pid %d) killed\n", pid); } else if (errno == ESRCH) { res = KQT_NODAEMON; } else { res = KQT_KILLFAIL; printf("\tWarning: daemon (pid %d) not killed:\n", pid); printf("\t %s\n", strerror(errsav)); } killdone: switch (res) { case KQT_LFERROR: printf("\tcannot open lock file: %s\n", strerror(errsav)); break; case KQT_NODAEMON: printf("\tno daemon to abort\n"); break; case KQT_KILLFAIL: case KQT_KILLOK: break; default: printf("\t<internal error in kill_qtask>\n"); break; } return (res); }
[ "static", "int", "kill_qtask", "(", "const", "char", "*", "lf", ")", "{", "FILE", "*", "fp", ";", "pid_t", "pid", ";", "int", "errsav", ",", "killres", ",", "lockres", ",", "res", ";", "seteuid", "(", "euid", ")", ";", "fp", "=", "fopen", "(", "lf", ",", "\"", "\"", ")", ";", "errsav", "=", "errno", ";", "seteuid", "(", "uid", ")", ";", "res", "=", "KQT_NODAEMON", ";", "if", "(", "fp", "==", "NULL", ")", "{", "if", "(", "errsav", "!=", "ENOENT", ")", "res", "=", "KQT_LFERROR", ";", "goto", "killdone", ";", "}", "if", "(", "get_line", "(", "fp", ")", "==", "0", ")", "goto", "killdone", ";", "lockres", "=", "flock", "(", "fileno", "(", "fp", ")", ",", "LOCK_SH", "|", "LOCK_NB", ")", ";", "fclose", "(", "fp", ")", ";", "if", "(", "lockres", "==", "0", ")", "goto", "killdone", ";", "pid", "=", "atoi", "(", "line", ")", ";", "if", "(", "pid", "<", "0", ")", "{", "res", "=", "KQT_LFERROR", ";", "goto", "killdone", ";", "}", "seteuid", "(", "uid", ")", ";", "killres", "=", "kill", "(", "pid", ",", "SIGTERM", ")", ";", "errsav", "=", "errno", ";", "seteuid", "(", "uid", ")", ";", "if", "(", "killres", "==", "0", ")", "{", "res", "=", "KQT_KILLOK", ";", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "pid", ")", ";", "}", "else", "if", "(", "errno", "==", "ESRCH", ")", "{", "res", "=", "KQT_NODAEMON", ";", "}", "else", "{", "res", "=", "KQT_KILLFAIL", ";", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "pid", ")", ";", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "strerror", "(", "errsav", ")", ")", ";", "}", "killdone", ":", "switch", "(", "res", ")", "{", "case", "KQT_LFERROR", ":", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "strerror", "(", "errsav", ")", ")", ";", "break", ";", "case", "KQT_NODAEMON", ":", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "break", ";", "case", "KQT_KILLFAIL", ":", "case", "KQT_KILLOK", ":", "break", ";", "default", ":", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "break", ";", "}", "return", "(", "res", ")", ";", "}" ]
Kill the current daemon, to stop printing of the active job.
[ "Kill", "the", "current", "daemon", "to", "stop", "printing", "of", "the", "active", "job", "." ]
[ "/*\n\t\t * If there is no lock file, then there is no daemon to\n\t\t * kill. Any other error return means there is some\n\t\t * kind of problem with the lock file.\n\t\t */", "/* If the lock file is empty, then there is no daemon to kill */", "/*\n\t * If the file can be locked without blocking, then there\n\t * no daemon to kill, or we should not try to kill it.\n\t *\n\t * XXX - not sure I understand the reasoning behind this...\n\t */", "/*\n\t\t * If we got a negative pid, then the contents of the\n\t\t * lock file is not valid.\n\t\t */", "/* These two already printed messages to the user. */" ]
[ { "param": "lf", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lf", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
upstat
void
static void upstat(struct printer *pp, const char *msg, int notifyuser) { int fd; char statfile[MAXPATHLEN]; status_file_name(pp, statfile, sizeof statfile); umask(0); seteuid(euid); fd = open(statfile, O_WRONLY|O_CREAT|O_EXLOCK, STAT_FILE_MODE); seteuid(uid); if (fd < 0) { printf("\tcannot create status file: %s\n", strerror(errno)); return; } ftruncate(fd, 0); if (msg == NULL) write(fd, "\n", 1); else write(fd, msg, strlen(msg)); close(fd); if (notifyuser) { if ((msg == NULL) || (strcmp(msg, "\n") == 0)) printf("\tstatus message is now set to nothing.\n"); else printf("\tstatus message is now: %s", msg); } }
/* * Write a message into the status file. */
Write a message into the status file.
[ "Write", "a", "message", "into", "the", "status", "file", "." ]
static void upstat(struct printer *pp, const char *msg, int notifyuser) { int fd; char statfile[MAXPATHLEN]; status_file_name(pp, statfile, sizeof statfile); umask(0); seteuid(euid); fd = open(statfile, O_WRONLY|O_CREAT|O_EXLOCK, STAT_FILE_MODE); seteuid(uid); if (fd < 0) { printf("\tcannot create status file: %s\n", strerror(errno)); return; } ftruncate(fd, 0); if (msg == NULL) write(fd, "\n", 1); else write(fd, msg, strlen(msg)); close(fd); if (notifyuser) { if ((msg == NULL) || (strcmp(msg, "\n") == 0)) printf("\tstatus message is now set to nothing.\n"); else printf("\tstatus message is now: %s", msg); } }
[ "static", "void", "upstat", "(", "struct", "printer", "*", "pp", ",", "const", "char", "*", "msg", ",", "int", "notifyuser", ")", "{", "int", "fd", ";", "char", "statfile", "[", "MAXPATHLEN", "]", ";", "status_file_name", "(", "pp", ",", "statfile", ",", "sizeof", "statfile", ")", ";", "umask", "(", "0", ")", ";", "seteuid", "(", "euid", ")", ";", "fd", "=", "open", "(", "statfile", ",", "O_WRONLY", "|", "O_CREAT", "|", "O_EXLOCK", ",", "STAT_FILE_MODE", ")", ";", "seteuid", "(", "uid", ")", ";", "if", "(", "fd", "<", "0", ")", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "strerror", "(", "errno", ")", ")", ";", "return", ";", "}", "ftruncate", "(", "fd", ",", "0", ")", ";", "if", "(", "msg", "==", "NULL", ")", "write", "(", "fd", ",", "\"", "\\n", "\"", ",", "1", ")", ";", "else", "write", "(", "fd", ",", "msg", ",", "strlen", "(", "msg", ")", ")", ";", "close", "(", "fd", ")", ";", "if", "(", "notifyuser", ")", "{", "if", "(", "(", "msg", "==", "NULL", ")", "||", "(", "strcmp", "(", "msg", ",", "\"", "\\n", "\"", ")", "==", "0", ")", ")", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "else", "printf", "(", "\"", "\\t", "\"", ",", "msg", ")", ";", "}", "}" ]
Write a message into the status file.
[ "Write", "a", "message", "into", "the", "status", "file", "." ]
[]
[ { "param": "pp", "type": "struct printer" }, { "param": "msg", "type": "char" }, { "param": "notifyuser", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pp", "type": "struct printer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "msg", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "notifyuser", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
abort_q
void
void abort_q(struct printer *pp) { int killres, setres; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); /* * Turn on the owner execute bit of the lock file to disable printing. */ setres = set_qstate(SQS_STOPP, lf); /* * If set_qstate found that there already was a lock file, then * call a routine which will read that lock file and kill the * lpd-process which is listed in that lock file. If the lock * file did not exist, then either there is no daemon running * for this queue, or there is one running but *it* could not * write a lock file (which means we can not determine the * process id of that lpd-process). */ switch (setres) { case SQS_CHGOK: case SQS_CHGFAIL: /* Kill the process */ killres = kill_qtask(lf); break; case SQS_CREOK: case SQS_CREFAIL: printf("\tno daemon to abort\n"); break; case SQS_STATFAIL: printf("\tassuming no daemon to abort\n"); break; default: printf("\t<unexpected result (%d) from set_qstate>\n", setres); break; } if (setres >= 0) upstat(pp, "printing disabled\n", 0); }
/* * kill an existing daemon and disable printing. */
kill an existing daemon and disable printing.
[ "kill", "an", "existing", "daemon", "and", "disable", "printing", "." ]
void abort_q(struct printer *pp) { int killres, setres; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); setres = set_qstate(SQS_STOPP, lf); switch (setres) { case SQS_CHGOK: case SQS_CHGFAIL: killres = kill_qtask(lf); break; case SQS_CREOK: case SQS_CREFAIL: printf("\tno daemon to abort\n"); break; case SQS_STATFAIL: printf("\tassuming no daemon to abort\n"); break; default: printf("\t<unexpected result (%d) from set_qstate>\n", setres); break; } if (setres >= 0) upstat(pp, "printing disabled\n", 0); }
[ "void", "abort_q", "(", "struct", "printer", "*", "pp", ")", "{", "int", "killres", ",", "setres", ";", "char", "lf", "[", "MAXPATHLEN", "]", ";", "lock_file_name", "(", "pp", ",", "lf", ",", "sizeof", "lf", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "pp", "->", "printer", ")", ";", "setres", "=", "set_qstate", "(", "SQS_STOPP", ",", "lf", ")", ";", "switch", "(", "setres", ")", "{", "case", "SQS_CHGOK", ":", "case", "SQS_CHGFAIL", ":", "killres", "=", "kill_qtask", "(", "lf", ")", ";", "break", ";", "case", "SQS_CREOK", ":", "case", "SQS_CREFAIL", ":", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "break", ";", "case", "SQS_STATFAIL", ":", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "break", ";", "default", ":", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "setres", ")", ";", "break", ";", "}", "if", "(", "setres", ">=", "0", ")", "upstat", "(", "pp", ",", "\"", "\\n", "\"", ",", "0", ")", ";", "}" ]
kill an existing daemon and disable printing.
[ "kill", "an", "existing", "daemon", "and", "disable", "printing", "." ]
[ "/*\n\t * Turn on the owner execute bit of the lock file to disable printing.\n\t */", "/*\n\t * If set_qstate found that there already was a lock file, then\n\t * call a routine which will read that lock file and kill the\n\t * lpd-process which is listed in that lock file. If the lock\n\t * file did not exist, then either there is no daemon running\n\t * for this queue, or there is one running but *it* could not\n\t * write a lock file (which means we can not determine the\n\t * process id of that lpd-process).\n\t */", "/* Kill the process */" ]
[ { "param": "pp", "type": "struct printer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pp", "type": "struct printer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
sortq
int
static int sortq(const struct dirent **a, const struct dirent **b) { const int a_lt_b = -1, a_gt_b = 1, cat_other = 10; const char *fname_a, *fname_b, *jnum_a, *jnum_b; int cat_a, cat_b, ch, res, seq_a, seq_b; fname_a = (*a)->d_name; fname_b = (*b)->d_name; /* * First separate filenames into cagatories. Catagories are * legitimate `cf', `df', `rf' & `tf' filenames, and "other" - in * that order. It is critical that the mapping be exactly the * same for 'a' vs 'b', so define a macro for the job. * * [aside: the standard `cf' file has the jobnumber start in * position 4, but some implementations have that as an extra * file-sequence letter, and start the job number in position 5.] */ #define MAP_TO_CAT(fname_X,cat_X,jnum_X,seq_X) do { \ cat_X = cat_other; \ ch = *(fname_X + 2); \ jnum_X = fname_X + 3; \ seq_X = 0; \ if ((*(fname_X + 1) == 'f') && (isalpha(ch))) { \ seq_X = ch; \ if (*fname_X == 'c') \ cat_X = 1; \ else if (*fname_X == 'd') \ cat_X = 2; \ else if (*fname_X == 'r') \ cat_X = 3; \ else if (*fname_X == 't') \ cat_X = 4; \ if (cat_X != cat_other) { \ ch = *jnum_X; \ if (!isdigit(ch)) { \ if (isalpha(ch)) { \ jnum_X++; \ ch = *jnum_X; \ seq_X = (seq_X << 8) + ch; \ } \ if (!isdigit(ch)) \ cat_X = cat_other; \ } \ } \ } \ } while (0) MAP_TO_CAT(fname_a, cat_a, jnum_a, seq_a); MAP_TO_CAT(fname_b, cat_b, jnum_b, seq_b); #undef MAP_TO_CAT /* First handle all cases which have "other" files */ if ((cat_a >= cat_other) || (cat_b >= cat_other)) { /* for two "other" files, just compare the full name */ if (cat_a == cat_b) res = strcmp(fname_a, fname_b); else if (cat_a < cat_b) res = a_lt_b; else res = a_gt_b; goto have_res; } /* * At this point, we know both files are legitimate `cf', `df', `rf', * or `tf' files. Compare them by job-number and machine name. */ res = strcmp(jnum_a, jnum_b); if (res != 0) goto have_res; /* * We have two files which belong to the same job. Sort based * on the catagory of file (`c' before `d', etc). */ if (cat_a < cat_b) { res = a_lt_b; goto have_res; } else if (cat_a > cat_b) { res = a_gt_b; goto have_res; } /* * Two files in the same catagory for a single job. Sort based * on the sequence letter(s). (usually `A' thru `Z', etc). */ if (seq_a < seq_b) { res = a_lt_b; goto have_res; } else if (seq_a > seq_b) { res = a_gt_b; goto have_res; } /* * Given that the filenames in a directory are unique, this SHOULD * never happen (unless there are logic errors in this routine). * But if it does happen, we must return "is equal" or the caller * might see inconsistent results in the sorting order, and that * can trigger other problems. */ printf("\t*** Error in sortq: %s == %s !\n", fname_a, fname_b); printf("\t*** cat %d == %d ; seq = %d %d\n", cat_a, cat_b, seq_a, seq_b); res = 0; have_res: return res; }
/* * Comparison routine that clean_q() uses for scandir. * * The purpose of this sort is to have all `df' files end up immediately * after the matching `cf' file. For files matching `cf', `df', `rf', or * `tf', it sorts by job number and machine, then by `cf', `df', `rf', or * `tf', and then by the sequence letter (which is A-Z, or a-z). This * routine may also see filenames which do not start with `cf', `df', `rf', * or `tf' (such as `errs.*'), and those are simply sorted by the full * filename. * * XXX * This assumes that all control files start with `cfA*', and it turns * out there are a few implementations of lpr which will create `cfB*' * filenames (they will have datafile names which start with `dfB*'). */
Comparison routine that clean_q() uses for scandir. The purpose of this sort is to have all `df' files end up immediately after the matching `cf' file. XXX This assumes that all control files start with `cfA*', and it turns out there are a few implementations of lpr which will create `cfB*' filenames (they will have datafile names which start with `dfB*').
[ "Comparison", "routine", "that", "clean_q", "()", "uses", "for", "scandir", ".", "The", "purpose", "of", "this", "sort", "is", "to", "have", "all", "`", "df", "'", "files", "end", "up", "immediately", "after", "the", "matching", "`", "cf", "'", "file", ".", "XXX", "This", "assumes", "that", "all", "control", "files", "start", "with", "`", "cfA", "*", "'", "and", "it", "turns", "out", "there", "are", "a", "few", "implementations", "of", "lpr", "which", "will", "create", "`", "cfB", "*", "'", "filenames", "(", "they", "will", "have", "datafile", "names", "which", "start", "with", "`", "dfB", "*", "'", ")", "." ]
static int sortq(const struct dirent **a, const struct dirent **b) { const int a_lt_b = -1, a_gt_b = 1, cat_other = 10; const char *fname_a, *fname_b, *jnum_a, *jnum_b; int cat_a, cat_b, ch, res, seq_a, seq_b; fname_a = (*a)->d_name; fname_b = (*b)->d_name; #define MAP_TO_CAT(fname_X,cat_X,jnum_X,seq_X) do { \ cat_X = cat_other; \ ch = *(fname_X + 2); \ jnum_X = fname_X + 3; \ seq_X = 0; \ if ((*(fname_X + 1) == 'f') && (isalpha(ch))) { \ seq_X = ch; \ if (*fname_X == 'c') \ cat_X = 1; \ else if (*fname_X == 'd') \ cat_X = 2; \ else if (*fname_X == 'r') \ cat_X = 3; \ else if (*fname_X == 't') \ cat_X = 4; \ if (cat_X != cat_other) { \ ch = *jnum_X; \ if (!isdigit(ch)) { \ if (isalpha(ch)) { \ jnum_X++; \ ch = *jnum_X; \ seq_X = (seq_X << 8) + ch; \ } \ if (!isdigit(ch)) \ cat_X = cat_other; \ } \ } \ } \ } while (0) MAP_TO_CAT(fname_a, cat_a, jnum_a, seq_a); MAP_TO_CAT(fname_b, cat_b, jnum_b, seq_b); #undef MAP_TO_CAT if ((cat_a >= cat_other) || (cat_b >= cat_other)) { if (cat_a == cat_b) res = strcmp(fname_a, fname_b); else if (cat_a < cat_b) res = a_lt_b; else res = a_gt_b; goto have_res; } res = strcmp(jnum_a, jnum_b); if (res != 0) goto have_res; if (cat_a < cat_b) { res = a_lt_b; goto have_res; } else if (cat_a > cat_b) { res = a_gt_b; goto have_res; } if (seq_a < seq_b) { res = a_lt_b; goto have_res; } else if (seq_a > seq_b) { res = a_gt_b; goto have_res; } printf("\t*** Error in sortq: %s == %s !\n", fname_a, fname_b); printf("\t*** cat %d == %d ; seq = %d %d\n", cat_a, cat_b, seq_a, seq_b); res = 0; have_res: return res; }
[ "static", "int", "sortq", "(", "const", "struct", "dirent", "*", "*", "a", ",", "const", "struct", "dirent", "*", "*", "b", ")", "{", "const", "int", "a_lt_b", "=", "-1", ",", "a_gt_b", "=", "1", ",", "cat_other", "=", "10", ";", "const", "char", "*", "fname_a", ",", "*", "fname_b", ",", "*", "jnum_a", ",", "*", "jnum_b", ";", "int", "cat_a", ",", "cat_b", ",", "ch", ",", "res", ",", "seq_a", ",", "seq_b", ";", "fname_a", "=", "(", "*", "a", ")", "->", "d_name", ";", "fname_b", "=", "(", "*", "b", ")", "->", "d_name", ";", "#define", "MAP_TO_CAT", "(", "fname_X", ",", "cat_X", ",", "jnum_X", ",", "seq_X", ")", " do { \\\n\tcat_X = cat_other; \\\n\tch = *(fname_X + 2); \\\n\tjnum_X = fname_X + 3; \\\n\tseq_X = 0; \\\n\tif ((*(fname_X + 1) == 'f') && (isalpha(ch))) { \\\n\t\tseq_X = ch; \\\n\t\tif (*fname_X == 'c') \\\n\t\t\tcat_X = 1; \\\n\t\telse if (*fname_X == 'd') \\\n\t\t\tcat_X = 2; \\\n\t\telse if (*fname_X == 'r') \\\n\t\t\tcat_X = 3; \\\n\t\telse if (*fname_X == 't') \\\n\t\t\tcat_X = 4; \\\n\t\tif (cat_X != cat_other) { \\\n\t\t\tch = *jnum_X; \\\n\t\t\tif (!isdigit(ch)) { \\\n\t\t\t\tif (isalpha(ch)) { \\\n\t\t\t\t\tjnum_X++; \\\n\t\t\t\t\tch = *jnum_X; \\\n\t\t\t\t\tseq_X = (seq_X << 8) + ch; \\\n\t\t\t\t} \\\n\t\t\t\tif (!isdigit(ch)) \\\n\t\t\t\t\tcat_X = cat_other; \\\n\t\t\t} \\\n\t\t} \\\n\t} \\\n} while (0)", "\n\n", "MAP_TO_CAT", "(", "fname_a", ",", "cat_a", ",", "jnum_a", ",", "seq_a", ")", ";", "MAP_TO_CAT", "(", "fname_b", ",", "cat_b", ",", "jnum_b", ",", "seq_b", ")", ";", "#undef", " MAP_TO_CAT", "\n\n", "if", "(", "(", "cat_a", ">=", "cat_other", ")", "||", "(", "cat_b", ">=", "cat_other", ")", ")", "{", "if", "(", "cat_a", "==", "cat_b", ")", "res", "=", "strcmp", "(", "fname_a", ",", "fname_b", ")", ";", "else", "if", "(", "cat_a", "<", "cat_b", ")", "res", "=", "a_lt_b", ";", "else", "res", "=", "a_gt_b", ";", "goto", "have_res", ";", "}", "res", "=", "strcmp", "(", "jnum_a", ",", "jnum_b", ")", ";", "if", "(", "res", "!=", "0", ")", "goto", "have_res", ";", "if", "(", "cat_a", "<", "cat_b", ")", "{", "res", "=", "a_lt_b", ";", "goto", "have_res", ";", "}", "else", "if", "(", "cat_a", ">", "cat_b", ")", "{", "res", "=", "a_gt_b", ";", "goto", "have_res", ";", "}", "if", "(", "seq_a", "<", "seq_b", ")", "{", "res", "=", "a_lt_b", ";", "goto", "have_res", ";", "}", "else", "if", "(", "seq_a", ">", "seq_b", ")", "{", "res", "=", "a_gt_b", ";", "goto", "have_res", ";", "}", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "fname_a", ",", "fname_b", ")", ";", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "cat_a", ",", "cat_b", ",", "seq_a", ",", "seq_b", ")", ";", "res", "=", "0", ";", "have_res", ":", "return", "res", ";", "}" ]
Comparison routine that clean_q() uses for scandir.
[ "Comparison", "routine", "that", "clean_q", "()", "uses", "for", "scandir", "." ]
[ "/*\n\t * First separate filenames into cagatories. Catagories are\n\t * legitimate `cf', `df', `rf' & `tf' filenames, and \"other\" - in\n\t * that order. It is critical that the mapping be exactly the\n\t * same for 'a' vs 'b', so define a macro for the job.\n\t *\n\t * [aside: the standard `cf' file has the jobnumber start in\n\t * position 4, but some implementations have that as an extra\n\t * file-sequence letter, and start the job number in position 5.]\n\t */", "/* First handle all cases which have \"other\" files */", "/* for two \"other\" files, just compare the full name */", "/*\n\t * At this point, we know both files are legitimate `cf', `df', `rf',\n\t * or `tf' files. Compare them by job-number and machine name.\n\t */", "/*\n\t * We have two files which belong to the same job. Sort based\n\t * on the catagory of file (`c' before `d', etc).\n\t */", "/*\n\t * Two files in the same catagory for a single job. Sort based\n\t * on the sequence letter(s). (usually `A' thru `Z', etc).\n\t */", "/*\n\t * Given that the filenames in a directory are unique, this SHOULD\n\t * never happen (unless there are logic errors in this routine).\n\t * But if it does happen, we must return \"is equal\" or the caller\n\t * might see inconsistent results in the sorting order, and that\n\t * can trigger other problems.\n\t */" ]
[ { "param": "a", "type": "struct dirent" }, { "param": "b", "type": "struct dirent" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "struct dirent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b", "type": "struct dirent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
enable_q
void
void enable_q(struct printer *pp) { int setres; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); setres = set_qstate(SQS_ENABLEQ, lf); }
/* * Enable queuing to the printer (allow lpr to add new jobs to the queue). */
Enable queuing to the printer (allow lpr to add new jobs to the queue).
[ "Enable", "queuing", "to", "the", "printer", "(", "allow", "lpr", "to", "add", "new", "jobs", "to", "the", "queue", ")", "." ]
void enable_q(struct printer *pp) { int setres; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); setres = set_qstate(SQS_ENABLEQ, lf); }
[ "void", "enable_q", "(", "struct", "printer", "*", "pp", ")", "{", "int", "setres", ";", "char", "lf", "[", "MAXPATHLEN", "]", ";", "lock_file_name", "(", "pp", ",", "lf", ",", "sizeof", "lf", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "pp", "->", "printer", ")", ";", "setres", "=", "set_qstate", "(", "SQS_ENABLEQ", ",", "lf", ")", ";", "}" ]
Enable queuing to the printer (allow lpr to add new jobs to the queue).
[ "Enable", "queuing", "to", "the", "printer", "(", "allow", "lpr", "to", "add", "new", "jobs", "to", "the", "queue", ")", "." ]
[]
[ { "param": "pp", "type": "struct printer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pp", "type": "struct printer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
down_gi
void
void down_gi(int argc, char **argv) { /* If `-msg' was specified, then this routine has nothing to do. */ if (generic_msg != NULL) return; /* * If the user only gave one parameter, then use a default msg. * (if argc == 1 at this point, then *argv == name of printer). */ if (argc == 1) { generic_msg = strdup("printing disabled\n"); return; } /* * The user specified multiple parameters, and did not specify * `-msg'. Build a message from all the parameters after the * first one (and nullify those parameters so generic-processing * will not process them as printer-queue names). */ argc--; argv++; generic_msg = args2line(argc, argv); for (; argc > 0; argc--, argv++) *argv = generic_nullarg; /* "erase" it */ }
/* * Disable queuing and printing and put a message into the status file * (reason for being down). If the user specified `-msg', then use * everything after that as the message for the status file. If the * user did NOT specify `-msg', then the command should take the first * parameter as the printer name, and all remaining parameters as the * message for the status file. (This is to be compatible with the * original definition of 'down', which was implemented long before * `-msg' was around). */
Disable queuing and printing and put a message into the status file (reason for being down). If the user specified `-msg', then use everything after that as the message for the status file. If the user did NOT specify `-msg', then the command should take the first parameter as the printer name, and all remaining parameters as the message for the status file. (This is to be compatible with the original definition of 'down', which was implemented long before `-msg' was around).
[ "Disable", "queuing", "and", "printing", "and", "put", "a", "message", "into", "the", "status", "file", "(", "reason", "for", "being", "down", ")", ".", "If", "the", "user", "specified", "`", "-", "msg", "'", "then", "use", "everything", "after", "that", "as", "the", "message", "for", "the", "status", "file", ".", "If", "the", "user", "did", "NOT", "specify", "`", "-", "msg", "'", "then", "the", "command", "should", "take", "the", "first", "parameter", "as", "the", "printer", "name", "and", "all", "remaining", "parameters", "as", "the", "message", "for", "the", "status", "file", ".", "(", "This", "is", "to", "be", "compatible", "with", "the", "original", "definition", "of", "'", "down", "'", "which", "was", "implemented", "long", "before", "`", "-", "msg", "'", "was", "around", ")", "." ]
void down_gi(int argc, char **argv) { if (generic_msg != NULL) return; if (argc == 1) { generic_msg = strdup("printing disabled\n"); return; } argc--; argv++; generic_msg = args2line(argc, argv); for (; argc > 0; argc--, argv++) *argv = generic_nullarg; }
[ "void", "down_gi", "(", "int", "argc", ",", "char", "*", "*", "argv", ")", "{", "if", "(", "generic_msg", "!=", "NULL", ")", "return", ";", "if", "(", "argc", "==", "1", ")", "{", "generic_msg", "=", "strdup", "(", "\"", "\\n", "\"", ")", ";", "return", ";", "}", "argc", "--", ";", "argv", "++", ";", "generic_msg", "=", "args2line", "(", "argc", ",", "argv", ")", ";", "for", "(", ";", "argc", ">", "0", ";", "argc", "--", ",", "argv", "++", ")", "*", "argv", "=", "generic_nullarg", ";", "}" ]
Disable queuing and printing and put a message into the status file (reason for being down).
[ "Disable", "queuing", "and", "printing", "and", "put", "a", "message", "into", "the", "status", "file", "(", "reason", "for", "being", "down", ")", "." ]
[ "/* If `-msg' was specified, then this routine has nothing to do. */", "/*\n\t * If the user only gave one parameter, then use a default msg.\n\t * (if argc == 1 at this point, then *argv == name of printer).\n\t */", "/*\n\t * The user specified multiple parameters, and did not specify\n\t * `-msg'. Build a message from all the parameters after the\n\t * first one (and nullify those parameters so generic-processing\n\t * will not process them as printer-queue names).\n\t */", "/* \"erase\" it */" ]
[ { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
restart_q
void
void restart_q(struct printer *pp) { int killres, setres, startok; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); killres = kill_qtask(lf); /* * XXX - if the kill worked, we should probably sleep for * a second or so before trying to restart the queue. */ /* make sure the queue is set to print jobs */ setres = set_qstate(SQS_STARTP, lf); seteuid(euid); startok = startdaemon(pp); seteuid(uid); if (!startok) printf("\tcouldn't restart daemon\n"); else printf("\tdaemon restarted\n"); }
/* * Kill and restart the daemon. */
Kill and restart the daemon.
[ "Kill", "and", "restart", "the", "daemon", "." ]
void restart_q(struct printer *pp) { int killres, setres, startok; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); killres = kill_qtask(lf); setres = set_qstate(SQS_STARTP, lf); seteuid(euid); startok = startdaemon(pp); seteuid(uid); if (!startok) printf("\tcouldn't restart daemon\n"); else printf("\tdaemon restarted\n"); }
[ "void", "restart_q", "(", "struct", "printer", "*", "pp", ")", "{", "int", "killres", ",", "setres", ",", "startok", ";", "char", "lf", "[", "MAXPATHLEN", "]", ";", "lock_file_name", "(", "pp", ",", "lf", ",", "sizeof", "lf", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "pp", "->", "printer", ")", ";", "killres", "=", "kill_qtask", "(", "lf", ")", ";", "setres", "=", "set_qstate", "(", "SQS_STARTP", ",", "lf", ")", ";", "seteuid", "(", "euid", ")", ";", "startok", "=", "startdaemon", "(", "pp", ")", ";", "seteuid", "(", "uid", ")", ";", "if", "(", "!", "startok", ")", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "else", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "}" ]
Kill and restart the daemon.
[ "Kill", "and", "restart", "the", "daemon", "." ]
[ "/*\n\t * XXX - if the kill worked, we should probably sleep for\n\t * a second or so before trying to restart the queue.\n\t */", "/* make sure the queue is set to print jobs */" ]
[ { "param": "pp", "type": "struct printer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pp", "type": "struct printer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
start_q
void
void start_q(struct printer *pp) { int setres, startok; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); setres = set_qstate(SQS_STARTP, lf); seteuid(euid); startok = startdaemon(pp); seteuid(uid); if (!startok) printf("\tcouldn't start daemon\n"); else printf("\tdaemon started\n"); seteuid(uid); }
/* * Enable printing on the specified printer and startup the daemon. */
Enable printing on the specified printer and startup the daemon.
[ "Enable", "printing", "on", "the", "specified", "printer", "and", "startup", "the", "daemon", "." ]
void start_q(struct printer *pp) { int setres, startok; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); setres = set_qstate(SQS_STARTP, lf); seteuid(euid); startok = startdaemon(pp); seteuid(uid); if (!startok) printf("\tcouldn't start daemon\n"); else printf("\tdaemon started\n"); seteuid(uid); }
[ "void", "start_q", "(", "struct", "printer", "*", "pp", ")", "{", "int", "setres", ",", "startok", ";", "char", "lf", "[", "MAXPATHLEN", "]", ";", "lock_file_name", "(", "pp", ",", "lf", ",", "sizeof", "lf", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "pp", "->", "printer", ")", ";", "setres", "=", "set_qstate", "(", "SQS_STARTP", ",", "lf", ")", ";", "seteuid", "(", "euid", ")", ";", "startok", "=", "startdaemon", "(", "pp", ")", ";", "seteuid", "(", "uid", ")", ";", "if", "(", "!", "startok", ")", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "else", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "seteuid", "(", "uid", ")", ";", "}" ]
Enable printing on the specified printer and startup the daemon.
[ "Enable", "printing", "on", "the", "specified", "printer", "and", "startup", "the", "daemon", "." ]
[]
[ { "param": "pp", "type": "struct printer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pp", "type": "struct printer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
status
void
void status(struct printer *pp) { struct stat stbuf; int fd, i; struct dirent *dp; DIR *dirp; char file[MAXPATHLEN]; printf("%s:\n", pp->printer); lock_file_name(pp, file, sizeof file); if (stat(file, &stbuf) >= 0) { printf("\tqueuing is %s\n", ((stbuf.st_mode & LFM_QUEUE_DIS) ? "disabled" : "enabled")); printf("\tprinting is %s\n", ((stbuf.st_mode & LFM_PRINT_DIS) ? "disabled" : "enabled")); } else { printf("\tqueuing is enabled\n"); printf("\tprinting is enabled\n"); } if ((dirp = opendir(pp->spool_dir)) == NULL) { printf("\tcannot examine spool directory\n"); return; } i = 0; while ((dp = readdir(dirp)) != NULL) { if (*dp->d_name == 'c' && dp->d_name[1] == 'f') i++; } closedir(dirp); if (i == 0) printf("\tno entries in spool area\n"); else if (i == 1) printf("\t1 entry in spool area\n"); else printf("\t%d entries in spool area\n", i); fd = open(file, O_RDONLY); if (fd < 0 || flock(fd, LOCK_SH|LOCK_NB) == 0) { close(fd); /* unlocks as well */ printf("\tprinter idle\n"); return; } close(fd); /* print out the contents of the status file, if it exists */ status_file_name(pp, file, sizeof file); fd = open(file, O_RDONLY|O_SHLOCK); if (fd >= 0) { fstat(fd, &stbuf); if (stbuf.st_size > 0) { putchar('\t'); while ((i = read(fd, line, sizeof(line))) > 0) fwrite(line, 1, i, stdout); } close(fd); /* unlocks as well */ } }
/* * Print the status of the printer queue. */
Print the status of the printer queue.
[ "Print", "the", "status", "of", "the", "printer", "queue", "." ]
void status(struct printer *pp) { struct stat stbuf; int fd, i; struct dirent *dp; DIR *dirp; char file[MAXPATHLEN]; printf("%s:\n", pp->printer); lock_file_name(pp, file, sizeof file); if (stat(file, &stbuf) >= 0) { printf("\tqueuing is %s\n", ((stbuf.st_mode & LFM_QUEUE_DIS) ? "disabled" : "enabled")); printf("\tprinting is %s\n", ((stbuf.st_mode & LFM_PRINT_DIS) ? "disabled" : "enabled")); } else { printf("\tqueuing is enabled\n"); printf("\tprinting is enabled\n"); } if ((dirp = opendir(pp->spool_dir)) == NULL) { printf("\tcannot examine spool directory\n"); return; } i = 0; while ((dp = readdir(dirp)) != NULL) { if (*dp->d_name == 'c' && dp->d_name[1] == 'f') i++; } closedir(dirp); if (i == 0) printf("\tno entries in spool area\n"); else if (i == 1) printf("\t1 entry in spool area\n"); else printf("\t%d entries in spool area\n", i); fd = open(file, O_RDONLY); if (fd < 0 || flock(fd, LOCK_SH|LOCK_NB) == 0) { close(fd); printf("\tprinter idle\n"); return; } close(fd); status_file_name(pp, file, sizeof file); fd = open(file, O_RDONLY|O_SHLOCK); if (fd >= 0) { fstat(fd, &stbuf); if (stbuf.st_size > 0) { putchar('\t'); while ((i = read(fd, line, sizeof(line))) > 0) fwrite(line, 1, i, stdout); } close(fd); } }
[ "void", "status", "(", "struct", "printer", "*", "pp", ")", "{", "struct", "stat", "stbuf", ";", "int", "fd", ",", "i", ";", "struct", "dirent", "*", "dp", ";", "DIR", "*", "dirp", ";", "char", "file", "[", "MAXPATHLEN", "]", ";", "printf", "(", "\"", "\\n", "\"", ",", "pp", "->", "printer", ")", ";", "lock_file_name", "(", "pp", ",", "file", ",", "sizeof", "file", ")", ";", "if", "(", "stat", "(", "file", ",", "&", "stbuf", ")", ">=", "0", ")", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "(", "(", "stbuf", ".", "st_mode", "&", "LFM_QUEUE_DIS", ")", "?", "\"", "\"", ":", "\"", "\"", ")", ")", ";", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "(", "(", "stbuf", ".", "st_mode", "&", "LFM_PRINT_DIS", ")", "?", "\"", "\"", ":", "\"", "\"", ")", ")", ";", "}", "else", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "}", "if", "(", "(", "dirp", "=", "opendir", "(", "pp", "->", "spool_dir", ")", ")", "==", "NULL", ")", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "return", ";", "}", "i", "=", "0", ";", "while", "(", "(", "dp", "=", "readdir", "(", "dirp", ")", ")", "!=", "NULL", ")", "{", "if", "(", "*", "dp", "->", "d_name", "==", "'", "'", "&&", "dp", "->", "d_name", "[", "1", "]", "==", "'", "'", ")", "i", "++", ";", "}", "closedir", "(", "dirp", ")", ";", "if", "(", "i", "==", "0", ")", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "else", "if", "(", "i", "==", "1", ")", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "else", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "i", ")", ";", "fd", "=", "open", "(", "file", ",", "O_RDONLY", ")", ";", "if", "(", "fd", "<", "0", "||", "flock", "(", "fd", ",", "LOCK_SH", "|", "LOCK_NB", ")", "==", "0", ")", "{", "close", "(", "fd", ")", ";", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "return", ";", "}", "close", "(", "fd", ")", ";", "status_file_name", "(", "pp", ",", "file", ",", "sizeof", "file", ")", ";", "fd", "=", "open", "(", "file", ",", "O_RDONLY", "|", "O_SHLOCK", ")", ";", "if", "(", "fd", ">=", "0", ")", "{", "fstat", "(", "fd", ",", "&", "stbuf", ")", ";", "if", "(", "stbuf", ".", "st_size", ">", "0", ")", "{", "putchar", "(", "'", "\\t", "'", ")", ";", "while", "(", "(", "i", "=", "read", "(", "fd", ",", "line", ",", "sizeof", "(", "line", ")", ")", ")", ">", "0", ")", "fwrite", "(", "line", ",", "1", ",", "i", ",", "stdout", ")", ";", "}", "close", "(", "fd", ")", ";", "}", "}" ]
Print the status of the printer queue.
[ "Print", "the", "status", "of", "the", "printer", "queue", "." ]
[ "/* unlocks as well */", "/* print out the contents of the status file, if it exists */", "/* unlocks as well */" ]
[ { "param": "pp", "type": "struct printer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pp", "type": "struct printer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
stop_q
void
void stop_q(struct printer *pp) { int setres; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); setres = set_qstate(SQS_STOPP, lf); if (setres >= 0) upstat(pp, "printing disabled\n", 0); }
/* * Stop the specified daemon after completing the current job and disable * printing. */
Stop the specified daemon after completing the current job and disable printing.
[ "Stop", "the", "specified", "daemon", "after", "completing", "the", "current", "job", "and", "disable", "printing", "." ]
void stop_q(struct printer *pp) { int setres; char lf[MAXPATHLEN]; lock_file_name(pp, lf, sizeof lf); printf("%s:\n", pp->printer); setres = set_qstate(SQS_STOPP, lf); if (setres >= 0) upstat(pp, "printing disabled\n", 0); }
[ "void", "stop_q", "(", "struct", "printer", "*", "pp", ")", "{", "int", "setres", ";", "char", "lf", "[", "MAXPATHLEN", "]", ";", "lock_file_name", "(", "pp", ",", "lf", ",", "sizeof", "lf", ")", ";", "printf", "(", "\"", "\\n", "\"", ",", "pp", "->", "printer", ")", ";", "setres", "=", "set_qstate", "(", "SQS_STOPP", ",", "lf", ")", ";", "if", "(", "setres", ">=", "0", ")", "upstat", "(", "pp", ",", "\"", "\\n", "\"", ",", "0", ")", ";", "}" ]
Stop the specified daemon after completing the current job and disable printing.
[ "Stop", "the", "specified", "daemon", "after", "completing", "the", "current", "job", "and", "disable", "printing", "." ]
[]
[ { "param": "pp", "type": "struct printer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pp", "type": "struct printer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
topq
void
void topq(int argc, char **argv) { int i; struct stat stbuf; int cmdstatus, changed; struct printer myprinter, *pp = &myprinter; if (argc < 3) { printf("usage: topq printer [jobnum ...] [user ...]\n"); return; } --argc; ++argv; init_printer(pp); cmdstatus = getprintcap(*argv, pp); switch(cmdstatus) { default: fatal(pp, "%s", pcaperr(cmdstatus)); case PCAPERR_NOTFOUND: printf("unknown printer %s\n", *argv); return; case PCAPERR_TCOPEN: printf("warning: %s: unresolved tc= reference(s)", *argv); break; case PCAPERR_SUCCESS: break; } printf("%s:\n", pp->printer); seteuid(euid); if (chdir(pp->spool_dir) < 0) { printf("\tcannot chdir to %s\n", pp->spool_dir); goto out; } seteuid(uid); nitems = getq(pp, &queue); if (nitems == 0) return; changed = 0; mtime = queue[0]->job_time; for (i = argc; --i; ) { if (doarg(argv[i]) == 0) { printf("\tjob %s is not in the queue\n", argv[i]); continue; } else changed++; } for (i = 0; i < nitems; i++) free(queue[i]); free(queue); if (!changed) { printf("\tqueue order unchanged\n"); return; } /* * Turn on the public execute bit of the lock file to * get lpd to rebuild the queue after the current job. */ seteuid(euid); if (changed && stat(pp->lock_file, &stbuf) >= 0) chmod(pp->lock_file, stbuf.st_mode | LFM_RESET_QUE); out: seteuid(uid); }
/* * Put the specified jobs at the top of printer queue. */
Put the specified jobs at the top of printer queue.
[ "Put", "the", "specified", "jobs", "at", "the", "top", "of", "printer", "queue", "." ]
void topq(int argc, char **argv) { int i; struct stat stbuf; int cmdstatus, changed; struct printer myprinter, *pp = &myprinter; if (argc < 3) { printf("usage: topq printer [jobnum ...] [user ...]\n"); return; } --argc; ++argv; init_printer(pp); cmdstatus = getprintcap(*argv, pp); switch(cmdstatus) { default: fatal(pp, "%s", pcaperr(cmdstatus)); case PCAPERR_NOTFOUND: printf("unknown printer %s\n", *argv); return; case PCAPERR_TCOPEN: printf("warning: %s: unresolved tc= reference(s)", *argv); break; case PCAPERR_SUCCESS: break; } printf("%s:\n", pp->printer); seteuid(euid); if (chdir(pp->spool_dir) < 0) { printf("\tcannot chdir to %s\n", pp->spool_dir); goto out; } seteuid(uid); nitems = getq(pp, &queue); if (nitems == 0) return; changed = 0; mtime = queue[0]->job_time; for (i = argc; --i; ) { if (doarg(argv[i]) == 0) { printf("\tjob %s is not in the queue\n", argv[i]); continue; } else changed++; } for (i = 0; i < nitems; i++) free(queue[i]); free(queue); if (!changed) { printf("\tqueue order unchanged\n"); return; } seteuid(euid); if (changed && stat(pp->lock_file, &stbuf) >= 0) chmod(pp->lock_file, stbuf.st_mode | LFM_RESET_QUE); out: seteuid(uid); }
[ "void", "topq", "(", "int", "argc", ",", "char", "*", "*", "argv", ")", "{", "int", "i", ";", "struct", "stat", "stbuf", ";", "int", "cmdstatus", ",", "changed", ";", "struct", "printer", "myprinter", ",", "*", "pp", "=", "&", "myprinter", ";", "if", "(", "argc", "<", "3", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "return", ";", "}", "--", "argc", ";", "++", "argv", ";", "init_printer", "(", "pp", ")", ";", "cmdstatus", "=", "getprintcap", "(", "*", "argv", ",", "pp", ")", ";", "switch", "(", "cmdstatus", ")", "{", "default", ":", "fatal", "(", "pp", ",", "\"", "\"", ",", "pcaperr", "(", "cmdstatus", ")", ")", ";", "case", "PCAPERR_NOTFOUND", ":", "printf", "(", "\"", "\\n", "\"", ",", "*", "argv", ")", ";", "return", ";", "case", "PCAPERR_TCOPEN", ":", "printf", "(", "\"", "\"", ",", "*", "argv", ")", ";", "break", ";", "case", "PCAPERR_SUCCESS", ":", "break", ";", "}", "printf", "(", "\"", "\\n", "\"", ",", "pp", "->", "printer", ")", ";", "seteuid", "(", "euid", ")", ";", "if", "(", "chdir", "(", "pp", "->", "spool_dir", ")", "<", "0", ")", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "pp", "->", "spool_dir", ")", ";", "goto", "out", ";", "}", "seteuid", "(", "uid", ")", ";", "nitems", "=", "getq", "(", "pp", ",", "&", "queue", ")", ";", "if", "(", "nitems", "==", "0", ")", "return", ";", "changed", "=", "0", ";", "mtime", "=", "queue", "[", "0", "]", "->", "job_time", ";", "for", "(", "i", "=", "argc", ";", "--", "i", ";", ")", "{", "if", "(", "doarg", "(", "argv", "[", "i", "]", ")", "==", "0", ")", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "argv", "[", "i", "]", ")", ";", "continue", ";", "}", "else", "changed", "++", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "nitems", ";", "i", "++", ")", "free", "(", "queue", "[", "i", "]", ")", ";", "free", "(", "queue", ")", ";", "if", "(", "!", "changed", ")", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "return", ";", "}", "seteuid", "(", "euid", ")", ";", "if", "(", "changed", "&&", "stat", "(", "pp", "->", "lock_file", ",", "&", "stbuf", ")", ">=", "0", ")", "chmod", "(", "pp", "->", "lock_file", ",", "stbuf", ".", "st_mode", "|", "LFM_RESET_QUE", ")", ";", "out", ":", "seteuid", "(", "uid", ")", ";", "}" ]
Put the specified jobs at the top of printer queue.
[ "Put", "the", "specified", "jobs", "at", "the", "top", "of", "printer", "queue", "." ]
[ "/*\n\t * Turn on the public execute bit of the lock file to\n\t * get lpd to rebuild the queue after the current job.\n\t */" ]
[ { "param": "argc", "type": "int" }, { "param": "argv", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argc", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "argv", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
touch
int
static int touch(struct jobqueue *jq) { struct timeval tvp[2]; int ret; tvp[0].tv_sec = tvp[1].tv_sec = --mtime; tvp[0].tv_usec = tvp[1].tv_usec = 0; seteuid(euid); ret = utimes(jq->job_cfname, tvp); seteuid(uid); return (ret); }
/* * Reposition the job by changing the modification time of * the control file. */
Reposition the job by changing the modification time of the control file.
[ "Reposition", "the", "job", "by", "changing", "the", "modification", "time", "of", "the", "control", "file", "." ]
static int touch(struct jobqueue *jq) { struct timeval tvp[2]; int ret; tvp[0].tv_sec = tvp[1].tv_sec = --mtime; tvp[0].tv_usec = tvp[1].tv_usec = 0; seteuid(euid); ret = utimes(jq->job_cfname, tvp); seteuid(uid); return (ret); }
[ "static", "int", "touch", "(", "struct", "jobqueue", "*", "jq", ")", "{", "struct", "timeval", "tvp", "[", "2", "]", ";", "int", "ret", ";", "tvp", "[", "0", "]", ".", "tv_sec", "=", "tvp", "[", "1", "]", ".", "tv_sec", "=", "--", "mtime", ";", "tvp", "[", "0", "]", ".", "tv_usec", "=", "tvp", "[", "1", "]", ".", "tv_usec", "=", "0", ";", "seteuid", "(", "euid", ")", ";", "ret", "=", "utimes", "(", "jq", "->", "job_cfname", ",", "tvp", ")", ";", "seteuid", "(", "uid", ")", ";", "return", "(", "ret", ")", ";", "}" ]
Reposition the job by changing the modification time of the control file.
[ "Reposition", "the", "job", "by", "changing", "the", "modification", "time", "of", "the", "control", "file", "." ]
[]
[ { "param": "jq", "type": "struct jobqueue" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "jq", "type": "struct jobqueue", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1efe91536a13c33094bb7339955dfd9b821d50a8
atrens/DragonFlyBSD-src
usr.sbin/lpr/lpc/cmds.c
[ "BSD-3-Clause" ]
C
doarg
int
static int doarg(char *job) { struct jobqueue **qq; int jobnum, n; char *cp, *machine; int cnt = 0; FILE *fp; /* * Look for a job item consisting of system name, colon, number * (example: ucbarpa:114) */ if ((cp = strchr(job, ':')) != NULL) { machine = job; *cp++ = '\0'; job = cp; } else machine = NULL; /* * Check for job specified by number (example: 112 or 235ucbarpa). */ if (isdigit(*job)) { jobnum = 0; do jobnum = jobnum * 10 + (*job++ - '0'); while (isdigit(*job)); for (qq = queue + nitems; --qq >= queue; ) { n = 0; for (cp = (*qq)->job_cfname+3; isdigit(*cp); ) n = n * 10 + (*cp++ - '0'); if (jobnum != n) continue; if (*job && strcmp(job, cp) != 0) continue; if (machine != NULL && strcmp(machine, cp) != 0) continue; if (touch(*qq) == 0) { printf("\tmoved %s\n", (*qq)->job_cfname); cnt++; } } return(cnt); } /* * Process item consisting of owner's name (example: henry). */ for (qq = queue + nitems; --qq >= queue; ) { seteuid(euid); fp = fopen((*qq)->job_cfname, "r"); seteuid(uid); if (fp == NULL) continue; while (get_line(fp) > 0) if (line[0] == 'P') break; fclose(fp); if (line[0] != 'P' || strcmp(job, line+1) != 0) continue; if (touch(*qq) == 0) { printf("\tmoved %s\n", (*qq)->job_cfname); cnt++; } } return(cnt); }
/* * Checks if specified job name is in the printer's queue. * Returns: negative (-1) if argument name is not in the queue. */
Checks if specified job name is in the printer's queue. Returns: negative (-1) if argument name is not in the queue.
[ "Checks", "if", "specified", "job", "name", "is", "in", "the", "printer", "'", "s", "queue", ".", "Returns", ":", "negative", "(", "-", "1", ")", "if", "argument", "name", "is", "not", "in", "the", "queue", "." ]
static int doarg(char *job) { struct jobqueue **qq; int jobnum, n; char *cp, *machine; int cnt = 0; FILE *fp; if ((cp = strchr(job, ':')) != NULL) { machine = job; *cp++ = '\0'; job = cp; } else machine = NULL; if (isdigit(*job)) { jobnum = 0; do jobnum = jobnum * 10 + (*job++ - '0'); while (isdigit(*job)); for (qq = queue + nitems; --qq >= queue; ) { n = 0; for (cp = (*qq)->job_cfname+3; isdigit(*cp); ) n = n * 10 + (*cp++ - '0'); if (jobnum != n) continue; if (*job && strcmp(job, cp) != 0) continue; if (machine != NULL && strcmp(machine, cp) != 0) continue; if (touch(*qq) == 0) { printf("\tmoved %s\n", (*qq)->job_cfname); cnt++; } } return(cnt); } for (qq = queue + nitems; --qq >= queue; ) { seteuid(euid); fp = fopen((*qq)->job_cfname, "r"); seteuid(uid); if (fp == NULL) continue; while (get_line(fp) > 0) if (line[0] == 'P') break; fclose(fp); if (line[0] != 'P' || strcmp(job, line+1) != 0) continue; if (touch(*qq) == 0) { printf("\tmoved %s\n", (*qq)->job_cfname); cnt++; } } return(cnt); }
[ "static", "int", "doarg", "(", "char", "*", "job", ")", "{", "struct", "jobqueue", "*", "*", "qq", ";", "int", "jobnum", ",", "n", ";", "char", "*", "cp", ",", "*", "machine", ";", "int", "cnt", "=", "0", ";", "FILE", "*", "fp", ";", "if", "(", "(", "cp", "=", "strchr", "(", "job", ",", "'", "'", ")", ")", "!=", "NULL", ")", "{", "machine", "=", "job", ";", "*", "cp", "++", "=", "'", "\\0", "'", ";", "job", "=", "cp", ";", "}", "else", "machine", "=", "NULL", ";", "if", "(", "isdigit", "(", "*", "job", ")", ")", "{", "jobnum", "=", "0", ";", "do", "jobnum", "=", "jobnum", "*", "10", "+", "(", "*", "job", "++", "-", "'", "'", ")", ";", "while", "(", "isdigit", "(", "*", "job", ")", ")", ";", "for", "(", "qq", "=", "queue", "+", "nitems", ";", "--", "qq", ">=", "queue", ";", ")", "{", "n", "=", "0", ";", "for", "(", "cp", "=", "(", "*", "qq", ")", "->", "job_cfname", "+", "3", ";", "isdigit", "(", "*", "cp", ")", ";", ")", "n", "=", "n", "*", "10", "+", "(", "*", "cp", "++", "-", "'", "'", ")", ";", "if", "(", "jobnum", "!=", "n", ")", "continue", ";", "if", "(", "*", "job", "&&", "strcmp", "(", "job", ",", "cp", ")", "!=", "0", ")", "continue", ";", "if", "(", "machine", "!=", "NULL", "&&", "strcmp", "(", "machine", ",", "cp", ")", "!=", "0", ")", "continue", ";", "if", "(", "touch", "(", "*", "qq", ")", "==", "0", ")", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "(", "*", "qq", ")", "->", "job_cfname", ")", ";", "cnt", "++", ";", "}", "}", "return", "(", "cnt", ")", ";", "}", "for", "(", "qq", "=", "queue", "+", "nitems", ";", "--", "qq", ">=", "queue", ";", ")", "{", "seteuid", "(", "euid", ")", ";", "fp", "=", "fopen", "(", "(", "*", "qq", ")", "->", "job_cfname", ",", "\"", "\"", ")", ";", "seteuid", "(", "uid", ")", ";", "if", "(", "fp", "==", "NULL", ")", "continue", ";", "while", "(", "get_line", "(", "fp", ")", ">", "0", ")", "if", "(", "line", "[", "0", "]", "==", "'", "'", ")", "break", ";", "fclose", "(", "fp", ")", ";", "if", "(", "line", "[", "0", "]", "!=", "'", "'", "||", "strcmp", "(", "job", ",", "line", "+", "1", ")", "!=", "0", ")", "continue", ";", "if", "(", "touch", "(", "*", "qq", ")", "==", "0", ")", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ",", "(", "*", "qq", ")", "->", "job_cfname", ")", ";", "cnt", "++", ";", "}", "}", "return", "(", "cnt", ")", ";", "}" ]
Checks if specified job name is in the printer's queue.
[ "Checks", "if", "specified", "job", "name", "is", "in", "the", "printer", "'", "s", "queue", "." ]
[ "/*\n\t * Look for a job item consisting of system name, colon, number \n\t * (example: ucbarpa:114) \n\t */", "/*\n\t * Check for job specified by number (example: 112 or 235ucbarpa).\n\t */", "/*\n\t * Process item consisting of owner's name (example: henry).\n\t */" ]
[ { "param": "job", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "job", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ac1b683724c48eeb2f54bef50c1fe9c42f3cc8f
atrens/DragonFlyBSD-src
usr.sbin/nscd/mp_rs_query.c
[ "BSD-3-Clause" ]
C
on_mp_read_session_destroy
void
static void on_mp_read_session_destroy(struct query_state *qstate) { TRACE_IN(on_mp_read_session_destroy); finalize_comm_element(&qstate->request); finalize_comm_element(&qstate->response); if (qstate->mdata != NULL) { configuration_lock_entry(qstate->config_entry, CELT_MULTIPART); close_cache_mp_read_session( (cache_mp_read_session)qstate->mdata); configuration_unlock_entry(qstate->config_entry, CELT_MULTIPART); } TRACE_OUT(on_mp_read_session_destroy); }
/* * This function is used as the query_state's destroy_func to make the * proper cleanup in case of errors. */
This function is used as the query_state's destroy_func to make the proper cleanup in case of errors.
[ "This", "function", "is", "used", "as", "the", "query_state", "'", "s", "destroy_func", "to", "make", "the", "proper", "cleanup", "in", "case", "of", "errors", "." ]
static void on_mp_read_session_destroy(struct query_state *qstate) { TRACE_IN(on_mp_read_session_destroy); finalize_comm_element(&qstate->request); finalize_comm_element(&qstate->response); if (qstate->mdata != NULL) { configuration_lock_entry(qstate->config_entry, CELT_MULTIPART); close_cache_mp_read_session( (cache_mp_read_session)qstate->mdata); configuration_unlock_entry(qstate->config_entry, CELT_MULTIPART); } TRACE_OUT(on_mp_read_session_destroy); }
[ "static", "void", "on_mp_read_session_destroy", "(", "struct", "query_state", "*", "qstate", ")", "{", "TRACE_IN", "(", "on_mp_read_session_destroy", ")", ";", "finalize_comm_element", "(", "&", "qstate", "->", "request", ")", ";", "finalize_comm_element", "(", "&", "qstate", "->", "response", ")", ";", "if", "(", "qstate", "->", "mdata", "!=", "NULL", ")", "{", "configuration_lock_entry", "(", "qstate", "->", "config_entry", ",", "CELT_MULTIPART", ")", ";", "close_cache_mp_read_session", "(", "(", "cache_mp_read_session", ")", "qstate", "->", "mdata", ")", ";", "configuration_unlock_entry", "(", "qstate", "->", "config_entry", ",", "CELT_MULTIPART", ")", ";", "}", "TRACE_OUT", "(", "on_mp_read_session_destroy", ")", ";", "}" ]
This function is used as the query_state's destroy_func to make the proper cleanup in case of errors.
[ "This", "function", "is", "used", "as", "the", "query_state", "'", "s", "destroy_func", "to", "make", "the", "proper", "cleanup", "in", "case", "of", "errors", "." ]
[]
[ { "param": "qstate", "type": "struct query_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "qstate", "type": "struct query_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ac1b683724c48eeb2f54bef50c1fe9c42f3cc8f
atrens/DragonFlyBSD-src
usr.sbin/nscd/mp_rs_query.c
[ "BSD-3-Clause" ]
C
on_mp_read_session_mapper
int
static int on_mp_read_session_mapper(struct query_state *qstate) { ssize_t result; int elem_type; TRACE_IN(on_mp_read_session_mapper); if (qstate->kevent_watermark == 0) { qstate->kevent_watermark = sizeof(int); } else { result = qstate->read_func(qstate, &elem_type, sizeof(int)); if (result != sizeof(int)) { LOG_ERR_3("on_mp_read_session_mapper", "read failed"); TRACE_OUT(on_mp_read_session_mapper); return (-1); } switch (elem_type) { case CET_MP_READ_SESSION_READ_REQUEST: qstate->kevent_watermark = 0; qstate->process_func = on_mp_read_session_read_request_process; break; case CET_MP_READ_SESSION_CLOSE_NOTIFICATION: qstate->kevent_watermark = 0; qstate->process_func = on_mp_read_session_close_notification; break; default: qstate->kevent_watermark = 0; qstate->process_func = NULL; LOG_ERR_3("on_mp_read_session_mapper", "unknown element type"); TRACE_OUT(on_mp_read_session_mapper); return (-1); } } TRACE_OUT(on_mp_read_session_mapper); return (0); }
/* * Mapper function is used to avoid multiple connections for each session * write or read requests. After processing the request, it does not close * the connection, but waits for the next request. */
Mapper function is used to avoid multiple connections for each session write or read requests. After processing the request, it does not close the connection, but waits for the next request.
[ "Mapper", "function", "is", "used", "to", "avoid", "multiple", "connections", "for", "each", "session", "write", "or", "read", "requests", ".", "After", "processing", "the", "request", "it", "does", "not", "close", "the", "connection", "but", "waits", "for", "the", "next", "request", "." ]
static int on_mp_read_session_mapper(struct query_state *qstate) { ssize_t result; int elem_type; TRACE_IN(on_mp_read_session_mapper); if (qstate->kevent_watermark == 0) { qstate->kevent_watermark = sizeof(int); } else { result = qstate->read_func(qstate, &elem_type, sizeof(int)); if (result != sizeof(int)) { LOG_ERR_3("on_mp_read_session_mapper", "read failed"); TRACE_OUT(on_mp_read_session_mapper); return (-1); } switch (elem_type) { case CET_MP_READ_SESSION_READ_REQUEST: qstate->kevent_watermark = 0; qstate->process_func = on_mp_read_session_read_request_process; break; case CET_MP_READ_SESSION_CLOSE_NOTIFICATION: qstate->kevent_watermark = 0; qstate->process_func = on_mp_read_session_close_notification; break; default: qstate->kevent_watermark = 0; qstate->process_func = NULL; LOG_ERR_3("on_mp_read_session_mapper", "unknown element type"); TRACE_OUT(on_mp_read_session_mapper); return (-1); } } TRACE_OUT(on_mp_read_session_mapper); return (0); }
[ "static", "int", "on_mp_read_session_mapper", "(", "struct", "query_state", "*", "qstate", ")", "{", "ssize_t", "result", ";", "int", "elem_type", ";", "TRACE_IN", "(", "on_mp_read_session_mapper", ")", ";", "if", "(", "qstate", "->", "kevent_watermark", "==", "0", ")", "{", "qstate", "->", "kevent_watermark", "=", "sizeof", "(", "int", ")", ";", "}", "else", "{", "result", "=", "qstate", "->", "read_func", "(", "qstate", ",", "&", "elem_type", ",", "sizeof", "(", "int", ")", ")", ";", "if", "(", "result", "!=", "sizeof", "(", "int", ")", ")", "{", "LOG_ERR_3", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "TRACE_OUT", "(", "on_mp_read_session_mapper", ")", ";", "return", "(", "-1", ")", ";", "}", "switch", "(", "elem_type", ")", "{", "case", "CET_MP_READ_SESSION_READ_REQUEST", ":", "qstate", "->", "kevent_watermark", "=", "0", ";", "qstate", "->", "process_func", "=", "on_mp_read_session_read_request_process", ";", "break", ";", "case", "CET_MP_READ_SESSION_CLOSE_NOTIFICATION", ":", "qstate", "->", "kevent_watermark", "=", "0", ";", "qstate", "->", "process_func", "=", "on_mp_read_session_close_notification", ";", "break", ";", "default", ":", "qstate", "->", "kevent_watermark", "=", "0", ";", "qstate", "->", "process_func", "=", "NULL", ";", "LOG_ERR_3", "(", "\"", "\"", ",", "\"", "\"", ")", ";", "TRACE_OUT", "(", "on_mp_read_session_mapper", ")", ";", "return", "(", "-1", ")", ";", "}", "}", "TRACE_OUT", "(", "on_mp_read_session_mapper", ")", ";", "return", "(", "0", ")", ";", "}" ]
Mapper function is used to avoid multiple connections for each session write or read requests.
[ "Mapper", "function", "is", "used", "to", "avoid", "multiple", "connections", "for", "each", "session", "write", "or", "read", "requests", "." ]
[]
[ { "param": "qstate", "type": "struct query_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "qstate", "type": "struct query_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ac1b683724c48eeb2f54bef50c1fe9c42f3cc8f
atrens/DragonFlyBSD-src
usr.sbin/nscd/mp_rs_query.c
[ "BSD-3-Clause" ]
C
on_mp_read_session_read_request_process
int
static int on_mp_read_session_read_request_process(struct query_state *qstate) { struct cache_mp_read_session_read_response *read_response; TRACE_IN(on_mp_read_session_response_process); init_comm_element(&qstate->response, CET_MP_READ_SESSION_READ_RESPONSE); read_response = get_cache_mp_read_session_read_response( &qstate->response); configuration_lock_entry(qstate->config_entry, CELT_MULTIPART); read_response->error_code = cache_mp_read( (cache_mp_read_session)qstate->mdata, NULL, &read_response->data_size); if (read_response->error_code == 0) { read_response->data = (char *)malloc(read_response->data_size); assert(read_response != NULL); read_response->error_code = cache_mp_read( (cache_mp_read_session)qstate->mdata, read_response->data, &read_response->data_size); } configuration_unlock_entry(qstate->config_entry, CELT_MULTIPART); if (read_response->error_code == 0) qstate->kevent_watermark = sizeof(size_t) + sizeof(int); else qstate->kevent_watermark = sizeof(int); qstate->process_func = on_mp_read_session_read_response_write1; qstate->kevent_filter = EVFILT_WRITE; TRACE_OUT(on_mp_read_session_response_process); return (0); }
/* * The functions below are used to process multipart read sessions read * requests. User doesn't have to pass any kind of data, besides the * request identificator itself. So we don't need any XXX_read functions and * start with the XXX_process function. * - on_mp_read_session_read_request_process processes it * - on_mp_read_session_read_response_write1 and * on_mp_read_session_read_response_write2 sends the response */
The functions below are used to process multipart read sessions read requests. User doesn't have to pass any kind of data, besides the request identificator itself. So we don't need any XXX_read functions and start with the XXX_process function. - on_mp_read_session_read_request_process processes it - on_mp_read_session_read_response_write1 and on_mp_read_session_read_response_write2 sends the response
[ "The", "functions", "below", "are", "used", "to", "process", "multipart", "read", "sessions", "read", "requests", ".", "User", "doesn", "'", "t", "have", "to", "pass", "any", "kind", "of", "data", "besides", "the", "request", "identificator", "itself", ".", "So", "we", "don", "'", "t", "need", "any", "XXX_read", "functions", "and", "start", "with", "the", "XXX_process", "function", ".", "-", "on_mp_read_session_read_request_process", "processes", "it", "-", "on_mp_read_session_read_response_write1", "and", "on_mp_read_session_read_response_write2", "sends", "the", "response" ]
static int on_mp_read_session_read_request_process(struct query_state *qstate) { struct cache_mp_read_session_read_response *read_response; TRACE_IN(on_mp_read_session_response_process); init_comm_element(&qstate->response, CET_MP_READ_SESSION_READ_RESPONSE); read_response = get_cache_mp_read_session_read_response( &qstate->response); configuration_lock_entry(qstate->config_entry, CELT_MULTIPART); read_response->error_code = cache_mp_read( (cache_mp_read_session)qstate->mdata, NULL, &read_response->data_size); if (read_response->error_code == 0) { read_response->data = (char *)malloc(read_response->data_size); assert(read_response != NULL); read_response->error_code = cache_mp_read( (cache_mp_read_session)qstate->mdata, read_response->data, &read_response->data_size); } configuration_unlock_entry(qstate->config_entry, CELT_MULTIPART); if (read_response->error_code == 0) qstate->kevent_watermark = sizeof(size_t) + sizeof(int); else qstate->kevent_watermark = sizeof(int); qstate->process_func = on_mp_read_session_read_response_write1; qstate->kevent_filter = EVFILT_WRITE; TRACE_OUT(on_mp_read_session_response_process); return (0); }
[ "static", "int", "on_mp_read_session_read_request_process", "(", "struct", "query_state", "*", "qstate", ")", "{", "struct", "cache_mp_read_session_read_response", "*", "read_response", ";", "TRACE_IN", "(", "on_mp_read_session_response_process", ")", ";", "init_comm_element", "(", "&", "qstate", "->", "response", ",", "CET_MP_READ_SESSION_READ_RESPONSE", ")", ";", "read_response", "=", "get_cache_mp_read_session_read_response", "(", "&", "qstate", "->", "response", ")", ";", "configuration_lock_entry", "(", "qstate", "->", "config_entry", ",", "CELT_MULTIPART", ")", ";", "read_response", "->", "error_code", "=", "cache_mp_read", "(", "(", "cache_mp_read_session", ")", "qstate", "->", "mdata", ",", "NULL", ",", "&", "read_response", "->", "data_size", ")", ";", "if", "(", "read_response", "->", "error_code", "==", "0", ")", "{", "read_response", "->", "data", "=", "(", "char", "*", ")", "malloc", "(", "read_response", "->", "data_size", ")", ";", "assert", "(", "read_response", "!=", "NULL", ")", ";", "read_response", "->", "error_code", "=", "cache_mp_read", "(", "(", "cache_mp_read_session", ")", "qstate", "->", "mdata", ",", "read_response", "->", "data", ",", "&", "read_response", "->", "data_size", ")", ";", "}", "configuration_unlock_entry", "(", "qstate", "->", "config_entry", ",", "CELT_MULTIPART", ")", ";", "if", "(", "read_response", "->", "error_code", "==", "0", ")", "qstate", "->", "kevent_watermark", "=", "sizeof", "(", "size_t", ")", "+", "sizeof", "(", "int", ")", ";", "else", "qstate", "->", "kevent_watermark", "=", "sizeof", "(", "int", ")", ";", "qstate", "->", "process_func", "=", "on_mp_read_session_read_response_write1", ";", "qstate", "->", "kevent_filter", "=", "EVFILT_WRITE", ";", "TRACE_OUT", "(", "on_mp_read_session_response_process", ")", ";", "return", "(", "0", ")", ";", "}" ]
The functions below are used to process multipart read sessions read requests.
[ "The", "functions", "below", "are", "used", "to", "process", "multipart", "read", "sessions", "read", "requests", "." ]
[]
[ { "param": "qstate", "type": "struct query_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "qstate", "type": "struct query_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0ac1b683724c48eeb2f54bef50c1fe9c42f3cc8f
atrens/DragonFlyBSD-src
usr.sbin/nscd/mp_rs_query.c
[ "BSD-3-Clause" ]
C
on_mp_read_session_close_notification
int
static int on_mp_read_session_close_notification(struct query_state *qstate) { TRACE_IN(on_mp_read_session_close_notification); configuration_lock_entry(qstate->config_entry, CELT_MULTIPART); close_cache_mp_read_session((cache_mp_read_session)qstate->mdata); configuration_unlock_entry(qstate->config_entry, CELT_MULTIPART); qstate->mdata = NULL; qstate->kevent_watermark = 0; qstate->process_func = NULL; TRACE_OUT(on_mp_read_session_close_notification); return (0); }
/* * Handles session close notification by calling close_cache_mp_read_session * function. */
Handles session close notification by calling close_cache_mp_read_session function.
[ "Handles", "session", "close", "notification", "by", "calling", "close_cache_mp_read_session", "function", "." ]
static int on_mp_read_session_close_notification(struct query_state *qstate) { TRACE_IN(on_mp_read_session_close_notification); configuration_lock_entry(qstate->config_entry, CELT_MULTIPART); close_cache_mp_read_session((cache_mp_read_session)qstate->mdata); configuration_unlock_entry(qstate->config_entry, CELT_MULTIPART); qstate->mdata = NULL; qstate->kevent_watermark = 0; qstate->process_func = NULL; TRACE_OUT(on_mp_read_session_close_notification); return (0); }
[ "static", "int", "on_mp_read_session_close_notification", "(", "struct", "query_state", "*", "qstate", ")", "{", "TRACE_IN", "(", "on_mp_read_session_close_notification", ")", ";", "configuration_lock_entry", "(", "qstate", "->", "config_entry", ",", "CELT_MULTIPART", ")", ";", "close_cache_mp_read_session", "(", "(", "cache_mp_read_session", ")", "qstate", "->", "mdata", ")", ";", "configuration_unlock_entry", "(", "qstate", "->", "config_entry", ",", "CELT_MULTIPART", ")", ";", "qstate", "->", "mdata", "=", "NULL", ";", "qstate", "->", "kevent_watermark", "=", "0", ";", "qstate", "->", "process_func", "=", "NULL", ";", "TRACE_OUT", "(", "on_mp_read_session_close_notification", ")", ";", "return", "(", "0", ")", ";", "}" ]
Handles session close notification by calling close_cache_mp_read_session function.
[ "Handles", "session", "close", "notification", "by", "calling", "close_cache_mp_read_session", "function", "." ]
[]
[ { "param": "qstate", "type": "struct query_state" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "qstate", "type": "struct query_state", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1eaadb65229966e1644ab3355ae4771253db1e7c
atrens/DragonFlyBSD-src
gnu/usr.bin/gdb/gdb/ada-lex.c
[ "BSD-3-Clause" ]
C
yy_get_previous_state
yy_state_type
static yy_state_type yy_get_previous_state (void) { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 207 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; }
/* yy_get_previous_state - get the state just before the EOB char was reached */
get the state just before the EOB char was reached
[ "get", "the", "state", "just", "before", "the", "EOB", "char", "was", "reached" ]
static yy_state_type yy_get_previous_state (void) { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 207 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; }
[ "static", "yy_state_type", "yy_get_previous_state", "(", "void", ")", "{", "register", "yy_state_type", "yy_current_state", ";", "register", "char", "*", "yy_cp", ";", "yy_current_state", "=", "(", "yy_start", ")", ";", "for", "(", "yy_cp", "=", "(", "yytext_ptr", ")", "+", "YY_MORE_ADJ", ";", "yy_cp", "<", "(", "yy_c_buf_p", ")", ";", "++", "yy_cp", ")", "{", "register", "YY_CHAR", "yy_c", "=", "(", "*", "yy_cp", "?", "yy_ec", "[", "YY_SC_TO_UI", "(", "*", "yy_cp", ")", "]", ":", "1", ")", ";", "if", "(", "yy_accept", "[", "yy_current_state", "]", ")", "{", "(", "yy_last_accepting_state", ")", "=", "yy_current_state", ";", "(", "yy_last_accepting_cpos", ")", "=", "yy_cp", ";", "}", "while", "(", "yy_chk", "[", "yy_base", "[", "yy_current_state", "]", "+", "yy_c", "]", "!=", "yy_current_state", ")", "{", "yy_current_state", "=", "(", "int", ")", "yy_def", "[", "yy_current_state", "]", ";", "if", "(", "yy_current_state", ">=", "207", ")", "yy_c", "=", "yy_meta", "[", "(", "unsigned", "int", ")", "yy_c", "]", ";", "}", "yy_current_state", "=", "yy_nxt", "[", "yy_base", "[", "yy_current_state", "]", "+", "(", "unsigned", "int", ")", "yy_c", "]", ";", "}", "return", "yy_current_state", ";", "}" ]
yy_get_previous_state - get the state just before the EOB char was reached
[ "yy_get_previous_state", "-", "get", "the", "state", "just", "before", "the", "EOB", "char", "was", "reached" ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
1eaadb65229966e1644ab3355ae4771253db1e7c
atrens/DragonFlyBSD-src
gnu/usr.bin/gdb/gdb/ada-lex.c
[ "BSD-3-Clause" ]
C
yyensure_buffer_stack
void
static void yyensure_buffer_stack (void) { int num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate xrealloc on the next call. */ num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyxrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } }
/* Allocates the stack if it does not exist. * Guarantees space for at least one push. */
Allocates the stack if it does not exist. Guarantees space for at least one push.
[ "Allocates", "the", "stack", "if", "it", "does", "not", "exist", ".", "Guarantees", "space", "for", "at", "least", "one", "push", "." ]
static void yyensure_buffer_stack (void) { int num_to_alloc; if (!(yy_buffer_stack)) { num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ int grow_size = 8 ; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyxrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } }
[ "static", "void", "yyensure_buffer_stack", "(", "void", ")", "{", "int", "num_to_alloc", ";", "if", "(", "!", "(", "yy_buffer_stack", ")", ")", "{", "num_to_alloc", "=", "1", ";", "(", "yy_buffer_stack", ")", "=", "(", "struct", "yy_buffer_state", "*", "*", ")", "yyalloc", "(", "num_to_alloc", "*", "sizeof", "(", "struct", "yy_buffer_state", "*", ")", ")", ";", "if", "(", "!", "(", "yy_buffer_stack", ")", ")", "YY_FATAL_ERROR", "(", "\"", "\"", ")", ";", "memset", "(", "(", "yy_buffer_stack", ")", ",", "0", ",", "num_to_alloc", "*", "sizeof", "(", "struct", "yy_buffer_state", "*", ")", ")", ";", "(", "yy_buffer_stack_max", ")", "=", "num_to_alloc", ";", "(", "yy_buffer_stack_top", ")", "=", "0", ";", "return", ";", "}", "if", "(", "(", "yy_buffer_stack_top", ")", ">=", "(", "(", "yy_buffer_stack_max", ")", ")", "-", "1", ")", "{", "int", "grow_size", "=", "8", ";", "num_to_alloc", "=", "(", "yy_buffer_stack_max", ")", "+", "grow_size", ";", "(", "yy_buffer_stack", ")", "=", "(", "struct", "yy_buffer_state", "*", "*", ")", "yyxrealloc", "(", "(", "yy_buffer_stack", ")", ",", "num_to_alloc", "*", "sizeof", "(", "struct", "yy_buffer_state", "*", ")", ")", ";", "if", "(", "!", "(", "yy_buffer_stack", ")", ")", "YY_FATAL_ERROR", "(", "\"", "\"", ")", ";", "memset", "(", "(", "yy_buffer_stack", ")", "+", "(", "yy_buffer_stack_max", ")", ",", "0", ",", "grow_size", "*", "sizeof", "(", "struct", "yy_buffer_state", "*", ")", ")", ";", "(", "yy_buffer_stack_max", ")", "=", "num_to_alloc", ";", "}", "}" ]
Allocates the stack if it does not exist.
[ "Allocates", "the", "stack", "if", "it", "does", "not", "exist", "." ]
[ "/* First allocation is just for 2 elements, since we don't know if this\n\t\t * scanner will even need a stack. We use 2 instead of 1 to avoid an\n\t\t * immediate xrealloc on the next call.\n */", "/* Increase the buffer to prepare for a possible push. */", "/* arbitrary grow size */", "/* zero only the new slots.*/" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
1eaadb65229966e1644ab3355ae4771253db1e7c
atrens/DragonFlyBSD-src
gnu/usr.bin/gdb/gdb/ada-lex.c
[ "BSD-3-Clause" ]
C
lexer_init
void
static void lexer_init (FILE *inp) { BEGIN INITIAL; yyrestart (inp); }
/* Initialize the lexer for processing new expression. */
Initialize the lexer for processing new expression.
[ "Initialize", "the", "lexer", "for", "processing", "new", "expression", "." ]
static void lexer_init (FILE *inp) { BEGIN INITIAL; yyrestart (inp); }
[ "static", "void", "lexer_init", "(", "FILE", "*", "inp", ")", "{", "BEGIN", "INITIAL", ";", "yyrestart", "(", "inp", ")", ";", "}" ]
Initialize the lexer for processing new expression.
[ "Initialize", "the", "lexer", "for", "processing", "new", "expression", "." ]
[]
[ { "param": "inp", "type": "FILE" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "inp", "type": "FILE", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1eaadb65229966e1644ab3355ae4771253db1e7c
atrens/DragonFlyBSD-src
gnu/usr.bin/gdb/gdb/ada-lex.c
[ "BSD-3-Clause" ]
C
canonicalizeNumeral
void
static void canonicalizeNumeral (char *s1, const char *s2) { for (; *s2 != '\000'; s2 += 1) { if (*s2 != '_') { *s1 = tolower(*s2); s1 += 1; } } s1[0] = '\000'; }
/* Copy S2 to S1, removing all underscores, and downcasing all letters. */
Copy S2 to S1, removing all underscores, and downcasing all letters.
[ "Copy", "S2", "to", "S1", "removing", "all", "underscores", "and", "downcasing", "all", "letters", "." ]
static void canonicalizeNumeral (char *s1, const char *s2) { for (; *s2 != '\000'; s2 += 1) { if (*s2 != '_') { *s1 = tolower(*s2); s1 += 1; } } s1[0] = '\000'; }
[ "static", "void", "canonicalizeNumeral", "(", "char", "*", "s1", ",", "const", "char", "*", "s2", ")", "{", "for", "(", ";", "*", "s2", "!=", "'", "\\000", "'", ";", "s2", "+=", "1", ")", "{", "if", "(", "*", "s2", "!=", "'", "'", ")", "{", "*", "s1", "=", "tolower", "(", "*", "s2", ")", ";", "s1", "+=", "1", ";", "}", "}", "s1", "[", "0", "]", "=", "'", "\\000", "'", ";", "}" ]
Copy S2 to S1, removing all underscores, and downcasing all letters.
[ "Copy", "S2", "to", "S1", "removing", "all", "underscores", "and", "downcasing", "all", "letters", "." ]
[]
[ { "param": "s1", "type": "char" }, { "param": "s2", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s1", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "s2", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1eaadb65229966e1644ab3355ae4771253db1e7c
atrens/DragonFlyBSD-src
gnu/usr.bin/gdb/gdb/ada-lex.c
[ "BSD-3-Clause" ]
C
processInt
int
static int processInt (const char *base0, const char *num0, const char *exp0) { ULONGEST result; long exp; int base; char *trailer; if (base0 == NULL) base = 10; else { base = strtol (base0, (char **) NULL, 10); if (base < 2 || base > 16) error (_("Invalid base: %d."), base); } if (exp0 == NULL) exp = 0; else exp = strtol(exp0, (char **) NULL, 10); errno = 0; result = strtoulst (num0, (const char **) &trailer, base); if (errno == ERANGE) error (_("Integer literal out of range")); if (isxdigit(*trailer)) error (_("Invalid digit `%c' in based literal"), *trailer); while (exp > 0) { if (result > (ULONG_MAX / base)) error (_("Integer literal out of range")); result *= base; exp -= 1; } if ((result >> (gdbarch_int_bit (parse_gdbarch)-1)) == 0) yylval.typed_val.type = type_int (); else if ((result >> (gdbarch_long_bit (parse_gdbarch)-1)) == 0) yylval.typed_val.type = type_long (); else if (((result >> (gdbarch_long_bit (parse_gdbarch)-1)) >> 1) == 0) { /* We have a number representable as an unsigned integer quantity. For consistency with the C treatment, we will treat it as an anonymous modular (unsigned) quantity. Alas, the types are such that we need to store .val as a signed quantity. Sorry for the mess, but C doesn't officially guarantee that a simple assignment does the trick (no, it doesn't; read the reference manual). */ yylval.typed_val.type = builtin_type (parse_gdbarch)->builtin_unsigned_long; if (result & LONGEST_SIGN) yylval.typed_val.val = (LONGEST) (result & ~LONGEST_SIGN) - (LONGEST_SIGN>>1) - (LONGEST_SIGN>>1); else yylval.typed_val.val = (LONGEST) result; return INT; } else yylval.typed_val.type = type_long_long (); yylval.typed_val.val = (LONGEST) result; return INT; }
/* Interprets the prefix of NUM that consists of digits of the given BASE as an integer of that BASE, with the string EXP as an exponent. Puts value in yylval, and returns INT, if the string is valid. Causes an error if the number is improperly formated. BASE, if NULL, defaults to "10", and EXP to "1". The EXP does not contain a leading 'e' or 'E'. */
Interprets the prefix of NUM that consists of digits of the given BASE as an integer of that BASE, with the string EXP as an exponent. Puts value in yylval, and returns INT, if the string is valid. Causes an error if the number is improperly formated. BASE, if NULL, defaults to "10", and EXP to "1". The EXP does not contain a leading 'e' or 'E'.
[ "Interprets", "the", "prefix", "of", "NUM", "that", "consists", "of", "digits", "of", "the", "given", "BASE", "as", "an", "integer", "of", "that", "BASE", "with", "the", "string", "EXP", "as", "an", "exponent", ".", "Puts", "value", "in", "yylval", "and", "returns", "INT", "if", "the", "string", "is", "valid", ".", "Causes", "an", "error", "if", "the", "number", "is", "improperly", "formated", ".", "BASE", "if", "NULL", "defaults", "to", "\"", "10", "\"", "and", "EXP", "to", "\"", "1", "\"", ".", "The", "EXP", "does", "not", "contain", "a", "leading", "'", "e", "'", "or", "'", "E", "'", "." ]
static int processInt (const char *base0, const char *num0, const char *exp0) { ULONGEST result; long exp; int base; char *trailer; if (base0 == NULL) base = 10; else { base = strtol (base0, (char **) NULL, 10); if (base < 2 || base > 16) error (_("Invalid base: %d."), base); } if (exp0 == NULL) exp = 0; else exp = strtol(exp0, (char **) NULL, 10); errno = 0; result = strtoulst (num0, (const char **) &trailer, base); if (errno == ERANGE) error (_("Integer literal out of range")); if (isxdigit(*trailer)) error (_("Invalid digit `%c' in based literal"), *trailer); while (exp > 0) { if (result > (ULONG_MAX / base)) error (_("Integer literal out of range")); result *= base; exp -= 1; } if ((result >> (gdbarch_int_bit (parse_gdbarch)-1)) == 0) yylval.typed_val.type = type_int (); else if ((result >> (gdbarch_long_bit (parse_gdbarch)-1)) == 0) yylval.typed_val.type = type_long (); else if (((result >> (gdbarch_long_bit (parse_gdbarch)-1)) >> 1) == 0) { yylval.typed_val.type = builtin_type (parse_gdbarch)->builtin_unsigned_long; if (result & LONGEST_SIGN) yylval.typed_val.val = (LONGEST) (result & ~LONGEST_SIGN) - (LONGEST_SIGN>>1) - (LONGEST_SIGN>>1); else yylval.typed_val.val = (LONGEST) result; return INT; } else yylval.typed_val.type = type_long_long (); yylval.typed_val.val = (LONGEST) result; return INT; }
[ "static", "int", "processInt", "(", "const", "char", "*", "base0", ",", "const", "char", "*", "num0", ",", "const", "char", "*", "exp0", ")", "{", "ULONGEST", "result", ";", "long", "exp", ";", "int", "base", ";", "char", "*", "trailer", ";", "if", "(", "base0", "==", "NULL", ")", "base", "=", "10", ";", "else", "{", "base", "=", "strtol", "(", "base0", ",", "(", "char", "*", "*", ")", "NULL", ",", "10", ")", ";", "if", "(", "base", "<", "2", "||", "base", ">", "16", ")", "error", "(", "_", "(", "\"", "\"", ")", ",", "base", ")", ";", "}", "if", "(", "exp0", "==", "NULL", ")", "exp", "=", "0", ";", "else", "exp", "=", "strtol", "(", "exp0", ",", "(", "char", "*", "*", ")", "NULL", ",", "10", ")", ";", "errno", "=", "0", ";", "result", "=", "strtoulst", "(", "num0", ",", "(", "const", "char", "*", "*", ")", "&", "trailer", ",", "base", ")", ";", "if", "(", "errno", "==", "ERANGE", ")", "error", "(", "_", "(", "\"", "\"", ")", ")", ";", "if", "(", "isxdigit", "(", "*", "trailer", ")", ")", "error", "(", "_", "(", "\"", "\"", ")", ",", "*", "trailer", ")", ";", "while", "(", "exp", ">", "0", ")", "{", "if", "(", "result", ">", "(", "ULONG_MAX", "/", "base", ")", ")", "error", "(", "_", "(", "\"", "\"", ")", ")", ";", "result", "*=", "base", ";", "exp", "-=", "1", ";", "}", "if", "(", "(", "result", ">>", "(", "gdbarch_int_bit", "(", "parse_gdbarch", ")", "-", "1", ")", ")", "==", "0", ")", "yylval", ".", "typed_val", ".", "type", "=", "type_int", "(", ")", ";", "else", "if", "(", "(", "result", ">>", "(", "gdbarch_long_bit", "(", "parse_gdbarch", ")", "-", "1", ")", ")", "==", "0", ")", "yylval", ".", "typed_val", ".", "type", "=", "type_long", "(", ")", ";", "else", "if", "(", "(", "(", "result", ">>", "(", "gdbarch_long_bit", "(", "parse_gdbarch", ")", "-", "1", ")", ")", ">>", "1", ")", "==", "0", ")", "{", "yylval", ".", "typed_val", ".", "type", "=", "builtin_type", "(", "parse_gdbarch", ")", "->", "builtin_unsigned_long", ";", "if", "(", "result", "&", "LONGEST_SIGN", ")", "yylval", ".", "typed_val", ".", "val", "=", "(", "LONGEST", ")", "(", "result", "&", "~", "LONGEST_SIGN", ")", "-", "(", "LONGEST_SIGN", ">>", "1", ")", "-", "(", "LONGEST_SIGN", ">>", "1", ")", ";", "else", "yylval", ".", "typed_val", ".", "val", "=", "(", "LONGEST", ")", "result", ";", "return", "INT", ";", "}", "else", "yylval", ".", "typed_val", ".", "type", "=", "type_long_long", "(", ")", ";", "yylval", ".", "typed_val", ".", "val", "=", "(", "LONGEST", ")", "result", ";", "return", "INT", ";", "}" ]
Interprets the prefix of NUM that consists of digits of the given BASE as an integer of that BASE, with the string EXP as an exponent.
[ "Interprets", "the", "prefix", "of", "NUM", "that", "consists", "of", "digits", "of", "the", "given", "BASE", "as", "an", "integer", "of", "that", "BASE", "with", "the", "string", "EXP", "as", "an", "exponent", "." ]
[ "/* We have a number representable as an unsigned integer quantity.\n For consistency with the C treatment, we will treat it as an\n\t anonymous modular (unsigned) quantity. Alas, the types are such\n\t that we need to store .val as a signed quantity. Sorry\n for the mess, but C doesn't officially guarantee that a simple\n assignment does the trick (no, it doesn't; read the reference manual).\n */" ]
[ { "param": "base0", "type": "char" }, { "param": "num0", "type": "char" }, { "param": "exp0", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "base0", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num0", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "exp0", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1eaadb65229966e1644ab3355ae4771253db1e7c
atrens/DragonFlyBSD-src
gnu/usr.bin/gdb/gdb/ada-lex.c
[ "BSD-3-Clause" ]
C
processString
null
static struct stoken processString (const char *text, int len) { const char *p; char *q; const char *lim = text + len; struct stoken result; q = result.ptr = obstack_alloc (&temp_parse_space, len); p = text; while (p < lim) { if (p[0] == '[' && p[1] == '"' && p+2 < lim) { if (p[2] == '"') /* "...["""]... */ { *q = '"'; p += 4; } else { int chr; sscanf (p+2, "%2x", &chr); *q = (char) chr; p += 5; } } else *q = *p; q += 1; p += 1; } result.length = q - result.ptr; return result; }
/* Return TEXT[0..LEN-1], a string literal without surrounding quotes, with special hex character notations replaced with characters. Result valid until the next call to ada_parse. */
Return TEXT[0..LEN-1], a string literal without surrounding quotes, with special hex character notations replaced with characters. Result valid until the next call to ada_parse.
[ "Return", "TEXT", "[", "0", "..", "LEN", "-", "1", "]", "a", "string", "literal", "without", "surrounding", "quotes", "with", "special", "hex", "character", "notations", "replaced", "with", "characters", ".", "Result", "valid", "until", "the", "next", "call", "to", "ada_parse", "." ]
static struct stoken processString (const char *text, int len) { const char *p; char *q; const char *lim = text + len; struct stoken result; q = result.ptr = obstack_alloc (&temp_parse_space, len); p = text; while (p < lim) { if (p[0] == '[' && p[1] == '"' && p+2 < lim) { if (p[2] == '"') { *q = '"'; p += 4; } else { int chr; sscanf (p+2, "%2x", &chr); *q = (char) chr; p += 5; } } else *q = *p; q += 1; p += 1; } result.length = q - result.ptr; return result; }
[ "static", "struct", "stoken", "processString", "(", "const", "char", "*", "text", ",", "int", "len", ")", "{", "const", "char", "*", "p", ";", "char", "*", "q", ";", "const", "char", "*", "lim", "=", "text", "+", "len", ";", "struct", "stoken", "result", ";", "q", "=", "result", ".", "ptr", "=", "obstack_alloc", "(", "&", "temp_parse_space", ",", "len", ")", ";", "p", "=", "text", ";", "while", "(", "p", "<", "lim", ")", "{", "if", "(", "p", "[", "0", "]", "==", "'", "'", "&&", "p", "[", "1", "]", "==", "'", "'", "&&", "p", "+", "2", "<", "lim", ")", "{", "if", "(", "p", "[", "2", "]", "==", "'", "'", ")", "{", "*", "q", "=", "'", "'", ";", "p", "+=", "4", ";", "}", "else", "{", "int", "chr", ";", "sscanf", "(", "p", "+", "2", ",", "\"", "\"", ",", "&", "chr", ")", ";", "*", "q", "=", "(", "char", ")", "chr", ";", "p", "+=", "5", ";", "}", "}", "else", "*", "q", "=", "*", "p", ";", "q", "+=", "1", ";", "p", "+=", "1", ";", "}", "result", ".", "length", "=", "q", "-", "result", ".", "ptr", ";", "return", "result", ";", "}" ]
Return TEXT[0..LEN-1], a string literal without surrounding quotes, with special hex character notations replaced with characters.
[ "Return", "TEXT", "[", "0", "..", "LEN", "-", "1", "]", "a", "string", "literal", "without", "surrounding", "quotes", "with", "special", "hex", "character", "notations", "replaced", "with", "characters", "." ]
[ "/* \"...[\"\"\"]... */" ]
[ { "param": "text", "type": "char" }, { "param": "len", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "len", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1eaadb65229966e1644ab3355ae4771253db1e7c
atrens/DragonFlyBSD-src
gnu/usr.bin/gdb/gdb/ada-lex.c
[ "BSD-3-Clause" ]
C
subseqMatch
int
static int subseqMatch (const char *subseq, const char *str) { if (subseq[0] == '\0') return 1; else if (str[0] == '\0') return 0; else if (tolower (subseq[0]) == tolower (str[0])) return subseqMatch (subseq+1, str+1) || subseqMatch (subseq, str+1); else return subseqMatch (subseq, str+1); }
/* Returns non-zero iff string SUBSEQ matches a subsequence of STR, ignoring case. */
Returns non-zero iff string SUBSEQ matches a subsequence of STR, ignoring case.
[ "Returns", "non", "-", "zero", "iff", "string", "SUBSEQ", "matches", "a", "subsequence", "of", "STR", "ignoring", "case", "." ]
static int subseqMatch (const char *subseq, const char *str) { if (subseq[0] == '\0') return 1; else if (str[0] == '\0') return 0; else if (tolower (subseq[0]) == tolower (str[0])) return subseqMatch (subseq+1, str+1) || subseqMatch (subseq, str+1); else return subseqMatch (subseq, str+1); }
[ "static", "int", "subseqMatch", "(", "const", "char", "*", "subseq", ",", "const", "char", "*", "str", ")", "{", "if", "(", "subseq", "[", "0", "]", "==", "'", "\\0", "'", ")", "return", "1", ";", "else", "if", "(", "str", "[", "0", "]", "==", "'", "\\0", "'", ")", "return", "0", ";", "else", "if", "(", "tolower", "(", "subseq", "[", "0", "]", ")", "==", "tolower", "(", "str", "[", "0", "]", ")", ")", "return", "subseqMatch", "(", "subseq", "+", "1", ",", "str", "+", "1", ")", "||", "subseqMatch", "(", "subseq", ",", "str", "+", "1", ")", ";", "else", "return", "subseqMatch", "(", "subseq", ",", "str", "+", "1", ")", ";", "}" ]
Returns non-zero iff string SUBSEQ matches a subsequence of STR, ignoring case.
[ "Returns", "non", "-", "zero", "iff", "string", "SUBSEQ", "matches", "a", "subsequence", "of", "STR", "ignoring", "case", "." ]
[]
[ { "param": "subseq", "type": "char" }, { "param": "str", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "subseq", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1eaadb65229966e1644ab3355ae4771253db1e7c
atrens/DragonFlyBSD-src
gnu/usr.bin/gdb/gdb/ada-lex.c
[ "BSD-3-Clause" ]
C
processAttribute
int
static int processAttribute (const char *str) { int i, k; for (i = 0; attributes[i].code != -1; i += 1) if (strcasecmp (str, attributes[i].name) == 0) return attributes[i].code; for (i = 0, k = -1; attributes[i].code != -1; i += 1) if (subseqMatch (str, attributes[i].name)) { if (k == -1) k = i; else error (_("ambiguous attribute name: `%s'"), str); } if (k == -1) error (_("unrecognized attribute: `%s'"), str); return attributes[k].code; }
/* Return the syntactic code corresponding to the attribute name or abbreviation STR. */
Return the syntactic code corresponding to the attribute name or abbreviation STR.
[ "Return", "the", "syntactic", "code", "corresponding", "to", "the", "attribute", "name", "or", "abbreviation", "STR", "." ]
static int processAttribute (const char *str) { int i, k; for (i = 0; attributes[i].code != -1; i += 1) if (strcasecmp (str, attributes[i].name) == 0) return attributes[i].code; for (i = 0, k = -1; attributes[i].code != -1; i += 1) if (subseqMatch (str, attributes[i].name)) { if (k == -1) k = i; else error (_("ambiguous attribute name: `%s'"), str); } if (k == -1) error (_("unrecognized attribute: `%s'"), str); return attributes[k].code; }
[ "static", "int", "processAttribute", "(", "const", "char", "*", "str", ")", "{", "int", "i", ",", "k", ";", "for", "(", "i", "=", "0", ";", "attributes", "[", "i", "]", ".", "code", "!=", "-1", ";", "i", "+=", "1", ")", "if", "(", "strcasecmp", "(", "str", ",", "attributes", "[", "i", "]", ".", "name", ")", "==", "0", ")", "return", "attributes", "[", "i", "]", ".", "code", ";", "for", "(", "i", "=", "0", ",", "k", "=", "-1", ";", "attributes", "[", "i", "]", ".", "code", "!=", "-1", ";", "i", "+=", "1", ")", "if", "(", "subseqMatch", "(", "str", ",", "attributes", "[", "i", "]", ".", "name", ")", ")", "{", "if", "(", "k", "==", "-1", ")", "k", "=", "i", ";", "else", "error", "(", "_", "(", "\"", "\"", ")", ",", "str", ")", ";", "}", "if", "(", "k", "==", "-1", ")", "error", "(", "_", "(", "\"", "\"", ")", ",", "str", ")", ";", "return", "attributes", "[", "k", "]", ".", "code", ";", "}" ]
Return the syntactic code corresponding to the attribute name or abbreviation STR.
[ "Return", "the", "syntactic", "code", "corresponding", "to", "the", "attribute", "name", "or", "abbreviation", "STR", "." ]
[]
[ { "param": "str", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "str", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1eaadb65229966e1644ab3355ae4771253db1e7c
atrens/DragonFlyBSD-src
gnu/usr.bin/gdb/gdb/ada-lex.c
[ "BSD-3-Clause" ]
C
rewind_to_char
void
static void rewind_to_char (int ch) { lexptr -= yyleng; while (toupper (*lexptr) != toupper (ch)) lexptr -= 1; yyrestart (NULL); }
/* Back up lexptr by yyleng and then to the rightmost occurrence of character CH, case-folded (there must be one). WARNING: since lexptr points to the next input character that Flex has not yet transferred to its internal buffer, the use of this function depends on the assumption that Flex calls YY_INPUT only when it is logically necessary to do so (thus, there is no reading ahead farther than needed to identify the next token.) */
Back up lexptr by yyleng and then to the rightmost occurrence of character CH, case-folded (there must be one). WARNING: since lexptr points to the next input character that Flex has not yet transferred to its internal buffer, the use of this function depends on the assumption that Flex calls YY_INPUT only when it is logically necessary to do so (thus, there is no reading ahead farther than needed to identify the next token.)
[ "Back", "up", "lexptr", "by", "yyleng", "and", "then", "to", "the", "rightmost", "occurrence", "of", "character", "CH", "case", "-", "folded", "(", "there", "must", "be", "one", ")", ".", "WARNING", ":", "since", "lexptr", "points", "to", "the", "next", "input", "character", "that", "Flex", "has", "not", "yet", "transferred", "to", "its", "internal", "buffer", "the", "use", "of", "this", "function", "depends", "on", "the", "assumption", "that", "Flex", "calls", "YY_INPUT", "only", "when", "it", "is", "logically", "necessary", "to", "do", "so", "(", "thus", "there", "is", "no", "reading", "ahead", "farther", "than", "needed", "to", "identify", "the", "next", "token", ".", ")" ]
static void rewind_to_char (int ch) { lexptr -= yyleng; while (toupper (*lexptr) != toupper (ch)) lexptr -= 1; yyrestart (NULL); }
[ "static", "void", "rewind_to_char", "(", "int", "ch", ")", "{", "lexptr", "-=", "yyleng", ";", "while", "(", "toupper", "(", "*", "lexptr", ")", "!=", "toupper", "(", "ch", ")", ")", "lexptr", "-=", "1", ";", "yyrestart", "(", "NULL", ")", ";", "}" ]
Back up lexptr by yyleng and then to the rightmost occurrence of character CH, case-folded (there must be one).
[ "Back", "up", "lexptr", "by", "yyleng", "and", "then", "to", "the", "rightmost", "occurrence", "of", "character", "CH", "case", "-", "folded", "(", "there", "must", "be", "one", ")", "." ]
[]
[ { "param": "ch", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ch", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
out_one
void
static inline void out_one (int byte) { FRAG_APPEND_1_CHAR (byte); }
/* Emit a single byte into the current segment. */
Emit a single byte into the current segment.
[ "Emit", "a", "single", "byte", "into", "the", "current", "segment", "." ]
static inline void out_one (int byte) { FRAG_APPEND_1_CHAR (byte); }
[ "static", "inline", "void", "out_one", "(", "int", "byte", ")", "{", "FRAG_APPEND_1_CHAR", "(", "byte", ")", ";", "}" ]
Emit a single byte into the current segment.
[ "Emit", "a", "single", "byte", "into", "the", "current", "segment", "." ]
[]
[ { "param": "byte", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "byte", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
out_sleb128
void
static void out_sleb128 (offsetT value) { output_leb128 (frag_more (sizeof_leb128 (value, 1)), value, 1); }
/* Emit an unsigned "little-endian base 128" number. */
Emit an unsigned "little-endian base 128" number.
[ "Emit", "an", "unsigned", "\"", "little", "-", "endian", "base", "128", "\"", "number", "." ]
static void out_sleb128 (offsetT value) { output_leb128 (frag_more (sizeof_leb128 (value, 1)), value, 1); }
[ "static", "void", "out_sleb128", "(", "offsetT", "value", ")", "{", "output_leb128", "(", "frag_more", "(", "sizeof_leb128", "(", "value", ",", "1", ")", ")", ",", "value", ",", "1", ")", ";", "}" ]
Emit an unsigned "little-endian base 128" number.
[ "Emit", "an", "unsigned", "\"", "little", "-", "endian", "base", "128", "\"", "number", "." ]
[]
[ { "param": "value", "type": "offsetT" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "value", "type": "offsetT", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
emit_expr_encoded
void
static void emit_expr_encoded (expressionS *exp, int encoding, bfd_boolean emit_encoding) { unsigned int size = encoding_size (encoding); bfd_reloc_code_real_type code; if (encoding == DW_EH_PE_omit) return; if (emit_encoding) out_one (encoding); code = tc_cfi_reloc_for_encoding (encoding); if (code != BFD_RELOC_NONE) { reloc_howto_type *howto = bfd_reloc_type_lookup (stdoutput, code); char *p = frag_more (size); gas_assert (size == (unsigned) howto->bitsize / 8); md_number_to_chars (p, 0, size); fix_new (frag_now, p - frag_now->fr_literal, size, exp->X_add_symbol, exp->X_add_number, howto->pc_relative, code); } else if ((encoding & 0x70) == DW_EH_PE_pcrel) { #if CFI_DIFF_EXPR_OK expressionS tmp = *exp; tmp.X_op = O_subtract; tmp.X_op_symbol = symbol_temp_new_now (); emit_expr (&tmp, size); #elif defined (tc_cfi_emit_pcrel_expr) tc_cfi_emit_pcrel_expr (exp, size); #else abort (); #endif } else emit_expr (exp, size); }
/* Emit expression EXP in ENCODING. If EMIT_ENCODING is true, first emit a byte containing ENCODING. */
Emit expression EXP in ENCODING. If EMIT_ENCODING is true, first emit a byte containing ENCODING.
[ "Emit", "expression", "EXP", "in", "ENCODING", ".", "If", "EMIT_ENCODING", "is", "true", "first", "emit", "a", "byte", "containing", "ENCODING", "." ]
static void emit_expr_encoded (expressionS *exp, int encoding, bfd_boolean emit_encoding) { unsigned int size = encoding_size (encoding); bfd_reloc_code_real_type code; if (encoding == DW_EH_PE_omit) return; if (emit_encoding) out_one (encoding); code = tc_cfi_reloc_for_encoding (encoding); if (code != BFD_RELOC_NONE) { reloc_howto_type *howto = bfd_reloc_type_lookup (stdoutput, code); char *p = frag_more (size); gas_assert (size == (unsigned) howto->bitsize / 8); md_number_to_chars (p, 0, size); fix_new (frag_now, p - frag_now->fr_literal, size, exp->X_add_symbol, exp->X_add_number, howto->pc_relative, code); } else if ((encoding & 0x70) == DW_EH_PE_pcrel) { #if CFI_DIFF_EXPR_OK expressionS tmp = *exp; tmp.X_op = O_subtract; tmp.X_op_symbol = symbol_temp_new_now (); emit_expr (&tmp, size); #elif defined (tc_cfi_emit_pcrel_expr) tc_cfi_emit_pcrel_expr (exp, size); #else abort (); #endif } else emit_expr (exp, size); }
[ "static", "void", "emit_expr_encoded", "(", "expressionS", "*", "exp", ",", "int", "encoding", ",", "bfd_boolean", "emit_encoding", ")", "{", "unsigned", "int", "size", "=", "encoding_size", "(", "encoding", ")", ";", "bfd_reloc_code_real_type", "code", ";", "if", "(", "encoding", "==", "DW_EH_PE_omit", ")", "return", ";", "if", "(", "emit_encoding", ")", "out_one", "(", "encoding", ")", ";", "code", "=", "tc_cfi_reloc_for_encoding", "(", "encoding", ")", ";", "if", "(", "code", "!=", "BFD_RELOC_NONE", ")", "{", "reloc_howto_type", "*", "howto", "=", "bfd_reloc_type_lookup", "(", "stdoutput", ",", "code", ")", ";", "char", "*", "p", "=", "frag_more", "(", "size", ")", ";", "gas_assert", "(", "size", "==", "(", "unsigned", ")", "howto", "->", "bitsize", "/", "8", ")", ";", "md_number_to_chars", "(", "p", ",", "0", ",", "size", ")", ";", "fix_new", "(", "frag_now", ",", "p", "-", "frag_now", "->", "fr_literal", ",", "size", ",", "exp", "->", "X_add_symbol", ",", "exp", "->", "X_add_number", ",", "howto", "->", "pc_relative", ",", "code", ")", ";", "}", "else", "if", "(", "(", "encoding", "&", "0x70", ")", "==", "DW_EH_PE_pcrel", ")", "{", "#if", "CFI_DIFF_EXPR_OK", "\n", "expressionS", "tmp", "=", "*", "exp", ";", "tmp", ".", "X_op", "=", "O_subtract", ";", "tmp", ".", "X_op_symbol", "=", "symbol_temp_new_now", "(", ")", ";", "emit_expr", "(", "&", "tmp", ",", "size", ")", ";", "#elif", "defined", "(", "tc_cfi_emit_pcrel_expr", ")", "\n", "tc_cfi_emit_pcrel_expr", "(", "exp", ",", "size", ")", ";", "#else", "abort", "(", ")", ";", "#endif", "}", "else", "emit_expr", "(", "exp", ",", "size", ")", ";", "}" ]
Emit expression EXP in ENCODING.
[ "Emit", "expression", "EXP", "in", "ENCODING", "." ]
[]
[ { "param": "exp", "type": "expressionS" }, { "param": "encoding", "type": "int" }, { "param": "emit_encoding", "type": "bfd_boolean" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "exp", "type": "expressionS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "encoding", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "emit_encoding", "type": "bfd_boolean", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
make_debug_seg
segT
static segT make_debug_seg (segT cseg, char *name, int sflags) { segT save_seg = now_seg; int save_subseg = now_subseg; segT r; flagword flags; r = subseg_new (name, 0); /* Check if code segment is marked as linked once. */ if (!cseg) flags = 0; else flags = (bfd_section_flags (cseg) & (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD | SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE | SEC_LINK_DUPLICATES_SAME_CONTENTS)); /* Add standard section flags. */ flags |= sflags; /* Apply possibly linked once flags to new generated segment, too. */ if (!bfd_set_section_flags (r, flags)) as_bad (_("bfd_set_section_flags: %s"), bfd_errmsg (bfd_get_error ())); /* Restore to previous segment. */ if (save_seg != NULL) subseg_set (save_seg, save_subseg); return r; }
/* Generate debug... segment with same linkonce properties of based segment. */
Generate debug... segment with same linkonce properties of based segment.
[ "Generate", "debug", "...", "segment", "with", "same", "linkonce", "properties", "of", "based", "segment", "." ]
static segT make_debug_seg (segT cseg, char *name, int sflags) { segT save_seg = now_seg; int save_subseg = now_subseg; segT r; flagword flags; r = subseg_new (name, 0); if (!cseg) flags = 0; else flags = (bfd_section_flags (cseg) & (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD | SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE | SEC_LINK_DUPLICATES_SAME_CONTENTS)); flags |= sflags; if (!bfd_set_section_flags (r, flags)) as_bad (_("bfd_set_section_flags: %s"), bfd_errmsg (bfd_get_error ())); if (save_seg != NULL) subseg_set (save_seg, save_subseg); return r; }
[ "static", "segT", "make_debug_seg", "(", "segT", "cseg", ",", "char", "*", "name", ",", "int", "sflags", ")", "{", "segT", "save_seg", "=", "now_seg", ";", "int", "save_subseg", "=", "now_subseg", ";", "segT", "r", ";", "flagword", "flags", ";", "r", "=", "subseg_new", "(", "name", ",", "0", ")", ";", "if", "(", "!", "cseg", ")", "flags", "=", "0", ";", "else", "flags", "=", "(", "bfd_section_flags", "(", "cseg", ")", "&", "(", "SEC_LINK_ONCE", "|", "SEC_LINK_DUPLICATES_DISCARD", "|", "SEC_LINK_DUPLICATES_ONE_ONLY", "|", "SEC_LINK_DUPLICATES_SAME_SIZE", "|", "SEC_LINK_DUPLICATES_SAME_CONTENTS", ")", ")", ";", "flags", "|=", "sflags", ";", "if", "(", "!", "bfd_set_section_flags", "(", "r", ",", "flags", ")", ")", "as_bad", "(", "_", "(", "\"", "\"", ")", ",", "bfd_errmsg", "(", "bfd_get_error", "(", ")", ")", ")", ";", "if", "(", "save_seg", "!=", "NULL", ")", "subseg_set", "(", "save_seg", ",", "save_subseg", ")", ";", "return", "r", ";", "}" ]
Generate debug... segment with same linkonce properties of based segment.
[ "Generate", "debug", "...", "segment", "with", "same", "linkonce", "properties", "of", "based", "segment", "." ]
[ "/* Check if code segment is marked as linked once. */", "/* Add standard section flags. */", "/* Apply possibly linked once flags to new generated segment, too. */", "/* Restore to previous segment. */" ]
[ { "param": "cseg", "type": "segT" }, { "param": "name", "type": "char" }, { "param": "sflags", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cseg", "type": "segT", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sflags", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
cfi_new_fde
void
void cfi_new_fde (symbolS *label) { struct fde_entry *fde = alloc_fde_entry (); fde->start_address = label; frchain_now->frch_cfi_data->last_address = label; }
/* Construct a new FDE structure that begins at LABEL. */
Construct a new FDE structure that begins at LABEL.
[ "Construct", "a", "new", "FDE", "structure", "that", "begins", "at", "LABEL", "." ]
void cfi_new_fde (symbolS *label) { struct fde_entry *fde = alloc_fde_entry (); fde->start_address = label; frchain_now->frch_cfi_data->last_address = label; }
[ "void", "cfi_new_fde", "(", "symbolS", "*", "label", ")", "{", "struct", "fde_entry", "*", "fde", "=", "alloc_fde_entry", "(", ")", ";", "fde", "->", "start_address", "=", "label", ";", "frchain_now", "->", "frch_cfi_data", "->", "last_address", "=", "label", ";", "}" ]
Construct a new FDE structure that begins at LABEL.
[ "Construct", "a", "new", "FDE", "structure", "that", "begins", "at", "LABEL", "." ]
[]
[ { "param": "label", "type": "symbolS" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "label", "type": "symbolS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
cfi_end_fde
void
void cfi_end_fde (symbolS *label) { frchain_now->frch_cfi_data->cur_fde_data->end_address = label; free (frchain_now->frch_cfi_data); frchain_now->frch_cfi_data = NULL; }
/* End the currently open FDE. */
End the currently open FDE.
[ "End", "the", "currently", "open", "FDE", "." ]
void cfi_end_fde (symbolS *label) { frchain_now->frch_cfi_data->cur_fde_data->end_address = label; free (frchain_now->frch_cfi_data); frchain_now->frch_cfi_data = NULL; }
[ "void", "cfi_end_fde", "(", "symbolS", "*", "label", ")", "{", "frchain_now", "->", "frch_cfi_data", "->", "cur_fde_data", "->", "end_address", "=", "label", ";", "free", "(", "frchain_now", "->", "frch_cfi_data", ")", ";", "frchain_now", "->", "frch_cfi_data", "=", "NULL", ";", "}" ]
End the currently open FDE.
[ "End", "the", "currently", "open", "FDE", "." ]
[]
[ { "param": "label", "type": "symbolS" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "label", "type": "symbolS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
cfi_set_return_column
void
void cfi_set_return_column (unsigned regno) { frchain_now->frch_cfi_data->cur_fde_data->return_column = regno; }
/* Set the return column for the current FDE. */
Set the return column for the current FDE.
[ "Set", "the", "return", "column", "for", "the", "current", "FDE", "." ]
void cfi_set_return_column (unsigned regno) { frchain_now->frch_cfi_data->cur_fde_data->return_column = regno; }
[ "void", "cfi_set_return_column", "(", "unsigned", "regno", ")", "{", "frchain_now", "->", "frch_cfi_data", "->", "cur_fde_data", "->", "return_column", "=", "regno", ";", "}" ]
Set the return column for the current FDE.
[ "Set", "the", "return", "column", "for", "the", "current", "FDE", "." ]
[]
[ { "param": "regno", "type": "unsigned" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "regno", "type": "unsigned", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
cfi_add_CFA_insn
void
static void cfi_add_CFA_insn (int insn) { struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); insn_ptr->insn = insn; }
/* Universal functions to store new instructions. */
Universal functions to store new instructions.
[ "Universal", "functions", "to", "store", "new", "instructions", "." ]
static void cfi_add_CFA_insn (int insn) { struct cfi_insn_data *insn_ptr = alloc_cfi_insn_data (); insn_ptr->insn = insn; }
[ "static", "void", "cfi_add_CFA_insn", "(", "int", "insn", ")", "{", "struct", "cfi_insn_data", "*", "insn_ptr", "=", "alloc_cfi_insn_data", "(", ")", ";", "insn_ptr", "->", "insn", "=", "insn", ";", "}" ]
Universal functions to store new instructions.
[ "Universal", "functions", "to", "store", "new", "instructions", "." ]
[]
[ { "param": "insn", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "insn", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
cfi_add_advance_loc
void
void cfi_add_advance_loc (symbolS *label) { struct cfi_insn_data *insn = alloc_cfi_insn_data (); insn->insn = DW_CFA_advance_loc; insn->u.ll.lab1 = frchain_now->frch_cfi_data->last_address; insn->u.ll.lab2 = label; frchain_now->frch_cfi_data->last_address = label; }
/* Add a CFI insn to advance the PC from the last address to LABEL. */
Add a CFI insn to advance the PC from the last address to LABEL.
[ "Add", "a", "CFI", "insn", "to", "advance", "the", "PC", "from", "the", "last", "address", "to", "LABEL", "." ]
void cfi_add_advance_loc (symbolS *label) { struct cfi_insn_data *insn = alloc_cfi_insn_data (); insn->insn = DW_CFA_advance_loc; insn->u.ll.lab1 = frchain_now->frch_cfi_data->last_address; insn->u.ll.lab2 = label; frchain_now->frch_cfi_data->last_address = label; }
[ "void", "cfi_add_advance_loc", "(", "symbolS", "*", "label", ")", "{", "struct", "cfi_insn_data", "*", "insn", "=", "alloc_cfi_insn_data", "(", ")", ";", "insn", "->", "insn", "=", "DW_CFA_advance_loc", ";", "insn", "->", "u", ".", "ll", ".", "lab1", "=", "frchain_now", "->", "frch_cfi_data", "->", "last_address", ";", "insn", "->", "u", ".", "ll", ".", "lab2", "=", "label", ";", "frchain_now", "->", "frch_cfi_data", "->", "last_address", "=", "label", ";", "}" ]
Add a CFI insn to advance the PC from the last address to LABEL.
[ "Add", "a", "CFI", "insn", "to", "advance", "the", "PC", "from", "the", "last", "address", "to", "LABEL", "." ]
[]
[ { "param": "label", "type": "symbolS" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "label", "type": "symbolS", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
cfi_add_label
void
void cfi_add_label (const char *name) { unsigned int len = strlen (name) + 1; struct cfi_insn_data *insn = alloc_cfi_insn_data (); insn->insn = CFI_label; obstack_grow (&notes, name, len); insn->u.sym_name = (char *) obstack_finish (&notes); }
/* Add a CFI insn to label the current position in the CFI segment. */
Add a CFI insn to label the current position in the CFI segment.
[ "Add", "a", "CFI", "insn", "to", "label", "the", "current", "position", "in", "the", "CFI", "segment", "." ]
void cfi_add_label (const char *name) { unsigned int len = strlen (name) + 1; struct cfi_insn_data *insn = alloc_cfi_insn_data (); insn->insn = CFI_label; obstack_grow (&notes, name, len); insn->u.sym_name = (char *) obstack_finish (&notes); }
[ "void", "cfi_add_label", "(", "const", "char", "*", "name", ")", "{", "unsigned", "int", "len", "=", "strlen", "(", "name", ")", "+", "1", ";", "struct", "cfi_insn_data", "*", "insn", "=", "alloc_cfi_insn_data", "(", ")", ";", "insn", "->", "insn", "=", "CFI_label", ";", "obstack_grow", "(", "&", "notes", ",", "name", ",", "len", ")", ";", "insn", "->", "u", ".", "sym_name", "=", "(", "char", "*", ")", "obstack_finish", "(", "&", "notes", ")", ";", "}" ]
Add a CFI insn to label the current position in the CFI segment.
[ "Add", "a", "CFI", "insn", "to", "label", "the", "current", "position", "in", "the", "CFI", "segment", "." ]
[]
[ { "param": "name", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
cfi_add_CFA_offset
void
void cfi_add_CFA_offset (unsigned regno, offsetT offset) { unsigned int abs_data_align; gas_assert (DWARF2_CIE_DATA_ALIGNMENT != 0); cfi_add_CFA_insn_reg_offset (DW_CFA_offset, regno, offset); abs_data_align = (DWARF2_CIE_DATA_ALIGNMENT < 0 ? -DWARF2_CIE_DATA_ALIGNMENT : DWARF2_CIE_DATA_ALIGNMENT); if (offset % abs_data_align) as_bad (_("register save offset not a multiple of %u"), abs_data_align); }
/* Add a DW_CFA_offset record to the CFI data. */
Add a DW_CFA_offset record to the CFI data.
[ "Add", "a", "DW_CFA_offset", "record", "to", "the", "CFI", "data", "." ]
void cfi_add_CFA_offset (unsigned regno, offsetT offset) { unsigned int abs_data_align; gas_assert (DWARF2_CIE_DATA_ALIGNMENT != 0); cfi_add_CFA_insn_reg_offset (DW_CFA_offset, regno, offset); abs_data_align = (DWARF2_CIE_DATA_ALIGNMENT < 0 ? -DWARF2_CIE_DATA_ALIGNMENT : DWARF2_CIE_DATA_ALIGNMENT); if (offset % abs_data_align) as_bad (_("register save offset not a multiple of %u"), abs_data_align); }
[ "void", "cfi_add_CFA_offset", "(", "unsigned", "regno", ",", "offsetT", "offset", ")", "{", "unsigned", "int", "abs_data_align", ";", "gas_assert", "(", "DWARF2_CIE_DATA_ALIGNMENT", "!=", "0", ")", ";", "cfi_add_CFA_insn_reg_offset", "(", "DW_CFA_offset", ",", "regno", ",", "offset", ")", ";", "abs_data_align", "=", "(", "DWARF2_CIE_DATA_ALIGNMENT", "<", "0", "?", "-", "DWARF2_CIE_DATA_ALIGNMENT", ":", "DWARF2_CIE_DATA_ALIGNMENT", ")", ";", "if", "(", "offset", "%", "abs_data_align", ")", "as_bad", "(", "_", "(", "\"", "\"", ")", ",", "abs_data_align", ")", ";", "}" ]
Add a DW_CFA_offset record to the CFI data.
[ "Add", "a", "DW_CFA_offset", "record", "to", "the", "CFI", "data", "." ]
[]
[ { "param": "regno", "type": "unsigned" }, { "param": "offset", "type": "offsetT" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "regno", "type": "unsigned", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "offset", "type": "offsetT", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
cfi_add_CFA_register
void
void cfi_add_CFA_register (unsigned reg1, unsigned reg2) { cfi_add_CFA_insn_reg_reg (DW_CFA_register, reg1, reg2); }
/* Add a DW_CFA_register record to the CFI data. */
Add a DW_CFA_register record to the CFI data.
[ "Add", "a", "DW_CFA_register", "record", "to", "the", "CFI", "data", "." ]
void cfi_add_CFA_register (unsigned reg1, unsigned reg2) { cfi_add_CFA_insn_reg_reg (DW_CFA_register, reg1, reg2); }
[ "void", "cfi_add_CFA_register", "(", "unsigned", "reg1", ",", "unsigned", "reg2", ")", "{", "cfi_add_CFA_insn_reg_reg", "(", "DW_CFA_register", ",", "reg1", ",", "reg2", ")", ";", "}" ]
Add a DW_CFA_register record to the CFI data.
[ "Add", "a", "DW_CFA_register", "record", "to", "the", "CFI", "data", "." ]
[]
[ { "param": "reg1", "type": "unsigned" }, { "param": "reg2", "type": "unsigned" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "reg1", "type": "unsigned", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reg2", "type": "unsigned", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a4fe8ac9196099f8049e3b650b8ea9744e1f1bb7
atrens/DragonFlyBSD-src
contrib/binutils-2.34/gas/dw2gencfi.c
[ "BSD-3-Clause" ]
C
output_compact_unwind_data
void
static void output_compact_unwind_data (struct fde_entry *fde, int align) { int data_size = fde->eh_data_size + 2; int align_padding; int amask; char *p; fde->eh_loc = symbol_temp_new_now (); p = frag_more (1); if (fde->personality_id != 0) *p = fde->personality_id; else if (fde->per_encoding != DW_EH_PE_omit) { *p = 0; emit_expr_encoded (&fde->personality, fde->per_encoding, FALSE); data_size += encoding_size (fde->per_encoding); } else *p = 1; amask = (1 << align) - 1; align_padding = ((data_size + amask) & ~amask) - data_size; p = frag_more (fde->eh_data_size + 1 + align_padding); memcpy (p, fde->eh_data, fde->eh_data_size); p += fde->eh_data_size; while (align_padding-- > 0) *(p++) = tc_compact_eh_opcode_pad; *(p++) = tc_compact_eh_opcode_stop; fde->eh_header_type = EH_COMPACT_OUTLINE_DONE; }
/* Function to emit the compact unwinding opcodes stored in the fde's eh_data field. The end of the opcode data will be padded to the value in align. */
Function to emit the compact unwinding opcodes stored in the fde's eh_data field. The end of the opcode data will be padded to the value in align.
[ "Function", "to", "emit", "the", "compact", "unwinding", "opcodes", "stored", "in", "the", "fde", "'", "s", "eh_data", "field", ".", "The", "end", "of", "the", "opcode", "data", "will", "be", "padded", "to", "the", "value", "in", "align", "." ]
static void output_compact_unwind_data (struct fde_entry *fde, int align) { int data_size = fde->eh_data_size + 2; int align_padding; int amask; char *p; fde->eh_loc = symbol_temp_new_now (); p = frag_more (1); if (fde->personality_id != 0) *p = fde->personality_id; else if (fde->per_encoding != DW_EH_PE_omit) { *p = 0; emit_expr_encoded (&fde->personality, fde->per_encoding, FALSE); data_size += encoding_size (fde->per_encoding); } else *p = 1; amask = (1 << align) - 1; align_padding = ((data_size + amask) & ~amask) - data_size; p = frag_more (fde->eh_data_size + 1 + align_padding); memcpy (p, fde->eh_data, fde->eh_data_size); p += fde->eh_data_size; while (align_padding-- > 0) *(p++) = tc_compact_eh_opcode_pad; *(p++) = tc_compact_eh_opcode_stop; fde->eh_header_type = EH_COMPACT_OUTLINE_DONE; }
[ "static", "void", "output_compact_unwind_data", "(", "struct", "fde_entry", "*", "fde", ",", "int", "align", ")", "{", "int", "data_size", "=", "fde", "->", "eh_data_size", "+", "2", ";", "int", "align_padding", ";", "int", "amask", ";", "char", "*", "p", ";", "fde", "->", "eh_loc", "=", "symbol_temp_new_now", "(", ")", ";", "p", "=", "frag_more", "(", "1", ")", ";", "if", "(", "fde", "->", "personality_id", "!=", "0", ")", "*", "p", "=", "fde", "->", "personality_id", ";", "else", "if", "(", "fde", "->", "per_encoding", "!=", "DW_EH_PE_omit", ")", "{", "*", "p", "=", "0", ";", "emit_expr_encoded", "(", "&", "fde", "->", "personality", ",", "fde", "->", "per_encoding", ",", "FALSE", ")", ";", "data_size", "+=", "encoding_size", "(", "fde", "->", "per_encoding", ")", ";", "}", "else", "*", "p", "=", "1", ";", "amask", "=", "(", "1", "<<", "align", ")", "-", "1", ";", "align_padding", "=", "(", "(", "data_size", "+", "amask", ")", "&", "~", "amask", ")", "-", "data_size", ";", "p", "=", "frag_more", "(", "fde", "->", "eh_data_size", "+", "1", "+", "align_padding", ")", ";", "memcpy", "(", "p", ",", "fde", "->", "eh_data", ",", "fde", "->", "eh_data_size", ")", ";", "p", "+=", "fde", "->", "eh_data_size", ";", "while", "(", "align_padding", "--", ">", "0", ")", "*", "(", "p", "++", ")", "=", "tc_compact_eh_opcode_pad", ";", "*", "(", "p", "++", ")", "=", "tc_compact_eh_opcode_stop", ";", "fde", "->", "eh_header_type", "=", "EH_COMPACT_OUTLINE_DONE", ";", "}" ]
Function to emit the compact unwinding opcodes stored in the fde's eh_data field.
[ "Function", "to", "emit", "the", "compact", "unwinding", "opcodes", "stored", "in", "the", "fde", "'", "s", "eh_data", "field", "." ]
[]
[ { "param": "fde", "type": "struct fde_entry" }, { "param": "align", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fde", "type": "struct fde_entry", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "align", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }