Show
Ignore:
Timestamp:
11/15/08 20:24:30 (22 months ago)
Author:
ahu
Message:

arg() -> ::arg(), plus improve error message somewhat

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/pdns/backends/bind/zone2sql.cc

    r1055 r1266  
    8686      cerr<<"Second SOA in zone, raised domain_id"<<endl; 
    8787      if(mode==POSTGRES || mode==ORACLE) { 
    88         if(g_intransaction && arg().mustDo("transactions")) { 
     88        if(g_intransaction && ::arg().mustDo("transactions")) { 
    8989          cout<<"COMMIT WORK;"<<endl; 
    9090        } 
    91         if(arg().mustDo("transactions")) { 
     91        if(::arg().mustDo("transactions")) { 
    9292          if(mode==POSTGRES) 
    9393            cout<<"BEGIN TRANSACTION;"<<endl; 
     
    173173#endif 
    174174    lastsoa_qname=" "; 
    175     arg().setSwitch("mysql","Output in format suitable for mysqlbackend")="yes"; 
    176     arg().setCmd("gpgsql","Output in format suitable for default gpgsqlbackend"); 
    177     arg().setCmd("gmysql","Output in format suitable for default gmysqlbackend"); 
    178     arg().setCmd("oracle","Output in format suitable for the oraclebackend"); 
    179     arg().setCmd("bare","Output in a bare format, suitable for further parsing"); 
    180     arg().setSwitch("verbose","Verbose comments on operation")="no"; 
    181     arg().setSwitch("slave","Keep BIND slaves as slaves")="no"; 
    182     arg().setSwitch("transactions","If target SQL supports it, use transactions")="no"; 
    183     arg().setSwitch("on-error-resume-next","Continue after errors")="no"; 
    184     arg().set("start-id","Value of first domain-id")="0"; 
    185     arg().set("zone","Zonefile with $ORIGIN to parse")=""; 
    186     arg().set("zone-name","Specify an $ORIGIN in case it is not present")=""; 
    187     arg().set("named-conf","Bind 8/9 named.conf to parse")=""; 
    188     arg().set("soa-minimum-ttl","Do not change")="0"; 
    189     arg().set("soa-refresh-default","Do not change")="0"; 
    190     arg().set("soa-retry-default","Do not change")="0"; 
    191     arg().set("soa-expire-default","Do not change")="0"; 
    192  
    193     arg().setCmd("help","Provide a helpful message"); 
     175    ::arg().setSwitch("mysql","Output in format suitable for mysqlbackend")="yes"; 
     176    ::arg().setCmd("gpgsql","Output in format suitable for default gpgsqlbackend"); 
     177    ::arg().setCmd("gmysql","Output in format suitable for default gmysqlbackend"); 
     178    ::arg().setCmd("oracle","Output in format suitable for the oraclebackend"); 
     179    ::arg().setCmd("bare","Output in a bare format, suitable for further parsing"); 
     180    ::arg().setSwitch("verbose","Verbose comments on operation")="no"; 
     181    ::arg().setSwitch("slave","Keep BIND slaves as slaves")="no"; 
     182    ::arg().setSwitch("transactions","If target SQL supports it, use transactions")="no"; 
     183    ::arg().setSwitch("on-error-resume-next","Continue after errors")="no"; 
     184    ::arg().set("start-id","Value of first domain-id")="0"; 
     185    ::arg().set("zone","Zonefile with $ORIGIN to parse")=""; 
     186    ::arg().set("zone-name","Specify an $ORIGIN in case it is not present")=""; 
     187    ::arg().set("named-conf","Bind 8/9 named.conf to parse")=""; 
     188    ::arg().set("soa-minimum-ttl","Do not change")="0"; 
     189    ::arg().set("soa-refresh-default","Do not change")="0"; 
     190    ::arg().set("soa-retry-default","Do not change")="0"; 
     191    ::arg().set("soa-expire-default","Do not change")="0"; 
     192 
     193    ::arg().setCmd("help","Provide a helpful message"); 
    194194 
    195195    S.declare("logmessages"); 
     
    198198    string zonefile=""; 
    199199 
    200     arg().parse(argc, argv); 
     200    ::arg().parse(argc, argv); 
    201201   
    202     if(argc<2 || arg().mustDo("help")) { 
     202    if(argc<2 || ::arg().mustDo("help")) { 
    203203      cerr<<"syntax:"<<endl<<endl; 
    204       cerr<<arg().helpstring()<<endl; 
     204      cerr<<::arg().helpstring()<<endl; 
    205205      exit(1); 
    206206    } 
    207207   
    208     if(arg().mustDo("mysql"))  
     208    if(::arg().mustDo("mysql"))  
    209209      mode=MYSQL; 
    210     if(arg().mustDo("gpgsql") || arg().mustDo("gmysql")) 
     210    if(::arg().mustDo("gpgsql") || ::arg().mustDo("gmysql")) 
    211211      mode=POSTGRES; 
    212     if(arg().mustDo("bare")) 
     212    if(::arg().mustDo("bare")) 
    213213      mode=BARE; 
    214     if(arg().mustDo("oracle")) { 
     214    if(::arg().mustDo("oracle")) { 
    215215      mode=ORACLE; 
    216       if(!arg().mustDo("transactions")) 
     216      if(!::arg().mustDo("transactions")) 
    217217        cout<<"set autocommit on;"<<endl; 
    218218    } 
    219219 
    220220 
    221     dirty_hack_num=arg().asNum("start-id"); 
    222     namedfile=arg()["named-conf"]; 
    223     zonefile=arg()["zone"]; 
     221    dirty_hack_num=::arg().asNum("start-id"); 
     222    namedfile=::arg()["named-conf"]; 
     223    zonefile=::arg()["zone"]; 
    224224 
    225225    int count=0, num_domainsdone=0; 
     
    227227    if(zonefile.empty()) { 
    228228      BindParser BP; 
    229       BP.setVerbose(arg().mustDo("verbose")); 
     229      BP.setVerbose(::arg().mustDo("verbose")); 
    230230      BP.parse(namedfile.empty() ? "./named.conf" : namedfile); 
    231231     
     
    251251          try { 
    252252            if(mode==POSTGRES || mode==ORACLE) { 
    253               if(g_intransaction && arg().mustDo("transactions")) { 
     253              if(g_intransaction && ::arg().mustDo("transactions")) { 
    254254                cout<<"COMMIT WORK;"<<endl; 
    255255              } 
    256               if(arg().mustDo("transactions")) { 
     256              if(::arg().mustDo("transactions")) { 
    257257                if(mode==POSTGRES) 
    258258                  cout<<"BEGIN TRANSACTION;"<<endl; 
     
    261261 
    262262              if(mode==POSTGRES) { 
    263                 if(arg().mustDo("slave")) { 
     263                if(::arg().mustDo("slave")) { 
    264264                  if(i->masters.empty()) 
    265265                    cout<<"insert into domains (name,type) values ("<<sqlstr(i->name)<<",'NATIVE');"<<endl; 
     
    289289          } 
    290290          catch(exception &ae) { 
    291             if(!arg().mustDo("on-error-resume-next")) 
     291            if(!::arg().mustDo("on-error-resume-next")) 
    292292              throw; 
    293293            else 
     
    296296 
    297297          catch(AhuException &ae) { 
    298             if(!arg().mustDo("on-error-resume-next")) 
     298            if(!::arg().mustDo("on-error-resume-next")) 
    299299              throw; 
    300300            else 
     
    309309    } 
    310310    else { 
    311       ZoneParserTNG zpt(zonefile, arg()["zone-name"]); 
     311      ZoneParserTNG zpt(zonefile, ::arg()["zone-name"]); 
    312312      DNSResourceRecord rr; 
    313313      dirty_hack_num=-1; // trigger first SOA output 
     
    332332  } 
    333333   
    334   if((mode==POSTGRES || mode==ORACLE) && arg().mustDo("transactions") && g_intransaction) 
     334  if((mode==POSTGRES || mode==ORACLE) && ::arg().mustDo("transactions") && g_intransaction) 
    335335    cout<<"COMMIT WORK;"<<endl; 
    336336  return 1;