license.c
来自「speech signal process tools」· C语言 代码 · 共 1,055 行 · 第 1/2 页
C
1,055 行
fprintf(stderr, "License manager on server %s initializing.\n", server_host); exit(-1); case ELM_FAIL: (void) fprintf(stderr, "Sorry, no ERS licenses currently are available.\n"); exit(-1); case ELM_SRV_DOWN: if (h && h[0]) fprintf(stderr, DOWN_MSG1, h, h); else fprintf(stderr, DOWN_MSG2); exit(-1); case ELM_EXPIRED: (void) fprintf(stderr, "Sorry, but your ERS license has expired.\n"); exit(-1); case ELM_ERROR: fprintf(stderr, "Sorry, but you do not seem to have a license for ERS.\n"); fprintf(stderr, "Is the key file installed and readable?\n"); fprintf(stderr, "The key file should be %s/lib/keys/%s\n", get_esps_base(NULL), feature); exit(-1); default: (void) fprintf(stderr, "Network or system error; code: %d\n", ret); (void) fprintf(stderr, "Perhaps your network is not running?\n"); fprintf(stderr, "Contact Entropic if you cannot resolve this.\n"); exit(-1); } waves_running = 1; return;}voidhtk_check(){ int i, j, ret, cnt; struct elm_user user; struct elm_info info; char feature[100]; char *getlogin(); struct passwd *pw, *getpwuid(); char user_name[ELM_USER_LEN + 1]; i = 0; while (erl_htk[i] != -1) { feature[i] = alpha[erl_htk[i]]; i++; } feature[i] = 0; /* * assume that the server is on the current host, unless this environment * variable is set */ server_host[0] = '\0'; if ((h = getenv("ELM_HOST")) && h[0]) (void) strcpy(server_host, h); elm_var = 0; /* * initialize the connection to the license server */#ifdef HP700#define MAX_CNT 5#else#define MAX_CNT 100#endif cnt = 0; while (ret = elm_init(server_host, (char *) NULL, (char *) NULL) == ELM_SRV_DOWN) { lsleep(); if (cnt++ > MAX_CNT) { fprintf(stderr, "Serious network problems here. \n"); fprintf(stderr, "Cannot communicate with server after %d tries.\n", MAX_CNT); exit(1); } } switch (ret) { case ELM_OK: break; case ELM_WAIT: fprintf(stderr, "License manager on server %s initializing.\n", server_host); fprintf(stderr, "Please try again in %ld seconds.\n", elm_var); exit(-1); case ELM_NOHOST: fprintf(stderr, "Invalid host name: %s\n", server_host); fprintf(stderr, "Check your ELM_HOST environment variable.\n"); exit(-1); case ELM_SRV_DOWN: if (h && h[0]) fprintf(stderr, DOWN_MSG1, h, h); else fprintf(stderr, DOWN_MSG2); exit(-1); case ELM_ERROR: default: (void) fprintf(stderr, "Network or system error; (elminit) code: %d\n", ret); (void) fprintf(stderr, "Perhaps your network is not running?\n"); fprintf(stderr, "Contact Entropic if you cannot resolve this.\n"); exit(-1); } pw = getpwuid(getuid()); strncpy(user_name, pw ? pw->pw_name : "<unknown>", ELM_USER_LEN); cnt = 0; for (i = 1; i > 0; i++) { while ((j = elm_getulist(&user, feature, i)) == ELM_SRV_DOWN) { lsleep(); if (cnt++ > MAX_CNT) { fprintf(stderr, "Serious network problems here. \n"); fprintf(stderr, "Cannot communicate with server after %d tries.\n", MAX_CNT); exit(1); } } if (j == 0) break; if ((strcmp(user_name, user.user) == 0)) { waves_running = 1; return; } i = j; } fprintf(stderr, "No HTK license checked out. Trying...\n"); exec_command("hcheckout"); (void) sleep(1); cnt = 0; for (i = 1; i > 0; i++) { while ((j = elm_getulist(&user, feature, i)) == ELM_SRV_DOWN) { lsleep(); if (cnt++ > MAX_CNT) { fprintf(stderr, "Serious network problems here. \n"); fprintf(stderr, "Cannot communicate with server after %d tries.\n", MAX_CNT); exit(1); } } if (j == 0) break; if ((strcmp(user_name, user.user) == 0)) { waves_running = 1; return; } i = j; } fprintf(stderr, NOLIC_MSG_HTK); exit(1);}voidtsm_free(){ elm_bye();}#define ALIGN_BEAT_RATE 60static voidalign_heartbeat(){ (void) alarm(0); signal(SIGALRM, SIG_IGN); feature[0] = '\0'; (void) elm_alive(feature); signal(SIGALRM, align_heartbeat); (void) alarm(ALIGN_BEAT_RATE);}voidalign_check(name) char *name;{ int ret, i; char feature[100]; spsassert(name, "align_check: name is null"); i = 0; while (erl_aligner[i] != -1) { feature[i] = alpha[erl_aligner[i]]; i++; } feature[i] = 0; init(NULL); ret = elm_getlicense(feature, ELM_GETLIC); switch (ret) { case ELM_OK: break; case ELM_WAIT: fprintf(stderr, "License manager on server %s initializing.\n", server_host); exit(-1); case ELM_FAIL: (void) fprintf(stderr, "Sorry, no ALIGNER licenses currently are available.\n"); exit(-1); case ELM_SRV_DOWN: if (h && h[0]) fprintf(stderr, DOWN_MSG1, h, h); else fprintf(stderr, DOWN_MSG2); exit(-1); case ELM_EXPIRED: (void) fprintf(stderr, "Sorry, but your ALIGNER license has expired.\n"); exit(-1); case ELM_ERROR: fprintf(stderr, "Sorry, but you do not seem to have a license for ALIGNER.\n"); fprintf(stderr, "Is the key file installed and readable?\n"); fprintf(stderr, "The key file should be %s/lib/keys/%s\n", get_esps_base(NULL), feature); exit(-1); default: (void) fprintf(stderr, "Network or system error; code: %d\n", ret); (void) fprintf(stderr, "Perhaps your network is not running?\n"); fprintf(stderr, "Contact Entropic if you cannot resolve this.\n"); fprintf(stderr, "Program: %s\n", name); exit(-1); } /* * now set up an alarm to call the elm heartbeat check every 60 seconds */ align_heartbeat(); header_checked = 1; return;}voidalign_check3(name) char *name;{ int ret, i; char feature[100]; spsassert(name, "align_check: name is null"); i = 0; while (erl_aligner[i] != -1) { feature[i] = alpha[erl_aligner[i]]; i++; } feature[i] = 0; init(NULL); ret = elm_getlicense(feature, ELM_GETLIC); switch (ret) { case ELM_OK: break; case ELM_WAIT: fprintf(stderr, "License manager on server %s initializing.\n", server_host); exit(-1); case ELM_FAIL: (void) fprintf(stderr, "Sorry, no ALIGNER licenses currently are available.\n"); exit(-1); case ELM_SRV_DOWN: if (h && h[0]) fprintf(stderr, DOWN_MSG1, h, h); else fprintf(stderr, DOWN_MSG2); exit(-1); case ELM_EXPIRED: (void) fprintf(stderr, "Sorry, but your ALIGNER license has expired.\n"); exit(-1); case ELM_ERROR: fprintf(stderr, "Sorry, but you do not seem to have a license for ALIGNER.\n"); fprintf(stderr, "Is the key file installed and readable?\n"); fprintf(stderr, "The key file should be %s/lib/keys/%s\n", get_esps_base(NULL), feature); exit(-1); default: (void) fprintf(stderr, "Network or system error; code: %d\n", ret); (void) fprintf(stderr, "Perhaps your network is not running?\n"); fprintf(stderr, "Contact Entropic if you cannot resolve this.\n"); fprintf(stderr, "Program: %s\n", name); exit(-1); } header_checked = 1; return;}voidalign_free(name) char *name;{ (void) alarm(0); signal(SIGALRM, SIG_IGN); elm_bye();}voidalign_alive(){ feature[0] = '\0'; (void) elm_alive(feature);}voidalign_free3(name) char *name;{ elm_bye();}static voidinit(){ /* initialize the connection to the license server */ int ret;#ifdef DEBUG fprintf(stderr, "inside of init()\n");#endif server_host[0] = '\0'; if ((h = getenv("ELM_HOST")) && h[0]) (void) strcpy(server_host, h); elm_var = 0;#ifdef DEBUG fprintf(stderr, "calling elm_init()\n");#endif ret = elm_init(server_host, (char *) NULL, (char *) NULL);#ifdef DEBUG fprintf(stderr, "ok\n");#endif switch (ret) { case ELM_OK:#ifdef DEBUG fprintf(stderr, "ok\n");#endif break; case ELM_WAIT: fprintf(stderr, "License manager on server %s initializing.\n", server_host); fprintf(stderr, "Please try again in %ld seconds.\n", elm_var); exit(-1); case ELM_NOHOST: fprintf(stderr, "Invalid host name: %s\n", server_host); fprintf(stderr, "Check your ELM_HOST environment variable.\n"); exit(-1); case ELM_SRV_DOWN: if (h && h[0]) fprintf(stderr, DOWN_MSG1, h, h); else fprintf(stderr, DOWN_MSG2); exit(-1); case ELM_ERROR: default: (void) fprintf(stderr, "Network or system error; (elminit) code: %d\n", ret); (void) fprintf(stderr, "Perhaps your network is not running?\n"); fprintf(stderr, "Contact Entropic if you cannot resolve this.\n"); exit(-1); }#ifdef DEBUG fprintf(stderr, "returning\n");#endif return;}align_check2(name) char *name;{ /* * if the following code is turned on, then the program will run if an * aligner license is present */ int i, ret; struct elm_info info; i = 0; while (erl_aligner[i] != -1) { feature[i] = alpha[erl_aligner[i]]; i++; } feature[i] = 0; init(NULL); ret = elm_getinfo(&info, feature, 0); if (ret > 0 && info.numlic && !expired(info.expiration)) { header_checked = 1; return; } switch (ret) { case ELM_FAIL: case ELM_ERROR: fprintf(stderr, "Sorry, but you do not seem to have a license for ALIGNER.\n"); exit(-1); case ELM_SRV_DOWN: if (h && h[0]) fprintf(stderr, DOWN_MSG1, h, h); else fprintf(stderr, DOWN_MSG2); exit(-1); default: (void) fprintf(stderr, "Network or system error; (getinfo) code: %d\n", ret); (void) fprintf(stderr, "Perhaps your network is not running?\n"); fprintf(stderr, "Contact Entropic if you cannot resolve this.\n"); fprintf(stderr, "Program: %s\n", name); exit(-1); } return;}#ifdef HTK_SPECIAL_KEYcheck_htk_special(fea) char *fea;{ /* * if the following code is turned on, then the program will run if an * aligner license is present */ int i, ret; struct elm_info info; char *leader = "htk_"; char *feature; assert(fea); feature = malloc(strlen(fea) + strlen(leader)); strcpy(feature, leader); strcat(feature, fea); ret = elm_getinfo(&info, feature, 0); if (ret > 0 && info.numlic && !expired(info.expiration)) { free(feature); return; } if (!info.numlic) { fprintf(stderr, "Sorry, you do not have a license for %s.\n", feature); exit(-1); } if (expired(info.expiration)) { fprintf(stderr, "Sorry, but your license %s has expired.\n", feature); exit(-1); } switch (ret) { case ELM_FAIL: case ELM_ERROR: fprintf(stderr, "Sorry, but you do not seem to have a license for %s.\n", feature); exit(-1); case ELM_SRV_DOWN: if (h && h[0]) fprintf(stderr, DOWN_MSG1, h, h); else fprintf(stderr, DOWN_MSG2); exit(-1); default: (void) fprintf(stderr, "Network or system error; (getinfo) code: %d\n", ret); (void) fprintf(stderr, "Perhaps your network is not running?\n"); fprintf(stderr, "Contact Entropic if you cannot resolve this.\n"); exit(-1); }}#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?