コードハイライト

| コメント(0) | トラックバック(0)

highlight.jsでコードハイライトを試してみました。

java


public class MainActivity extends FragmentActivity {
static final String TAG = "MainActivity";

/**
* The {@link android.support.v4.view.PagerAdapter} that will provide
* fragments for each of the sections. We use a {@link FragmentPagerAdapter}
* derivative, which will keep every loaded fragment in memory. If this
* becomes too memory intensive, it may be best to switch to a
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
*/

/**
* The {@link ViewPager} that will host the section contents.
*/
// ViewPager mViewPager;
GoogleMap map;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();

MapsInitializer.initialize(this);

moveToSapporoStation();
}
}

C++


/*
* main.cpp
*
* Created on: 2012/06/12
* Author: yasuoki
*/

#include "sentinel.h"
#include "sst_memory.h"
#include "pjson.h"
#include
#include
#include
#include
#include
#include

using namespace SST;

int main(int argc, char *argv[])
{
char confFile[1024];

strcpy(confFile, SST_CONFFOLDER "/" SST_CONFFILE);

openlog(SST_SYSLOGIDENT, LOG_PID, LOG_USER);
Sentinel *obj = new Sentinel();

argc--; argv++;
while(argc) {
char *p = *argv;
if( *p == '-' ) {
if( strcmp( p+1, "f") == 0 ) {
argc--; argv++;
if( !argc ) {
obj->log(LOG_ERR, "param error (-f)");
exit(EXIT_FAILURE);
}
strcpy(confFile, *argv );
argc--; argv++;
} else if( strcmp(p+1, "v") == 0 ) {
#ifdef _DEBUG
printf("sentinel %s (DEBUG build)\n", SST_VERSION);
#else
printf("sentinel %s\n", SST_VERSION);
#endif
return 0;
}
continue;
}
fprintf(stderr, "param error (%s)", p);
exit(EXIT_FAILURE);
}
obj->log(LOG_NOTICE, "sentinel %s", SST_VERSION);

if( !obj->loadConfig(confFile) ) {
exit(EXIT_FAILURE);
closelog();
}

Conf *conf = obj->getConf();
int f = LOG_USER;
if( conf->daemonaize )
f = LOG_DAEMON;
if( (conf->logIdent && strcmp(conf->logIdent, SST_SYSLOGIDENT) != 0) || conf->daemonaize || conf->logFacility != f ) {
closelog();
int f = LOG_USER;
if( conf->daemonaize )
f = LOG_DAEMON;
if( conf->logFacility != 0)
f = conf->logFacility;
openlog(conf->logIdent, LOG_PID, f);
obj->log(LOG_NOTICE, "sentinel %s", SST_VERSION);
}

if( conf->daemonaize ) {
pid_t pid, sid;
pid = fork();
if (pid < 0) {
obj->log(LOG_ERR, "fork");
exit(EXIT_FAILURE);
}
if (pid > 0)
exit(EXIT_SUCCESS);

sid = setsid();
if (sid < 0) {
obj->log(LOG_ERR, "setsid");
exit(EXIT_FAILURE);
}
if (chdir("/") < 0) {
obj->log(LOG_ERR, "chdir");
exit(EXIT_FAILURE);
}
umask(0);
{
FILE *fp = fopen(conf->pidFile, "w");
if( fp == NULL ) {
fprintf(stderr, "create pid file error.\n");
obj->log(LOG_ERR, "create pid file error.");
exit(EXIT_FAILURE);
}
fprintf(fp,"%d", getpid());
fclose(fp);
}
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
}

if( !obj->run() ) {
obj->log(LOG_ERR, "sentinel aborted");
if( conf->daemonaize ) {
unlink(conf->pidFile);
}
exit(EXIT_FAILURE);
}
if( conf->daemonaize ) {
unlink(conf->pidFile);
}
delete obj;
closelog();
#ifdef SST_DEBUG
sst_dump();
#endif
exit(EXIT_SUCCESS);
}

MTで使うには簡単で良いですね。

トラックバック(0)

トラックバックURL: http://diylabo.sakura.ne.jp/db/mt-tb.cgi/62

コメントする

2023年10月

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
OpenID対応しています OpenIDについて