flashpolicyd c °æ±¾
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#define MAX_READFILE 24
#define MAX_INPUTFILE 10240
char *file ;
void time_out(){
syslog(LOG_INFO,"read input timeout!");
exit(1);
}
void
usage(void)
/* print a help message about command line options and exit */
{
syslog(LOG_INFO,"system error:be short of params!");
fprintf (stdout,"system error:be short of params!");
exit(1);
}
char *f_opt_arg;
struct option longopts[] = {
{ "file",required_argument,NULL,'f'},
{ 0, 0, 0, 0}
};
void
parseopt(int argc, char *argv[])
/* set options */
{
int c;
/* constants and variables defined by command line */
while(1) {
c = getopt_long(argc, argv, ":f:", longopts, NULL);
if (c == EOF) break;
switch (c) {
case 'f':
file = optarg; break;
case ':':
usage();
case '?':
usage();
default:
usage();
}
}
}
int main(int argc ,char **argv)
{
/* interpret command line options */
parseopt(argc, argv);
FILE *fd ;
char xmlnote[MAX_INPUTFILE+1] ;
syslog(LOG_INFO,"start read xml:%s",file);
if((fd = fopen(file ,"r")) ==NULL){
syslog(LOG_INFO,"not found xml:%s",file);
exit(1);
}
int ch;
int counter=0;
while ( (ch = fgetc(fd)) != EOF ) {
xmlnote[counter] = ch;
counter++;
}
fclose(fd);
char *base ="<policy-file-request/>\000";
char input[MAX_READFILE+1] ;
signal(SIGALRM,time_out);
alarm(1);
char *r = fgets(input, MAX_READFILE, stdin);
alarm(0);
int cmp = memcmp(base,input,MAX_READFILE);
if( cmp<0 || cmp>0){
syslog(LOG_INFO,"read input bad format!");
exit(1);
}
if ( r!= NULL ) {
syslog(LOG_INFO,"end read input:%s",input);
fprintf (stdout,xmlnote);
}
return 0;
}
Ïà¹ØÎĵµ£º
ǶÈëʽϵͳÓÉÓÚÊܹ¦ºÄ¡¢³É±¾ºÍÌå»ýµÈÒòËصÄÖÆÔ¼£¬Ç¶Èëʽ΢´¦ÀíÆ÷µÄ´¦ÀíÄÜÁ¦Óë×ÀÃæϵͳ´¦ÀíÆ÷Ïà±ÈÒ²´æÔڽϴó²î¾à£¬¹ÊǶÈëʽϵͳ¶Ô³ÌÐòÔËÐеĿռäºÍʱ¼äÒªÇó¸üΪ¿Á¿Ì¡£
ͨ³££¬ÐèÒª¶ÔǶÈëʽӦÓóÌÐò½øÐÐÐÔÄÜÓÅ»¯£¬ÒÔÂú×ãǶÈëʽӦÓõÄÐÔÄÜÐèÇó¡£
1 ǶÈëʽ³ÌÐòÓÅ»¯µÄÀàÐÍ
&nbs ......
1.×Ô¶¨ÒåÊä³ö
Ïë±Ø´ó¼Ò¶¼ÓÐÀûÓÃÊä³öº¯ÊýÈçprintfÀ´°ïÖúÎÒÃǵ÷ÊÔ³ÌÐòµÄ¾Àú£¬ÕâÊÇÒ»ÖֱȽÏÔʼµÄ³ÌÐòµ÷ÊÔ¸¨Öú·½·¨£¬ÔÚLinuxÏÂÒ²¿ÉÒÔΪÎÒÃÇËùÓᣲ»¹ýÕâÖÖ·½·¨ÓÐÒ»¸öÃ÷ÏÔµÄȱµã£¬¾ÍÊÇÔÚµ÷ÊÔÍêºóÎÒÃDZØÐë×¢ÊÍ»òɾ³ýµôÕâЩ¸¨Öú´úÂë¡£Linux CÌṩÁË-DDEBUGÕâ¸ö±àÒë±ê¼ÇÀ´¶¨ÒåDEBUGÕâ¸ö·ûºÅ£¬½èÖúÓڸ÷ûºÅ£¬ÎÒÃÇ¿ÉÒÔÔÚÓ¦Ó ......
¡¡¡¡1.¸ÅÊö
¡¡¡¡Ðí¶à³õѧÕ߶ÔC/C++ÓïÑÔÖеÄvoid¼°voidÖ¸ÕëÀàÐͲ»ÉõÀí½â£¬Òò´ËÔÚʹÓÃÉϳöÏÖÁËһЩ´íÎó¡£±¾ÎĽ«¶Ôvoid¹Ø¼ü×ÖµÄÉî¿Ìº¬Òå½øÐнâ˵£¬²¢ÏêÊövoid¼°voidÖ¸ÕëÀàÐ͵ÄʹÓ÷½·¨Óë¼¼ÇÉ¡£
¡¡¡¡2.voidµÄº¬Òå
¡¡¡¡voidµÄ×ÖÃæÒâ˼ÊÇ“ÎÞÀàÐÍ”£¬void *ÔòΪ“ÎÞÀàÐÍÖ¸Õ딣¬void *¿ÉÒÔÖ¸ÏòÈκÎÀàÐ͵ÄÊ ......
VCÖÐÏÂÃ漸¸ö½á¹¹Ìå´óС·Ö±ðÊǶàÉÙÄØ
struct MyStruct
{
double m4;
char m1;
int m3£»
};
struct MyStruct {
  ......
£¨Î壩
40. Á´±íÌ⣺һ¸öÁ´±íµÄ½áµã½á¹¹
struct Node
{
int data ;
Node *next ;
};
typedef struct Node Node ;
(1)ÒÑÖªÁ´±íµÄÍ·½áµãhead,дһ¸öº¯Êý°ÑÕâ¸öÁ´±íÄæÐò ( Intel)
Node * ReverseList(Node *head) //Á´±íÄæÐò
{
i ......