[bugzcxx-devel] few doubts and some example cleanup patch
Status: Alpha
Brought to you by:
mindstorm2600
From: BugzCXX D. <bug...@li...> - 2010-01-07 10:23:00
|
Hello Juan, I was trying examples with live bugzilla.redhat.com using this line: [rakesh@simu bugzc]$ ./getbugs https://bugzilla.redhat.com/xmlrpc.cgi rp...@re... 543433 Bugzilla version at: https://bugzilla.redhat.com/xmlrpc.cgi is 3.2.5+ Enter bugzilla password: Querying info for #543433... Bug id: 543433 Summary: Created On: � (4244782496754601) Last Change On: (4244782496754601) /builddir/build/BUILD/xmlrpc-c-1.16.6/src/xmlrpc_client.c:622: assertion failed Aborted (core dumped) [rakesh@simu bugzc]$ It gets bug details but gets a SIGABRT at bugzc_user_logout(&conn); call in same example. Upon investigating I found following function call from bugzc_bug.c at line 604 sets the bconn->xenv to {fault_occurred = 1, fault_code = -501, fault_string = 0x626f50 "Value of type ARRAY supplied where string type was expected."} which means their is something wrong in there. May you suggest what could be wrong with the expected format we are supplying in this call ? xmlrpc_decompose_value(&bconn->xenv, bug_item, "{s:s,s:i,s:s,s:8,s:8,*}", "summary", &b_summary, "id", &tmp_id, "alias", &b_alias, "creation_time", &b_ctime, "last_change_time", &b_lctime ); One more question, how do I investigate or come to know which API call will throw what type of information so that I can select proper format in decompose value function ? Below is a patch which fixes examples a bit more and makes them sane. May you review it before I can commit ? Can I commit now or you will approve my commit access in some time ? Log: 1. Fixed password entry in all tests and made login as mandatory argument. 2. Removed unused variables. Regards, -- Rakesh Pandit https://fedoraproject.org/wiki/User:Rakesh freedom, friends, features, first Index: submit_bug.c =================================================================== --- submit_bug.c (revision 23) +++ submit_bug.c (working copy) @@ -13,6 +13,7 @@ #include<stdio.h> #include<string.h> #include<stdlib.h> +#include<unistd.h> #include<bugzc/bugzc.h> char *fgets_s(char *str, size_t siz, FILE *fptr){ @@ -29,10 +30,8 @@ int main(int argc, char *argv[]){ char *url; char *login; - char pw[24]; + char *pass; char version[12]; - int i; - char product[65]; char component[65]; char summary[256]; @@ -48,15 +47,15 @@ description[0] = 0; if(argc <= 1){ - fprintf(stderr, "At least you must provide bugzilla's server url\n"); + fprintf(stderr, "At least you must provide bugzilla's server url and login\n"); return 0; } if(strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0){ - printf("%s --help\n%s <url> [username] [field_name] [product_name]\n\n"); + printf("%s --help\n%s <url> [username] [field_name] [product_name]\n\n", argv[0], argv[0]); return 0; } url = argv[1]; - + login = argv[2]; bugzc_init2(&conn, url); printf("Bugzilla version at: %s ", conn.url); fflush(stdout); @@ -78,20 +77,9 @@ fprintf(stderr, "%s\n", conn.xenv.fault_string); return 1; } - if(argc > 2){ - login = argv[2]; - printf("\nLogin "); - } - else{ - login = malloc(100); - printf("\nLogin (or e-mail): "); - login[99] = 0; - fgets_s(login, 98, stdin); - } - printf("Password: "); - fgets_s(pw, 23, stdin); + pass = getpass("Enter bugzilla password: "); /* Perform login */ - if(bugzc_user_login(&conn, login, pw, 0) < 0){ + if(bugzc_user_login(&conn, login, pass, 0) < 0){ if(conn.err_code != 0){ fprintf(stderr, "\n"); if(conn.xenv.fault_occurred){ @@ -104,7 +92,6 @@ } return 1; } - pw[0] = 0; printf("Product: "); fgets_s(product, 64, stdin); printf("Component: "); Index: get_products.c =================================================================== --- get_products.c (revision 23) +++ get_products.c (working copy) @@ -13,6 +13,7 @@ #include<stdio.h> #include<string.h> #include<stdlib.h> +#include<unistd.h> #include<bugzc/bugzc.h> @@ -67,9 +68,7 @@ int main(int argc, char *argv[]){ char *url; char *login; - char *field_name; - char *product_name; - char pw[24]; + char *pass; char version[12]; int *p_ids; int i; @@ -78,16 +77,16 @@ bugzc_list p_list; bugzc_conn conn; bugzc_node *node; - if(argc <= 1){ - fprintf(stderr, "At least you must provide bugzilla's server url\n"); + if(argc <= 2){ + fprintf(stderr, "At least you must provide bugzilla's server url and login\n"); return 0; } if(strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0){ - printf("%s --help\n%s <url> [username]\n\n"); + printf("%s --help\n%s <url> [username]\n\n", argv[0], argv[0]); return 0; } url = argv[1]; - + login = argv[2]; bugzc_init2(&conn, url); printf("Bugzilla version at: %s ", conn.url); fflush(stdout); @@ -109,20 +108,9 @@ fprintf(stderr, "%s\n", conn.xenv.fault_string); return 1; } - if(argc > 2){ - login = argv[2]; - printf("\nLogin "); - } - else{ - login = malloc(100); - printf("\nLogin (or e-mail): "); - login[99] = 0; - fgets(login, 98, stdin); - } - printf("Password: "); - fgets(pw, 23, stdin); + pass = getpass("Enter bugzilla password: "); /* Perform login */ - if(bugzc_user_login(&conn, login, pw, 0) < 0){ + if(bugzc_user_login(&conn, login, pass, 0) < 0){ if(conn.err_code != 0){ fprintf(stderr, "\n"); if(conn.xenv.fault_occurred){ @@ -135,7 +123,6 @@ } return 1; } - pw[0] = 0; bugzc_list_create(&list); printf("Selectable product ids: "); if(bugzc_product_get_selectable_products(&conn, &list) < 0){ Index: get_legal_field_values.c =================================================================== --- get_legal_field_values.c (revision 23) +++ get_legal_field_values.c (working copy) @@ -13,6 +13,7 @@ #include<stdio.h> #include<string.h> #include<stdlib.h> +#include<unistd.h> #include<bugzc/bugzc.h> char *fgets_s(char *str, size_t siz, FILE *fptr){ @@ -31,22 +32,21 @@ char *login; char *field_name; char *product_name; - char pw[24]; + char *pass; char version[12]; bugzc_list list; - int i; bugzc_conn conn; bugzc_node *node; - if(argc <= 1){ - fprintf(stderr, "At least you must provide bugzilla's server url\n"); + if(argc <= 2){ + fprintf(stderr, "At least you must provide bugzilla's server url and login\n"); return 0; } if(strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0){ - printf("%s --help\n%s <url> [username] [field_name] [product_name]\n\n"); + printf("%s --help\n%s <url> [username] [field_name] [product_name]\n\n", argv[0], argv[0]); return 0; } url = argv[1]; - + login = argv[2]; bugzc_init2(&conn, url); printf("Bugzilla version at: %s ", conn.url); fflush(stdout); @@ -68,20 +68,9 @@ fprintf(stderr, "%s\n", conn.xenv.fault_string); return 1; } - if(argc > 2){ - login = argv[2]; - printf("\nLogin "); - } - else{ - login = malloc(100); - printf("\nLogin (or e-mail): "); - login[99] = 0; - fgets(login, 98, stdin); - } - printf("Password: "); - fgets(pw, 23, stdin); + pass = getpass("Enter bugzilla password: "); /* Perform login */ - if(bugzc_user_login(&conn, login, pw, 0) < 0){ + if(bugzc_user_login(&conn, login, pass, 0) < 0){ if(conn.err_code != 0){ fprintf(stderr, "\n"); if(conn.xenv.fault_occurred){ @@ -94,7 +83,6 @@ } return 1; } - pw[0] = 0; if(argc > 3){ field_name = argv[3]; if(argc > 4) printf("\n"); Index: bugz_create_user.c =================================================================== --- bugz_create_user.c (revision 23) +++ bugz_create_user.c (working copy) @@ -13,6 +13,7 @@ #include<stdio.h> #include<string.h> #include<stdlib.h> +#include<unistd.h> #include<bugzc/bugzc.h> char *fgets_s(char *str, size_t siz, FILE *fptr){ @@ -29,13 +30,13 @@ int main(int argc, char *argv[]){ char *url; char *login; - char pw[24]; + char *pass; char email[80]; char fullname[80]; char password[80]; char version[12]; bugzc_conn conn; - if(argc <= 1){ + if(argc <= 2){ fprintf(stderr, "At least you must provide bugzilla's server url" \ " and your user login after that.\n"); return 0; @@ -45,7 +46,6 @@ bugzc_init2(&conn, url); printf("Bugzilla version at: %s ", conn.url); - fflush(stdout); if(bugzc_bugzilla_version(&conn, version, 12) < 0){ if(conn.err_code != 0){ fprintf(stderr, "\n"); @@ -59,9 +59,9 @@ return 1; } printf("is %s\n", version); - printf("Enter password for %s: ", login); - fgets(pw, 23, stdin); - if(bugzc_user_login(&conn, login, pw, 0) < 0){ + fflush(stdout); + pass = getpass("Enter bugzilla password: "); + if(bugzc_user_login(&conn, login, pass, 0) < 0){ if(conn.err_code != 0){ fprintf(stderr, "\n"); if(conn.xenv.fault_occurred){ @@ -73,7 +73,6 @@ } return 1; } - pw[0] = 0; printf("Ready to create new user account...\n"); printf("e-mail: "); fgets_s(email, 79, stdin); Index: testlogin.c =================================================================== --- testlogin.c (revision 23) +++ testlogin.c (working copy) @@ -13,22 +13,23 @@ #include<stdio.h> #include<string.h> #include<stdlib.h> +#include<unistd.h> #include<bugzc/bugzc.h> int main(int argc, char *argv[]){ char *url; char *login; - char pw[24]; + char *pass; char version[12]; char tzone[12]; bugzc_conn conn; - if(argc <= 1){ - fprintf(stderr, "At least you must provide bugzilla's server url\n"); + if(argc <= 2){ + fprintf(stderr, "At least you must provide bugzilla's server url and login\n"); return 0; } url = argv[1]; - + login = argv[2]; bugzc_init2(&conn, url); printf("Bugzilla version at: %s ", conn.url); fflush(stdout); @@ -50,20 +51,9 @@ fprintf(stderr, "%s\n", conn.xenv.fault_string); return 1; } - if(argc > 2){ - login = argv[2]; - printf("\nLogin "); - } - else{ - login = malloc(1024); - printf("\nLogin (or e-mail): "); - login[1023] = 0; - fgets(login, 1022, stdin); - } - printf("Password: "); - fgets(pw, 23, stdin); + pass = getpass("Enter bugzilla password: "); /* Perform login */ - if(bugzc_user_login(&conn, login, pw, 0) < 0){ + if(bugzc_user_login(&conn, login, pass, 0) < 0){ if(conn.err_code != 0){ fprintf(stderr, "\n"); if(conn.xenv.fault_occurred){ @@ -76,7 +66,6 @@ } return 1; } - pw[0] = 0; printf("Server timezone: "); fflush(stdout); if(bugzc_bugzilla_timezone(&conn, tzone, 12) < 0){ |