C初心者がmemcached-1.4.5を追いかける。(6)
C初心者がmemcached-1.4.5を追いかける。(5)の続き
ソースはコチラにてDLしました。
getoptで受け取ったパラメータによって処理を行っている部分を追いかける。
memcached.c(4318行目あたり)
case 'U': settings.udpport = atoi(optarg); udp_specified = true; break;
起動時の引数オプションにUを加えた場合の処理。
atoi関数の結果をsettings.udpportに返してudp_specified をtrueに。
atoi(3)*1は文字列のはじめの数字の部分を数値(int型)に変換する関数失敗した場合は0となる。
#include <stdlib.h> int atoi(const char *);
数値文字列を整数に変換するAPIは他に、atol、strtol、strtoll、strtodがあるそう*2
ちなみにsettings.udpportのデフォルトは11211です。
memcached.c(180行目あたり)
settings.udpport = 11211;