本文整理汇总了C++中rstrip函数的典型用法代码示例。如果您正苦于以下问题:C++ rstrip函数的具体用法?C++ rstrip怎么用?C++ rstrip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rstrip函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is
void HttpSession::parseHeader() {
istream is(&impl->data);
string line;
getline(is, line);
auto rc = split(line, " ");
impl->code = stol(rc[1]);
LOGD(">>%s", line);
while(!is.eof()) {
getline(is, line);
if(line == "" || line == "\r")
break;
LOGD("%s", line);
auto parts = split(line, ": ", 2);
if(parts.size() == 2) {
parts[1] = rstrip(rstrip(parts[1], '\n'), '\r');
impl->header[parts[0]] = parts[1];
}
}
auto cl = impl->header["Content-Length"];
impl->cntSize = cl != "" ? stol(impl->header["Content-Length"]) : 0;
if(isRedirect()) {
LOGD("Should redirect to '%s'", impl->header["Location"]);
//sleepms(500);
}
}
示例2: int
int CConfigHandler::parseFile(FILE *pFile, int (*handler)(void *, const char *, const char *, const char *), void *object)
{
char line[MAX_LINE];
char section[MAX_SECTION];
char *start;
char *end;
char *name;
char *value;
char *chr;
int lineno = 0;
memset(line, 0, sizeof(line));
while (fgets(line, MAX_LINE, pFile) != NULL)
{
start = line;
start = lstrip(rstrip(start));
if (*start == ';' || *start == '#' || 0 >= strlen(start))
{
memset(line, 0, sizeof(line));
continue;
}
/**
* [section] line
*/
chr = strchr(line, '[');
if (chr)
{
end = strchr(chr + 1, ']');
if (end)
{
*end = '\0';
memset(section, 0, sizeof(section));
strcpy(section, chr + 1);
}
continue;
}
/**
* name = value
*/
end = strchr(line, '=');
if (end && strlen(section))
{
*end = '\0';
name = lstrip(rstrip(start));
value = lstrip(end + 1);
rstrip(value);
handler(object, section, name, value);
++lineno;
}
}
return lineno;
}
示例3: extinputs_parse_2D
int extinputs_parse_2D(const char *filename, struct pulse_2D **cfginputs,
int N1, int N2)
{
FILE *fin;
char buf[MAX_LINE];
char *start;
char *end;
char *values;
int error = 0;
fin = fopen(filename, "r");
if (!fin)
return -1;
int lineno = 0;
double t, q1, q2, i, d, m; /* the values to be read */
/* Scan through file line by line */
while (fgets(buf, sizeof(buf), fin) != NULL) {
lineno++;
start = lskip(rstrip(buf)); /* chop whites */
if (*start && *start != '#') {
/* Remove possible comments at the end */
end = find_char_or_comment(start, '#');
if (*end == '#')
*end = '\0';
values = rstrip(start);
/* Not a comment, must be a line containing 6 numbers */
/* Scan and check if the inputs is correctly formatted */
if (sscanf(values, "%lf %lf %lf %lf %lf %lf",
&t, &d, &q1, &q2, &i, &m) == 6) {
if (t >= 0 && d > 0 && m >= 0) {
*cfginputs =
append_pulse_2D(*cfginputs,
new_pulse_2D(N1, N2, t, d,
-q1, -q2, i, m));
} else {
printf("Durations and time onsets should be positive.\n");
printf("Check configuration file for external inputs.\n");
error = lineno;
}
} else if (!error) {
/* No '=' found on name=value line */
error = lineno;
}
}
}
fclose(fin);
return error;
}
示例4: conf_parse
int conf_parse(const char *filename,
int (*handler) (void *, const char *, const char *),
void *usercfg)
{
FILE *fin;
char buf[MAX_LINE];
char *start;
char *end;
char *name;
char *value;
int error = 0;
fin = fopen(filename, "r");
if (!fin)
return -1;
int lineno = 0;
/* Scan through file line by line */
while (fgets(buf, sizeof(buf), fin) != NULL) {
lineno++;
start = lskip(rstrip(buf)); /* chop whites */
if (*start && *start != '#') {
/* Not a comment, must be a name = value pair */
end = find_char_or_comment(start, '=');
if (*end == '=') {
*end = '\0';
name = rstrip(start);
value = lskip(end + 1);
end = find_char_or_comment(value, '#');
if (*end == '#')
*end = '\0';
value = rstrip(value);
value = strip_quotes(value);
/* Valid name=value pair found, call handler */
if (handler(usercfg, name, value) && !error)
error = lineno;
} else if (!error) {
/* No '=' found on name=value line */
error = lineno;
}
}
}
fclose(fin);
return error;
}
示例5: gadget_print
void gadget_print(gadget_t *gadgets)
{
/* If we're at a leaf node in the tree... */
if (gadgets->previous.head == NULL) {
/* Print instructions from the leaf up to the root as a gadget. */
x86_insn_t instr;
char line[1000];
gadget_t *cursor = gadgets;
while (cursor != NULL) {
x86_disasm(cursor->instr, cursor->instr_len, 0, 0, &instr);
x86_format_insn(&instr, line, sizeof(line), intel_syntax);
rstrip(line);
tab_to_space(line);
printf("0x%08x: %-50s\n", cursor->virtual_address, line);
/* Set cursor to its parent in the tree (closer to the RET). */
cursor = cursor->next;
}
printf("-----------------------\n");
} else {
/* We're not at a leaf, so recursively print all of the children. */
gadget_list_item_t *cursor = gadgets->previous.head;
while (cursor != NULL) {
gadget_print(cursor->gadget);
cursor = cursor->next;
}
}
}
示例6: strip
void strip(
char *s,
const char *delimiters)
{
lstrip(s, delimiters);
rstrip(s, delimiters);
}
示例7: flytec_pbrrts
static void
flytec_pbrrts(flytec_t *flytec)
{
flytec_puts_nmea(flytec, "PBRRTS,");
flytec_expectc(flytec, XOFF);
route_head *route = 0;
char line[128];
while (flytec_gets_nmea(flytec, line, sizeof line)) {
const char *p = line;
p = match_literal(p, "PBRRTS,");
int index = 0, count = 0, routepoint_index = 0;
p = match_unsigned(p, &index);
p = match_char(p, ',');
p = match_unsigned(p, &count);
p = match_char(p, ',');
p = match_unsigned(p, &routepoint_index);
p = match_char(p, ',');
if (!p)
continue;
if (routepoint_index == 0) {
char *name = 0;
p = match_string_until(p, '\0', 0, &name);
p = match_eos(p);
if (p) {
route = route_head_alloc();
route->rte_num = index + 1;
route->rte_name = rstrip(name);
route_add_head(route);
} else {
free(name);
}
} else {
char *name = 0;
p = match_string_until(p, ',', 1, 0);
p = match_string_until(p, '\0', 0, &name);
p = match_eos(p);
if (p) {
const waypoint *w = find_waypt_by_name(rstrip(name));
if (w)
route_add_wpt(route, waypt_dupe(w));
}
free(name);
}
}
flytec_expectc(flytec, XON);
}
示例8: initLemmaLexicon
bool initLemmaLexicon ( const std::string sInputFile )
{
std::ifstream *is;
is = new std::ifstream(sInputFile.c_str());
if ( is->fail() ) return false;
bool bReadSuccessful;
std::string line;
std::string curToken;
getline(*is, line);
while(is && !lstrip(line).empty())
{
std::string form;
std::string lemma;
std::string tag;
std::istringstream iss(rstrip(line));
getline(iss, curToken, '\t');
ASSERT(is && !curToken.empty(), "Not well formatted lexicon data (form not found)");
form = curToken;
//iss = std::istringstream(rstrip(line));
getline(iss, curToken, '\t');
ASSERT(is && !curToken.empty(), "Not well formatted lexicon data (lemma not found)");
lemma = curToken;
if ( lemma == "=" ) lemma = form; //lexicon uses = to represent that lemma equals form
//iss = std::istringstream(rstrip(line));
getline(iss, curToken, '\t');
ASSERT(is && !curToken.empty(), "Not well formatted lexicon data (tag not found)");
tag = curToken;
//add to the word to lemma map
//wordToLemma.insert(form,lemma);
wordToLemma[form]=lemma;
CMorphTag morphTag = lexiconTagToMorphTag(tag);
std::pair<std::string,CMorphTag> wordMorphPair = std::pair<std::string,CMorphTag>(form,morphTag);
wordAndTagToLemma[wordMorphPair] = lemma;
getline(*is, line);
}
is->close();
delete is;
//And we are done.
return true;
}
示例9: lskip
static char *stripquote(char *s)
{
s = lskip(s);
char *p=NULL;
rstrip(s, &p);
p--;
if( ISQUOTE(*s) && ISQUOTE(*p) ) {
s++;
*p = '\0';
}
return s;
}
示例10: LoadExcludes
void LoadExcludes (char ***ex,int *nex,char *filename) {
FILE *fp;
int x;
char **test;
static char s[CCHMAXPATHCOMP + 4];
BOOL temp = fSuspend;
if(!ex ||
!nex ||
!filename)
return;
fSuspend = TRUE;
if(*ex)
FreeExcludes(ex,
nex);
x = 0;
sprintf(s,
"%s%s",
mydir,
filename);
fp = fopen(s,"r");
if(fp) {
while(!feof(fp)) {
if(!fgets(s,
sizeof(s),
fp))
break;
s[sizeof(s) - 1] = 0;
stripcr(s);
lstrip(rstrip(s));
if(*s) {
if(x >= *nex - 1) {
test = realloc(*ex,
sizeof(char *) * (*nex + 2));
if(test)
*ex = test;
else
break;
}
(*ex)[*nex] = strdup(s);
if((*ex)[*nex]) {
(*nex)++;
(*ex)[*nex] = NULL;
}
else
break;
}
}
fclose(fp);
}
fSuspend = temp;
}
示例11: main
/* print longest input line */
int main()
{
int len; /* current line length */
int cursor; /* The current position in the array */
char line[MAXLINE]; /* current input line */
while ((len = getline(line, MAXLINE)) > 0) {
cursor = rstrip(len,line);
if (cursor >= 0)
printf("%s", line);
}
return 0;
}
示例12: main
int main (int argc, char *argv[])
{
char search_for[80];
/* take input from the user and search */
printf("Search for: ");
fgets(search_for, 80, stdin);
rstrip(search_for);
/*find_track(search_for);*/
find_track_regex(search_for);
return 0;
}
示例13: main
void main()
{
char line[MAXLINE];
int length;
while(length = getLine(line, MAXLINE) > 0)
{
printf("input: %s", line);
if (length == 0 && line[0] == '\n')
continue;
rstrip(line);
printf(line);
}
}
示例14: polezero_comment_token
static char *
polezero_comment_token(char *p) {
if(!p) {
return p;
}
p = strchr(p, ':');
if(p) {
p = p + 1;
p = lstrip(p);
p = rstrip(p);
}
return p;
}
示例15: event_init
void
event_init(pmID pmid)
{
char cmd[MAXPATHLEN];
int i, fd;
for (i = 0; i < numlogfiles; i++) {
size_t pathlen = strlen(logfiles[i].pathname);
/*
* We support 2 kinds of PATHNAMEs:
* (1) Regular paths. These paths are opened normally.
* (2) Pipes. If the path ends in '|', the filename is
* interpreted as a command which pipes input to us.
*/
if (logfiles[i].pathname[pathlen - 1] != '|') {
fd = open(logfiles[i].pathname, O_RDONLY|O_NONBLOCK);
if (fd < 0) {
if (logfiles[i].fd >= 0) /* log once only */
__pmNotifyErr(LOG_ERR, "open: %s - %s",
logfiles[i].pathname, strerror(errno));
} else {
if (fstat(fd, &logfiles[i].pathstat) < 0)
if (logfiles[i].fd >= 0) /* log once only */
__pmNotifyErr(LOG_ERR, "fstat: %s - %s",
logfiles[i].pathname, strerror(errno));
lseek(fd, 0, SEEK_END);
}
}
else {
strncpy(cmd, logfiles[i].pathname, sizeof(cmd));
cmd[pathlen - 1] = '\0'; /* get rid of the '|' */
rstrip(cmd); /* Remove all trailing whitespace. */
fd = start_cmd(cmd, &logfiles[i].pid);
if (fd < 0) {
if (logfiles[i].fd >= 0) /* log once only */
__pmNotifyErr(LOG_ERR, "pipe: %s - %s",
logfiles[i].pathname, strerror(errno));
} else {
if (fd > maxfd)
maxfd = fd;
FD_SET(fd, &fds);
}
}
logfiles[i].fd = fd; /* keep file descriptor (or error) */
logfiles[i].pmid = pmid; /* string param metric identifier */
logfiles[i].queueid = pmdaEventNewQueue(logfiles[i].pmnsname, maxmem);
}
}