本文整理汇总了C++中process_line函数的典型用法代码示例。如果您正苦于以下问题:C++ process_line函数的具体用法?C++ process_line怎么用?C++ process_line使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了process_line函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spnl
void nl_convert_spice_t::convert(const pstring &contents)
{
std::vector<pstring> spnl(plib::psplit(contents, "\n"));
// Add gnd net
// FIXME: Parameter
out("NETLIST_START(dummy)\n");
add_term("0", "GND");
pstring line = "";
for (const auto &i : spnl)
{
// Basic preprocessing
pstring inl = plib::ucase(plib::trim(i));
if (plib::startsWith(inl, "+"))
line = line + inl.substr(1);
else
{
process_line(line);
line = inl;
}
}
process_line(line);
dump_nl();
// FIXME: Parameter
out("NETLIST_END()\n");
}
示例2: spnl
void nl_convert_spice_t::convert(const pstring &contents)
{
pstring_vector_t spnl(contents, "\n");
// Add gnd net
// FIXME: Parameter
out("NETLIST_START(dummy)\n");
add_term("0", "GND");
pstring line = "";
for (std::size_t i=0; i < spnl.size(); i++)
{
// Basic preprocessing
pstring inl = spnl[i].trim().ucase();
if (inl.startsWith("+"))
line = line + inl.substr(1);
else
{
process_line(line);
line = inl;
}
}
process_line(line);
dump_nl();
// FIXME: Parameter
out("NETLIST_END()\n");
}
示例3: compile_shader_mem
void compile_shader_mem(void *data, int len) {
char line[256];
memset(&line,0,sizeof(line));
int i =0;
char c;
char *p = (char *)data;
while((len-- > 0) && (c = (char)*p++)) {
if(c == 0) {
line[i] = 0;
if(line[0] != '#' || line[0] == ';')
process_line(line);
//printf("Last line: %s\n",line);
break;
} else if(c == '\t' || c=='\r') {
} else if(c == '\n') {
line[i] = 0;
i = 0;
if(line[0] != '#' || line[0] == ';')
process_line(line);
//printf("Parse line: %s\n",line);
}else {
line[i++] = c;
}
}
}
示例4: process
/*
* Open the file and initiate recursive processing.
*/
static int
process(const char *fname) {
char buf[8192];
char *collector = 0;
size_t collector_size = sizeof(buf);
size_t collector_offset = 0;
int lineno = 0;
FILE *fp;
if(strcmp(fname, "-")) {
fp = fopen(fname, "r");
if(!fp) {
perror(fname);
return -1;
}
} else {
fp = stdin;
}
while(fgets(buf, sizeof(buf), fp) || !feof(fp)) {
size_t len = strlen(buf);
if(!len) continue;
if(collector_offset || buf[len - 1] != '\n') {
if((collector_size - collector_offset) <= len || !collector) {
collector_size <<= 1;
collector = REALLOC(collector, collector_size);
if(!collector) {
perror("realloc()");
exit(EX_OSERR);
}
}
memcpy(collector + collector_offset, buf, len + 1);
collector_offset += len;
}
if(buf[len - 1] != '\n') continue;
if(collector_offset) {
assert(collector[collector_offset - 1] == '\n');
process_line(fname, collector, ++lineno);
collector_offset = 0;
} else {
process_line(fname, buf, ++lineno);
}
}
if(fp != stdin) fclose(fp);
return 0;
}
示例5: while
void unix_console_connection::process_input(int len) {
int st = 0;
while (st < len) {
int i;
for (i = st; i < len; i++) {
if (buffer[i] == '\n' || buffer[i] == ';' || buffer[i] == '?') {
break;
}
}
if (buffer[i] == '?') {
//std::string in((const char *)buffer + st, i - st);
std::string in((const char *)buffer + st, (i + 1) - st);
dump_partial(in.c_str());
} else if ((i - st) > 0) {
if (buffer[i] == '\n')
i--;
std::string in((const char *)buffer + st, i - st);
process_line(in.c_str());
}
st = i + 1;
}
if (autoclose) {
if (bufbuffer.empty())
console->release_connection(this);
else
doom();
}
}
示例6: DEFINE_CMD_MAIN
DEFINE_CMD_MAIN(filecmd,int argc,TCHAR** argv) {
int i;
TCHAR* fn;
FILE* fp;
for(i=1;i<argc;i++) {
fn=argv[i];
if(_tcscmp(fn,TEXT("-"))==0)
fp=stdin;
else {
fp=_tfopen(fn,TEXT("r"));
}
if(fp) {
TCHAR* line = malloc(MAX_ARG_LENGTH*sizeof(TCHAR)+1);
int l=0;
DEBUG_PRINT(TEXT("reading file %s\n"),fn);
while((l=fgetline(line,MAX_ARG_LENGTH,fp))!=-1) {
if(l==0)
continue;
if(!process_line(APPNAME,line))
break;
}
fclose(fp);
}
else {
fprintf(stderr,TEXT("File not accessable:\"%s\"\n"),fn);
}
}
return 0;
}
示例7: process_file
static int process_file(const char *fname)
{
FILE *fp;
int linenum = 0, err = 0;
char linebuf[256];
fp = fopen(fname, "r");
if (!fp) {
err = ERR_FILE_NOT_FOUND;
goto ret;
}
while (fgets(linebuf, sizeof(linebuf), fp)) {
++linenum;
err = process_line(linebuf);
if (err) {
fprintf(stderr, "error at line %d: ", linenum);
break;
}
}
ret:
if (fp) fclose(fp);
return err;
}
示例8: do_connection
/* process a single client connection */
static void do_connection(mysocket_t sd)
{
char line[256];
int rc;
/* loop over:
- get a request from the client
- process the request
*/
for (;;)
{
rc = get_nvt_line(sd, line);
if (rc < 0 || !*line)
goto done;
fprintf(stderr, "client: %s\n", line);
if (process_line(sd, line) < 0)
{
perror("process_line");
goto done;
}
} /* for (;;) */
done:
if (myclose(sd) < 0)
{
perror("myclose (sd)");
}
}
示例9: set_read
void set_read(const char *filename)
{
FILE *fp;
char line[4096];
if (config_file_has_been_read) {
warn("%s(): trying to read config file again", __func__);
return;
}
config_file_has_been_read = 1;
fp = fopen(filename, "r");
if (!fp) {
warn("could not open file %s", filename);
return;
}
while (fgets(line, sizeof(line), fp)) {
char *p;
if (line[0] == '\0')
continue;
p = strrchr(line, '\n');
if (!p)
continue;
*p = '\0';
process_line(line);
}
fclose(fp);
}
示例10: my_parsefile
/*
** Write the header of the file (minus the prog size)
** init the linked lists storing label definition and reference
** Read every line of the file fd_champ,
** split them into a word tab and send them
** to process_line
** Then launch late_operation
** if any error is encountered during these operations,
** return -1, else return 0
*/
int my_parsefile(int fd_champ, int fd_binary)
{
char *line;
char **lexed_line;
int j;
int fileoffset;
t_lateinfo info;
my_init_info(&info);
if ((fileoffset = write_header(fd_champ, fd_binary)) == -1)
return (-1);
j = 1;
while ((line = get_next_line(fd_champ)) != NULL)
{
if (line[0] != COMMENT_CHAR && line[0] != '.' && line[0] && line[0])
{
if ((lexed_line = my_epur(all_in_tab(line))) == NULL
|| process_line(lexed_line, fd_binary, &fileoffset, &info) == -1)
{
my_fprintf(2, "at line %i : \"%s\" ", j, line);
return (-1);
}
}
free(line);
++j;
}
return (late_operation(fd_binary, fileoffset, &info));
}
示例11: user_marker_info
static void user_marker_info(char *fname)
{
int idx;
char *buf;
const char *msg;
FILE *ins;
ins = fopen(fname, "r");
if (ins == NULL)
{
warning("unable to open marker info file");
return;
}
idx = 1;
buf = (char *) malloc(MaxLineLen);
assert(buf != NULL);
while (get_line(ins, buf, MaxLineLen, &msg) != NULL)
{
if (msg != NULL)
{
fflush(stdout);
fprintf(stderr, "%s, line %d: %s\n", fname, idx, msg);
fprintf(stderr, " (length = %d)\n", (int) strlen(buf));
fflush(stderr);
}
process_line(buf, fname, idx);
idx += 1;
}
free(buf);
fclose(ins);
}
示例12: risin_processf
int
risin_processf( fields *risin, char *p, char *filename, long nref )
{
newstr tag, data;
newstr_init( &tag );
newstr_init( &data );
while ( *p ) {
if ( risin_istag( p ) ) {
p = process_line( &tag, &data, p );
/* no anonymous fields allowed */
/* if ( tag.len && data.len )*/
if ( tag.len )
fields_add( risin, tag.data, data.data, 0 );
} else {
p = process_line2( &tag, &data, p );
if ( data.len && risin->nfields>0 ) {
newstr *od;
od = &(risin->data[risin->nfields-1] );
newstr_addchar( od, ' ' );
newstr_strcat( od, data.data );
}
}
newstr_empty( &tag );
newstr_empty( &data );
}
newstr_free( &tag );
newstr_free( &data );
return 1;
}
示例13: load_lines
/** Get the lines and boundaries from the map and load them in an array
*/
void load_lines(struct Map_info *map, struct Point **points, int *num_points,
struct Line **lines, int *num_lines)
{
int index_line = 0;
int index_point = 0;
struct line_pnts *sites;
struct line_cats *cats;
int cat = 0;
int type;
sites = Vect_new_line_struct();
cats = Vect_new_cats_struct();
while ((type = Vect_read_next_line(map, sites, cats)) > -1) {
if (type != GV_LINE && type != GV_BOUNDARY && type != GV_POINT)
continue;
if (type == GV_LINE)
process_line(sites, points, &index_point, lines, &index_line, -1);
else if (type == GV_BOUNDARY)
process_boundary(sites, points, &index_point, lines, &index_line,
cat++);
else if (type == GV_POINT)
process_point(sites, points, &index_point, -1);
}
*num_points = index_point;
*num_lines = index_line;
Vect_destroy_line_struct(sites);
Vect_destroy_cats_struct(cats);
}
示例14: make_repl
void *connection_handler(void *socket_desc) {
repl_t *repl = make_repl();
repl->current_prompt = form_prompt(repl->current_ns, false);
repl->session_id = ++session_id_counter;
int sock = *(int *) socket_desc;
ssize_t read_size;
char client_message[4096];
write(sock, repl->current_prompt, strlen(repl->current_prompt));
while ((read_size = recv(sock, client_message, 4095, 0)) > 0) {
sock_to_write_to = sock;
cljs_set_print_sender(&socket_sender);
client_message[read_size] = '\0';
process_line(repl, strdup(client_message));
cljs_set_print_sender(NULL);
sock_to_write_to = 0;
write(sock, repl->current_prompt, strlen(repl->current_prompt));
}
free(socket_desc);
return NULL;
}
示例15: main
/* main program controls all the action
*/
int
main(int argc, char *argv[]) {
int fileinput=0;
command_t comd;
csv_t D;
/* first argument on commandline is the data file name */
read_csv_file(argv[1], &D);
/* second argument, if it exists, is file of input commands */
if (argc==3) {
fileinput = 1;
reassign_input(argv[2]);
}
/* start the main execution loop */
print_prompt();
while (read_command(&comd, fileinput, D.ncols)) {
process_line(&comd, &D);
/* then round we go */
print_prompt();
}
/* all done, so pack up and go home */
printf("bye\n");
return 0;
}