int main(int c, char **v) { if (c != 2){ perror("usage..."); return 0; } char buf[256], path[32]; IpInfoTmp tmp; int ret, type; init_from_file(v[1], path); init_cache_ipinfo(path); while (1){ printf("%s\n", help); printf("please input your Choose: "); fflush(stdout); ret = read(0, buf, sizeof(buf)); buf[ret - 1] = '\0'; type = atoi(buf); switch (type) { case 0: memset(&tmp, 0, sizeof(IpInfoTmp)); printf("please input ipstr:"); fflush(stdout); ret = read(0, buf, sizeof(buf)); buf[ret - 1] = '\0'; if (!getIpInfo(buf, &tmp)){ printf("\n%s %s %s %s\n", tmp.countrybuf, tmp.areabuf, tmp.ip[0], tmp.ip[1]); } break; case 1: printf("please input city name or addr name:"); fflush(stdout); ret = read(0, buf, sizeof(buf)); buf[ret - 1] = '\0'; getIpByAddr(buf); break; case 2: show_cache_ipinfo(); break; case 3: export_all_records(); break; case 4: goto OUT; default: printf("\n your input is err!\n"); } } OUT: return 0; }
Wagnis::Wagnis(QNetworkAccessManager *manager, const QString &applicationName, const QString applicationVersion, QObject *parent) : QObject(parent) { qDebug() << "Initializing Wagnis..."; this->manager = manager; this->applicationName = applicationName; this->applicationVersion = applicationVersion; getIpInfo(); /* Load the human readable error strings for libcrypto */ ERR_load_crypto_strings(); /* Load all digest and cipher algorithms */ OpenSSL_add_all_algorithms(); /* Load config file, and other important initialisation */ OPENSSL_config(NULL); generateId(); readRegistration(); }