Ejemplo n.º 1
0
int
refresh_proc_net_snmp(proc_net_snmp_t *snmp)
{
    char	buf[MAXPATHLEN];
    char	header[1024];
    FILE	*fp;

    init_refresh_proc_net_snmp(snmp);
    if ((fp = linux_statsfile("/proc/net/snmp", buf, sizeof(buf))) == NULL)
	return -oserror();
    while (fgets(header, sizeof(header), fp) != NULL) {
	if (fgets(buf, sizeof(buf), fp) != NULL) {
	    if (strncmp(buf, "Ip:", 3) == 0)
		get_fields(ip_fields, header, buf);
	    else if (strncmp(buf, "Icmp:", 5) == 0)
		get_fields(icmp_fields, header, buf);
	    else if (strncmp(buf, "IcmpMsg:", 8) == 0)
		get_ordinal_fields(icmpmsg_fields, header, buf,
                                   NR_ICMPMSG_COUNTERS);
	    else if (strncmp(buf, "Tcp:", 4) == 0)
		get_fields(tcp_fields, header, buf);
	    else if (strncmp(buf, "Udp:", 4) == 0)
		get_fields(udp_fields, header, buf);
	    else if (strncmp(buf, "UdpLite:", 8) == 0)
		get_fields(udplite_fields, header, buf);
	    else
	    	fprintf(stderr, "Error: unrecognised snmp row: %s", buf);
	}
    }
    fclose(fp);
    return 0;
}
Ejemplo n.º 2
0
int get_code(unsigned* pycbuf, struct code_obj* pobj, int cur, int size)
{
    int func_idx = 0;
    int op_arg = 0;
    int num_obj = 1;
    int dealt = 0;
    int len = length(pycbuf, cur-5);
    int end = cur + len;
    while (cur < end-1 && !(cur >= size)) {
        if(!(callable(cur, pycbuf))) {
            field_add(&(pobj->code), pycbuf[cur]);
            if (have_arg(pycbuf[cur])) {
                op_arg = get_op_arg(pycbuf, cur);
                field_add(&(pobj->code), op_arg);
                cur += 3;
            } else {
                cur += 1; 
            }
        } else {
            //printf("****:dealing function\n");
            dealt = find_next_callable(pycbuf, cur, num_obj);
            struct code_obj* pnew_obj = malloc(sizeof(*pnew_obj));
            func_idx = get_fields(pycbuf, pnew_obj, dealt, size); /* get fields of the entire code object */
            objects[func_idx]->val.pobj =  pnew_obj;
            objects[func_idx]->type =  TYPE_CODE;
            num_obj++;
            cur += 9; 
        }
    }
    field_add(&(pobj->code), pycbuf[cur]);
    return cur+1; 
}
Ejemplo n.º 3
0
/**
 * 打印结果
 */
int
print_result(){
	int i;
	while ((g_row = mysql_fetch_row(g_res))) {
		for(i=0; i<get_fields(); i++){
			printf("%s\t", g_row[i]);
		}
		printf("\n");
	}
	return i;
}
Ejemplo n.º 4
0
/*
  get_columns - Get a list of the columns (fields)

  This method returns an instance of the column_names structure
  that contains an array of fields.

  Note: you should call free_columns_buffer() after consuming
        the field data to free memory.
*/
column_names *MySQL_Cursor::get_columns() {
  free_columns_buffer();
  free_row_buffer();
  num_cols = 0;
  if (get_fields()) {
    columns_read = true;
    return &columns;
  }
  else {
    return NULL;
  }
}
Ejemplo n.º 5
0
int
refresh_proc_net_netstat(proc_net_netstat_t *netstat)
{
    /* Need a sufficiently large value to hold a full line */
    char	buf[MAXPATHLEN];
    char	header[2048];
    FILE	*fp;

    init_refresh_proc_net_netstat(netstat);
    if ((fp = linux_statsfile("/proc/net/netstat", buf, sizeof(buf))) == NULL)
	return -oserror();
    while (fgets(header, sizeof(header), fp) != NULL) {
	if (fgets(buf, sizeof(buf), fp) != NULL) {
	    if (strncmp(buf, "IpExt:", 6) == 0)
		get_fields(netstat_ip_fields, header, buf);
	    else if (strncmp(buf, "TcpExt:", 7) == 0)
		get_fields(netstat_tcp_fields, header, buf);
	    else
		__pmNotifyErr(LOG_ERR, "Unrecognised netstat row: %s\n", buf);
	}
    }
    fclose(fp);
    return 0;
}
Ejemplo n.º 6
0
int get_line(FILE **input, char *field1, char *field2, char *field3,
		char *field4, char *field5, char *field6, char *field7, char *type)
{
	char input_str[100], *strptr;
	int num_fields, i;
    sd_long len;

	for (i = 0; i < 100; i++)
		input_str[i] = '\0';

	len = 0;
	input_str[0] = '*';

	/*  test for and skip over empty lines and comments  */
	while (len <= 1 || input_str[0] == '*')
	{
		strptr = fgets(input_str, 100, *input);
		if (strptr == NULL)
		{
			return 0;
		}

		len = strlen(input_str);
	}

	/*  identify type of input string (title or field)  */
	if (input_str[0] >= '0' && input_str[0] <= 'Z')
	{
		num_fields = title(input_str, field1, field2);
		type[0] = 't'; /* input string is title string */
	}
	else
	{
		num_fields = get_fields(input_str, field1, field2, field3, field4,
				field5, field6, field7);
		type[0] = 'f'; /* input string is field string */
	}

	return (num_fields);
}
Ejemplo n.º 7
0
/**
 * 根据位置查询文件信息
 */
int
query_file_by_curr_location(char* diskName,char* dirId,char *start_ra, char *end_ra, char *start_dec, char *end_dec){

	char sql[MAX_BUF_SIZE];
	memset(sql, 0, sizeof(sql));
	sprintf(sql, "SELECT * FROM `file_info` Where ra_val >= '%s' AND ra_val <= '%s' AND dec_val >= '%s' AND dec_val <= '%s' AND disk_name = '%s' AND directory_id = '%s'",
			start_ra, end_ra, start_dec, end_dec,diskName,dirId);

	if (mysql_query(g_conn, sql)){
		 print_mysql_error(NULL);
	}

	g_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,mysql_use_result直接使用服务器上的记录集
    print_result();
    free_result();

    memset(sql,0,sizeof(sql));
    sprintf(sql,"SELECT directory_id FROM 'directory_info' WHERE disk_name = '%s' AND parent_id = '%s'",diskName,dirId);

    if(mysql_query(g_conn,sql)){
    	print_mysql_error(NULL);
    }

    g_res = mysql_store_result(g_conn);

    int i;
    char* childId = (char*)malloc(MAX_BUF_SIZE);

    while((g_row = mysql_fetch_row(g_res)))
    {
    	for(i = 0; i < get_fields(g_res); i++)
    	{
    		memset(childId,0,sizeof(childId));
    		sprintf(childId,"%s",g_row[i]);
    		query_file_by_curr_location(diskName,childId,start_ra,end_ra,start_dec,end_dec);
    	}
    }

	return EXIT_SUCCESS;
}
Ejemplo n.º 8
0
VOID edit_box(LONG tree, WORD sobj)
{
	LONG	obspec; 
	WORD	where, type, exitobj, ok, nilok;
	BYTE	name[9], text[2], bxchar;
	GRECT	p;

	if (rcs_state != ALRT_STATE)
	{
		get_fields(tree, sobj, &type, &obspec, &p);

		ini_tree(&tree, BOXDIAL);
		where = set_obname(tree, BOXNAME, name, ad_view, sobj);
		if ( where != NIL && tree_view() && tree_kind( get_kind(where)) )
			nilok = FALSE;
		else
			nilok = TRUE;
		bxchar = LHIBT(LHIWD(LLGET(obspec)));
		set_text(tree, OCHRITEM, (LONG)ADDR(&text[0]), 2);
		text[0] = bxchar? bxchar: '@';
		text[1] = '\0';

		do {
			exitobj = hndl_dial(tree, OCHRITEM, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while (ok && !name_ok(name, where, nilok));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			bxchar = (text[0] == '@')? '\0': text[0];
			LLSET(obspec, (LLGET(obspec) & 0xffffffL) | 
				((LONG) ((UWORD) bxchar) << 24));
		}
	}
}
Ejemplo n.º 9
0
/**
 * 获取文件ID
 */
char*
get_file_id(char *fileName, char *dirName, char *diskName){

	char sql[MAX_BUF_SIZE];
	memset(sql, 0, sizeof(sql));
	sprintf(sql, "SELECT file_id FROM `file_info` Where file_name = '%s' AND directory_name = '%s' AND disk_name = '%s'", fileName, dirName, diskName);

	if (mysql_query(g_conn, sql)){
		 print_mysql_error(NULL);
	}

	g_res = mysql_store_result(g_conn); // 从服务器传送结果集至本地,mysql_use_result直接使用服务器上的记录集

	char *file_id = (char *) malloc(MAX_BUF_SIZE);
	int i;
	while ((g_row = mysql_fetch_row(g_res))) {
		for(i=0; i<get_fields(); i++){
			sprintf(file_id, "%s", g_row[i]);   //获取目录ID
		}
	}

	return file_id;
}
Ejemplo n.º 10
0
gint
main (gint argc, gchar * argv[])
{

#ifdef ENABLE_NLS
        setlocale (LC_ALL, "");
        bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
        textdomain (GETTEXT_PACKAGE);
#endif

        if (!splashy_init_config (SPL_CONFIG_FILE))
        {
                ERROR_PRINT ("%s",
                             _("Error occured while starting Splashy\n"
                               "Make sure that you can read Splashy's configuration file\n"));
                return RETURN_ERROR;
        }
        g_set_prgname (PROGNAME);

        XmlFields *inline_theme = g_new0 (XmlFields, 1);
        gint retopt = 0;
        gint create_retopt = 0;
        gint option_index = 0;
        gint create_option_index = 0;
        retopt = getopt_long (argc, argv, "hs:i:r:ic::k:g:", long_options,
                              &option_index);
        if (retopt == -1)
        {
                printf (_("Missing arguments\n"));
                printf (USAGE, g_get_prgname ());
                return R_OK;
        }

        gint ret = RETURN_ERROR;
        switch (retopt)
        {
        case 's':
                ret = set_new_theme (optarg);
                break;
        case 'i':
                ret = install_theme (optarg);
                break;
        case 'r':
                ret = remove_theme (optarg);
                break;
        case 'a':
                ret = information ();
                break;
        case 'c':
                if (argv[optind] == NULL)       // interactive mode */
                        ret = create_theme (get_fields ());
                else            // inline mode
                {

                        while (argc > optind)
                        {

                                create_retopt =
                                        getopt_long_only (argc, argv, "",
                                                          create_options,
                                                          &create_option_index);
                                switch (create_retopt)
                                {
                                case 'a':
                                        inline_theme->name =
                                                g_strdup (optarg);
                                        break;
                                case 'b':
                                        inline_theme->version =
                                                g_strdup (optarg);
                                        break;
                                case 'c':
                                        inline_theme->description =
                                                g_strdup (optarg);
                                        break;
                                case 'd':
                                        inline_theme->urls =
                                                g_strdup (optarg);
                                        break;
                                case 'e':
                                        inline_theme->author =
                                                g_strdup (optarg);
                                        break;
                                case 'f':
                                        inline_theme->pb_x =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'g':
                                        inline_theme->pb_y =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'h':
                                        inline_theme->pb_width =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'i':
                                        inline_theme->pb_height =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'j':
                                        inline_theme->pb_red =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'k':
                                        inline_theme->pb_green =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'l':
                                        inline_theme->pb_blue =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'm':
                                        inline_theme->pb_alpha =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'n':
                                        inline_theme->pb_border_show =
                                                g_strdup (optarg);
                                        break;
                                case 'o':
                                        inline_theme->pb_border_red =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'p':
                                        inline_theme->pb_border_green =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'q':
                                        inline_theme->pb_border_blue =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'r':
                                        inline_theme->pb_border_alpha =
                                                g_strtod (optarg, 0);
                                        break;
                                case 's':
                                        inline_theme->bg_boot =
                                                g_strdup (optarg);
                                        break;
                                case 't':
                                        inline_theme->bg_shutdown =
                                                g_strdup (optarg);
                                        break;
                                case 'u':
                                        inline_theme->bg_error =
                                                g_strdup (optarg);
                                        break;
                                case 'v':
                                        inline_theme->bg_width =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'w':
                                        inline_theme->bg_height =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'x':
                                        inline_theme->textbox_show =
                                                g_strdup (optarg);
                                        break;
                                case 'y':
                                        inline_theme->textbox_x =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'z':
                                        inline_theme->textbox_y =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'A':
                                        inline_theme->textbox_width =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'B':
                                        inline_theme->textbox_height =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'C':
                                        inline_theme->textbox_red =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'D':
                                        inline_theme->textbox_green =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'E':
                                        inline_theme->textbox_blue =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'F':
                                        inline_theme->textbox_alpha =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'G':
                                        inline_theme->textbox_border_show =
                                                g_strdup (optarg);
                                        break;
                                case 'H':
                                        inline_theme->textbox_border_red =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'I':
                                        inline_theme->textbox_border_green =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'J':
                                        inline_theme->textbox_border_blue =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'K':
                                        inline_theme->textbox_border_alpha =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'L':
                                        inline_theme->textfont_file =
                                                g_strdup (optarg);
                                        break;
                                case 'M':
                                        inline_theme->textfont_height =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'N':
                                        inline_theme->textfont_red =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'O':
                                        inline_theme->textfont_green =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'P':
                                        inline_theme->textfont_blue =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'Q':
                                        inline_theme->textfont_alpha =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'R':
                                        inline_theme->verbose =
                                                g_strdup (optarg);
                                        break;
                                case 'U':
                                        inline_theme->fadein =
                                                g_strdup (optarg);
                                        break;
                                case 'V':
                                        inline_theme->fadeout =
                                                g_strdup (optarg);
                                        break;
                                case 'W':
                                        inline_theme->pb_bg_red =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'X':
                                        inline_theme->pb_bg_green =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'Y':
                                        inline_theme->pb_bg_blue =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'Z':
                                        inline_theme->pb_bg_alpha =
                                                g_strtod (optarg, 0);
                                        break;
                                case 'S':
                                        inline_theme->bg_resume =
                                                g_strdup (optarg);
                                        break;
                                case 'T':
                                        inline_theme->bg_suspend =
                                                g_strdup (optarg);
                                        break;
                                case 300:
                                        inline_theme->pb_dir_boot =
                                                g_strdup (optarg);
                                        break;
                                case 301:
                                        inline_theme->pb_dir_shutdown =
                                                g_strdup (optarg);
                                        break;
                                case 302:
                                        inline_theme->pb_dir_resume =
                                                g_strdup (optarg);
                                        break;
                                case 303:
                                        inline_theme->pb_dir_suspend =
                                                g_strdup (optarg);
                                        break;
                                case 304:
                                        inline_theme->pb_on_boot =
                                                g_strdup (optarg);
                                        break;
                                case 305:
                                        inline_theme->pb_on_shutdown =
                                                g_strdup (optarg);
                                        break;
                                case 306:
                                        inline_theme->pb_on_resume =
                                                g_strdup (optarg);
                                        break;
                                case 307:
                                        inline_theme->pb_on_suspend =
                                                g_strdup (optarg);
                                        break;

                                }
                        }
                        ret = create_theme (inline_theme);

                        /*
                         * memory free up 
                         */

                        if (inline_theme->name)
                                g_free (inline_theme->name);
                        if (inline_theme->version)
                                g_free (inline_theme->version);
                        if (inline_theme->description)
                                g_free (inline_theme->description);
                        if (inline_theme->urls)
                                g_free (inline_theme->urls);
                        if (inline_theme->author)
                                g_free (inline_theme->author);
                        if (inline_theme->pb_border_show)
                                g_free (inline_theme->pb_border_show);
                        if (inline_theme->bg_boot)
                                g_free (inline_theme->bg_boot);
                        if (inline_theme->bg_shutdown)
                                g_free (inline_theme->bg_shutdown);
                        if (inline_theme->bg_error)
                                g_free (inline_theme->bg_error);
                        if (inline_theme->textbox_show)
                                g_free (inline_theme->textbox_show);
                        if (inline_theme->textbox_border_show)
                                g_free (inline_theme->textbox_border_show);
                        if (inline_theme->textfont_file)
                                g_free (inline_theme->textfont_file);
                        if (inline_theme->verbose)
                                g_free (inline_theme->verbose);
                        if (inline_theme->fadein)
                                g_free (inline_theme->fadein);
                        if (inline_theme->fadeout)
                                g_free (inline_theme->fadeout);
                        if (inline_theme->bg_resume)
                                g_free (inline_theme->bg_resume);
                        if (inline_theme->bg_suspend)
                                g_free (inline_theme->bg_suspend);


                }
                break;
        case 'g':
        case 'k':
                g_print ("%s", splashy_get_config_string (optarg));
                break;
        case 'h':
                printf (HELP, g_get_prgname ());
                break;
        case '?':
                printf (USAGE, g_get_prgname ());
                break;
        }

        return ret;
}
Ejemplo n.º 11
0
VOID edit_icon(LONG tree, WORD sobj)
{
	LONG	obspec, taddr; 
	WORD	where, type, itmp, exitobj, ok;
	GRECT	p;
	BYTE	text[14], valid[2], name[9]; 
	WORD	trule, crule, w, h;

	if (rcs_state != ALRT_STATE)
	{
		get_fields(tree, sobj, &type, &obspec, &p);

		ini_tree(&tree, ICONDIAL);
		where = set_obname(tree, ICONNAME, name, ad_view, sobj);
		taddr = LLGET(obspec);
		set_text(tree, IBTEXT, (LONG)ADDR(&text[0]), 13);
		set_text(tree, IBCHAR, (LONG)ADDR(&valid[0]), 2);
		icon_set(taddr, &text[0], &valid[0]);
		trule = icon_twhich(LWGET(IB_YTEXT(taddr)), LWGET(IB_HICON(taddr)));
		sel_obj(tree, IBTPOS0 + trule);
		itmp = icon_cwhich(LWGET(IB_YCHAR(taddr)),
			gl_hschar, LWGET(IB_HICON(taddr)));
		crule = icon_cwhich(LWGET(IB_XCHAR(taddr)),
			gl_wschar, LWGET(IB_WICON(taddr)));
		crule += 3 * itmp;
		sel_obj(tree, IBCPOS0 + crule);

		do {
			exitobj = hndl_dial(tree, IBTEXT, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while (ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			icon_get(taddr, &text[0], &valid[0]);
			itmp = encode(tree, IBTPOS0, 3);
			if (itmp != trule)
			{		
				itmp = icon_tapply(itmp, gl_hschar,
					LWGET(IB_HICON(taddr)));
				LWSET(IB_YTEXT(taddr), itmp);
			}
			LWSET(IB_WTEXT(taddr), (WORD)(gl_wschar * strlen(text)));
			icon_tfix(taddr);
			itmp = encode(tree, IBCPOS0, 9);
			if (itmp != crule)
			{
				crule = itmp;
				itmp = icon_capply(crule / 3, gl_hschar,
					LWGET(IB_HICON(taddr)));
				LWSET(IB_YCHAR(taddr), itmp);
				itmp = icon_capply(crule % 3, gl_wschar,
					LWGET(IB_WICON(taddr)));
				LWSET(IB_XCHAR(taddr), itmp);
			}
			icon_wh(taddr, &w, &h);
			newsize_obj(ad_view, sobj, w, h, FALSE);
		}
		map_tree(tree, ROOT, NIL, (fkt_parm)desel_obj);	/* clear radio buttons */
	}
}
Ejemplo n.º 12
0
VOID edit_text(LONG tree, WORD sobj)
{
	LONG	obspec, taddr; 
	WORD	min_width, where, type, deftext, w, h, exitobj, ok;
	GRECT	p;
	BYTE	text[73], valid[73], tmplt[73], name[9]; 

	if (rcs_state != ALRT_STATE)
	{
		get_fields(tree, sobj, &type, &obspec, &p);
		taddr = LLGET(obspec);
		if (type == G_FTEXT || type == G_FBOXTEXT)
			if (LSTRLEN(LLGET(TE_PTMPLT(taddr))) > 72)
				return;
		ini_tree(&tree, TEXTDIAL);
		where = set_obname(tree, TEXTNAME, name, ad_view, sobj);
		set_text(tree, OTMPITEM, (LONG)ADDR(&tmplt[0]), 73);
		set_text(tree, OVALITEM, (LONG)ADDR(&valid[0]), 73);
		set_text(tree, OTEXITEM, (LONG)ADDR(&text[0]), 73);
		LLSTRCPY(LLGET(TE_PTMPLT(taddr)), (LONG)ADDR(&tmplt[0]));
		ted_set(taddr, &tmplt[0], &valid[0], &text[0]);

		if (type == G_TEXT || type == G_BOXTEXT)
		{
			if (LSTRLEN(LLGET(TE_PTEXT(taddr))) > 72)
				return;
			hide_obj(tree, TMPLTTAG);
			hide_obj(tree, OTMPITEM);
			hide_obj(tree, VALIDTAG);
			hide_obj(tree, OVALITEM);
			deftext = OTEXITEM;
		}		   
		else
			deftext = (tmplt[0] != '@')? OTMPITEM: OTEXITEM;
		do {
			exitobj = hndl_dial(tree, deftext, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while (ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			ted_get(taddr, &tmplt[0], &valid[0], &text[0]);
			if (type == G_TEXT || type == G_FTEXT || type == G_BOXTEXT)
			{
				text_wh(taddr, type, &w, &h);
				min_width = GET_WIDTH(ad_view, sobj);
				if ( w > min_width)
					newsize_obj(ad_view, sobj, w, h, TRUE);
			}
		}

		unhide_obj(tree,TMPLTTAG);
		unhide_obj(tree,OTMPITEM);
		unhide_obj(tree, VALIDTAG);
		unhide_obj(tree,OVALITEM);
		map_tree(tree, ROOT, NIL, (fkt_parm)desel_obj);	/* clear radio buttons */
	}
}
Ejemplo n.º 13
0
VOID edit_str(LONG tree, WORD sobj)
{
	LONG	obspec; 
	WORD	where, type, exitobj, ok;
	GRECT	p;
	WORD	min_width, neww, len; 
	BYTE	text[73], name[9]; 

	get_fields(tree, sobj, &type, &obspec, &p);
	len = (WORD)LSTRLEN(LLGET(obspec));
	if (len <= 72)
	{
		ini_tree(&tree, STRDIAL);
		where = set_obname(tree, STRNAME, name, ad_view, sobj);
		set_text(tree, OSTRITEM, (LONG)ADDR(&text[0]), 73);
		LLSTRCPY(LLGET(obspec), (LONG)ADDR(&text[0]));
		if ( rcs_state == ALRT_STATE )
			hide_obj( tree, STRNAME);
		if (!text[0])
			text[0] = '@';
		do {
			exitobj = hndl_dial(tree, OSTRITEM, &p);
			desel_obj(tree, exitobj);
			ok = DEFAULT & GET_FLAGS(tree, exitobj);
		} while ( ok && !name_ok(name, where, TRUE));

		if (ok)
		{
			rcs_edited = TRUE;
			get_obname(name, ad_view, sobj);
			if (text[0] == '@')
				text[0] = '\0';

			if (rcs_state == ALRT_STATE)
			{		
				if (strlen(text) > 40 )
				{
					hndl_alert(1, string_addr(STOOLONG));
					text[40] = '\0';
				}
				update_if(obspec, &text[0]);
				fix_alert(ad_view);
				unhide_obj(tree, STRNAME);
			}
			else
			{
				neww = (WORD)(gl_wchar * strlen(text));
				if (rcs_state == MENU_STATE)
				{
					if (type == G_TITLE)
					{
						if (!newsize_obj(ad_view, sobj, neww,gl_hchar, TRUE))
							text[len] = '\0';
						fix_menu_bar(ad_view);
					}
					else if (in_which_menu(ad_view, sobj) == 1
						&& in_menu(ad_view, sobj) == 1
						&& strlen(text) > 20 )
		    		{
						hndl_alert(1, string_addr(STOOLONG));	
						text[20] = '\0';
					}
					else  if(!newsize_obj(ad_view, sobj, neww,gl_hchar, FALSE))
						text[len] = '\0';
				}
				else if (type == G_STRING || type == G_BUTTON )
				{
					min_width = GET_WIDTH(ad_view, sobj);
					if( neww > min_width )
						if(!newsize_obj(ad_view, sobj, neww,gl_hchar, FALSE))
							text[len] = '\0';
				}
			}
			if( rcs_state != ALRT_STATE)
				update_if(obspec, &text[0]);
		}
	}
}
main(int argc ,char *argv[])
{
	int i;

	/*checking for creation and printing the tree ---Working*/
	node *tree ;
	tree=create_tree();
	read_ssf_from_file(tree, argv[1]);
	print_tree(tree);
	printf("Checked read and print\n\n");



	/*checking for get_nth_child ----Working*/
	node *child = get_nth_child(tree, 2);
	print_node_without_index(child);
	printf("Checked get_nth_child\n\n");

	/*checking for getchildren-----Working*/
	list_of_nodes *l1;
	l1=getchildren(tree);
	printf("\n\nsize=%d\n", l1->size);
	for (i=0; i< l1->size; i++)
	{
		print_attr_of_node(l1->l[i] );
		printf("\n");
	}
	printf("Checked getchildren\n\n");


	/*checking for getleaves----Working*/
	list_of_nodes *l2;
	l2=getleaves(tree);
	printf("\n\nsize=%d\n", l2->size);
	for (i=0; i< l2->size; i++)
	{
		print_attr_of_node(l2->l[i] );
		printf("\n");
	}
	printf("Checked getleaves\n\n");
	
	/*checking for getleaves_child---Working*/
	list_of_nodes *l3;
	l3=getleaves_child(l1->l[1]);
	printf("\n\nsize=%d\n", l3->size);
	for (i=0; i< l3->size; i++)
	{
		print_attr_of_node(l3->l[i] );
		printf("\n");
	}
	printf("Checked getleaves_child\n\n");

	/*checking for get_nodes---Working*/
	list_of_nodes *l4;
	l4=get_nodes(2,"NNS",tree);
	printf("\n\nsize=%d\n",l4->size);
	for (i=0; i< l4->size; i++)
	{
		print_attr_of_node(l4->l[i]);
		printf("\n");
	}
	printf("Checked get_nodes\n\n");


	/*checking for get_pattern---Working*/
	list_of_nodes *l5;
	l5=get_pattern(2,".*N.*",tree);
	printf("\n\nsize=%d\n",l5->size);
	for (i=0; i< l5->size; i++)
	{
		print_attr_of_node(l5->l[i]);
		printf("\n");
	}
	printf("Checked get_pattern\n\n");

	//checking for delete_node------Working
	//printf("%d\n",delete_node(l5->l[1]));
	//print_tree(tree);

	//checking for count_leaf_nodes ----Working
	printf("count of leaf nodes----%d\n\n", count_leaf_nodes(tree));

	//checking for get_field(s)  ----Working 
	char *str;
       	str=get_field(l5->l[1],1);
	printf("%s\n",str);
	str=get_fields(l5->l[1]);
	printf("%s\n", str);
	printf("Checked get_field and get_fields\n\n");


	//checking for get_next_node  and get_previos_node----Working
	node *N;
	N=get_next_node(l1->l[1]);
	str=get_fields(N);
	printf("%s\n", str);
	N=get_previous_node(l1->l[1]);
	str=get_fields(N);
	printf("%s\n", str);
	printf("Checked get_next_node & get_previous_node\n\n");


	//checking for insert_node_position------Working
	node *M;
	M=create_node_with_attr("iiit","NNP","<loc=hyd>",NULL);
	insert_node_into_position(tree,M,1);
	print_tree(tree);
	printf("Checked insert_node_position\n\n");
	
	/*Checkin print_attr_of_or_node--------Working*/	
	print_attr_of_or_node(M->OR);
	printf("\nChecked print_attr_of_or_node\n\n");
		
}
		void StructAccessExpressionBuilder::build(VMProgram* program, VMExpressionVisitor* visitor, StructAccessExpression* expression, const ElsaType* current)
		{
			// If we do not have a base expression we can expect the base to already be on the stack e.g. chained array access.
			if(expression->get_base() != nullptr)
				IdentifierExpressionBuilder::build(program, visitor, expression->get_base());

			auto current_type = current;
			if (current_type == nullptr)
			{
				current_type = visitor->current_type();

				if (expression->get_base() != nullptr)
					current_type = expression->get_base()->get_type();
			}

			for (const auto& exp : expression->get_expressions())
			{
				auto current_struct = get_current_struct(current_type);

				if (exp->get_expression_type() == ExpressionType::FieldAccess)
				{
					for (const auto& field : current_struct->get_fields())
					{
						if (field->get_name() == exp->get_name())
						{
							if (field->get_type()->get_type() == ObjectType::GCOPtr)
								current_type = field->get_type();

							program->emit(OpCode::l_field);
							program->emit(static_cast<int>(field->get_index()));
							break;
						}
					}
				}
				else if(exp->get_expression_type() == ExpressionType::FuncCall)
				{
					for (const auto& function : current_struct->get_functions())
					{
						if (function->get_name() == exp->get_name())
						{
							const auto fi = program->get_struct(current_type->get_struct_declaration_expression()->get_name(true))->get_function(function->get_name());

							if (function->get_return_type()->get_type() == ObjectType::GCOPtr)
								current_type = function->get_return_type();

							FuncCallExpressionBuilder::build_member(program, visitor, dynamic_cast<FuncCallExpression*>(exp.get()), fi);
							break;
						}
					}
				}
				else if (exp->get_expression_type() == ExpressionType::ArrayAccess)
				{
					for (const auto& field : current_struct->get_fields())
					{
						if (field->get_name() == exp->get_name())
						{
							current_type = field->get_type()->get_struct_declaration_expression()->get_generic_type();

							program->emit(OpCode::l_field);
							program->emit(static_cast<int>(field->get_index()));

							dynamic_cast<ArrayAccessExpression*>(exp.get())->get_index_expression()->accept(visitor);
							program->emit(OpCode::l_ele);
							break;
						}
					}
				}
				else if (exp->get_expression_type() == ExpressionType::Identifier)
				{
					if (exp->get_type()->get_type() == ObjectType::Function)
					{
						for (const auto& function : current_struct->get_functions())
						{
							if (function->get_name() == exp->get_name())
							{
								const auto fi = program->get_struct(current_type->get_struct_declaration_expression()->get_name(true))->get_function(function->get_name());
								program->emit(OpCode::fnconst);
								program->emit(static_cast<int>(fi->get_addr()));
								break;
							}
						}
					}
					else
					{
						throw CodeGenException("Unsupported type -> StructAccessExpressionBuilder -> ExpressionType::Identifier");
					}
				}
			}
		}
Ejemplo n.º 16
0
int main (int argc, char **argv)
{
    Octstr *message, *whoami;
    struct emimsg *emimsg;

    printf("/* This tool can decode an UCP/EMI packet. <*****@*****.**> */\n\n");

    gwlib_init();

    if (argc < 2)
        panic(0, "Syntax: %s <packet_without_STX/ETX>\n", argv[0]);

    message = octstr_format("\02%s\03", argv[1]); // fit the UCP specs.
    whoami = octstr_create("DECODE");

    emimsg = get_fields(message, whoami);

    if (emimsg != NULL) {
        printf("\n");
        printf("TRN      \t%d\n", emimsg->trn);
        printf("TYPE     \t%c (%s)\n", emimsg->or, emimsg->or == 'R' ? "Result" : "Operation");
        printf("OPERATION\t%d (%s)\n", emimsg->ot, emi_typeop (emimsg->ot));

        if (emimsg->ot == 01) {
            printf("E01_ADC  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E01_ADC]));
            printf("E01_OADC \t%s\n",
                    octstr_get_cstr(emimsg->fields[E01_OADC]));
            printf("E01_AC   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E01_AC]));
            printf("E01_ADC  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E01_ADC]));
            printf("E01_MT   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E01_MT]));
            if (octstr_get_char(emimsg->fields[E01_MT], 0) == '3') {
                charset_gsm_to_latin1(emimsg->fields[E01_AMSG]);
            }
            printf("E01_AMSG \t%s\n",
                    octstr_get_cstr(emimsg->fields[E01_AMSG]));
        }

        if ((emimsg->ot == 31 || (emimsg->ot >= 50 && emimsg->ot <= 60))
                && emimsg->or == 'R' && 
                (octstr_get_char(emimsg->fields[E50_ADC], 0) == 'A' ||
                octstr_get_char(emimsg->fields[E50_ADC], 0) == 'N')) {
            printf("E%d_ACK  \t%s\n", emimsg->ot,
                    octstr_get_cstr(emimsg->fields[E50_ADC]));
            printf("E%d_SM   \t%s\n", emimsg->ot,
                    octstr_get_cstr(emimsg->fields[E50_OADC]));
        }

        if (emimsg->ot == 31 && emimsg->or == 'O') {
            printf("E50_ADC  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_ADC]));
            printf("E50_PID  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_OADC]));
        }

        if (emimsg->ot >= 50 && emimsg->ot <= 59 && 
                octstr_get_char(emimsg->fields[E50_ADC], 0) != 'A' &&
                octstr_get_char(emimsg->fields[E50_ADC], 0) != 'N') {
            printf("E50_ADC  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_ADC]));
            printf("E50_OADC \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_OADC]));
            printf("E50_AC   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_AC]));
            printf("E50_NRQ  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_NRQ]));
            printf("E50_NADC \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_NADC]));
            printf("E50_NT   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_NT]));
            printf("E50_NPID \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_NPID]));
            printf("E50_LRQ  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_LRQ]));
            printf("E50_LRAD \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_LRAD]));
            printf("E50_LPID \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_LPID]));
            printf("E50_DD   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_DD]));
            printf("E50_DDT  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_DDT]));
            printf("E50_VP   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_VP]));
            printf("E50_RPID \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_RPID]));
            printf("E50_SCTS \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_SCTS]));
            printf("E50_DST  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_DST]));
            printf("E50_RSN  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_RSN]));
            printf("E50_DSCTS\t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_DSCTS]));
            printf("E50_MT   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_MT]));
            printf("E50_NB   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_NB]));
            printf("E50_NMSG \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_NMSG]));
            if (emimsg->fields[E50_AMSG])
                octstr_hex_to_binary (emimsg->fields[E50_AMSG]);
            if (octstr_get_char(emimsg->fields[E50_MT], 0) == '3') {
                charset_gsm_to_latin1(emimsg->fields[E50_AMSG]);
            }

            printf("E50_AMSG \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_AMSG]));
            printf("E50_TMSG \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_TMSG]));
            printf("E50_MMS  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_MMS]));
            printf("E50_PR   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_PR]));
            printf("E50_DCS  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_DCS]));
            printf("E50_MCLS \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_MCLS]));
            printf("E50_RPI  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_RPI]));
            printf("E50_CPG  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_CPG]));
            printf("E50_RPLY \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_RPLY]));
            printf("E50_OTOA \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_OTOA]));
            printf("E50_HPLMN\t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_HPLMN]));
            printf("E50_XSER \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_XSER]));
            printf("E50_RES4 \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_RES4]));
            printf("E50_RES5 \t%s\n",
                    octstr_get_cstr(emimsg->fields[E50_RES5]));
        }

        if ((emimsg->ot == 60 || emimsg->ot == 61) &&
                (octstr_get_char(emimsg->fields[E50_ADC], 0) != 'A' &&
                octstr_get_char(emimsg->fields[E50_ADC], 0) != 'N')) {
            printf("E60_OADC  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_OADC]));
            printf("E60_OTON  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_OTON]));
            printf("E60_ONPI  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_ONPI]));
            printf("E60_STYP  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_STYP]));
            if (emimsg->fields[E60_PWD])
                octstr_hex_to_binary (emimsg->fields[E60_PWD]);
            printf("E60_PWD   \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_PWD]));
            printf("E60_NPWD  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_NPWD]));
            printf("E60_VERS  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_VERS]));
            printf("E60_LADC  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_LADC]));
            printf("E60_LTON  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_LTON]));
            printf("E60_LNPI  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_LNPI]));
            printf("E60_OPID  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_OPID]));
            printf("E60_RES1  \t%s\n",
                    octstr_get_cstr(emimsg->fields[E60_RES1]));
        }
    }

    octstr_destroy(message);
    octstr_destroy(whoami);
    gwlib_shutdown();
    
    return 0;
}