www.pudn.com > mypro-telnet.rar > showpu.c, change:2010-07-16,size:678b
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <netinet/in.h> #include <arpa/inet.h> int RegStatus = 0; int readRegStatus() { FILE *fpReg = NULL; if ((fpReg=fopen("/tmp/regstatus.bin","r")) == NULL) { return 0; } else { if (fread(&RegStatus,1,sizeof(int),fpReg) != sizeof(int)) { printf("Error:Reading from /tmp/regstatus.bin failed!\n"); return -1; } fclose(fpReg); } return 0; } int main(int argc, char* argv[]) { if (readRegStatus() < 0) return -1; if (RegStatus) printf("the device is online\n"); else printf("the device is not online\n"); return 0; }