common.c

来自「Linux内核监控工具。 Linux内核监控工具。 Linux内核监控工具。」· C语言 代码 · 共 114 行

C
114
字号
/***************************************************************************                          common.c  -  description                             -------------------    begin                : Thu Sep 27 08:08:03 EET 2001    copyright            : (C) 2001-2002 by Petri Turunen    email                : petri.turunen@pete.fi.eu.org ***************************************************************************//*************************************************************************** *                                                                         * *   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.                                   * *                                                                         * ***************************************************************************/#ifdef HAVE_CONFIG_H#include <config.h>#endif#include<linux_mond.h>#include <stdarg.h> //va_endint slog(int k, char *fmt, ...){//1=no pid & 2= with pidchar message[1024];va_list ap;va_start (ap, fmt);vsnprintf(message, 1024, fmt, ap);if (k==1)        {        openlog("linux_mond",LOG_PID,LOG_USER);        syslog(LOG_INFO, message);        closelog();        return 0;        }if (k==2)        {        openlog("linux_mond",LOG_PID,LOG_USER);        syslog(LOG_ALERT, message);        closelog();        return 0;        }va_end(ap);return 0;}char *rm_first_spaces(char *k){        int lenght,tmp = 0;        lenght = strlen(k);        while(*k==' ' || *k=='\t'){                k++;        if(tmp >= lenght)                break;        tmp++;        }        return(k);}int is_comment(char *c){if(*c=='#' || *c=='\0'){        return 0;} else {        return 1;}}//Writes stuff to socketint send_tcp(unsigned char *buf, int buf_len, int sockfd){ int len;  while( buf_len > 0) {  len = write(sockfd, buf, buf_len);  buf_len -= len;  buf += buf_len; } return 0;}char *escapeunwanted (const char *const s){  GString *str = g_string_new (s);  register gint i = 0;  gchar *ret;  while (str->str[i] != '\0')  {    if (str->str[i] == '\\' || str->str[i] == '\'')      g_string_insert_c (str, i++, '\\');    i++;  }  ret = str->str;  g_string_free (str, FALSE);  return (ret);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?