/********************************************************************** * float_read * * Read an integer value and save it in a variable structure. **********************************************************************/ void float_read(VARIABLE *variable, char *string) { float f; #ifdef EMBEDDED // We have no sscanf with float functionality here *((float *) variable->address) = strtofloat(strip_line (string)); #else sscanf (strip_line (string), "%f", &f); *((float *) variable->address) = f; #endif }
static void read_conf(void) { FILE *fp = fopen(FUSE_CONF, "r"); if (fp != NULL) { int linenum = 1; char line[256]; int isnewline = 1; while (fgets(line, sizeof(line), fp) != NULL) { if (isnewline) { if (strlen(line) && line[strlen(line)-1] == '\n') { strip_line(line); parse_line(line, linenum); } else { isnewline = 0; } } else if(strlen(line) && line[strlen(line)-1] == '\n') { fprintf(stderr, "%s: reading %s: line %i too long\n", progname, FUSE_CONF, linenum); isnewline = 1; } if (isnewline) linenum ++; } if (!isnewline) { fprintf(stderr, "%s: reading %s: missing newline at end of file\n", progname, FUSE_CONF); } fclose(fp); } else if (errno != ENOENT) { fprintf(stderr, "%s: failed to open %s: %s\n", progname, FUSE_CONF, strerror(errno)); } }
/* * Start parsing a new line from the cache. * * line starts with "<device" return 1 -> continue parsing line * line starts with "<foo", empty, or # return 0 -> skip line * line starts with other, return -BLKID_ERR_CACHE -> error */ static int parse_start(char **cp) { char *p; p = strip_line(*cp); /* Skip comment or blank lines. We can't just NUL the first '#' char, * in case it is inside quotes, or escaped. */ if (*p == '\0' || *p == '#') return 0; if (!strncmp(p, "<device", 7)) { DBG(READ, ul_debug("found device header: %8s", p)); p += 7; *cp = p; return 1; } if (*p == '<') return 0; return -BLKID_ERR_CACHE; }
/********************************************************************** * int_read * * Read an integer value and save it in a variable structure. **********************************************************************/ void int_read(VARIABLE *variable, char *string) { char *stripped; int integer; stripped = strip_line (string); /* Add the value */ if (stripped[0] == '+') { scan_int(stripped, integer); *((int *) variable->address) += integer; } else if (stripped[0] == '|') { scan_int(stripped, integer); *((int *) variable->address) = integer | *((int *) variable->address); } /* Subtract the value */ else if (stripped[0] == '_') { scan_int(stripped, integer); *((int *) variable->address) = (~integer) & *((int *) variable->address); } else { /* Set the value */ if (stripped[1] == 'x') { sscanf (&stripped[2], "%x", &integer); } else { sscanf (stripped, "%d", &integer); } *((int *) variable->address) = integer; } }
static errcode_t parse_line(char *line, struct parse_state *state, char **ret_modspec) { char *cp; if (strncmp(line, "include", 7) == 0 && isspace(line[7])) { cp = skip_over_blanks(line + 7); strip_line(cp); return parse_include_file(cp, state->root_section); } if (strncmp(line, "includedir", 10) == 0 && isspace(line[10])) { cp = skip_over_blanks(line + 10); strip_line(cp); return parse_include_dir(cp, state->root_section); } switch (state->state) { case STATE_INIT_COMMENT: if (strncmp(line, "module", 6) == 0 && isspace(line[6])) { /* * If we are expecting a module declaration, fill in *ret_modspec * and return PROF_MODULE, which will cause parsing to abort and * the module to be loaded instead. If we aren't expecting a * module declaration, return PROF_MODULE without filling in * *ret_modspec, which will be treated as an ordinary error. */ if (ret_modspec) { cp = skip_over_blanks(line + 6); strip_line(cp); *ret_modspec = strdup(cp); if (!*ret_modspec) return ENOMEM; } return PROF_MODULE; } if (line[0] != '[') return 0; state->state = STATE_STD_LINE; case STATE_STD_LINE: return parse_std_line(line, state); case STATE_GET_OBRACE: cp = skip_over_blanks(line); if (*cp != '{') return PROF_MISSING_OBRACE; state->state = STATE_STD_LINE; } return 0; }
ANSC_STATUS COSADmlUploadLogsStatus ( ANSC_HANDLE Context, char* pValue, ULONG* pUlSize ) { char uploadStatus[150]; int ret, status; FILE *ptr_file; char buf[50]; snprintf(uploadStatus,sizeof(uploadStatus),"sh /rdklogger/opsLogUpload.sh %s","status"); ret=system(uploadStatus); status=WEXITSTATUS(ret); switch (status) { case 0 : AnscCopyString(pValue, "Not triggered"); *pUlSize = AnscSizeOfString(pValue); break; case 1 : AnscCopyString(pValue, "Triggered"); *pUlSize = AnscSizeOfString(pValue); break; case 2: AnscCopyString(pValue, "In progress"); *pUlSize = AnscSizeOfString(pValue); break; case 3 : AnscCopyString(pValue, "Failed"); *pUlSize = AnscSizeOfString(pValue); break; case 4 : ptr_file =fopen("/nvram/uploadsuccess","r"); if (!ptr_file) break; if (fgets(buf,50, ptr_file)!=NULL) { fclose(ptr_file); strip_line(buf); AnscCopyString(pValue, buf); *pUlSize = AnscSizeOfString(pValue); } break; default : AnscCopyString(pValue, "Not triggered"); *pUlSize = AnscSizeOfString(pValue); break; } return ANSC_STATUS_SUCCESS; }
/*-----------------------------------------------------------------------* * Main routine which takes a string as input and returns a parse string * *-----------------------------------------------------------------------*/ Gal_Frame send_to_parse(Gal_Frame f, void *server_data) { int i, path_score; char *in_string, *out_string, *sysid; Gal_Frame f_new = Gal_MakeFrame("main", GAL_CLAUSE); /* get the input string to parse from the key's value */ in_string = Gal_GetString(f, ":input_string"); sysid = Gal_GetString(f, ":sysid"); path_score = Gal_GetInt(f, ":path_score"); if (in_string == NULL) in_string = Gal_GetString(f, ":parse_input"); /* strip out punctuation, comments, etc, to uppercase */ strip_line(in_string); /* Call Phoenix Parse function */ parse(in_string, gram); /* print parses to buffer */ if( num_parses > MaxParses ) num_parses= MaxParses; if( num_parses < 1 ) { strcpy(outbuf, "No Parse"); } else { out_string= outbuf; for(i= 0; i < num_parses; i++ ) { sprintf(out_string, "PARSE_%d:\n", i); out_string += strlen(out_string); print_parse(i, out_string, extract, gram); out_string += strlen(out_string); sprintf(out_string, "END_PARSE\n"); out_string += strlen(out_string); } sprintf(out_string, "\n"); out_string= outbuf; } /* clear parser temps */ reset(num_nets); /* create a new frame containing the parse */ Gal_SetProp(f_new, ":parse_input", Gal_StringObject(in_string)); Gal_SetProp(f_new, ":parse_output", Gal_StringObject(outbuf)); if (sysid != NULL) Gal_SetProp(f_new, ":sysid", Gal_StringObject(sysid)); if (path_score != 0) Gal_SetProp(f_new, ":path_score", Gal_IntObject(path_score)); /* write parse output frame to HUB */ GalSS_EnvWriteFrame((GalSS_Environment *) server_data, f_new, 0); return(f); }
/* * Extract a tag of the form NAME="value" from the line. */ static int parse_token(char **name, char **value, char **cp) { char *end; if (!name || !value || !cp) return -BLKID_ERR_PARAM; if (!(*value = strchr(*cp, '='))) return 0; **value = '\0'; *name = strip_line(*cp); *value = skip_over_blank(*value + 1); if (**value == '"') { char *p = end = *value + 1; /* convert 'foo\"bar' to 'foo"bar' */ while (*p) { if (*p == '\\') { p++; *end = *p; } else { *end = *p; if (*p == '"') break; } p++; end++; } if (*end != '"') { DBG(READ, ul_debug("unbalanced quotes at: %s", *value)); *cp = *value; return -BLKID_ERR_CACHE; } (*value)++; *end = '\0'; end = ++p; } else { end = skip_over_word(*value); if (*end) { *end = '\0'; end++; } } *cp = end; return 1; }
static int parse_fstab_line(char *line, struct fs_info **ret_fs) { char *dev, *device, *mntpnt, *type, *opts, *freq, *passno, *cp; struct fs_info *fs; *ret_fs = 0; strip_line(line); if ((cp = strchr(line, '#'))) *cp = 0; /* Ignore everything after the comment char */ cp = line; device = parse_word(&cp); mntpnt = parse_word(&cp); type = parse_word(&cp); opts = parse_word(&cp); freq = parse_word(&cp); passno = parse_word(&cp); if (!device) return 0; /* Allow blank lines */ if (!mntpnt || !type) return -1; parse_escape(device); parse_escape(mntpnt); parse_escape(type); parse_escape(opts); parse_escape(freq); parse_escape(passno); dev = blkid_get_devname(cache, device, NULL); if (dev) device = dev; if (strchr(type, ',')) type = 0; fs = create_fs_device(device, mntpnt, type ? type : "auto", opts, freq ? atoi(freq) : -1, passno ? atoi(passno) : -1); if (dev) free(dev); if (!fs) return -1; *ret_fs = fs; return 0; }
/* Process each line from ping command */ void scan_foreach (Netinfo * netinfo, gchar * line, gint len, gpointer user_data) { scan_data data; gint count; g_return_if_fail (netinfo != NULL); g_return_if_fail (line != NULL); count = strip_line (line, &data); if (count == 3) { scan_define_model (netinfo, data); } }
/** Stores a line stripped of comments in the provided string. Returns the length of the line on success, FREESASA_FAIL if malloc/realloc errors. */ static int next_line(char **line, FILE *fp) { char *linebuf = NULL; size_t len = 0; int ret; ret = getline(&linebuf,&len,fp); if (ret >= 0) ret = strip_line(line,linebuf); else ret = FREESASA_FAIL; free(linebuf); return ret; }
static int parse_fstab_line(char *line, struct fs_info **ret_fs) { char *device, *mntpnt, *type, *opts, *freq, *passno, *cp; struct fs_info *fs; *ret_fs = 0; strip_line(line); if ((cp = strchr(line, '#'))) *cp = 0; /* Ignore everything after the comment char */ cp = line; device = parse_word(&cp); mntpnt = parse_word(&cp); type = parse_word(&cp); opts = parse_word(&cp); freq = parse_word(&cp); passno = parse_word(&cp); if (!device) return 0; /* Allow blank lines */ if (!mntpnt || !type) return -1; if (!(fs = malloc(sizeof(struct fs_info)))) return -1; fs->device = string_copy(device); fs->mountpt = string_copy(mntpnt); fs->type = string_copy(type); fs->opts = string_copy(opts ? opts : ""); fs->freq = freq ? atoi(freq) : -1; fs->passno = passno ? atoi(passno) : -1; fs->flags = 0; fs->next = NULL; *ret_fs = fs; return 0; }
static long parse_line(char *line, struct parse_state *state) { char *cp, ch, *tag, *value; char *p; long retval; struct profile_node *node; int do_subsection = 0; void *iter = 0; state->line_num++; if (state->state == STATE_GET_OBRACE) { cp = skip_over_blanks(line); if (*cp != '{') return PROF_MISSING_OBRACE; state->state = STATE_STD_LINE; return 0; } if (state->state == STATE_INIT_COMMENT) { if (line[0] != '[') return 0; state->state = STATE_STD_LINE; } if (*line == 0) return 0; strip_line(line); cp = skip_over_blanks(line); ch = *cp; if (end_or_comment(ch)) return 0; if (ch == '[') { if (state->group_level > 0) return PROF_SECTION_NOTOP; cp++; cp = skip_over_blanks(cp); p = strchr(cp, ']'); if (p == NULL) return PROF_SECTION_SYNTAX; if (*cp == '"') { cp++; parse_quoted_string(cp); } else { *p-- = '\0'; while (isspace(*p) && (p > cp)) *p-- = '\0'; if (*cp == 0) return PROF_SECTION_SYNTAX; } retval = profile_find_node(state->root_section, cp, 0, 1, &iter, &state->current_section); if (retval == PROF_NO_SECTION) { retval = profile_add_node(state->root_section, cp, 0, &state->current_section); if (retval) return retval; } else if (retval) return retval; /* * Finish off the rest of the line. */ cp = p+1; if (*cp == '*') { state->current_section->final = 1; cp++; } /* * Spaces or comments after ']' should not be fatal */ cp = skip_over_blanks(cp); if (!end_or_comment(*cp)) return PROF_SECTION_SYNTAX; return 0; }
void parse_finit_conf(char *file) { FILE *fp; char line[LINE_SIZE]; char cmd[CMD_SIZE]; username = strdup(DEFUSER); hostname = strdup(DEFHOST); rcsd = strdup(FINIT_RCSD); if ((fp = fopen(file, "r")) != NULL) { char *x; const char *err = NULL; _d("Parse %s ...", file); while (!feof(fp)) { if (!fgets(line, sizeof(line), fp)) continue; chomp(line); _d("conf: %s", line); /* Skip comments. */ if (MATCH_CMD(line, "#", x)) continue; /* Do this before mounting / read-write * XXX: Move to plugin which checks /etc/fstab instead */ if (MATCH_CMD(line, "check ", x)) { char *dev = strip_line(x); strcpy(cmd, "/sbin/fsck -C -a "); strlcat(cmd, dev, sizeof(cmd)); run_interactive(cmd, "Checking file system %s", dev); continue; } if (MATCH_CMD(line, "user ", x)) { if (username) free(username); username = strdup(strip_line(x)); continue; } if (MATCH_CMD(line, "host ", x)) { if (hostname) free(hostname); hostname = strdup(strip_line(x)); continue; } if (MATCH_CMD(line, "module ", x)) { char *mod = strip_line(x); strcpy(cmd, "/sbin/modprobe "); strlcat(cmd, mod, sizeof(cmd)); run_interactive(cmd, "Loading kernel module %s", mod); continue; } if (MATCH_CMD(line, "mknod ", x)) { char *dev = strip_line(x); strcpy(cmd, "/bin/mknod "); strlcat(cmd, dev, sizeof(cmd)); run_interactive(cmd, "Creating device node %s", dev); continue; } if (MATCH_CMD(line, "network ", x)) { if (network) free(network); network = strdup(strip_line(x)); continue; } if (MATCH_CMD(line, "runparts ", x)) { if (rcsd) free(rcsd); rcsd = strdup(strip_line(x)); continue; } if (MATCH_CMD(line, "startx ", x)) { svc_register(SVC_CMD_SERVICE, strip_line(x), username); continue; } if (MATCH_CMD(line, "shutdown ", x)) { if (sdown) free(sdown); sdown = strdup(strip_line(x)); continue; } /* The desired runlevel to start when leaving * bootstrap (S). Finit supports 1-9, but most * systems only use 1-6, where 6 is reserved for * reboot */ if (MATCH_CMD(line, "runlevel ", x)) { char *token = strip_line(x); cfglevel = strtonum(token, 1, 9, &err); if (err) cfglevel = RUNLEVEL; if (cfglevel < 1 || cfglevel > 9 || cfglevel == 6) cfglevel = 2; /* Fallback */ continue; } /* Monitored daemon, will be respawned on exit, as * long as the (optional) service callback returns * non-zero */ if (MATCH_CMD(line, "service ", x)) { svc_register(SVC_CMD_SERVICE, x, NULL); continue; } /* One-shot task, will not be respawned. Only runs if * the (optional) service callback returns true */ if (MATCH_CMD(line, "task ", x)) { svc_register(SVC_CMD_TASK, x, NULL); continue; } /* Like task but waits for completion, useful w/ [S] */ if (MATCH_CMD(line, "run ", x)) { svc_register(SVC_CMD_RUN, x, NULL); continue; } if (MATCH_CMD(line, "console ", x)) { if (console) free(console); console = strdup(strip_line(x)); continue; } if (MATCH_CMD(line, "tty ", x)) { tty_register(strip_line(x)); continue; } } fclose(fp); } }
static void parse_static(char *line) { char *x; char cmd[CMD_SIZE]; /* Do this before mounting / read-write * XXX: Move to plugin which checks /etc/fstab instead */ if (MATCH_CMD(line, "check ", x)) { char *dev = strip_line(x); strcpy(cmd, "/sbin/fsck -C -a "); strlcat(cmd, dev, sizeof(cmd)); run_interactive(cmd, "Checking file system %s", dev); return; } if (MATCH_CMD(line, "user ", x)) { if (username) free(username); username = strdup(strip_line(x)); return; } if (MATCH_CMD(line, "host ", x)) { if (hostname) free(hostname); hostname = strdup(strip_line(x)); return; } if (MATCH_CMD(line, "module ", x)) { char *mod = strip_line(x); strcpy(cmd, "/sbin/modprobe "); strlcat(cmd, mod, sizeof(cmd)); run_interactive(cmd, "Loading kernel module %s", mod); return; } if (MATCH_CMD(line, "mknod ", x)) { char *dev = strip_line(x); strcpy(cmd, "/bin/mknod "); strlcat(cmd, dev, sizeof(cmd)); run_interactive(cmd, "Creating device node %s", dev); return; } if (MATCH_CMD(line, "network ", x)) { if (network) free(network); network = strdup(strip_line(x)); return; } if (MATCH_CMD(line, "runparts ", x)) { if (runparts) free(runparts); runparts = strdup(strip_line(x)); return; } if (MATCH_CMD(line, "include ", x)) { char *file = strip_line(x); strlcpy(cmd, file, sizeof(cmd)); if (!fexist(cmd)) { _e("Cannot find include file %s, absolute path required!", x); return; } parse_conf(cmd); return; } if (MATCH_CMD(line, "startx ", x)) { service_register(SVC_TYPE_SERVICE, strip_line(x), 0, username); return; } if (MATCH_CMD(line, "shutdown ", x)) { if (sdown) free(sdown); sdown = strdup(strip_line(x)); return; } /* The desired runlevel to start when leaving bootstrap (S). * Finit supports 1-9, but most systems only use 1-6, where * 6 is reserved for reboot */ if (MATCH_CMD(line, "runlevel ", x)) { char *token = strip_line(x); const char *err = NULL; cfglevel = strtonum(token, 1, 9, &err); if (err) cfglevel = RUNLEVEL; if (cfglevel < 1 || cfglevel > 9 || cfglevel == 6) cfglevel = 2; /* Fallback */ return; } /* TODO: Make console & tty dynamically loadable from /etc/finit.d */ if (MATCH_CMD(line, "console ", x)) { if (console) free(console); console = strdup(strip_line(x)); return; } /* TODO: Make console & tty dynamically loadable from /etc/finit.d */ if (MATCH_CMD(line, "tty ", x)) { tty_register(strip_line(x)); return; } }
/********************************************************************** * string_read * * Read an integer value and save it in a variable structure. **********************************************************************/ void string_read(VARIABLE *variable, char *string) { char *value; value = strsave (strip_line (string)); *((char **) variable->address) = value; }
static errcode_t parse_std_line(char *line, struct parse_state *state) { char *cp, ch, *tag, *value; char *p; errcode_t retval; struct profile_node *node; int do_subsection = 0; void *iter = 0; if (*line == 0) return 0; cp = skip_over_blanks(line); if (cp[0] == ';' || cp[0] == '#') return 0; strip_line(cp); ch = *cp; if (ch == 0) return 0; if (ch == '[') { if (state->group_level > 0) return PROF_SECTION_NOTOP; cp++; p = strchr(cp, ']'); if (p == NULL) return PROF_SECTION_SYNTAX; *p = '\0'; retval = profile_find_node_subsection(state->root_section, cp, &iter, 0, &state->current_section); if (retval == PROF_NO_SECTION) { retval = profile_add_node(state->root_section, cp, 0, &state->current_section); if (retval) return retval; } else if (retval) return retval; /* * Finish off the rest of the line. */ cp = p+1; if (*cp == '*') { profile_make_node_final(state->current_section); cp++; } /* * A space after ']' should not be fatal */ cp = skip_over_blanks(cp); if (*cp) return PROF_SECTION_SYNTAX; return 0; } if (ch == '}') { if (state->group_level == 0) return PROF_EXTRA_CBRACE; if (*(cp+1) == '*') profile_make_node_final(state->current_section); retval = profile_get_node_parent(state->current_section, &state->current_section); if (retval) return retval; state->group_level--; return 0; } /* * Parse the relations */ tag = cp; cp = strchr(cp, '='); if (!cp) return PROF_RELATION_SYNTAX; if (cp == tag) return PROF_RELATION_SYNTAX; *cp = '\0'; p = tag; /* Look for whitespace on left-hand side. */ while (p < cp && !isspace((int)*p)) p++; if (p < cp) { /* Found some sort of whitespace. */ *p++ = 0; /* If we have more non-whitespace, it's an error. */ while (p < cp) { if (!isspace((int)*p)) return PROF_RELATION_SYNTAX; p++; } } cp = skip_over_blanks(cp+1); value = cp; if (value[0] == '"') { value++; parse_quoted_string(value); } else if (value[0] == 0) { do_subsection++; state->state = STATE_GET_OBRACE; } else if (value[0] == '{' && *(skip_over_blanks(value+1)) == 0) do_subsection++; else { cp = value + strlen(value) - 1; while ((cp > value) && isspace((int) (*cp))) *cp-- = 0; } if (do_subsection) { p = strchr(tag, '*'); if (p) *p = '\0'; retval = profile_add_node(state->current_section, tag, 0, &state->current_section); if (retval) return retval; if (p) profile_make_node_final(state->current_section); state->group_level++; return 0; } p = strchr(tag, '*'); if (p) *p = '\0'; profile_add_node(state->current_section, tag, value, &node); if (p) profile_make_node_final(node); return 0; }
void ping_foreach_with_tree (Netinfo * netinfo, gchar * line, gint len, gpointer user_data) { GtkTreeIter iter; GList *columns; GtkTreePath *path; GtkTreeModel *model; GtkTreeView *widget; gint count; ping_data data; gdouble rtt; GtkLabel *min, *avg, *max, *pkt_transmitted, *pkt_received, *pkt_success; gchar stmp[128]; g_return_if_fail (netinfo != NULL); g_return_if_fail (line != NULL); widget = (GTK_TREE_VIEW (netinfo->output)); min = GTK_LABEL (netinfo->min); avg = GTK_LABEL (netinfo->avg); max = GTK_LABEL (netinfo->max); pkt_transmitted = GTK_LABEL (netinfo->packets_transmitted); pkt_received = GTK_LABEL (netinfo->packets_received); pkt_success = GTK_LABEL (netinfo->packets_success); if (len > 0) { /* there are data to show */ count = strip_line (line, &data, netinfo); if ((count == 5) || (count == 7)) { /* Creation of GtkTreeView */ gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (widget), TRUE); columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (widget)); if (g_list_length (columns) == 0) { model = ping_create_model (widget); gtk_tree_view_set_model (GTK_TREE_VIEW (widget), model); } g_list_free (columns); model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); gtk_tree_view_get_cursor (GTK_TREE_VIEW (widget), &path, NULL); #ifdef DEBUG g_print ("%d %s %d %d %s %s\n", data.bytes, data.ip, data.icmp_seq, data.ttl, data.srtt, data.unit); #endif /* DEBUG */ gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, BYTES_COLUMN, data.bytes, IP_COLUMN, data.ip, ICMP_SEQ_COLUMN, data.icmp_seq, SRTT_COLUMN, data.srtt, UNIT_COLUMN, data.unit, -1); gtk_tree_view_set_model (GTK_TREE_VIEW (widget), model); if (path) { gtk_tree_view_set_cursor ( GTK_TREE_VIEW (widget), path, NULL, FALSE); gtk_tree_path_free (path); } rtt = g_ascii_strtod (data.srtt, NULL); rttmin = (rttmin > 0.0) ? MIN (rttmin, rtt) : rtt; rttmax = MAX (rttmax, rtt); if (data.icmp_seq == 0 || rttavg == 0.0) { rttavg = rtt; } else { rttavg = (rttavg * data.icmp_seq + rtt) / (data.icmp_seq + 1.0); } /* Beep if user selected to */ if (netinfo->has_beep) { gdk_beep (); }; /* ICMP SEQuence tarts at 0, but we need to calculate it as count */ packets_transmitted = data.icmp_seq + 1; packets_received++; gtk_label_set_text (min, g_ascii_formatd (stmp, 128, "%0.2f", rttmin)); gtk_label_set_text (avg, g_ascii_formatd (stmp, 128, "%0.2f", rttavg)); gtk_label_set_text (max, g_ascii_formatd (stmp, 128, "%0.2f", rttmax)); #ifdef DEBUG g_print ("min/avg/max: %0.2f/%0.2f/%0.2f", rttmin, rttavg, rttmax); g_print ("\npackets received: %d\n", packets_received); #endif /* DEBUG */ } else if (g_strrstr (line, "packets transmitted")) { count = strip_total_line (line, &packets_transmitted); } if (packets_transmitted == 0) { packets_success = 0; } else { packets_success = ((float) packets_received / packets_transmitted * 100); } g_sprintf (stmp, "%d", packets_transmitted); gtk_label_set_text (pkt_transmitted, stmp); g_sprintf (stmp, "%d", packets_received); gtk_label_set_text (pkt_received, stmp); g_sprintf (stmp, "%d%%", packets_success); gtk_label_set_text (pkt_success, stmp); } gtk_widget_queue_draw (netinfo->graph); }