📄 gmctest.cpp
字号:
/*************************************************************************** gmctest.cpp - Test de cliente del Monitor ------------------- begin : Miercoles 30 de octubre de 2002 copyright : (C) 2002 by Walter Gabriel Pirri email : gnumonitor@witch-blade.com.ar ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#include <unistd.h>#include <stdio.h>#include <stdlib.h>#include <signal.h>#include <string.h>#include <sys/wait.h>#include <syslog.h>#include <gnumonitor/gmc.h>int main(int argc, char** argv){ gm_stinit st_init; char query[256]; char* response; unsigned int qlen = strlen(query); unsigned int rlen; int rc; char strtemp[256]; memset(&st_init, 0, sizeof(st_init)); strcpy(st_init.host,"localhost"); strcpy(st_init.user, "USER"); strcpy(st_init.client, "CLIENT"); strcpy(st_init.key, "KEY"); strcpy(st_init.group, "GROUP"); if(argc > 1) { strcpy(st_init.host,argv[1]); } if(gminit(&st_init) != 0) return 1;/**/ while(1) { rlen = 0; strcpy(query, "la verdad de la milanesa"); qlen = strlen(query)+1; rc = gmcall(".eco", query, qlen, &response, &rlen, 30000); if(rc != 0) { printf("<!> Error -> %i\n", rc); printf(" ERROR: %s\n", gmerrortext(rc)); break; } else { printf("<i> Ok [%u]\n", rlen); /* response[rlen] = '\0'; */ printf("%s\n", response); gmfree(response); } break; // una sola vez //sleep(2); } gmterm(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -