软著申请源代码
软件著作权申请材料清单(源代码的整理)
附件二:(如何整理源代码—源代码注意的事项)
1、看你的软件是否是分:主要模块和次要模块---如果有主次模块之分---请提供主要模块的前后各2000行。
2、如果没有主次要模块之分:就从源代码的最开头提供前2000行,最后结尾提供后2000行。
代码的要求
1.
代码要求是提供原始的代码不是关键代码语法上要求完整
例如C++代码应该是 include 之类开头的而不是直接一开始就是函数
C#代码应该是 using 之类开头的而不是直接一开始就是函数
例如以下为完整的C#代码开头
要求提供的是对应的代码文件的原始文本
2.
第一页应该是以下一种情况所在的页面的原始代码
1.主函数
2.程序的入口比如登录函数
3.主页比如index default页面
3.
尽量少提供或者不提供设计器生成的代码
以C#语言为例设计器生成的代码语言文件一般为XXXt.designer.cs:
内容比如
4.
代码量4000行以下的提供全部源代码
代码量4000行以上的至少提供4000行代码Word中有行数统计功能
方法如下。
计算机软件著作权登记-源代码范本
package .example.shuoya;import java.util.Set;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.os.Bundle;import android.telephony.SmsMessage;import android.util.Log;import android.widget.Toast;public class Breast extends BroadcastReceiver{private static final String mACTION = "android.provider.Telephony.SMS_RECEIVED"; Overridepublic void onReceive(Context context, Intent intent){// TODO Auto-generated method stubif (intent.getAction().equals(mACTION)){StringBuilder sb = new StringBuilder();Bundle bundle = intent.getExtras();if (bundle != null){Set<String> keysSet=bundle.keySet();for(String keyString:keysSet){Log.d("key", keyString);}Object[] myOBJpdus = (Object[]) bundle.get("pdus");SmsMessage[] messages = new SmsMessage[myOBJpdus.length];for (int i = 0; i<myOBJpdus.length; i++){messages[i] = SmsMessage.createFromPdu ((byte[]) myOBJpdus[i]);}for (SmsMessage currentMessage : messages){//sb.append("接收到来告:\n");//sb.append(currentMessage.getDisplayOriginatingAddress());//sb.append("\n------传来的短信------\n");sb.append(currentMessage.getDisplayMessageBody());}}Toast.makeText(context, sb, Toast.LENGTH_LONG).show();Intent i2 = new Intent(context, FuzhuActivity.class);Bundle bundle2=new Bundle();bundle2.putString("SMS", sb.toString());i2.putExtra("SMSS", bundle2);i2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);context.startActivity(i2);}}}package .example.shuoya;import android.content.Context;import android.database.sqlite.SQLiteDatabase;import android.database.sqlite.SQLiteDatabase.CursorFactory;import android.database.sqlite.SQLiteOpenHelper;public class DbAdapter extends SQLiteOpenHelper{private static final int VERSION = 1;private static final String DBNAME = "test.db";public DbAdapter(Context context, String name,CursorFactory factory, int version) {super(context, name, factory, version);// TODO Auto-generated constructor stub}public DbAdapter(Context context,String name){this(context,name,VERSION);}public DbAdapter(Context context){this(context,DBNAME,VERSION);}public DbAdapter(Context context,String name,int version){this(context,name,null,VERSION);}public void onCreate(SQLiteDatabase db) {// TODO Auto-generated method stub}public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stubSystem.out.println("update a database");}}package .example.shuoya;import java.util.List;import .example.shuoya.R;import android.app.AlertDialog;import android.content.Context;import android.database.DataSetObserver;import youtInflater;import android.view.MotionEvent;import android.view.View;import android.view.View.OnClickListener;import android.view.View.OnLongClickListener;import android.view.View.OnTouchListener;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.LinearLayout;import android.widget.TextView;//public class DetailAdapter implements ListAdapterpublic class DetailAdapter extends BaseAdapter{private List<DetailEntity> coll;private Context ctx;DetailEntity entity;LinearLayout layout;LayoutInflater vi;LinearLayout layout_bj;TextView tvName;TextView tvDate;TextView tvText;public DetailAdapter(Context context, List<DetailEntity> coll) {ctx = context;this.coll = coll;}public boolean areAllItemsEnabled(){return true;}public boolean isEnabled(int arg0){return true;}public int getCount(){return coll.size();}public Object getItem(int position){return coll.get(position);}public long getItemId(int position){return position;}public int getItemViewType(int position){return position;}public View getView(int position, View convertView, ViewGroup parent) {entity = coll.get(position);int itemLayout = entity.getLayoutID();layout = new LinearLayout(ctx);vi = (LayoutInflater) ctx.getSystemService(YOUT_INFLATER_SERVICE);vi.inflate(itemLayout, layout, true);layout.setBackgroundColor(0xffB4B4B4);layout_bj = (LinearLayout) layout.findViewById(yout_bj);tvName = (TextView) layout.findViewById(R.id.messagedetail_row_name);tvName.setText(entity.getName());tvDate = (TextView) layout.findViewById(R.id.messagedetail_row_date);tvDate.setText(entity.getDate());tvText = (TextView) layout.findViewById(R.id.messagedetail_row_text);tvText.setText(entity.getText());addListener(tvName, tvDate, tvText, layout_bj);return layout;}public int getViewTypeCount(){return coll.size();}public boolean hasStableIds(){return true;}public boolean isEmpty(){return true;}Overridepublic void registerDataSetObserver(DataSetObserver observer){// TODO Auto-generated method stub}Overridepublic void unregisterDataSetObserver(DataSetObserver observer){// TODO Auto-generated method stub}public void addListener(final TextView tvName, final TextView tvDate, final TextView tvText, LinearLayout layout_bj){layout_bj.setOnClickListener(new OnClickListener(){Overridepublic void onClick(View v){}});//实例并初始化TTS对象layout_bj.setOnLongClickListener(new OnLongClickListener(){Overridepublic boolean onLongClick(final View v){tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setTextColor(0xffffffff);new AlertDialog.Builder(ctx).setMessage("说呀聊天辅助系统-应答模式").setPositiveButton("确定",null).show();return true;}});////layout_bj.setOnTouchListener(new OnTouchListener(){Overridepublic boolean onTouch(View v, MotionEvent event){switch (event.getAction()){case MotionEvent.ACTION_DOWN:case MotionEvent.ACTION_MOVE:tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setTextColor(0xffffffff);break;default:tvName.setTextColor(0xff000000);tvDate.setTextColor(0xff000000);tvText.setTextColor(0xff0000ff);break;}return false;}});}}package .example.shuoya;public class DetailEntity{private String name;private String date;private String text;private int layoutID;public String getName(){return name;}public void setName(String name){ = name;}public String getDate(){return date;}public void setDate(String date){this.date = date;}public String getText(){return text;}public void setText(String text){this.text = text;}public int getLayoutID(){return layoutID;}public void setLayoutID(int layoutID){youtID = layoutID;}public DetailEntity(){}public DetailEntity(String name, String date, String text, int layoutID){super(); = name;this.date = date;this.text = text;youtID = layoutID;}}package .example.shuoya;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import .URL;import .URLEncoder;public class Fenci{/* Called when the activity is first created. */static String u = "/fudannlp/";public String str;public static String nlp(String func, String input){String str1="";try{input = URLEncoder.encode(input, "utf-8");URL url = new URL( u + func + "/" + input);StringBuffer sb = new StringBuffer();BufferedReader out = new BufferedReader(new InputStreamReader(url.openStream(), "utf-8"));String line;while ((line = out.readLine()) != null)sb.append(line);str1=sb.toString();out.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}int i=str1.indexOf("s");str1=str1.substring(i+1);return str1;}}package .example.shuoya;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import java.io.OutputStream;import java.util.ArrayList;import java.util.List;import .example.shuoya.R;import android.app.Activity;import android.app.AlertDialog;import android.content.Context;import android.content.DialogInterface;import android.content.Intent;import android.content.pm.PackageManager;import android.content.pm.ResolveInfo;import android.os.Bundle;import android.speech.RecognizerIntent;import youtInflater;import android.view.View;import android.view.Window;import android.view.View.OnClickListener;import android.view.WindowManager;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.ListView;import android.widget.PopupWindow;import android.widget.Toast;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.graphics.drawable.BitmapDrawable;public class FuzhuActivity extends Activity{private ListView talkView;private List<DetailEntity> list = null;//menu菜单模块private PopupWindow popupWindow;private ListView lv_menu;private View view;private List<String> Menus;private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;private EditText mText1;private Button speakButton;private Button qdButton;private Button chooseButton;long exitTime=-2000;Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(yout.test);//将数据库放到手机中,测试时注释掉PackageManager pm = getPackageManager();//管理应用程序包List<ResolveInfo> activities = pm.queryIntentActivities(newIntent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);}public String getResponce(String et){String answer="";String myFenci=Fenci.nlp("pos",et);String mySubject,myPredicate,myObject;//定义主谓宾mySubject=GetWord.ReturnSubject(myFenci);myPredicate=GetWord.ReturnPredicate(myFenci);myObject=GetWord.ReturnObject(myFenci);DbAdapter dbHelper = new DbAdapter(FuzhuActivity.this,"test.db");//只有调用了DatabaseHelper对象的//getReadableDatabase()方法,或者是getWritableDatabase()方法之后,才会创建,或打开一个数据库SQLiteDatabase db = dbHelper.getReadableDatabase();int id_temp1,id_temp2,id_temp3;String search_id;Cursor cursor1;if(mySubject==null){id_temp1=0;}else{cursor1 = db.query("r_sheet", new String[]{"id"}, "charName=?", newString[]{mySubject}, null, null, null);if(cursor1.moveToNext()){//在r表中查询id_temp1=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp1=0;}}if(myPredicate==null){id_temp2=0;}else{cursor1 = db.query("verb_sheet", new String[]{"id"}, "verbName=?", newString[]{myPredicate}, null, null, null);if(cursor1.moveToNext()){//在v表中查询id_temp2=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp2=0;}}if(myObject==null){id_temp3=0;}else{cursor1 = db.query("noun_sheet", new String[]{"id"}, "nounName=?", newString[]{myObject}, null, null, null);if(cursor1.moveToNext()){//在n表中查询id_temp3=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp3=0;}}search_id=numberToString(id_temp1)+numberToString(id_temp2)+numberToString(id_temp3);cursor1 = db.query("answer_sheet", new String[]{"answer"}, "id=?", newString[]{search_id}, null, null, null);if(cursor1.moveToNext()){//在answer表中查询answer=cursor1.getString(cursor1.getColumnIndex("answer"));}else{}if(answer!=""){Toast.makeText(getApplicationContext(), answer, Toast.LENGTH_LONG).show();}else if(answer==""){Toast.makeText(getApplicationContext(), "暂无提示", Toast.LENGTH_LONG).show();}else{Toast.makeText(getApplicationContext(), "暂无提示", Toast.LENGTH_LONG).show();}return answer;}public String numberToString(int number){String s="";if (number==0||number<10)s="00"+String.valueOf(number);else if(number<100)s="0"+String.valueOf(number);elses=String.valueOf(number);return s;}}package .example.shuoya;import android.os.AsyncTask;public class GetResTask extends AsyncTask<String,Void,String>{TestActivity atxs=new TestActivity();Overrideprotected String doInBackground(String... params) { // TODO Auto-generated method stubreturn atxs.getResponce(params[0]);}protected Void onPostExcute(String result){return null;}}package .example.shuoya;import unchOnKeyguardExit; import android.app.Activity;import android.content.Intent;import android.content.SharedPreferences;import android.graphics.Bitmap;import android.os.Bundle;import android.preference.PreferenceManager;import android.view.Display;import android.view.View;import android.view.Window;import android.view.WindowManager;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.ScrollView;import android.widget.TextView;public class SMSPopupActivity extends Activity {private SmsMmsMessage message;private boolean exitingKeyguardSecurely = false;private Bundle bundle = null;private SharedPreferences myPrefs;private TextView headerTV;private TextView messageTV;private TextView fromTV;private TextView mmsSubjectTV;private LinearLayout viewButtonLayout;private LinearLayout mmsLinearLayout;private ScrollView messageScrollView;private boolean wasVisible = false;private final double WIDTH = 0.8;Overrideprotected void onCreate(Bundle bundle) {super.onCreate(bundle);Log.v("SMSPopupActivity: onCreate()");//First things first, acquire wakelock, otherwise the phone may sleepManageWakeLock.acquirePartial(getApplicationContext());requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(yout.popup);//Get shared prefsmyPrefs = PreferenceManager.getDefaultSharedPreferences(this);//Check preferences and then blur out background behind windowif (myPrefs.getBoolean(getString(R.string.pref_blur_key),Boolean.valueOf(getString(R.string.pref_blur_default)))) {getWindow().setFlags(youtParams.FLAG_BLUR_BEHIND, youtParams.FLAG_BLUR_BEHIND);}//This sets the minimum width of the activity to 75% of the screen size//only needed because the theme of this activity is "dialog" so it looks //like it's floating and doesn't seem to fill_parent like a regular activity LinearLayout mainLL = (LinearLayout) findViewById(R.id.MainLinearLayout);Display d = getWindowManager().getDefaultDisplay();int width = (int)(d.getWidth() * WIDTH);Log.v("setting width to: " + width);mainLL.setMinimumWidth(width);//Find the main textviewsfromTV = (TextView) findViewById(R.id.FromTextView);messageTV = (TextView) findViewById(R.id.MessageTextView);headerTV = (TextView) findViewById(R.id.HeaderTextView);mmsSubjectTV = (TextView) findViewById(R.id.MmsSubjectTextView);viewButtonLayout = (LinearLayout) findViewById(R.id.ViewButtonLinearLayout);messageScrollView = (ScrollView) findViewById(R.id.MessageScrollView);mmsLinearLayout = (LinearLayout) findViewById(R.id.MmsLinearLayout);//The close buttonButton closeButton = (Button) findViewById(R.id.closeButton);closeButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {Intent i = new Intent(SMSPopupActivity.this.getApplicationContext(),SMSPopupUtilsService.class);// i.putExtra(SMSPopupUtilsService.EXTRAS_THREAD_ID,// message.getThreadId());i.setAction(SMSPopupUtilsService.ACTION_MARK_THREAD_READ);i.putExtras(message.toBundle());SMSPopupUtilsService.beginStartingService(SMSPopupActivity.this.getApplicationContext(), i);// Finish up this activitymyFinish();}});//The inbox buttonButton inboxButton = (Button) findViewById(R.id.InboxButton);inboxButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() {public void LaunchOnKeyguardExitSuccess() {Intent i = SMSPopupUtils.getSmsIntent();SMSPopupActivity.this.getApplicationContext().startActivity(i); }});myFinish();}});//The view button (if in privacy mode)Button viewButton = (Button) findViewById(R.id.ViewButton);viewButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() {public void LaunchOnKeyguardExitSuccess() {Intent i = getIntent();i.putExtra(SmsMmsMessage.EXTRAS_NOTIFY, false);startActivity(i);// finish();}});}});//The reply buttonButton replyButton = (Button) findViewById(R.id.replyButton);replyButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() {public void LaunchOnKeyguardExitSuccess() {Intent reply = message.getReplyIntent();SMSPopupActivity.this.getApplicationContext().startActivity(reply); }});ManageNotification.clearAll(SMSPopupActivity.this.getApplicationContext(), true);myFinish();}});// The ViewMMS buttonButton viewMmsButton = (Button) findViewById(R.id.ViewMmsButton);viewMmsButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() {public void LaunchOnKeyguardExitSuccess() {Intent reply = message.getReplyIntent();SMSPopupActivity.this.getApplicationContext().startActivity(reply);}});ManageNotification.clearAll(SMSPopupActivity.this.getApplicationContext(), true);myFinish();}});if (bundle == null) {populateViews(getIntent().getExtras());} else {populateViews(bundle);}wakeApp();}Overrideprotected void onNewIntent(Intent intent) {super.onNewIntent(intent);Log.v("SMSPopupActivity: onNewIntent()");//First things first, acquire wakelock, otherwise the phone may sleepManageWakeLock.acquirePartial(getApplicationContext());setIntent(intent);//Re-populate views with new intent data (ie. new sms data)populateViews(intent.getExtras());wakeApp();}Overrideprotected void onStart() {super.onStart();Log.v("SMSPopupActivity: onStart()");ManageWakeLock.acquirePartial(getApplicationContext());}Overrideprotected void onResume() {super.onResume();Log.v("SMSPopupActivity: onResume()");wasVisible = false;//Reset exitingKeyguardSecurely bool to falseexitingKeyguardSecurely = false;}Overrideprotected void onPause() {super.onPause();Log.v("SMSPopupActivity: onPause()");if (wasVisible) {//Cancel the receiver that will clear our locksClearAllReceiver.removeCancel(getApplicationContext());ClearAllReceiver.clearAll(!exitingKeyguardSecurely);}}Overrideprotected void onStop() {super.onStop();Log.v("SMSPopupActivity: onStop()");//Cancel the receiver that will clear our locksClearAllReceiver.removeCancel(getApplicationContext());ClearAllReceiver.clearAll(!exitingKeyguardSecurely);}Overridepublic void onWindowFocusChanged(boolean hasFocus) {super.onWindowFocusChanged(hasFocus);Log.v("SMSPopupActivity: onWindowFocusChanged(" + hasFocus + ")");if (hasFocus) {wasVisible = true;}}Overridepublic void onSaveInstanceState(Bundle outState) {super.onSaveInstanceState(outState);Log.v("SMSPopupActivity: onSaveInstanceState()");outState.putAll(bundle);}private void myFinish() {ManageNotification.clearAll(getApplicationContext());ReminderReceiver.cancelReminder(getApplicationContext());finish();}private void populateViews(Bundle b) {bundle = b;message = new SmsMmsMessage(getApplicationContext(), bundle);refreshPrivacy();ImageView iv = (ImageView) findViewById(R.id.FromImageView);Bitmap contactPhoto = message.getContactPhoto();if (contactPhoto != null) {iv.setImageBitmap(contactPhoto);} else {iv.setImageDrawable(getResources().getDrawable(android.R.drawable.ic_dialog_info));}LinearLayout mLL = (LinearLayout) findViewById(R.id.UnreadCountLinearLayout);TextView tv = (TextView) findViewById(R.id.UnreadCountTextView);if (message.getUnreadCount() <= 1) {mLL.setVisibility(View.GONE);tv.setText("");} else {String textWaiting = String.format(getString(R.string.unread_text_waiting), message.getUnreadCount() - 1);tv.setText(textWaiting);mLL.setVisibility(View.VISIBLE);}String headerText = getString(R.string.new_text_at);headerText = headerText.replaceAll("%s", message.getFormattedTimestamp());fromTV.setText(message.getContactName());if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_SMS) {messageTV.setText(message.getMessageBody());} else {mmsSubjectTV.setText(getString(R.string.mms_subject) + " " +message.getMessageBody());}headerTV.setText(headerText);}private void refreshPrivacy() {ManageKeyguard.initialize(getApplicationContext());boolean privacyMode = myPrefs.getBoolean(getString(R.string.pref_privacy_key),Boolean.valueOf(getString(R.string.pref_privacy_default)));if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_MMS) { viewButtonLayout.setVisibility(View.GONE);messageScrollView.setVisibility(View.GONE);mmsLinearLayout.setVisibility(View.VISIBLE);boolean subjectAvailable = true;if (message.getMessageBody() == null) {subjectAvailable = false;} else {if (message.getMessageBody().length() == 0) {subjectAvailable = false;}}if (!subjectAvailable) {mmsSubjectTV.setVisibility(View.GONE);} else {mmsSubjectTV.setVisibility(View.VISIBLE);}} else {mmsLinearLayout.setVisibility(View.GONE);if (privacyMode && ManageKeyguard.inKeyguardRestrictedInputMode()) { viewButtonLayout.setVisibility(View.VISIBLE);messageScrollView.setVisibility(View.GONE);} else {viewButtonLayout.setVisibility(View.GONE);messageScrollView.setVisibility(View.VISIBLE);}}}private void wakeApp() {ManageWakeLock.acquireFull(getApplicationContext());if (message.getNotify()) {bundle.putBoolean(SmsMmsMessage.EXTRAS_NOTIFY, false);message.updateReminderCount(0);ReminderReceiver.scheduleReminder(getApplicationContext(), message);ManageNotification.show(getApplicationContext(), message);}}Overrideprotected void onDestroy() {Log.v("onDestroy()");super.onDestroy();}}package .example.shuoya;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;public class SMSReceiver extends BroadcastReceiver {Overridepublic void onReceive(Context context, Intent intent) {Log.v("SMSReceiver: onReceive()");intent.setClass(context, SMSReceiverService.class);intent.putExtra("result", getResultCode());SMSReceiverService.beginStartingService(context, intent);}}package .example.shuoya;import android.app.AlarmManager;import android.app.PendingIntent;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;import android.preference.PreferenceManager;public class ReminderReceiver extends BroadcastReceiver {private static PendingIntent reminderPendingIntent = null;Overridepublic void onReceive(Context context, Intent intent) {intent.setClass(context, ReminderReceiverService.class);ReminderReceiverService.beginStartingService(context, intent);}public static void scheduleReminder(Context context, SmsMmsMessage message) { SharedPreferences myPrefs = PreferenceManager.getDefaultSharedPreferences(context);boolean reminder_notifications = myPrefs.getBoolean(context.getString(R.string.pref_notif_repeat_key), Boolean.valueOf(context.getString(R.string.pref_notif_repeat_default)));if (reminder_notifications) {int reminder_interval = Integer.parseInt(myPrefs.getString(context.getString(R.string.pref_notif_repeat_interval_key), context.getString(R.string.pref_notif_repeat_interval_default)));reminder_interval *= 60;AlarmManager myAM = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);Intent reminderIntent = new Intent(context, ReminderReceiver.class);reminderIntent.setAction(ReminderReceiverService.ACTION_REMIND);message.incrementReminderCount();reminderIntent.putExtras(message.toBundle());reminderPendingIntent = PendingIntent.getBroadcast(context, 0, reminderIntent,PendingIntent.FLAG_CANCEL_CURRENT);long triggerTime = System.currentTimeMillis() + (reminder_interval * 1000);Log.v("ReminderReceiver: scheduled reminder notification in " + reminder_interval+ " seconds, count is " + message.getReminderCount());myAM.set(AlarmManager.RTC_WAKEUP, triggerTime, reminderPendingIntent);}}public static void cancelReminder(Context context) {if (reminderPendingIntent != null) {AlarmManager myAM = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);myAM.cancel(reminderPendingIntent);reminderPendingIntent.cancel();reminderPendingIntent = null;Log.v("ReminderReceiver: cancelReminder()");}}}package .example.shuoya;import android.app.Activity;import android.app.Service;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;import android.os.Bundle;import android.os.Handler;import android.os.HandlerThread;import android.os.IBinder;import android.os.Looper;import android.os.Message;import android.os.PowerManager;import android.os.Process;import android.preference.PreferenceManager;import android.telephony.gsm.SmsManager;import android.telephony.gsm.SmsMessage;public class SMSReceiverService extends Service {private static final String ACTION_SMS_RECEIVED ="android.provider.Telephony.SMS_RECEIVED";private static final String ACTION_MMS_RECEIVED ="android.provider.Telephony.WAP_PUSH_RECEIVED";private static final String MMS_DATA_TYPE = "application/vnd.wap.mms-message";private static final String ACTION_MESSAGE_SENT = ".android.mms.transaction.MESSAGE_SENT";private Context context;private ServiceHandler mServiceHandler;private Looper mServiceLooper;。
申请软著python源代码文档
申请软著python源代码文档我国的软件知识产权保护制度逐渐完善,软件著作权作为软件知识产权的重要组成部分,对保护软件开发者的利益、推动软件产业发展、鼓励创新具有重要意义。
然而,随着互联网技术的飞速发展,网络环境下软件著作权的侵权现象屡禁不止,因此软件的著作权保护尤为重要。
Python作为一种高级程序设计语言,其广泛应用于各类软件开发中,对其源代码文档的著作权保护显得尤为重要。
本文将围绕申请软著Python源代码文档展开讨论,探讨在申请过程中应该注意的事项及具体流程。
一、Python源代码文档的保护对象Python源代码文档是指程序员通过Python语言编写的程序源代码及其相关文档。
Python源代码文档作为具有独创性和创作性的作品,符合软件著作权的基本要求,可以作为软件著作权的保护对象。
在申请软著Python源代码文档时,需要注意的是,该文档应当具有独立性和完整性,在构成上应当能够独立存在并发挥作用。
二、申请软著Python源代码文档的条件1. 独创性:Python源代码文档应当具有一定的独创性,即具有相对独立性和创作性。
在申请软著时,需要证明该文档具有一定的原创性,不属于他人已经拥有著作权的作品。
2. 完整性:Python源代码文档应当具有一定的完整性,即具有相对完整、独立的结构,并具备一定的功能。
3. 可复制性:Python源代码文档应当具有可复制性,即可以通过程序运行等方式进行复制、展示、传播或利用。
三、申请软著Python源代码文档的流程1. 准备材料:首先需要准备好软著申请表、Python源代码文档及其说明文档、作者唯一识别信息明等相关材料。
2. 登录软著申请系统:登录国家版权局软著申请系统,填写软著申请表,并上传Python源代码文档及其相关材料。
3. 审查与备案:国家版权局在接受软著申请后,将对申请材料进行审查,如果符合著作权法和软件著作权保护的相关规定,将予以受理并备案。
四、申请软著Python源代码文档的注意事项1. 注意文档的独立性和完整性:在申请软著Python源代码文档时,需要特别注意文档的独立性和完整性,确保其能够独立存在并发挥作用。
软件著作权源代码
#include <tybs/commandline.h>#include <tybs/dir.h>#include <tybs/entropy.h>#include <tybs/file.h>#include <tybs/hash.h>#include <tybs/os.h>#include <tybs/platform.h>#include <tybs/resource.h>#include <tybs/stdio.h>#include <tybs/string.h>#include <tybs/task.h>#include <tybs/timer.h>#include <tybs/util.h>#include <tybscc/result.h>#include <dns/dispatch.h>#include <dns/name.h>#include <dns/result.h>#include <dns/view.h>#include <dst/result.h>#define NS_MAIN 1#include <named/ns_smf_globals.h>#endif#ifdef DLZ#include <dlz/dlz_drivers.h>#endifstatic tybs_boolean_t want_stats = TYBS_FALSE;static char program_name[TYBS_DIR_NAMEMAX] = "named"; static char absolute_conffile[TYBS_DIR_PATHMAX];static char saved_command_line[512];static char version[512];static unsigned int maxsocks = 0;voidns_main_earlywarning(const char *format, ...) {va_list args;va_start(args, format);if (ns_g_lctx != NULL) {tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_W ARNING,format, args);} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);}Void ns_main_earlyfatal(const char *format, ...) {va_list args;va_start(args, format);if (ns_g_lctx != NULL) {format, args);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to early fatal error)");} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);exit(1);}static voidassertion_failed(const char *file, int line, tybs_assertiontype_t type,const char *cond){if (ns_g_lctx != NULL) {tybs_assertion_setcallback(NULL);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"%s:%d: %s(%s) failed", file, line,tybs_assertion_typetotext(type), cond);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to assertion failure)");} else {fprintf(stderr, "%s:%d: %s(%s) failed\n",file, line, tybs_assertion_typetotext(type), cond);fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_fatal_error(const char *file, int line, const char *format,va_list args) TYBS_FORMA T_PRINTF(3, 0);static voidlibrary_fatal_error(const char *file, int line, const char *format,va_list args){if (ns_g_lctx != NULL) {tybs_error_setfatal(NULL);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"%s:%d: fatal error:", file, line);tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,format, args);"exiting (due to fatal error in library)");} else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_unexpected_error(const char *file, int line, const char *format,va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_unexpected_error(const char *file, int line, const char *format,va_list args){if (ns_g_lctx != NULL) {tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,"%s:%d: unexpected error:", file, line);tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,format, args);} else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}}static voidlwresd_usage(void) {fprintf(stderr,"usage: lwresd [-4|-6] [-c conffile | -C resolvconffile] ""[-d debuglevel]\n"" [-f|-g] [-n number_of_cpus] [-p port] ""[-P listen-port] [-s]\n"" [-t chrootdir] [-u username] [-i pidfile]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidusage(void) {if (ns_g_lwresdonly) {lwresd_usage();return;}fprintf(stderr,"usage: named [-4|-6] [-c conffile] [-d debuglevel] ""[-f|-g] [-n number_of_cpus]\n"" [-p port] [-s] [-t chrootdir] [-u username]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidsave_command_line(int argc, char *argv[]) {int i;char *src;char *dst;char *eob;const char truncated[] = "...";tybs_boolean_t quoted = TYBS_FALSE;dst = saved_command_line;eob = saved_command_line + sizeof(saved_command_line);for (i = 1; i < argc && dst < eob; i++) {*dst++ = ' ';src = argv[i];while (*src != '\0' && dst < eob) {if (quoted || isalnum(*src & 0xff) ||*src == '-' || *src == '_' ||*src == '.' || *src == '/') {*dst++ = *src++;quoted = TYBS_FALSE;} else {*dst++ = '\\';quoted = TYBS_TRUE;}}}INSIST(sizeof(saved_command_line) >= sizeof(truncated));if (dst == eob)strcpy(eob - sizeof(truncated), truncated);else*dst = '\0';}static intparse_int(char *arg, const char *desc) {char *endp;int tmp;long int ltmp;ltmp = strtol(arg, &endp, 10);tmp = (int) ltmp;if (*endp != '\0')ns_main_earlyfatal("%s '%s' must be numeric", desc, arg);if (tmp < 0 || tmp != ltmp)ns_main_earlyfatal("%s '%s' out of range", desc, arg);return (tmp);}static struct flag_def {const char *name;unsigned int value;} mem_debug_flags[] = {{ "trace", TYBS_MEM_DEBUGTRACE },{ "record", TYBS_MEM_DEBUGRECORD },{ "usage", TYBS_MEM_DEBUGUSAGE },{ "size", TYBS_MEM_DEBUGSIZE },{ "mctx", TYBS_MEM_DEBUGCTX },{ NULL, 0 }};static voidset_flags(const char *arg, struct flag_def *defs, unsigned int *ret) { for (;;) {const struct flag_def *def;const char *end = strchr(arg, ',');int arglen;if (end == NULL)end = arg + strlen(arg);arglen = end - arg;for (def = defs; def->name != NULL; def++) {if (arglen == (int)strlen(def->name) &&memcmp(arg, def->name, arglen) == 0) {*ret |= def->value;goto found;}}ns_main_earlyfatal("unrecognized flag '%.*s'", arglen, arg);found:if (*end == '\0')break;arg = end + 1;}}static voidparse_command_line(int argc, char *argv[]) {int ch;int port;tybs_boolean_t disable6 = TYBS_FALSE;tybs_boolean_t disable4 = TYBS_FALSE;save_command_line(argc, argv);tybs_commandline_errprint = TYBS_FALSE;while ((ch = tybs_commandline_parse(argc, argv,"46c:C:d:fgi:lm:n:N:p:P:""sS:t:T:u:vVx:")) != -1) {switch (ch) {case '4':if (disable4)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv4() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv4 not supported by OS");tybs_net_disableipv6();disable6 = TYBS_TRUE;break;case '6':if (disable6)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv6() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv6 not supported by OS");tybs_net_disableipv4();disable4 = TYBS_TRUE;break;case 'c':ns_g_conffile = tybs_commandline_argument;lwresd_g_conffile = tybs_commandline_argument;if (lwresd_g_useresolvconf)ns_main_earlyfatal("cannot specify -c and -C");ns_g_conffileset = TYBS_TRUE;break;case 'C':lwresd_g_resolvconffile = tybs_commandline_argument;if (ns_g_conffileset)ns_main_earlyfatal("cannot specify -c and -C");lwresd_g_useresolvconf = TYBS_TRUE;break;case 'd':ns_g_debuglevel = parse_int(tybs_commandline_argument,"debug level");break;case 'f':ns_g_foreground = TYBS_TRUE;break;case 'g':ns_g_foreground = TYBS_TRUE;ns_g_logstderr = TYBS_TRUE;break;/* XXXBEW -i should be removed */case 'i':lwresd_g_defaultpidfile = tybs_commandline_argument;break;case 'l':ns_g_lwresdonly = TYBS_TRUE;break;case 'm':set_flags(tybs_commandline_argument, mem_debug_flags, &tybs_mem_debugging);break;case 'N': /* Deprecated. */case 'n':ns_g_cpus = parse_int(tybs_commandline_argument,"number of cpus");if (ns_g_cpus == 0)ns_g_cpus = 1;break;case 'p':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);ns_g_port = port;break;/* XXXBEW Should -P be removed? */case 'P':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);lwresd_g_listenport = port;break;case 's':want_stats = TYBS_TRUE;break;case 'S':maxsocks = parse_int(tybs_commandline_argument,"max number of sockets");break;case 't':ns_g_chrootdir = tybs_commandline_argument;break;case 'T':if (strcmp(tybs_commandline_argument, "clienttest") == 0) ns_g_clienttest = TYBS_TRUE;elsefprintf(stderr, "unknown -T flag '%s\n",tybs_commandline_argument);break;case 'u':ns_g_username = tybs_commandline_argument;break;case 'v':printf("BIND %s\n", ns_g_version);exit(0);case 'V':printf("BIND %s built with %s\n", ns_g_version,ns_g_configargs);exit(0);case '?':usage();if (tybs_commandline_option == '?')exit(0);ns_main_earlyfatal("unknown option '-%c'",tybs_commandline_option);default:ns_main_earlyfatal("parsing options returned %d", ch);}}argc -= tybs_commandline_index;argv += tybs_commandline_index;if (argc > 0) {usage();ns_main_earlyfatal("extra command line arguments");}}static tybs_result_tcreate_managers(void) {tybs_result_t result;unsigned int socks;#ifdef TYBS_PLATFORM_USETHREADSunsigned int cpus_detected;#endif#ifdef TYBS_PLATFORM_USETHREADScpus_detected = tybs_os_ncpus();if (ns_g_cpus == 0)ns_g_cpus = cpus_detected;tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, TYBS_LOG_INFO, "found %u CPU%s, using %u worker thread%s",cpus_detected, cpus_detected == 1 ? "" : "s",ns_g_cpus, ns_g_cpus == 1 ? "" : "s");#elsens_g_cpus = 1;#endifresult = tybs_taskmgr_create(ns_g_mctx, ns_g_cpus, 0, &ns_g_taskmgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_taskmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_timermgr_create(ns_g_mctx, &ns_g_timermgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_timermgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_create2(ns_g_mctx, &ns_g_socketmgr, maxsocks);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_socketmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_getmaxsockets(ns_g_socketmgr, &socks);if (result == TYBS_R_SUCCESS) {tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_SERVER,TYBS_LOG_INFO, "using up to %u sockets", socks);}result = tybs_entropy_create(ns_g_mctx, &ns_g_entropy);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_entropy_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_hash_create(ns_g_mctx, ns_g_entropy, DNS_NAME_MAXWIRE);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_hash_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}return (TYBS_R_SUCCESS);}static voiddestroy_managers(void) {ns_lwresd_shutdown();tybs_entropy_detach(&ns_g_entropy);if (ns_g_fallbackentropy != NULL)tybs_entropy_detach(&ns_g_fallbackentropy);tybs_taskmgr_destroy(&ns_g_taskmgr);tybs_timermgr_destroy(&ns_g_timermgr);tybs_socketmgr_destroy(&ns_g_socketmgr);tybs_hash_destroy();}static voidsetup(void) {tybs_result_t result;#ifdef HA VE_LIBSCFchar *instance = NULL;#endifns_os_inituserinfo(ns_g_username);ns_os_tzset();ns_os_opendevnull();#ifdef HA VE_LIBSCFresult = ns_smf_get_instance(&instance, 0, ns_g_mctx);if (result == TYBS_R_SUCCESS)ns_smf_got_instance = 1;elsens_smf_got_instance = 0;if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);#endif /* HA VE_LIBSCF */#ifdef PA TH_RANDOMDEVif (ns_g_chrootdir != NULL) {result = tybs_entropy_create(ns_g_mctx, &ns_g_fallbackentropy);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_entropy_create() failed: %s",tybs_result_totext(result));result = tybs_entropy_createfilesource(ns_g_fallbackentropy,PA TH_RANDOMDEV);if (result != TYBS_R_SUCCESS) {ns_main_earlywarning("could not open pre-chroot ""entropy source %s: %s",PATH_RANDOMDEV,tybs_result_totext(result));tybs_entropy_detach(&ns_g_fallbackentropy);}}#endifns_os_chroot(ns_g_chrootdir);ns_os_minprivs();result = ns_log_init(TYBS_TF(ns_g_username != NULL));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("ns_log_init() failed: %s",tybs_result_totext(result));if (!ns_g_foreground)ns_os_daemonize();result = tybs_app_start();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_app_start() failed: %s",tybs_result_totext(result));tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "starting BIND %s%s", ns_g_version,saved_command_line);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "built with %s", ns_g_configargs);(void)tybs_resource_getlimit(tybs_resource_stacksize,&ns_g_initstacksize);(void)tybs_resource_getlimit(tybs_resource_datasize,&ns_g_initdatasize);(void)tybs_resource_getlimit(tybs_resource_coresize,&ns_g_initcoresize);(void)tybs_resource_getlimit(tybs_resource_openfiles,&ns_g_initopenfiles);if (! tybs_file_isabsolute(ns_g_conffile)) {result = tybs_file_absolutepath(ns_g_conffile,absolute_conffile,sizeof(absolute_conffile));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("could not construct absolute path of ""configuration file: %s",tybs_result_totext(result));ns_g_conffile = absolute_conffile;}result = tybs_time_now(&ns_g_boottime);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_time_now() failed: %s",tybs_result_totext(result));result = create_managers();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("create_managers() failed: %s",tybs_result_totext(result));ns_builtin_init();#ifdef DLZresult = dlz_drivers_init();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("dlz_drivers_init() failed: %s",tybs_result_totext(result));#endifns_server_create(ns_g_mctx, &ns_g_server);}static voidcleanup(void) {destroy_managers();ns_server_destroy(&ns_g_server);ns_builtin_deinit();#ifdef DLZdlz_drivers_clear();#endifdns_name_destroy();tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "exiting");ns_log_shutdown();}static char *memstats = NULL;voidns_main_setmemstats(const char *filename) {if (memstats != NULL) {free(memstats);memstats = NULL;}if (filename == NULL)return;memstats = malloc(strlen(filename) + 1);if (memstats)strcpy(memstats, filename);}#ifdef HA VE_LIBSCFtybs_result_tns_smf_get_instance(char **ins_name, int debug, tybs_mem_t *mctx) {scf_handle_t *h = NULL;int namelen;char *instance;REQUIRE(ins_name != NULL && *ins_name == NULL);if ((h = scf_handle_create(SCF_VERSION)) == NULL) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_handle_create() failed: %s",scf_strerror(scf_error()));return (TYBS_R_FAILURE);}if (scf_handle_bind(h) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_handle_bind() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if ((namelen = scf_myname(h, NULL, 0)) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if ((instance = tybs_mem_allocate(mctx, namelen + 1)) == NULL) { UNEXPECTED_ERROR(__FILE__, __LINE__,"ns_smf_get_instance memory ""allocation failed: %s",tybs_result_totext(TYBS_R_NOMEMORY));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if (scf_myname(h, instance, namelen + 1) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);tybs_mem_free(mctx, instance);return (TYBS_R_FAILURE);}scf_handle_destroy(h);*ins_name = instance;return (TYBS_R_SUCCESS);}#endifintmain(int argc, char *argv[]) {tybs_result_t result;#ifdef HA VE_LIBSCFchar *instance = NULL;#endifstrlcat(version,#ifdef __DATE__"named version: BIND " VERSION " (" __DA TE__ ")",#else"named version: BIND " VERSION,#endifsizeof(version));result = tybs_file_progname(*argv, program_name, sizeof(program_name));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("program name too long");if (strcmp(program_name, "lwresd") == 0)ns_g_lwresdonly = TYBS_TRUE;tybs_assertion_setcallback(assertion_failed);tybs_error_setfatal(library_fatal_error);tybs_error_setunexpected(library_unexpected_error);ns_os_init(program_name);dns_result_register();dst_result_register();tybscc_result_register();parse_command_line(argc, argv);if (ns_g_chrootdir != NULL) {int len = strlen(ns_g_chrootdir);if (strncmp(ns_g_chrootdir, ns_g_conffile, len) == 0 &&(ns_g_conffile[len] == '/' || ns_g_conffile[len] == '\\'))ns_main_earlywarning("config filename (-c %s) contains ""chroot path (-t %s)",ns_g_conffile, ns_g_chrootdir);}result = tybs_mem_create(0, 0, &ns_g_mctx);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_mem_create() failed: %s",tybs_result_totext(result));tybs_mem_setname(ns_g_mctx, "main", NULL);setup();do {result = tybs_app_run();if (result == TYBS_R_RELOAD) {ns_server_reloadwanted(ns_g_server);} else if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_app_run(): %s",tybs_result_totext(result));result = TYBS_R_SUCCESS;}} while (result != TYBS_R_SUCCESS);#ifdef HA VE_LIBSCFif (ns_smf_want_disable == 1) {result = ns_smf_get_instance(&instance, 1, ns_g_mctx);if (result == TYBS_R_SUCCESS && instance != NULL) {if (smf_disable_instance(instance, 0) != 0)UNEXPECTED_ERROR(__FILE__, __LINE__,"smf_disable_instance() ""failed for %s : %s",instance,scf_strerror(scf_error()));}if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);}#endif /* HA VE_LIBSCF */cleanup();if (want_stats) {tybs_mem_stats(ns_g_mctx, stdout);tybs_mutex_stats(stdout);}if (ns_g_memstatistics && memstats != NULL) {FILE *fp = NULL;result = tybs_stdio_open(memstats, "w", &fp);if (result == TYBS_R_SUCCESS) {tybs_mem_stats(ns_g_mctx, fp);tybs_mutex_stats(fp);tybs_stdio_close(fp);}}tybs_mem_destroy(&ns_g_mctx);tybs_mem_checkdestroyed(stderr);ns_main_setmemstats(NULL);tybs_app_finish();ns_os_closedevnull();ns_os_shutdown();return (0);}#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h"#include <stdio.h>#include <fcntl.h>#ifdef PHP_WIN32#include "win32/time.h"#include "win32/signal.h"#include "win32/php_win32_globals.h"#include <process.h>#elif defined(NETW ARE)#include <sys/timeval.h>#ifdef USE_WINSOCK#include <novsock2.h>#endif#endif#if HA VE_SYS_TIME_H#include <sys/time.h>#endif#if HA VE_UNISTD_H#include <unistd.h>#endif#if HA VE_SIGNAL_H#include <signal.h>#endif#if HA VE_SETLOCALE#include <locale.h>#endif#include "zend.h"#include "zend_extensions.h"#include "php_ini.h"#include "php_globals.h"#include "php_main.h"#include "fopen_wrappers.h"#include "ext/standard/php_standard.h"#include "php_variables.h"#include "ext/standard/credits.h"#ifdef PHP_WIN32#include <io.h>#include "win32/php_registry.h"#include "ext/standard/flock_compat.h"#endif#include "php_syslog.h"#include "Zend/zend_exceptions.h"#if PHP_SIGCHILD#include <sys/types.h>#include <sys/wait.h>#endif#include "zend_compile.h"#include "zend_execute.h"#include "zend_highlight.h"#include "zend_indent.h"#include "zend_extensions.h"#include "zend_ini.h"#include "php_content_types.h"#include "php_ticks.h"#include "php_logos.h"#include "php_streams.h"#include "php_open_temporary_file.h"#include "SAPI.h"#include "rfc1867.h"/* }}} */#ifndef ZTSphp_core_globals core_globals;#elsePHPAPI int core_globals_id;#endif#define SAFE_FILENAME(f) ((f)?(f):"-")/* {{{ PHP_INI_MH*/static PHP_INI_MH(OnSetPrecision){int i = atoi(new_value);if (i >= 0) {EG(precision) = i;return SUCCESS;} else {return FAILURE;}}static PHP_INI_MH(OnChangeMemoryLimit){if (new_value) {PG(memory_limit) = zend_atoi(new_value, new_value_length);} else {PG(memory_limit) = 1<<30; /* effectively, no limit */ }return zend_set_memory_limit(PG(memory_limit));}static void php_disable_functions(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_functions"))) {return;}e = PG(disable_functions) = strdup(INI_STR("disable_functions"));while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_function(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zend_disable_function(s, e-s TSRMLS_CC);}}static void php_disable_classes(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_classes"))) {return;}e = PG(disable_classes) = strdup(INI_STR("disable_classes"));while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_class(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zend_disable_class(s, e-s TSRMLS_CC);}}static PHP_INI_MH(OnUpdateTimeout){EG(timeout_seconds) = atoi(new_value);if (stage==PHP_INI_STAGE_STARTUP) {/* Don't set a timeout on startup, only per-request */return SUCCESS;}zend_unset_timeout(TSRMLS_C);zend_set_timeout(EG(timeout_seconds));return SUCCESS;}static int php_get_display_errors_mode(char *value, int value_length){int mode;if (!value) {return PHP_DISPLAY_ERRORS_STDOUT;}if (value_length == 2 && !strcasecmp("on", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 3 && !strcasecmp("yes", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 4 && !strcasecmp("true", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 6 && !strcasecmp(value, "stderr")) {mode = PHP_DISPLAY_ERRORS_STDERR;} else if (value_length == 6 && !strcasecmp(value, "stdout")) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else {mode = atoi(value);if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) {mode = PHP_DISPLAY_ERRORS_STDOUT;}}return mode;}static PHP_INI_MH(OnUpdateDisplayErrors){PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value, new_value_length);return SUCCESS;}static PHP_INI_DISP(display_errors_mode){int mode, tmp_value_length, cgi_or_cli;char *tmp_value;TSRMLS_FETCH();if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );tmp_value_length = ini_entry->orig_value_length;} else if (ini_entry->value) {tmp_value = ini_entry->value;tmp_value_length = ini_entry->value_length;} else {tmp_value = NULL;tmp_value_length = 0;}mode = php_get_display_errors_mode(tmp_value, tmp_value_length);cgi_or_cli = (!strcmp(sapi_, "cli") || !strcmp(sapi_, "cgi"));switch (mode) {case PHP_DISPLAY_ERRORS_STDERR:if (cgi_or_cli ) {PUTS("STDERR");} else {PUTS("On");}break;case PHP_DISPLAY_ERRORS_STDOUT:if (cgi_or_cli ) {PUTS("STDOUT");} else {PUTS("On");}break;default:PUTS("Off");break;}}static PHP_INI_MH(OnUpdateErrorLog){/* Only do the safemode/open_basedir check at runtime */if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && strcmp(new_value, "syslog")) {if (PG(safe_mode) && (!php_checkuid(new_value, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {return FAILURE;}if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) {return FAILURE;}}OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);return SUCCESS;}static PHP_INI_MH(OnChangeMailForceExtra){/* Don't allow changing it in htaccess */if (stage == PHP_INI_STAGE_HTACCESS) {。
软件著作权-源代码范本
软件著作权-源代码范本之欧侯瑞魂创作注意事项:罕见的源代码包含:C语言,VB,C++,JAVA,.NET等。
提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,著作权人,软件名字等,不克不及出现开源代码,不克不及出现任何版权纠纷。
格式要求:一、源代码应提交前、后各连续30页,缺乏60页的,应当全部提交。
二、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页眉右上应标注页码,源代码每页很多于50行。
范例如下:#include <tybs/commandline.h>#include <tybs/dir.h>#include <tybs/entropy.h>#include <tybs/file.h>#include <tybs/hash.h>#include <tybs/os.h>#include <tybs/platform.h>#include <tybs/resource.h>#include <tybs/stdio.h>#include <tybs/string.h>#include <tybs/task.h>#include <tybs/timer.h>#include <tybs/util.h>#include <tybscc/result.h>#include <dns/dispatch.h>#include <dns/name.h>#include <dns/result.h>#include <dns/view.h>#include <dst/result.h>#define NS_MAIN 1#include <named/ns_smf_globals.h>#endif#ifdef DLZ#include <dlz/dlz_drivers.h>#endifstatic tybs_boolean_t want_stats = TYBS_FALSE;static char program_name[TYBS_DIR_NAMEMAX] = "named"; static char absolute_conffile[TYBS_DIR_PATHMAX]; static char saved_command_line[512];static char version[512];static unsigned int maxsocks = 0;voidns_main_earlywarning(const char *format, ...) { va_list args;va_start(args, format);if (ns_g_lctx != NULL) {tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_WARNING,format, args);} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);}Voidns_main_earlyfatal(const char *format, ...) {va_list args;va_start(args, format);if (ns_g_lctx != NULL) {tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,format, args);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to early fatal error)");} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);exit(1);}static voidassertion_failed(const char *file, int line, tybs_assertiontype_t type,const char *cond){if (ns_g_lctx != NULL) {tybs_assertion_setcallback(NULL);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"%s:%d: %s(%s) failed", file, line,tybs_assertion_typetotext(type), cond);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to assertion failure)");} else {fprintf(stderr, "%s:%d: %s(%s) failed\n",file, line, tybs_assertion_typetotext(type), cond);fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_fatal_error(const char *file, int line, const char *format, va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_fatal_error(const char *file, int line, const char *format, va_list args){if (ns_g_lctx != NULL) {tybs_error_setfatal(NULL);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"%s:%d: fatal error:", file, line);tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,format, args);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to fatal error in library)");} else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_unexpected_error(const char *file, int line, const char *format,va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_unexpected_error(const char *file, int line, const char *format,va_list args){if (ns_g_lctx != NULL) {tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,"%s:%d: unexpected error:", file, line);tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,format, args);} else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}}static voidlwresd_usage(void) {fprintf(stderr,"usage: lwresd [-4|-6] [-c conffile | -C resolvconffile] ""[-d debuglevel]\n"" [-f|-g] [-n number_of_cpus] [-p port] ""[-P listen-port] [-s]\n"" [-t chrootdir] [-u username] [-i pidfile]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidusage(void) {if (ns_g_lwresdonly) {lwresd_usage();return;}fprintf(stderr,"usage: named [-4|-6] [-c conffile] [-d debuglevel] ""[-f|-g] [-n number_of_cpus]\n"" [-p port] [-s] [-t chrootdir] [-u username]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidsave_command_line(int argc, char *argv[]) {int i;char *src;char *dst;char *eob;const char truncated[] = "...";tybs_boolean_t quoted = TYBS_FALSE;dst = saved_command_line;eob = saved_command_line + sizeof(saved_command_line);for (i = 1; i < argc && dst < eob; i++) {*dst++ = ' ';src = argv[i];while (*src != '\0' && dst < eob) {if (quoted || isalnum(*src & 0xff) ||*src == '-' || *src == '_' ||*src == '.' || *src == '/') {*dst++ = *src++;quoted = TYBS_FALSE;} else {*dst++ = '\\';quoted = TYBS_TRUE;}}}INSIST(sizeof(saved_command_line) >= sizeof(truncated));if (dst == eob)strcpy(eob - sizeof(truncated), truncated);else*dst = '\0';}static intparse_int(char *arg, const char *desc) {char *endp;int tmp;long int ltmp;ltmp = strtol(arg, &endp, 10);tmp = (int) ltmp;if (*endp != '\0')ns_main_earlyfatal("%s '%s' must be numeric", desc, arg);if (tmp < 0 || tmp != ltmp)ns_main_earlyfatal("%s '%s' out of range", desc, arg);return (tmp);}static struct flag_def {const char *name;unsigned int value;} mem_debug_flags[] = {{ "trace", TYBS_MEM_DEBUGTRACE },{ "record", TYBS_MEM_DEBUGRECORD },{ "usage", TYBS_MEM_DEBUGUSAGE },{ "size", TYBS_MEM_DEBUGSIZE },{ "mctx", TYBS_MEM_DEBUGCTX },{ NULL, 0 }};static voidset_flags(const char *arg, struct flag_def *defs, unsigned int *ret) {for (;;) {const struct flag_def *def;const char *end = strchr(arg, ',');int arglen;if (end == NULL)end = arg + strlen(arg);arglen = end - arg;for (def = defs; def->name != NULL; def++) {if (arglen == (int)strlen(def->name) &&memcmp(arg, def->name, arglen) == 0) {*ret |= def->value;goto found;}}ns_main_earlyfatal("unrecognized flag '%.*s'", arglen, arg);found:if (*end == '\0')break;arg = end + 1;}}static voidparse_command_line(int argc, char *argv[]) {int ch;int port;tybs_boolean_t disable6 = TYBS_FALSE;tybs_boolean_t disable4 = TYBS_FALSE;save_command_line(argc, argv);tybs_commandline_errprint = TYBS_FALSE;while ((ch = tybs_commandline_parse(argc, argv,"46c:C:d:fgi:lm:n:N:p:P:""sS:t:T:u:vVx:")) != -1) {switch (ch) {case '4':if (disable4)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv4() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv4 not supported by OS");tybs_net_disableipv6();disable6 = TYBS_TRUE;break;case '6':if (disable6)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv6() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv6 not supported by OS"); tybs_net_disableipv4();disable4 = TYBS_TRUE;break;case 'c':ns_g_conffile = tybs_commandline_argument;lwresd_g_conffile = tybs_commandline_argument;if (lwresd_g_useresolvconf)ns_main_earlyfatal("cannot specify -c and -C");ns_g_conffileset = TYBS_TRUE;break;case 'C':lwresd_g_resolvconffile = tybs_commandline_argument;if (ns_g_conffileset)ns_main_earlyfatal("cannot specify -c and -C");lwresd_g_useresolvconf = TYBS_TRUE;break;case 'd':ns_g_debuglevel = parse_int(tybs_commandline_argument,"debug level");break;case 'f':ns_g_foreground = TYBS_TRUE;break;case 'g':ns_g_foreground = TYBS_TRUE;ns_g_logstderr = TYBS_TRUE;break;/* XXXBEW -i should be removed */case 'i':lwresd_g_defaultpidfile = tybs_commandline_argument;break;case 'l':ns_g_lwresdonly = TYBS_TRUE;break;case 'm':set_flags(tybs_commandline_argument, mem_debug_flags, &tybs_mem_debugging);break;case 'N': /* Deprecated. */case 'n':ns_g_cpus = parse_int(tybs_commandline_argument, "number of cpus");if (ns_g_cpus == 0)ns_g_cpus = 1;break;case 'p':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);ns_g_port = port;break;/* XXXBEW Should -P be removed? */case 'P':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);lwresd_g_listenport = port;break;case 's':want_stats = TYBS_TRUE;break;case 'S':maxsocks = parse_int(tybs_commandline_argument,"max number of sockets");break;case 't':ns_g_chrootdir = tybs_commandline_argument;break;case 'T':if (strcmp(tybs_commandline_argument, "clienttest") == 0) ns_g_clienttest = TYBS_TRUE;elsefprintf(stderr, "unknown -T flag '%s\n",tybs_commandline_argument);break;case 'u':ns_g_username = tybs_commandline_argument;break;case 'v':printf("BIND %s\n", ns_g_version);exit(0);case 'V':printf("BIND %s built with %s\n", ns_g_version,ns_g_configargs);exit(0);case '?':usage();if (tybs_commandline_option == '?')exit(0);ns_main_earlyfatal("unknown option '-%c'",tybs_commandline_option);default:ns_main_earlyfatal("parsing options returned %d", ch);}}argc -= tybs_commandline_index;argv += tybs_commandline_index;if (argc > 0) {usage();ns_main_earlyfatal("extra command line arguments");}}static tybs_result_tcreate_managers(void) {tybs_result_t result;unsigned int socks;#ifdef TYBS_PLATFORM_USETHREADSunsigned int cpus_detected;#endif#ifdef TYBS_PLATFORM_USETHREADScpus_detected = tybs_os_ncpus();if (ns_g_cpus == 0)ns_g_cpus = cpus_detected;tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,TYBS_LOG_INFO, "found %u CPU%s, using %u worker thread%s", cpus_detected, cpus_detected == 1 ? "" : "s",ns_g_cpus, ns_g_cpus == 1 ? "" : "s");#elsens_g_cpus = 1;#endifresult = tybs_taskmgr_create(ns_g_mctx, ns_g_cpus, 0, &ns_g_taskmgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_taskmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_timermgr_create(ns_g_mctx, &ns_g_timermgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_timermgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_create2(ns_g_mctx, &ns_g_socketmgr, maxsocks);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_socketmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_getmaxsockets(ns_g_socketmgr, &socks);if (result == TYBS_R_SUCCESS) {tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_SERVER,TYBS_LOG_INFO, "using up to %u sockets", socks);}result = tybs_entropy_create(ns_g_mctx, &ns_g_entropy);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_entropy_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_hash_create(ns_g_mctx, ns_g_entropy, DNS_NAME_MAXWIRE);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_hash_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}return (TYBS_R_SUCCESS);}static voiddestroy_managers(void) {ns_lwresd_shutdown();tybs_entropy_detach(&ns_g_entropy);if (ns_g_fallbackentropy != NULL)tybs_entropy_detach(&ns_g_fallbackentropy);tybs_taskmgr_destroy(&ns_g_taskmgr);tybs_timermgr_destroy(&ns_g_timermgr);tybs_socketmgr_destroy(&ns_g_socketmgr);tybs_hash_destroy();}static voidsetup(void) {tybs_result_t result;#ifdef HAVE_LIBSCFchar *instance = NULL;#endifns_os_inituserinfo(ns_g_username);ns_os_tzset();ns_os_opendevnull();#ifdef HAVE_LIBSCFresult = ns_smf_get_instance(&instance, 0, ns_g_mctx);if (result == TYBS_R_SUCCESS)ns_smf_got_instance = 1;elsens_smf_got_instance = 0;if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);#endif /* HAVE_LIBSCF */#ifdef PATH_RANDOMDEVif (ns_g_chrootdir != NULL) {result = tybs_entropy_create(ns_g_mctx, &ns_g_fallbackentropy);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_entropy_create() failed: %s",tybs_result_totext(result));result = tybs_entropy_createfilesource(ns_g_fallbackentropy,PATH_RANDOMDEV);if (result != TYBS_R_SUCCESS) {ns_main_earlywarning("could not open pre-chroot ""entropy source %s: %s",PATH_RANDOMDEV,tybs_result_totext(result));tybs_entropy_detach(&ns_g_fallbackentropy);}}#endifns_os_chroot(ns_g_chrootdir);ns_os_minprivs();result = ns_log_init(TYBS_TF(ns_g_username != NULL));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("ns_log_init() failed: %s",tybs_result_totext(result));if (!ns_g_foreground)ns_os_daemonize();result = tybs_app_start();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_app_start() failed: %s",tybs_result_totext(result));tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,TYBS_LOG_NOTICE, "starting BIND %s%s", ns_g_version,saved_command_line);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,TYBS_LOG_NOTICE, "built with %s", ns_g_configargs);(void)tybs_resource_getlimit(tybs_resource_stacksize,&ns_g_initstacksize);(void)tybs_resource_getlimit(tybs_resource_datasize,&ns_g_initdatasize);(void)tybs_resource_getlimit(tybs_resource_coresize,&ns_g_initcoresize);(void)tybs_resource_getlimit(tybs_resource_openfiles,&ns_g_initopenfiles);if (! tybs_file_isabsolute(ns_g_conffile)) {result = tybs_file_absolutepath(ns_g_conffile,absolute_conffile,sizeof(absolute_conffile));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("could not construct absolute path of ""configuration file: %s",tybs_result_totext(result));ns_g_conffile = absolute_conffile;}result = tybs_time_now(&ns_g_boottime);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_time_now() failed: %s",tybs_result_totext(result));result = create_managers();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("create_managers() failed: %s",tybs_result_totext(result));ns_builtin_init();#ifdef DLZresult = dlz_drivers_init();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("dlz_drivers_init() failed: %s",tybs_result_totext(result));#endifns_server_create(ns_g_mctx, &ns_g_server);}static voidcleanup(void) {destroy_managers();ns_server_destroy(&ns_g_server);ns_builtin_deinit();#ifdef DLZdlz_drivers_clear();#endifdns_name_destroy();tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,TYBS_LOG_NOTICE, "exiting");ns_log_shutdown();}static char *memstats = NULL;voidns_main_setmemstats(const char *filename) {if (memstats != NULL) {free(memstats);}if (filename == NULL)return;memstats = malloc(strlen(filename) + 1);if (memstats)strcpy(memstats, filename);}#ifdef HAVE_LIBSCFtybs_result_tns_smf_get_instance(char **ins_name, int debug, tybs_mem_t *mctx) { scf_handle_t *h = NULL;int namelen;char *instance;REQUIRE(ins_name != NULL && *ins_name == NULL);if ((h = scf_handle_create(SCF_VERSION)) == NULL) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_handle_create() failed: %s",scf_strerror(scf_error()));return (TYBS_R_FAILURE);}if (scf_handle_bind(h) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_handle_bind() failed: %s",scf_strerror(scf_error()));return (TYBS_R_FAILURE);}if ((namelen = scf_myname(h, NULL, 0)) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if ((instance = tybs_mem_allocate(mctx, namelen + 1)) == NULL) { UNEXPECTED_ERROR(__FILE__, __LINE__,"ns_smf_get_instance memory ""allocation failed: %s",tybs_result_totext(TYBS_R_NOMEMORY));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if (scf_myname(h, instance, namelen + 1) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);tybs_mem_free(mctx, instance);return (TYBS_R_FAILURE);scf_handle_destroy(h);*ins_name = instance;return (TYBS_R_SUCCESS);}#endifintmain(int argc, char *argv[]) {tybs_result_t result;#ifdef HAVE_LIBSCFchar *instance = NULL;#endifstrlcat(version,#ifdef __DATE__"named version: BIND " VERSION " (" __DATE__ ")",#else"named version: BIND " VERSION,#endifsizeof(version));result = tybs_file_progname(*argv, program_name, sizeof(program_name));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("program name too long");if (strcmp(program_name, "lwresd") == 0)ns_g_lwresdonly = TYBS_TRUE;tybs_assertion_setcallback(assertion_failed);tybs_error_setfatal(library_fatal_error);ns_os_init(program_name);dns_result_register();dst_result_register();tybscc_result_register();parse_command_line(argc, argv);if (ns_g_chrootdir != NULL) {int len = strlen(ns_g_chrootdir);if (strncmp(ns_g_chrootdir, ns_g_conffile, len) == 0 &&(ns_g_conffile[len] == '/' || ns_g_conffile[len] == '\\')) ns_main_earlywarning("config filename (-c %s) contains ""chroot path (-t %s)",ns_g_conffile, ns_g_chrootdir);}result = tybs_mem_create(0, 0, &ns_g_mctx);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_mem_create() failed: %s",tybs_result_totext(result));tybs_mem_setname(ns_g_mctx, "main", NULL);setup();do {result = tybs_app_run();if (result == TYBS_R_RELOAD) {ns_server_reloadwanted(ns_g_server);} else if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_app_run(): %s",result = TYBS_R_SUCCESS;}} while (result != TYBS_R_SUCCESS);#ifdef HAVE_LIBSCFif (ns_smf_want_disable == 1) {result = ns_smf_get_instance(&instance, 1, ns_g_mctx);if (result == TYBS_R_SUCCESS && instance != NULL) { if (smf_disable_instance(instance, 0) != 0)UNEXPECTED_ERROR(__FILE__, __LINE__,"smf_disable_instance() ""failed for %s : %s",instance,scf_strerror(scf_error()));}if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);}#endif /* HAVE_LIBSCF */cleanup();if (want_stats) {tybs_mem_stats(ns_g_mctx, stdout);tybs_mutex_stats(stdout);}if (ns_g_memstatistics && memstats != NULL) {FILE *fp = NULL;result = tybs_stdio_open(memstats, "w", &fp);tybs_mem_stats(ns_g_mctx, fp);tybs_mutex_stats(fp);tybs_stdio_close(fp);}}tybs_mem_destroy(&ns_g_mctx);tybs_mem_checkdestroyed(stderr);ns_main_setmemstats(NULL);tybs_app_finish();ns_os_closedevnull();ns_os_shutdown();return (0);}#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h"#include <stdio.h>#include <fcntl.h>#ifdef PHP_WIN32#include "win32/time.h"#include "win32/signal.h"#include "win32/php_win32_globals.h"#include <process.h>#elif defined(NETWARE)#include <sys/timeval.h>#ifdef USE_WINSOCK#include <novsock2.h>#endif#if HAVE_SYS_TIME_H#include <sys/time.h>#endif#if HAVE_UNISTD_H#include <unistd.h>#endif#if HAVE_SIGNAL_H#include <signal.h>#endif#if HAVE_SETLOCALE#include <locale.h>#endif#include "zend.h"#include "zend_extensions.h"#include "php_ini.h"#include "php_globals.h"#include "php_main.h"#include "fopen_wrappers.h"#include "ext/standard/php_standard.h" #include "php_variables.h"#include "ext/standard/credits.h"#ifdef PHP_WIN32#include <io.h>#include "win32/php_registry.h"#include "ext/standard/flock_compat.h"#include "php_syslog.h"#include "Zend/zend_exceptions.h"#if PHP_SIGCHILD#include <sys/types.h>#include <sys/wait.h>#endif#include "zend_compile.h"#include "zend_execute.h"#include "zend_highlight.h"#include "zend_indent.h"#include "zend_extensions.h"#include "zend_ini.h"#include "php_content_types.h"#include "php_ticks.h"#include "php_logos.h"#include "php_streams.h"#include "php_open_temporary_file.h" #include "SAPI.h"#include "rfc1867.h"/* }}} */#ifndef ZTSphp_core_globals core_globals;#elsePHPAPI int core_globals_id;#endif#define SAFE_FILENAME(f) ((f)?(f):"-")*/static PHP_INI_MH(OnSetPrecision){int i = atoi(new_value);if (i >= 0) {EG(precision) = i;return SUCCESS;} else {return FAILURE;}}static PHP_INI_MH(OnChangeMemoryLimit){if (new_value) {PG(memory_limit) = zend_atoi(new_value, new_value_length);} else {PG(memory_limit) = 1<<30; /* effectively, no limit */ }return zend_set_memory_limit(PG(memory_limit));}static void php_disable_functions(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_functions"))) {return;}while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_function(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zend_disable_function(s, e-s TSRMLS_CC);}}static void php_disable_classes(TSRMLS_D){char *s = NULL, *e;}e = PG(disable_classes) = strdup(INI_STR("disable_classes"));while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_class(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zend_disable_class(s, e-s TSRMLS_CC);}}static PHP_INI_MH(OnUpdateTimeout)if (stage==PHP_INI_STAGE_STARTUP) {/* Don't set a timeout on startup, only per-request */return SUCCESS;}zend_unset_timeout(TSRMLS_C);zend_set_timeout(EG(timeout_seconds));return SUCCESS;}static int php_get_display_errors_mode(char *value, int value_length){int mode;if (!value) {return PHP_DISPLAY_ERRORS_STDOUT;}if (value_length == 2 && !strcasecmp("on", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 3 && !strcasecmp("yes", value)) { mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 4 && !strcasecmp("true", value)) { mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 6 && !strcasecmp(value, "stderr")) { mode = PHP_DISPLAY_ERRORS_STDERR;} else if (value_length == 6 && !strcasecmp(value, "stdout")) { mode = PHP_DISPLAY_ERRORS_STDOUT;if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) {mode = PHP_DISPLAY_ERRORS_STDOUT;}}return mode;}static PHP_INI_MH(OnUpdateDisplayErrors){PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value, new_value_length);return SUCCESS;}static PHP_INI_DISP(display_errors_mode){int mode, tmp_value_length, cgi_or_cli;char *tmp_value;TSRMLS_FETCH();if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );tmp_value_length = ini_entry->orig_value_length;} else if (ini_entry->value) {tmp_value = ini_entry->value;tmp_value_length = ini_entry->value_length;tmp_value_length = 0;}mode = php_get_display_errors_mode(tmp_value, tmp_value_length);cgi_or_cli = (!strcmp(sapi_, "cli") || !strcmp(sapi_, "cgi"));switch (mode) {case PHP_DISPLAY_ERRORS_STDERR:if (cgi_or_cli ) {PUTS("STDERR");} else {PUTS("On");}break;case PHP_DISPLAY_ERRORS_STDOUT:if (cgi_or_cli ) {PUTS("STDOUT");} else {PUTS("On");}break;default:PUTS("Off");break;}}/* Only do the safemode/open_basedir check at runtime */if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) &&strcmp(new_value, "syslog")) {if (PG(safe_mode) && (!php_checkuid(new_value, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {return FAILURE;}if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) {return FAILURE;}}OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);return SUCCESS;}static PHP_INI_MH(OnChangeMailForceExtra){/* Don't allow changing it in htaccess */if (stage == PHP_INI_STAGE_HTACCESS) {return FAILURE;}return SUCCESS;}。
软著申请源代码格式要求
软著申请源代码格式要求
软件著作权申请中的源代码格式要求通常包括以下几个方面:
1. 格式规范,源代码应当符合一定的格式规范,以确保代码的可读性和可维护性。
通常情况下,代码应当缩进合理、命名规范统一、注释清晰等。
2. 版本标识,在软件著作权申请中,需要提供源代码的版本标识,包括版本号、更新日期等信息,以便于对不同版本的代码进行比较和分析。
3. 完整性,申请软件著作权时,需要提交完整的源代码,确保所有相关的代码文件和依赖文件都包含在内,以便于对软件的功能和实现进行全面的评估。
4. 注释说明,源代码中应当包含详细的注释,对关键算法、功能模块、重要变量等进行说明,以便于他人阅读和理解代码的逻辑和设计思路。
5. 语言要求,根据软件开发的实际情况,源代码可以使用不同
的编程语言编写,但需要在申请中明确说明所使用的编程语言和相应的版本。
总的来说,软件著作权申请中的源代码格式要求主要是为了确保提交的代码能够清晰地展现软件的功能和实现逻辑,以便于著作权部门对软件进行评估和审查。
因此,在准备软件著作权申请时,需要仔细遵守相关的格式要求,并确保提交的源代码符合规定,以提高申请成功的几率。
计算机软件著作权登记-源代码范本
package com.example.shuoya;import java.util.Set;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.os.Bundle;import android.telephony.SmsMessage;import android.util.Log;import android.widget.Toast;public class Breast extends BroadcastReceiver{private static final String mACTION = "android.provider.Telephony.SMS_RECEIVED"; @Overridepublic void onReceive(Context context, Intent intent){// TODO Auto-generated method stubif (intent.getAction().equals(mACTION)){StringBuilder sb = new StringBuilder();Bundle bundle = intent.getExtras();if (bundle != null){Set<String> keysSet=bundle.keySet();for(String keyString:keysSet){Log.d("key", keyString);}Object[] myOBJpdus = (Object[]) bundle.get("pdus");SmsMessage[] messages = new SmsMessage[myOBJpdus.length];for (int i = 0; i<myOBJpdus.length; i++){messages[i] = SmsMessage.createFromPdu ((byte[]) myOBJpdus[i]);}for (SmsMessage currentMessage : messages){//sb.append("接收到来告:\n");//sb.append(currentMessage.getDisplayOriginatingAddress());//sb.append("\n------传来的短信------\n");sb.append(currentMessage.getDisplayMessageBody());}}Toast.makeText(context, sb, Toast.LENGTH_LONG).show();Intent i2 = new Intent(context, FuzhuActivity.class);Bundle bundle2=new Bundle();bundle2.putString("SMS", sb.toString());i2.putExtra("SMSS", bundle2);i2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);context.startActivity(i2);}}}package com.example.shuoya;import android.content.Context;import android.database.sqlite.SQLiteDatabase;import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteOpenHelper;public class DbAdapter extends SQLiteOpenHelper{private static final int VERSION = 1;private static final String DBNAME = "test.db";public DbAdapter(Context context, String name,CursorFactory factory, int version) {super(context, name, factory, version);// TODO Auto-generated constructor stub}public DbAdapter(Context context,String name){this(context,name,VERSION);}public DbAdapter(Context context){this(context,DBNAME,VERSION);}public DbAdapter(Context context,String name,int version){ this(context,name,null,VERSION);}public void onCreate(SQLiteDatabase db) {// TODO Auto-generated method stub}public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stubSystem.out.println("update a database");}}package com.example.shuoya;import java.util.List;import com.example.shuoya.R;import android.app.AlertDialog;import android.content.Context;import android.database.DataSetObserver;import youtInflater;import android.view.MotionEvent;import android.view.View;import android.view.View.OnClickListener;import android.view.View.OnLongClickListener;import android.view.View.OnTouchListener;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.LinearLayout;import android.widget.TextView;//public class DetailAdapter implements ListAdapterpublic class DetailAdapter extends BaseAdapter{private List<DetailEntity> coll;private Context ctx;DetailEntity entity;LinearLayout layout;LayoutInflater vi;LinearLayout layout_bj;TextView tvName;TextView tvDate;TextView tvText;public DetailAdapter(Context context, List<DetailEntity> coll) {ctx = context;this.coll = coll;}public boolean areAllItemsEnabled(){return true;}public boolean isEnabled(int arg0) {return true;}public int getCount(){return coll.size();}public Object getItem(int position){return coll.get(position);}public long getItemId(int position){return position;}public int getItemViewType(int position) {return position;}public View getView(int position, View convertView, ViewGroup parent){entity = coll.get(position);int itemLayout = entity.getLayoutID();layout = new LinearLayout(ctx);vi = (LayoutInflater) ctx.getSystemService(YOUT_INFLATER_SERVICE);vi.inflate(itemLayout, layout, true);layout.setBackgroundColor(0xffB4B4B4);layout_bj = (LinearLayout) layout.findViewById(yout_bj);tvName = (TextView) layout.findViewById(R.id.messagedetail_row_name);tvName.setText(entity.getName());tvDate = (TextView) layout.findViewById(R.id.messagedetail_row_date);tvDate.setText(entity.getDate());tvText = (TextView) layout.findViewById(R.id.messagedetail_row_text);tvText.setText(entity.getText());addListener(tvName, tvDate, tvText, layout_bj);return layout;}public int getViewTypeCount(){return coll.size();}public boolean hasStableIds(){return true;}public boolean isEmpty(){return true;}@Overridepublic void registerDataSetObserver(DataSetObserver observer) {// TODO Auto-generated method stub}@Overridepublic void unregisterDataSetObserver(DataSetObserver observer) {// TODO Auto-generated method stub}public void addListener(final TextView tvName, final TextView tvDate, final TextView tvText, LinearLayout layout_bj){layout_bj.setOnClickListener(new OnClickListener(){@Overridepublic void onClick(View v){}});//实例并初始化TTS对象layout_bj.setOnLongClickListener(new OnLongClickListener(){@Overridepublic boolean onLongClick(final View v){tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setTextColor(0xffffffff);new AlertDialog.Builder(ctx).setMessage("说呀聊天辅助系统-应答模式").setPositiveButton("确定",null).show();return true;}});////layout_bj.setOnTouchListener(new OnTouchListener(){@Overridepublic boolean onTouch(View v, MotionEvent event){switch (event.getAction()){case MotionEvent.ACTION_DOWN:case MotionEvent.ACTION_MOVE:tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setTextColor(0xffffffff);break;default:tvName.setTextColor(0xff000000);tvDate.setTextColor(0xff000000);tvText.setTextColor(0xff0000ff);break;}return false;}});}}package com.example.shuoya;public class DetailEntity{private String name;private String date;private String text;private int layoutID;public String getName(){return name;}public void setName(String name) { = name;}public String getDate(){return date;}public void setDate(String date) {this.date = date;}public String getText(){return text;}public void setText(String text) {this.text = text;}public int getLayoutID(){return layoutID;}public void setLayoutID(int layoutID){youtID = layoutID;}public DetailEntity(){}public DetailEntity(String name, String date, String text, int layoutID) {super(); = name;this.date = date;this.text = text;youtID = layoutID;}}package com.example.shuoya;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import .URL;import .URLEncoder;public class Fenci{/* Called when the activity is first created. */static String u = "/fudannlp/";public String str;public static String nlp(String func, String input){String str1="";try{input = URLEncoder.encode(input, "utf-8");URL url = new URL( u + func + "/" + input);StringBuffer sb = new StringBuffer();BufferedReader out = new BufferedReader(new InputStreamReader(url.openStream(), "utf-8"));String line;while ((line = out.readLine()) != null)sb.append(line);str1=sb.toString();out.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}int i=str1.indexOf("s");str1=str1.substring(i+1);return str1;}}package com.example.shuoya;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import java.io.OutputStream;import java.util.ArrayList;import java.util.List;import com.example.shuoya.R;import android.app.Activity;import android.app.AlertDialog;import android.content.Context;import android.content.DialogInterface; import android.content.Intent;import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Bundle;import android.speech.RecognizerIntent;import youtInflater;import android.view.View;import android.view.Window;import android.view.View.OnClickListener;import android.view.WindowManager;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.ListView;import android.widget.PopupWindow;import android.widget.Toast;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.graphics.drawable.BitmapDrawable;public class FuzhuActivity extends Activity{private ListView talkView;private List<DetailEntity> list = null;//menu菜单模块private PopupWindow popupWindow;private ListView lv_menu;private View view;private List<String> Menus;private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;private EditText mText1;private Button speakButton;private Button qdButton;private Button chooseButton;long exitTime=-2000;@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(yout.test);//将数据库放到手机中,测试时注释掉PackageManager pm = getPackageManager();//管理应用程序包List<ResolveInfo> activities = pm.queryIntentActivities(newIntent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);}public String getResponce(String et){String answer="";String myFenci=Fenci.nlp("pos",et);String mySubject,myPredicate,myObject;//定义主谓宾mySubject=GetWord.ReturnSubject(myFenci);myPredicate=GetWord.ReturnPredicate(myFenci);myObject=GetWord.ReturnObject(myFenci);DbAdapter dbHelper = new DbAdapter(FuzhuActivity.this,"test.db");//只有调用了DatabaseHelper对象的//getReadableDatabase()方法,或者是getWritableDatabase()方法之后,才会创建,或打开一个数据库SQLiteDatabase db = dbHelper.getReadableDatabase();int id_temp1,id_temp2,id_temp3;String search_id;Cursor cursor1;if(mySubject==null){id_temp1=0;}else{cursor1 = db.query("r_sheet", new String[]{"id"}, "charName=?", new String[]{mySubject}, null, null, null);if(cursor1.moveToNext()){//在r表中查询id_temp1=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp1=0;}}if(myPredicate==null){id_temp2=0;else{cursor1 = db.query("verb_sheet", new String[]{"id"}, "verbName=?", new String[]{myPredicate}, null, null, null);if(cursor1.moveToNext()){//在v表中查询id_temp2=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp2=0;}}if(myObject==null){id_temp3=0;}else{cursor1 = db.query("noun_sheet", new String[]{"id"}, "nounName=?", new String[]{myObject}, null, null, null);if(cursor1.moveToNext()){//在n表中查询id_temp3=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp3=0;}search_id=numberToString(id_temp1)+numberToString(id_temp2)+numberToString(id_temp3);cursor1 = db.query("answer_sheet", new String[]{"answer"}, "id=?", new String[]{search_id}, null, null, null);if(cursor1.moveToNext()){//在answer表中查询answer=cursor1.getString(cursor1.getColumnIndex("answer"));}else{}if(answer!=""){Toast.makeText(getApplicationContext(), answer, Toast.LENGTH_LONG).show();}else if(answer==""){Toast.makeText(getApplicationContext(), "暂无提示", Toast.LENGTH_LONG).show();}else{Toast.makeText(getApplicationContext(), "暂无提示", Toast.LENGTH_LONG).show();}return answer;}public String numberToString(int number){String s="";if (number==0||number<10)s="00"+String.valueOf(number);else if(number<100)s="0"+String.valueOf(number);elses=String.valueOf(number);return s;}}package com.example.shuoya;import android.os.AsyncTask;public class GetResTask extends AsyncTask<String,Void,String>{TestActivity atxs=new TestActivity();@Overrideprotected String doInBackground(String... params) {// TODO Auto-generated method stubreturn atxs.getResponce(params[0]);}protected Void onPostExcute(String result){return null;}}package com.example.shuoya;import unchOnKeyguardExit; import android.app.Activity;import android.content.Intent;import android.content.SharedPreferences;import android.graphics.Bitmap;import android.os.Bundle;import android.preference.PreferenceManager;import android.view.Display;import android.view.View;import android.view.Window;import android.view.WindowManager;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.ScrollView;import android.widget.TextView;public class SMSPopupActivity extends Activity {private SmsMmsMessage message;private boolean exitingKeyguardSecurely = false;private Bundle bundle = null;private SharedPreferences myPrefs;private TextView headerTV;private TextView messageTV;private TextView fromTV;private TextView mmsSubjectTV;private LinearLayout viewButtonLayout;private LinearLayout mmsLinearLayout;private ScrollView messageScrollView;private boolean wasVisible = false;private final double WIDTH = 0.8;@Overrideprotected void onCreate(Bundle bundle) {super.onCreate(bundle);Log.v("SMSPopupActivity: onCreate()");//First things first, acquire wakelock, otherwise the phone may sleep ManageWakeLock.acquirePartial(getApplicationContext());requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(yout.popup);//Get shared prefsmyPrefs = PreferenceManager.getDefaultSharedPreferences(this);//Check preferences and then blur out background behind windowif (myPrefs.getBoolean(getString(R.string.pref_blur_key),Boolean.valueOf(getString(R.string.pref_blur_default)))) {getWindow().setFlags(youtParams.FLAG_BLUR_BEHIND, youtParams.FLAG_BLUR_BEHIND);}//This sets the minimum width of the activity to 75% of the screen size//only needed because the theme of this activity is "dialog" so it looks//like it's floating and doesn't seem to fill_parent like a regular activity LinearLayout mainLL = (LinearLayout) findViewById(R.id.MainLinearLayout); Display d = getWindowManager().getDefaultDisplay();int width = (int)(d.getWidth() * WIDTH);Log.v("setting width to: " + width);mainLL.setMinimumWidth(width);//Find the main textviewsfromTV = (TextView) findViewById(R.id.FromTextView);messageTV = (TextView) findViewById(R.id.MessageTextView);headerTV = (TextView) findViewById(R.id.HeaderTextView);mmsSubjectTV = (TextView) findViewById(R.id.MmsSubjectTextView); viewButtonLayout = (LinearLayout) findViewById(R.id.ViewButtonLinearLayout);messageScrollView = (ScrollView) findViewById(R.id.MessageScrollView); mmsLinearLayout = (LinearLayout) findViewById(R.id.MmsLinearLayout);//The close buttonButton closeButton = (Button) findViewById(R.id.closeButton);closeButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {Intent i = new Intent(SMSPopupActivity.this.getApplicationContext(), SMSPopupUtilsService.class);// i.putExtra(SMSPopupUtilsService.EXTRAS_THREAD_ID,// message.getThreadId());i.setAction(SMSPopupUtilsService.ACTION_MARK_THREAD_READ);i.putExtras(message.toBundle());SMSPopupUtilsService.beginStartingService(SMSPopupActivity.this.getApplicationContext(), i);// Finish up this activitymyFinish();}});//The inbox buttonButton inboxButton = (Button) findViewById(R.id.InboxButton);inboxButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() { public void LaunchOnKeyguardExitSuccess() {Intent i = SMSPopupUtils.getSmsIntent();SMSPopupActivity.this.getApplicationContext().startActivity(i);}});myFinish();}});//The view button (if in privacy mode)Button viewButton = (Button) findViewById(R.id.ViewButton);viewButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() { public void LaunchOnKeyguardExitSuccess() {Intent i = getIntent();i.putExtra(SmsMmsMessage.EXTRAS_NOTIFY, false);startActivity(i);// finish();}});}});//The reply buttonButton replyButton = (Button) findViewById(R.id.replyButton);replyButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() { public void LaunchOnKeyguardExitSuccess() {Intent reply = message.getReplyIntent();SMSPopupActivity.this.getApplicationContext().startActivity(reply);}});ManageNotification.clearAll(SMSPopupActivity.this.getApplicationContext(), true);myFinish();}});// The ViewMMS buttonButton viewMmsButton = (Button) findViewById(R.id.ViewMmsButton); viewMmsButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() { public void LaunchOnKeyguardExitSuccess() {Intent reply = message.getReplyIntent();SMSPopupActivity.this.getApplicationContext().startActivity(reply);}});ManageNotification.clearAll(SMSPopupActivity.this.getApplicationContext(), true);myFinish();}});if (bundle == null) {populateViews(getIntent().getExtras());} else {populateViews(bundle);}wakeApp();}@Overrideprotected void onNewIntent(Intent intent) {super.onNewIntent(intent);Log.v("SMSPopupActivity: onNewIntent()");//First things first, acquire wakelock, otherwise the phone may sleepManageWakeLock.acquirePartial(getApplicationContext());setIntent(intent);//Re-populate views with new intent data (ie. new sms data) populateViews(intent.getExtras());wakeApp();}@Overrideprotected void onStart() {super.onStart();Log.v("SMSPopupActivity: onStart()");ManageWakeLock.acquirePartial(getApplicationContext()); }@Overrideprotected void onResume() {super.onResume();Log.v("SMSPopupActivity: onResume()");wasVisible = false;//Reset exitingKeyguardSecurely bool to falseexitingKeyguardSecurely = false;}@Overrideprotected void onPause() {super.onPause();Log.v("SMSPopupActivity: onPause()");if (wasVisible) {//Cancel the receiver that will clear our locksClearAllReceiver.removeCancel(getApplicationContext());ClearAllReceiver.clearAll(!exitingKeyguardSecurely);}}@Overrideprotected void onStop() {super.onStop();Log.v("SMSPopupActivity: onStop()");//Cancel the receiver that will clear our locksClearAllReceiver.removeCancel(getApplicationContext());ClearAllReceiver.clearAll(!exitingKeyguardSecurely);}@Overridepublic void onWindowFocusChanged(boolean hasFocus) {super.onWindowFocusChanged(hasFocus);Log.v("SMSPopupActivity: onWindowFocusChanged(" + hasFocus + ")");if (hasFocus) {wasVisible = true;}}@Overridepublic void onSaveInstanceState(Bundle outState) {super.onSaveInstanceState(outState);Log.v("SMSPopupActivity: onSaveInstanceState()");outState.putAll(bundle);}private void myFinish() {ManageNotification.clearAll(getApplicationContext());ReminderReceiver.cancelReminder(getApplicationContext());finish();}private void populateViews(Bundle b) {bundle = b;message = new SmsMmsMessage(getApplicationContext(), bundle);refreshPrivacy();ImageView iv = (ImageView) findViewById(R.id.FromImageView);Bitmap contactPhoto = message.getContactPhoto();if (contactPhoto != null) {iv.setImageBitmap(contactPhoto);} else {iv.setImageDrawable(getResources().getDrawable(android.R.drawable.ic_dialog_info));}LinearLayout mLL = (LinearLayout) findViewById(R.id.UnreadCountLinearLayout);TextView tv = (TextView) findViewById(R.id.UnreadCountTextView);if (message.getUnreadCount() <= 1) {mLL.setVisibility(View.GONE);tv.setText("");} else {String textWaiting = String.format(getString(R.string.unread_text_waiting), message.getUnreadCount() - 1);tv.setText(textWaiting);mLL.setVisibility(View.VISIBLE);}String headerText = getString(R.string.new_text_at);headerText = headerText.replaceAll("%s", message.getFormattedTimestamp());fromTV.setText(message.getContactName());if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_SMS) { messageTV.setText(message.getMessageBody());} else {mmsSubjectTV.setText(getString(R.string.mms_subject) + " " +message.getMessageBody());}headerTV.setText(headerText);}private void refreshPrivacy() {ManageKeyguard.initialize(getApplicationContext());boolean privacyMode = myPrefs.getBoolean(getString(R.string.pref_privacy_key),Boolean.valueOf(getString(R.string.pref_privacy_default)));if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_MMS) { viewButtonLayout.setVisibility(View.GONE);messageScrollView.setVisibility(View.GONE);mmsLinearLayout.setVisibility(View.VISIBLE);boolean subjectAvailable = true;if (message.getMessageBody() == null) {subjectAvailable = false;} else {if (message.getMessageBody().length() == 0) {subjectAvailable = false;}}if (!subjectAvailable) {mmsSubjectTV.setVisibility(View.GONE);} else {mmsSubjectTV.setVisibility(View.VISIBLE);}} else {mmsLinearLayout.setVisibility(View.GONE);if (privacyMode && ManageKeyguard.inKeyguardRestrictedInputMode()) { viewButtonLayout.setVisibility(View.VISIBLE);messageScrollView.setVisibility(View.GONE);} else {viewButtonLayout.setVisibility(View.GONE);messageScrollView.setVisibility(View.VISIBLE);}}}private void wakeApp() {ManageWakeLock.acquireFull(getApplicationContext());if (message.getNotify()) {bundle.putBoolean(SmsMmsMessage.EXTRAS_NOTIFY, false);message.updateReminderCount(0);ReminderReceiver.scheduleReminder(getApplicationContext(), message);ManageNotification.show(getApplicationContext(), message);}}@Overrideprotected void onDestroy() {Log.v("onDestroy()");super.onDestroy();}}package com.example.shuoya;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;public class SMSReceiver extends BroadcastReceiver { @Overridepublic void onReceive(Context context, Intent intent) {Log.v("SMSReceiver: onReceive()");intent.setClass(context, SMSReceiverService.class);intent.putExtra("result", getResultCode());SMSReceiverService.beginStartingService(context, intent);}}package com.example.shuoya;import android.app.AlarmManager;import android.app.PendingIntent;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;import android.preference.PreferenceManager;public class ReminderReceiver extends BroadcastReceiver { private static PendingIntent reminderPendingIntent = null;@Overridepublic void onReceive(Context context, Intent intent) {intent.setClass(context, ReminderReceiverService.class);ReminderReceiverService.beginStartingService(context, intent);}public static void scheduleReminder(Context context, SmsMmsMessage message) { SharedPreferences myPrefs = PreferenceManager.getDefaultSharedPreferences(context);boolean reminder_notifications = myPrefs.getBoolean(context.getString(R.string.pref_notif_repeat_key), Boolean.valueOf(context.getString(R.string.pref_notif_repeat_default)));if (reminder_notifications) {int reminder_interval = Integer.parseInt(myPrefs.getString(context.getString(R.string.pref_notif_repeat_interval_key), context.getString(R.string.pref_notif_repeat_interval_default)));reminder_interval *= 60;AlarmManager myAM = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);Intent reminderIntent = new Intent(context, ReminderReceiver.class);reminderIntent.setAction(ReminderReceiverService.ACTION_REMIND);message.incrementReminderCount();reminderIntent.putExtras(message.toBundle());reminderPendingIntent = PendingIntent.getBroadcast(context, 0, reminderIntent, PendingIntent.FLAG_CANCEL_CURRENT);long triggerTime = System.currentTimeMillis() + (reminder_interval * 1000);Log.v("ReminderReceiver: scheduled reminder notification in " + reminder_interval + " seconds, count is " + message.getReminderCount());myAM.set(AlarmManager.RTC_WAKEUP, triggerTime, reminderPendingIntent);}}public static void cancelReminder(Context context) {if (reminderPendingIntent != null) {AlarmManager myAM = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);myAM.cancel(reminderPendingIntent);reminderPendingIntent.cancel();reminderPendingIntent = null;Log.v("ReminderReceiver: cancelReminder()");}}}package com.example.shuoya;import android.app.Activity;import android.app.Service;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;import android.os.Bundle;import android.os.Handler;import android.os.HandlerThread;import android.os.IBinder;import android.os.Looper;import android.os.Message;import android.os.PowerManager;import android.os.Process;import android.preference.PreferenceManager;import android.telephony.gsm.SmsManager;import android.telephony.gsm.SmsMessage;public class SMSReceiverService extends Service {private static final String ACTION_SMS_RECEIVED ="android.provider.Telephony.SMS_RECEIVED";private static final String ACTION_MMS_RECEIVED ="android.provider.Telephony.WAP_PUSH_RECEIVED";private static final String MMS_DATA_TYPE = "application/vnd.wap.mms-message";private static final String ACTION_MESSAGE_SENT ="com.android.mms.transaction.MESSAGE_SENT";private Context context;private ServiceHandler mServiceHandler;private Looper mServiceLooper;private int mResultCode;。
计算机软件著作权登记-源代码范本
packageimportimportimportimportimportimportimportimportimportimport{{{{}{}{//sb.append("\n------传来的短信------\n");sb.append(currentMessage.getDisplayMessageBody()); }}Toast.makeText(context,sb,Toast.LENGTH_LONG).show();Intenti2=newIntent(context,FuzhuActivity.class);Bundlebundle2=newBundle();bundle2.putString("SMS",sb.toString());i2.putExtra("SMSS",bundle2);i2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);context.startActivity(i2);}}}packageimportimportimportimport publicclassDbAdapterextendsSQLiteOpenHelper{privatestaticfinalintVERSION=1;privatestaticfinalStringDBNAME="test.db";publicDbAdapter(Contextcontext,Stringname,CursorFactoryfactory,intversion){super(context,name,factory,version);importimportimportimportimportimportimportimportimportimportimportimportimportimportimport//publicclassDetailAdapterimplementsListAdapter publicclassDetailAdapterextendsBaseAdapter{privateList<DetailEntity>coll;privateContextctx;DetailEntityentity;LinearLayoutlayout;LayoutInflatervi;LinearLayoutlayout_bj;TextViewtvName;TextViewtvDate;TextViewtvText;publicDetailAdapter(Contextcontext,List<DetailEntity>coll){ctx=context;this.coll=coll;}{}{}{}{}{}{}{entity=coll.get(position);intitemLayout=entity.getLayoutID();layout=newLinearLayout(ctx);vi=(LayoutInflater)ctx.getSystemService(YOUT_INFLATER_SERVICE);vi.inflate(itemLayout,layout,true);layout.setBackgroundColor(0xffB4B4B4);layout_bj=(LinearLayout)tvName=(TextView)tvName.setText(entity.getName());tvDate=(TextView)tvDate.setText(entity.getDate());tvText=(TextView)tvText.setText(entity.getText());addListener(tvName,tvDate,tvText,layout_bj);returnlayout;}publicintgetViewTypeCount(){returncoll.size();}publicbooleanhasStableIds(){}{}{}{}{//实例并初始化TTS对象layout_bj.setOnLongClickListener(newOnLongClickListener(){@OverridepublicbooleanonLongClick(finalViewv){tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setTextColor(0xffffffff);newAlertDialog.Builder(ctx).setMessage("说呀聊天辅助系统-应答模式").setPositiveButton("确定",null).show();returntrue;}});////layout_bj.setOnTouchListener(newOnTouchListener(){@OverridepublicbooleanonTouch(Viewv,MotionEventevent){switch(event.getAction()){caseMotionEvent.ACTION_DOWN:caseMotionEvent.ACTION_MOVE:}}package{{}publicvoidsetName(Stringname){=name;}publicStringgetDate(){returndate;}publicvoidsetDate(Stringdate){this.date=date;}publicStringgetText(){returntext;}publicvoidsetText(Stringtext){this.text=text;}publicintgetLayoutID(){returnlayoutID;}{}{}{}}packageimportimportimportimportimportpublicstaticStringnlp(Stringfunc,Stringinput){Stringstr1="";try{input=URLEncoder.encode(input,"utf-8");URLurl=newURL(u+func+"/"+input);StringBuffersb=newStringBuffer();BufferedReaderout=newBufferedReader(newInputStreamReader(url.openStream(),"utf-8")); Stringline;while((line=out.readLine())!=null)sb.append(line);str1=sb.toString();out.close();}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}inti=str1.indexOf("s");str1=str1.substring(i+1);returnstr1;}}packageimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportpublicclassFuzhuActivityextendsActivity{privateListViewtalkView;privateList<DetailEntity>list=null;//menu菜单模块privatePopupWindowpopupWindow;privateListViewlv_menu;privateViewview;privateList<String>Menus;privatestaticfinalintVOICE_RECOGNITION_REQUEST_CODE=1234; privateEditTextmText1;privateButtonspeakButton;privateButtonqdButton;privateButtonchooseButton;longexitTime=-2000;@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);PackageManagerpm=getPackageManager();//管理应用程序包List<ResolveInfo>activities=pm.queryIntentActivities(newIntent(RecognizerIntent.ACTION_RECOGNIZE_ SPEECH),0);}{ll);id_temp1=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp1=0;}}if(myPredicate==null){id_temp2=0;}else{cursor1=db.query("verb_sheet",newString[]{"id"},"verbName=?",newString[]{myPredicate},null,nu ll,null);if(cursor1.moveToNext()){//在v表中查询id_temp2=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp2=0;}}if(myObject==null){null);,null);elseif(answer==""){Toast.makeText(getApplicationContext(),"暂无提示",Toast.LENGTH_LONG).show();}else{Toast.makeText(getApplicationContext(),"暂无提示",Toast.LENGTH_LONG).show();}returnanswer;}publicStringnumberToString(intnumber){Strings="";if(number==0||number<10)s="00"+String.valueOf(number);elseif(number<100)s="0"+String.valueOf(number);elses=String.valueOf(number);returns;}}packageimportpublicclassGetResTaskextendsAsyncTask<String,Void,String>{ TestActivityatxs=newTestActivity();@Override}}}packageimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportpublicclassSMSPopupActivityextendsActivity{privateSmsMmsMessagemessage;privatebooleanexitingKeyguardSecurely=false;privateBundlebundle=null;privateSharedPreferencesmyPrefs;privateTextViewheaderTV;privateTextViewmessageTV;privateTextViewfromTV;privateTextViewmmsSubjectTV;privateLinearLayoutviewButtonLayout;privateLinearLayoutmmsLinearLayout;privateScrollViewmessageScrollView;privatebooleanwasVisible=false;privatefinaldoubleWIDTH=0.8;@OverrideprotectedvoidonCreate(Bundlebundle){super.onCreate(bundle);Log.v("SMSPopupActivity:onCreate()");//Firstthingsfirst,acquirewakelock,otherwisethephonemaysleepManageWakeLock.acquirePartial(getApplicationContext());requestWindowFeature(Window.FEATURE_NO_TITLE);//GetsharedprefsmyPrefs=PreferenceManager.getDefaultSharedPreferences(this);//Checkpreferencesandthenbluroutbackgroundbehindwindow{//message.getThreadId());i.setAction(SMSPopupUtilsService.ACTION_MARK_THREAD_READ);i.putExtras(message.toBundle());SMSPopupUtilsService.beginStartingService(i);//FinishupthisactivitymyFinish();}});//TheinboxbuttonButtoninboxButton=(Button)publicvoidonClick(Viewv){exitingKeyguardSecurely=true;ManageKeyguard.exitKeyguardSecurely(newLaunchOnKeyguardExit(){publicvoidLaunchOnKeyguardExitSuccess(){Intenti=SMSPopupUtils.getSmsIntent();}});myFinish();}});//Theviewbutton(ifinprivacymode)ButtonviewButton=(Button)}}true);});//TheViewMMSbuttonButtonviewMmsButton=(Button)viewMmsButton.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewv){exitingKeyguardSecurely=true;ManageKeyguard.exitKeyguardSecurely(newLaunchOnKeyguardExit(){publicvoidLaunchOnKeyguardExitSuccess(){Intentreply=message.getReplyIntent();}});myFinish();}});if(bundle==null){populateViews(getIntent().getExtras());}else{populateViews(bundle);}wakeApp();}@OverrideprotectedvoidonNewIntent(Intentintent){}}}Log.v("SMSPopupActivity:onPause()");if(wasVisible){//CancelthereceiverthatwillclearourlocksClearAllReceiver.removeCancel(getApplicationContext());ClearAllReceiver.clearAll(!exitingKeyguardSecurely);}}@OverrideprotectedvoidonStop(){super.onStop();Log.v("SMSPopupActivity:onStop()");ClearAllReceiver.removeCancel(getApplicationContext());ClearAllReceiver.clearAll(!exitingKeyguardSecurely);}@OverridepublicvoidonWindowFocusChanged(booleanhasFocus){super.onWindowFocusChanged(hasFocus);Log.v("SMSPopupActivity:onWindowFocusChanged("+hasFocus+")");if(hasFocus){wasVisible=true;}}@Override}}}else{StringtextWaiting=String.format(message.getUnreadCount()-1);tv.setText(textWaiting);mLL.setVisibility(View.VISIBLE);}StringheaderText=headerText=headerText.replaceAll("%s",message.getFormattedTimestamp());fromTV.setText(message.getContactName());if(message.getMessageType()==SmsMmsMessage.MESSAGE_TYPE_SMS){}else{+""+message.getMessageBody());}headerTV.setText(headerText);}privatevoidrefreshPrivacy(){ManageKeyguard.initialize(getApplicationContext());booleanprivacyMode=myPrefs.getBoolean(if(message.getMessageType()==SmsMmsMessage.MESSAGE_TYPE_MMS){viewButtonLayout.setVisibility(View.GONE);messageScrollView.setVisibility(View.GONE);mmsLinearLayout.setVisibility(View.VISIBLE);}if(message.getNotify()){bundle.putBoolean(SmsMmsMessage.EXTRAS_NOTIFY,false);message.updateReminderCount(0);ReminderReceiver.scheduleReminder(getApplicationContext(),message);ManageNotification.show(getApplicationContext(),message);}}@OverrideprotectedvoidonDestroy(){Log.v("onDestroy()");super.onDestroy();}packageimportimportimportpublicclassSMSReceiverextendsBroadcastReceiver{@OverridepublicvoidonReceive(Contextcontext,Intentintent){Log.v("SMSReceiver:onReceive()");intent.setClass(context,SMSReceiverService.class);intent.putExtra("result",getResultCode());SMSReceiverService.beginStartingService(context,intent);}}packageimportimportimportimportimportimportimport}IntentreminderIntent=newIntent(context,ReminderReceiver.class);reminderIntent.setAction(ReminderReceiverService.ACTION_REMIND);message.incrementReminderCount();reminderIntent.putExtras(message.toBundle());reminderPendingIntent=PendingIntent.getBroadcast(context,0,reminderIntent,PendingIntent.FLAG_CANCEL_CURRENT);longtriggerTime=System.currentTimeMillis()+(reminder_interval*1000);Log.v("ReminderReceiver:scheduledremindernotificationin"+reminder_interval+"seconds,countis"+message.getReminderCount());myAM.set(AlarmManager.RTC_WAKEUP,triggerTime,reminderPendingIntent);}publicstaticvoidcancelReminder(Contextcontext){if(reminderPendingIntent!=null){AlarmManagermyAM=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);myAM.cancel(reminderPendingIntent);reminderPendingIntent.cancel();reminderPendingIntent=null;Log.v("ReminderReceiver:cancelReminder()");}}}packageimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimport@OverridepublicvoidonCreate(){Log.v("SMSReceiverService:onCreate()");HandlerThreadthread=newHandlerThread(Log.LOGTAG,Process.THREAD_PRIORITY_BACKGROUND);thread.start();context=getApplicationContext();mServiceLooper=thread.getLooper();mServiceHandler=newServiceHandler(mServiceLooper);}@OverridepublicvoidonStart(Intentintent,intstartId){mResultCode=intent.getIntExtra("result",0);Messagemsg=mServiceHandler.obtainMessage();msg.arg1=startId;msg.obj=intent;mServiceHandler.sendMessage(msg);}@OverridepublicvoidonDestroy(){Log.v("SMSReceiverService:onDestroy()");mServiceLooper.quit();}@Override}}StringBuilderbody=newStringBuilder();Bundlebundle=intent.getExtras();if(bundle!=null){SharedPreferencesmyPrefs=PreferenceManager.getDefaultSharedPreferences(context);booleanonlyShowOnKeyguard=myPrefs.getBoolean(contextBoolean.valueOf(contextSmsMessage[]messages=SMSPopupUtils.getMessagesFromIntent(intent);if(messages!=null){SmsMessagesms=messages[0];if(sms.getMessageClass()==||sms.isReplace()){}else{body.append(messages[i].getMessageBody());}Stringaddress=messages[0].getOriginatingAddress();Log.v("smsaddress:"+address);Log.v("smsbody:"+body);longtimestamp=messages[0].getTimestampMillis();Stringmessage=body.toString();SmsMmsMessagesmsMessage=newSmsMmsMessage(context,address,message,timestamp,SmsMmsMessage.MESSAGE_TYPE_SMS);ManageKeyguard.initialize(context);if(ManageKeyguard.inKeyguardRestrictedInputMode()||!onlyShowOnKeyguard){Log.v("^^^^^^Inkeyguardorprefsettoalwaysshow-showingpopupactivity");}ManageNotification.show(context,mmsMessage);ReminderReceiver.scheduleReminder(context,mmsMessage);}}}privatevoidhandleMessageSent(Intentintent){if(mResultCode!=Activity.RESULT_OK&&mResultCode!=SmsManager.RESULT_ERROR_RADIO_OFF){}}publicstaticvoidbeginStartingService(Contextcontext,Intentintent){synchronized(mStartingServiceSync){if(mStartingService==null){PowerManagerpm=(PowerManager)context.getSystemService(Context.POWER_SERVICE);mStartingService=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,Log.LOGTAG);mStartingService.setReferenceCounted(false);}mStartingService.acquire();context.startService(intent);}}publicstaticvoidfinishStartingService(Serviceservice,intstartId){synchronized(mStartingServiceSync){}}package{zhuyu[k]=temp;k++;}elseif(sInput2[i].indexOf("/专有名")!=-1){intindex=sInput2[i].indexOf("/专有名");temp=sInput2[i].substring(0,index);zhuyu[k]=temp;k++;}elseif(sInput2[i].indexOf("/名词")!=-1)intindex=sInput2[i].indexOf("/名词");temp=sInput2[i].substring(0,index);if(i>=1&&(sInput2[i-1].indexOf("/动词")!=-1||sInput2[i-1].indexOf("/能愿动词")!=-1||sInput2[i-1].indexOf("/把动词")!=-1)){}else{zhuyu[k]=temp;k++;}}}sInput2=sInput.split("");//讲输入的句子分为数组intk=0;for(i=0;i<sInput2.length;i++){if(sInput2[i].indexOf("/动词")!=-1){intindex=sInput2[i].indexOf("/动词");temp=sInput2[i].substring(0,index);weiyu[k]=temp;k++;}elseif(sInput2[i].indexOf("/能愿动词")!=-1){intindex=sInput2[i].indexOf("/能愿动词");temp=sInput2[i].substring(0,index);weiyu[k]=temp;k++;}elseif(sInput2[i].indexOf("/形谓词")!=-1){intindex=sInput2[i].indexOf("/形谓词");temp=sInput2[i].substring(0,index);weiyu[k]=temp;k++;}{if(sInput2[i2].startsWith(zhuyuTemp)){j=i2;}else{}}}if(j!=-1){for(i=0;i<j;i++){sInput2[i]=sInput2[i];}for(i=j;i<sInput2.length-1;i++){sInput2[i]=sInput2[i+1];//讲sIput2中的值向前挪一位}}else{}for(i=0;i<sInput2.length;i++){if(sInput2[i].indexOf("/人称代词")!=-1)}elseif(sInput2[i].indexOf("/时间短语")!=-1){intindex=sInput2[i].indexOf("/时间短语");temp=sInput2[i].substring(0,index);binyu[k]=temp;k++;}elseif(sInput2[i].indexOf("/量词")!=-1){intindex=sInput2[i].indexOf("/量词");temp=sInput2[i].substring(0,index);binyu[k]=temp;k++;}elseif(sInput2[i].indexOf("/语气词")!=-1){intindex=sInput2[i].indexOf("/语气词");temp=sInput2[i].substring(0,index);binyu[k]=temp;k++;}else{}}packageimportimportimportimport{}}packageimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportpublicclassMainActivityextendsActivity{longexitTime=-2000;publicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);CreateSdcardDatabase();ButtonfuzhuBtn=(Button)fuzhuBtn.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewv){Intent(MainActivity.this,SmsActivity.class));Toast.makeText(MainActivity.this,"聊天辅助开启",Toast.LENGTH_SHORT).show();}});ButtonfstBtn=(Button)fstBtn.setOnClickListener(newOnClickListener(){publicvoidonClick(Viewv){startActivity(newIntent(MainActivity.this,TestActivity.class));});});});});}用,肯定大于2000{Toast.makeText(getApplicationContext(),"再次返回退出",1000).show();exitTime=System.currentTimeMillis();}else{finish();System.exit(0);}returntrue;}returntrue;}publicvoidCreateSdcardDatabase(){StringDB_PATH=StringDB_NAME="test.db";if((newFile(DB_PATH+DB_NAME)).exists()==false){Filef=newFile(DB_PATH);if(!f.exists()){f.mkdir();}try{InputStreamis=getBaseContext().getAssets().open(DB_NAME);//}//}}}}packageimportimportimportimportimportimportimportimportimportpublicclassMenuAdapterextendsBaseAdapter{ privateContextcontext;privateList<String>list;publicMenuAdapter(Contextcontext,List<String>list){this.context=context;this.list=list;}@OverridepublicintgetCount(){returnlist.size();}@OverridepublicObjectgetItem(intposition){returnlist.get(position);}@OverridepubliclonggetItemId(intposition){returnposition;}@OverridepublicViewgetView(intposition,ViewconvertView,ViewGroupviewGroup){ ViewHolderholder;if(convertView==null){null);}else{}}}}packageimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportimportpublicclassSearchActivityextendsActivity{{SPEECH),0);if(activities.size()!=0){speakButton.setOnClickListener(newSpeakListener()); }else{speakButton.setEnabled(false);}}//------------屏幕显示模块-----------publicvoidlistInit()talkView=(ListView)list=newArrayList<DetailEntity>();DetailEntityd1=newDetailEntity("说呀",Time.getTime(),"欢迎使用说呀聊天辅助系统!", e_item);list.add(d1);talkView.setAdapter(newDetailAdapter(SearchActivity.this,list));talkView.setSelection(talkView.getBottom());talkView.setDivider(null);}//--------------屏幕显示模块------------//--------------语音识别模块------------{}}}}}}else{DetailEntityd=newDetailEntity("我",Time.getTime(),et,yout.list_say_me_item);list.add(d);talkView.setAdapter(newDetailAdapter(SearchActivity.this,list));talkView.setSelection(talkView.getBottom());((EditText)mText1).setText("");getResponce(et);}}}/////////////////////////////////////////////////////////////////////////////// privatevoidshowMenu(Viewparent){WindowManagerwindowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);if(popupWindow==null){LayoutInflaterlayoutInflater=(LayoutInflater)getSystemService(YOUT_INFLATER_SERVICE); view=null);lv_menu=(ListView)Menus=newArrayList<String>();Menus.add("应答模式");Menus.add("录入模式");Menus.add("删除记录");//}//////if(Menus.get(position)=="应答模式"){startActivity(newIntent(SearchActivity.this,TestActivity.class));intversion=if(version>5){}finish();}if(Menus.get(position)=="录入模式"){startActivity(newIntent(SearchActivity.this,StudyActivity.class));intversion=if(version>5){}finish();}if(Menus.get(position)=="删除记录"){newAlertDialog.Builder(SearchActivity.this).setMessage("是否删除聊天记录?").setPositiveButton("删除",newDialogInterface.OnClickListener(){@OverridepublicvoidonClick(DialogInterfacedialog,intwhich){//TODOAuto-generatedmethodstublist.clear();聊天.setNegativeButton("取消",null).show();}if(popupWindow!=null){popupWindow.dismiss();}}});}publicvoidgetResponce(Stringet){finalWebViewwv=(WebView)findViewById(R.id.webView1);wv.getSettings().setJavaScriptEnabled(true);wv.setScrollBarStyle(0);WebSettingswebSettings=wv.getSettings();webSettings.setAllowFileAccess(true);webSettings.setBuiltInZoomControls(true);StringURL=+et+"&cl=3";wv.loadUrl(URL);//加载数据wv.setWebChromeClient(newWebChromeClient(){@OverridepublicvoidonProgressChanged(WebViewview,intnewProgress){if(newProgress==100){}else{}}});}});}}});}elseif(number<100)s="0"+String.valueOf(number);//如果数字是两位数,则在前面加一个"0"elses=String.valueOf(number);//默认数据库中主谓宾三张表数据不会超过999条。
python申请软著源代码
python申请软著源代码申请软著的源代码通常指的是软件著作权的申请材料中所需的软件源代码。
在申请软件著作权时,需要提供软件的源代码作为证明。
对于 Python 语言的软件,您可以按照以下步骤准备申请软著的源代码:1. 打开您的 Python 项目,找到主要的源代码文件和相关依赖文件。
这些文件通常以 .py 为后缀。
2. 将项目中所有的源代码文件(包括主文件和依赖文件)复制到一个新的文件夹中,以便整理和提交。
3. 确保源代码文件中不包含任何敏感信息或私密数据,例如数据库密码、API 密钥等。
如果有敏感信息,请在复制源代码之前进行删除或替换。
4. 检查源代码文件的编码格式是否为 UTF-8,这是软著申请要求的常见编码格式。
5. 如果您的项目使用了第三方库或框架,确保在源代码文件中包含了这些库的引用和依赖关系。
您可以在源代码文件的开头或注释中注明使用的第三方库和版本信息。
6. 如果您的项目有多个模块或组件,建议将每个模块的源代码放在不同的文件中,并在文件中添加合适的注释和说明,以便评审人员更好地理解您的代码结构和功能。
7. 检查源代码文件的格式和排版是否清晰易读,可以使用代码编辑器或自动化工具进行格式化和排版,以提高可读性。
8. 在准备软著申请材料时,将整理好的源代码文件打包成一个压缩文件,例如 ZIP 或 RAR 格式。
确保压缩文件不包含其他无关文件。
9. 在软著申请表格中按要求填写相关信息,包括软件名称、版本号、作者信息等。
同时,将准备好的源代码压缩文件附加在申请材料中一并提交。
请注意,以上步骤仅为一般性指导,具体的软著申请要求可能因地区和法规而有所不同。
建议您在申请软著之前,仔细阅读当地软著申请指南或咨询专业律师以确保申请的准确性和合法性。
软件著作权-源代码例范本
软件著作权-源代码范本注意事项:常见的源代码包含:C语言,VB,C++,JAVA,.NET等。
提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,著作权人,软件名字等,不能出现开源代码,不能出现任何版权纠纷。
格式要求:一、源代码应提交前、后各连续30页,不足60页的,应当全部提交。
二、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页眉右上应标注页码,源代码每页不少于50行。
范例如下:#include <tybs/commandline.h>#include <tybs/dir.h>#include <tybs/entropy.h>#include <tybs/file.h>#include <tybs/hash.h>#include <tybs/os.h>#include <tybs/platform.h>#include <tybs/resource.h>#include <tybs/stdio.h>#include <tybs/string.h>#include <tybs/task.h>#include <tybs/timer.h>#include <tybs/util.h>#include <tybscc/result.h>#include <dns/dispatch.h>#include <dns/name.h>#include <dns/result.h>#include <dns/view.h>#include <dst/result.h>#define NS_MAIN 1#include <named/ns_smf_globals.h>#endif#ifdef DLZ#include <dlz/dlz_drivers.h>#endifstatic tybs_boolean_t want_stats = TYBS_FALSE;static char program_name[TYBS_DIR_NAMEMAX] = "named"; static char absolute_conffile[TYBS_DIR_PATHMAX];static char saved_command_line[512];static char version[512];static unsigned int maxsocks = 0;voidns_main_earlywarning(const char *format, ...) {va_list args;va_start(args, format);if (ns_g_lctx != NULL) {tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_WARNING,format, args);} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);}Void ns_main_earlyfatal(const char *format, ...) { va_list args;if (ns_g_lctx != NULL) {tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,format, args);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to early fatal error)");} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);exit(1);}static voidassertion_failed(const char *file, int line, tybs_assertiontype_t type, const char *cond){if (ns_g_lctx != NULL) {tybs_assertion_setcallback(NULL);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"%s:%d: %s(%s) failed", file, line,tybs_assertion_typetotext(type), cond);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to assertion failure)");} else {fprintf(stderr, "%s:%d: %s(%s) failed\n",file, line, tybs_assertion_typetotext(type), cond);fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_fatal_error(const char *file, int line, const char *format, va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_fatal_error(const char *file, int line, const char *format, va_list args){if (ns_g_lctx != NULL) {tybs_error_setfatal(NULL);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,format, args);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to fatal error in library)");} else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_unexpected_error(const char *file, int line, const char *format, va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_unexpected_error(const char *file, int line, const char *format, va_list args){if (ns_g_lctx != NULL) {tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,"%s:%d: unexpected error:", file, line);tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,format, args);} else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}}static voidlwresd_usage(void) {fprintf(stderr,"usage: lwresd [-4|-6] [-c conffile | -C resolvconffile] ""[-d debuglevel]\n"" [-f|-g] [-n number_of_cpus] [-p port] ""[-P listen-port] [-s]\n"" [-t chrootdir] [-u username] [-i pidfile]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidusage(void) {lwresd_usage();return;}fprintf(stderr,"usage: named [-4|-6] [-c conffile] [-d debuglevel] ""[-f|-g] [-n number_of_cpus]\n"" [-p port] [-s] [-t chrootdir] [-u username]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidsave_command_line(int argc, char *argv[]) {int i;char *src;char *dst;char *eob;const char truncated[] = "...";tybs_boolean_t quoted = TYBS_FALSE;dst = saved_command_line;eob = saved_command_line + sizeof(saved_command_line);for (i = 1; i < argc && dst < eob; i++) {*dst++ = ' ';src = argv[i];while (*src != '\0' && dst < eob) {if (quoted || isalnum(*src & 0xff) ||*src == '-' || *src == '_' ||*src == '.' || *src == '/') {*dst++ = *src++;quoted = TYBS_FALSE;} else {*dst++ = '\\';quoted = TYBS_TRUE;}}}INSIST(sizeof(saved_command_line) >= sizeof(truncated));if (dst == eob)strcpy(eob - sizeof(truncated), truncated);else*dst = '\0';}static intparse_int(char *arg, const char *desc) {char *endp;int tmp;long int ltmp;ltmp = strtol(arg, &endp, 10);tmp = (int) ltmp;if (*endp != '\0')ns_main_earlyfatal("%s '%s' must be numeric", desc, arg);ns_main_earlyfatal("%s '%s' out of range", desc, arg);return (tmp);}static struct flag_def {const char *name;unsigned int value;} mem_debug_flags[] = {{ "trace", TYBS_MEM_DEBUGTRACE },{ "record", TYBS_MEM_DEBUGRECORD },{ "usage", TYBS_MEM_DEBUGUSAGE },{ "size", TYBS_MEM_DEBUGSIZE },{ "mctx", TYBS_MEM_DEBUGCTX },{ NULL, 0 }};static voidset_flags(const char *arg, struct flag_def *defs, unsigned int *ret) { for (;;) {const struct flag_def *def;const char *end = strchr(arg, ',');int arglen;if (end == NULL)end = arg + strlen(arg);arglen = end - arg;for (def = defs; def->name != NULL; def++) {if (arglen == (int)strlen(def->name) &&memcmp(arg, def->name, arglen) == 0) {*ret |= def->value;goto found;}}ns_main_earlyfatal("unrecognized flag '%.*s'", arglen, arg);found:if (*end == '\0')break;arg = end + 1;}}static voidparse_command_line(int argc, char *argv[]) {int ch;int port;tybs_boolean_t disable6 = TYBS_FALSE;tybs_boolean_t disable4 = TYBS_FALSE;save_command_line(argc, argv);tybs_commandline_errprint = TYBS_FALSE;while ((ch = tybs_commandline_parse(argc, argv,"46c:C:d:fgi:lm:n:N:p:P:""sS:t:T:u:vVx:")) != -1) {switch (ch) {if (disable4)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv4() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv4 not supported by OS");tybs_net_disableipv6();disable6 = TYBS_TRUE;break;case '6':if (disable6)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv6() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv6 not supported by OS");tybs_net_disableipv4();disable4 = TYBS_TRUE;break;case 'c':ns_g_conffile = tybs_commandline_argument;lwresd_g_conffile = tybs_commandline_argument;if (lwresd_g_useresolvconf)ns_main_earlyfatal("cannot specify -c and -C");ns_g_conffileset = TYBS_TRUE;break;case 'C':lwresd_g_resolvconffile = tybs_commandline_argument;if (ns_g_conffileset)ns_main_earlyfatal("cannot specify -c and -C");lwresd_g_useresolvconf = TYBS_TRUE;break;case 'd':ns_g_debuglevel = parse_int(tybs_commandline_argument,"debug level");break;case 'f':ns_g_foreground = TYBS_TRUE;break;case 'g':ns_g_foreground = TYBS_TRUE;ns_g_logstderr = TYBS_TRUE;break;/* XXXBEW -i should be removed */case 'i':lwresd_g_defaultpidfile = tybs_commandline_argument;break;case 'l':ns_g_lwresdonly = TYBS_TRUE;break;case 'm':set_flags(tybs_commandline_argument, mem_debug_flags, &tybs_mem_debugging);case 'N': /* Deprecated. */case 'n':ns_g_cpus = parse_int(tybs_commandline_argument,"number of cpus");if (ns_g_cpus == 0)ns_g_cpus = 1;break;case 'p':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);ns_g_port = port;break;/* XXXBEW Should -P be removed? */case 'P':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);lwresd_g_listenport = port;break;case 's':want_stats = TYBS_TRUE;break;case 'S':maxsocks = parse_int(tybs_commandline_argument,"max number of sockets");break;case 't':ns_g_chrootdir = tybs_commandline_argument;break;case 'T':if (strcmp(tybs_commandline_argument, "clienttest") == 0) ns_g_clienttest = TYBS_TRUE;elsefprintf(stderr, "unknown -T flag '%s\n",tybs_commandline_argument);break;case 'u':ns_g_username = tybs_commandline_argument;break;case 'v':printf("BIND %s\n", ns_g_version);exit(0);case 'V':printf("BIND %s built with %s\n", ns_g_version,ns_g_configargs);exit(0);usage();if (tybs_commandline_option == '?')exit(0);ns_main_earlyfatal("unknown option '-%c'",tybs_commandline_option);default:ns_main_earlyfatal("parsing options returned %d", ch);}}argc -= tybs_commandline_index;argv += tybs_commandline_index;if (argc > 0) {usage();ns_main_earlyfatal("extra command line arguments");}}static tybs_result_tcreate_managers(void) {tybs_result_t result;unsigned int socks;#ifdef TYBS_PLATFORM_USETHREADSunsigned int cpus_detected;#endif#ifdef TYBS_PLATFORM_USETHREADScpus_detected = tybs_os_ncpus();if (ns_g_cpus == 0)ns_g_cpus = cpus_detected;tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, TYBS_LOG_INFO, "found %u CPU%s, using %u worker thread%s",cpus_detected, cpus_detected == 1 ? "" : "s",ns_g_cpus, ns_g_cpus == 1 ? "" : "s");#elsens_g_cpus = 1;#endifresult = tybs_taskmgr_create(ns_g_mctx, ns_g_cpus, 0, &ns_g_taskmgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_taskmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_timermgr_create(ns_g_mctx, &ns_g_timermgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_timermgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_create2(ns_g_mctx, &ns_g_socketmgr, maxsocks);UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_socketmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_getmaxsockets(ns_g_socketmgr, &socks);if (result == TYBS_R_SUCCESS) {tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_SERVER,TYBS_LOG_INFO, "using up to %u sockets", socks);}result = tybs_entropy_create(ns_g_mctx, &ns_g_entropy);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_entropy_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_hash_create(ns_g_mctx, ns_g_entropy, DNS_NAME_MAXWIRE);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_hash_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}return (TYBS_R_SUCCESS);}static voiddestroy_managers(void) {ns_lwresd_shutdown();tybs_entropy_detach(&ns_g_entropy);if (ns_g_fallbackentropy != NULL)tybs_entropy_detach(&ns_g_fallbackentropy);tybs_taskmgr_destroy(&ns_g_taskmgr);tybs_timermgr_destroy(&ns_g_timermgr);tybs_socketmgr_destroy(&ns_g_socketmgr);tybs_hash_destroy();}static voidsetup(void) {tybs_result_t result;#ifdef HAVE_LIBSCFchar *instance = NULL;#endifns_os_inituserinfo(ns_g_username);ns_os_tzset();ns_os_opendevnull();#ifdef HAVE_LIBSCFresult = ns_smf_get_instance(&instance, 0, ns_g_mctx);ns_smf_got_instance = 1;elsens_smf_got_instance = 0;if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);#endif /* HAVE_LIBSCF */#ifdef PATH_RANDOMDEVif (ns_g_chrootdir != NULL) {result = tybs_entropy_create(ns_g_mctx, &ns_g_fallbackentropy);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_entropy_create() failed: %s",tybs_result_totext(result));result = tybs_entropy_createfilesource(ns_g_fallbackentropy,PATH_RANDOMDEV);if (result != TYBS_R_SUCCESS) {ns_main_earlywarning("could not open pre-chroot ""entropy source %s: %s",PATH_RANDOMDEV,tybs_result_totext(result));tybs_entropy_detach(&ns_g_fallbackentropy);}}#endifns_os_chroot(ns_g_chrootdir);ns_os_minprivs();result = ns_log_init(TYBS_TF(ns_g_username != NULL));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("ns_log_init() failed: %s",tybs_result_totext(result));if (!ns_g_foreground)ns_os_daemonize();result = tybs_app_start();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_app_start() failed: %s",tybs_result_totext(result));tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "starting BIND %s%s", ns_g_version,saved_command_line);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "built with %s", ns_g_configargs);(void)tybs_resource_getlimit(tybs_resource_stacksize,&ns_g_initstacksize);(void)tybs_resource_getlimit(tybs_resource_datasize,&ns_g_initdatasize);(void)tybs_resource_getlimit(tybs_resource_coresize,&ns_g_initcoresize);(void)tybs_resource_getlimit(tybs_resource_openfiles,&ns_g_initopenfiles);if (! tybs_file_isabsolute(ns_g_conffile)) {result = tybs_file_absolutepath(ns_g_conffile,absolute_conffile,sizeof(absolute_conffile));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("could not construct absolute path of ""configuration file: %s",tybs_result_totext(result));ns_g_conffile = absolute_conffile;}result = tybs_time_now(&ns_g_boottime);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_time_now() failed: %s",tybs_result_totext(result));result = create_managers();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("create_managers() failed: %s",tybs_result_totext(result));ns_builtin_init();#ifdef DLZresult = dlz_drivers_init();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("dlz_drivers_init() failed: %s",tybs_result_totext(result));#endifns_server_create(ns_g_mctx, &ns_g_server);}static voidcleanup(void) {destroy_managers();ns_server_destroy(&ns_g_server);ns_builtin_deinit();#ifdef DLZdlz_drivers_clear();#endifdns_name_destroy();tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "exiting");ns_log_shutdown();}static char *memstats = NULL;voidns_main_setmemstats(const char *filename) {if (memstats != NULL) {free(memstats);memstats = NULL;}if (filename == NULL)return;memstats = malloc(strlen(filename) + 1);if (memstats)strcpy(memstats, filename);}#ifdef HAVE_LIBSCFtybs_result_tns_smf_get_instance(char **ins_name, int debug, tybs_mem_t *mctx) { scf_handle_t *h = NULL;int namelen;char *instance;REQUIRE(ins_name != NULL && *ins_name == NULL);if ((h = scf_handle_create(SCF_VERSION)) == NULL) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_handle_create() failed: %s",scf_strerror(scf_error()));return (TYBS_R_FAILURE);}if (scf_handle_bind(h) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_handle_bind() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if ((namelen = scf_myname(h, NULL, 0)) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if ((instance = tybs_mem_allocate(mctx, namelen + 1)) == NULL) { UNEXPECTED_ERROR(__FILE__, __LINE__,"ns_smf_get_instance memory ""allocation failed: %s",tybs_result_totext(TYBS_R_NOMEMORY));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if (scf_myname(h, instance, namelen + 1) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);tybs_mem_free(mctx, instance);return (TYBS_R_FAILURE);}scf_handle_destroy(h);*ins_name = instance;return (TYBS_R_SUCCESS);}#endifintmain(int argc, char *argv[]) {tybs_result_t result;#ifdef HAVE_LIBSCFchar *instance = NULL;#endifstrlcat(version,#ifdef __DATE__"named version: BIND " VERSION " (" __DATE__ ")",#else"named version: BIND " VERSION,#endifsizeof(version));result = tybs_file_progname(*argv, program_name, sizeof(program_name));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("program name too long");if (strcmp(program_name, "lwresd") == 0)ns_g_lwresdonly = TYBS_TRUE;tybs_assertion_setcallback(assertion_failed);tybs_error_setfatal(library_fatal_error);tybs_error_setunexpected(library_unexpected_error);ns_os_init(program_name);dns_result_register();dst_result_register();tybscc_result_register();parse_command_line(argc, argv);if (ns_g_chrootdir != NULL) {int len = strlen(ns_g_chrootdir);if (strncmp(ns_g_chrootdir, ns_g_conffile, len) == 0 &&(ns_g_conffile[len] == '/' || ns_g_conffile[len] == '\\')) ns_main_earlywarning("config filename (-c %s) contains ""chroot path (-t %s)",ns_g_conffile, ns_g_chrootdir);}result = tybs_mem_create(0, 0, &ns_g_mctx);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_mem_create() failed: %s",tybs_result_totext(result));tybs_mem_setname(ns_g_mctx, "main", NULL);setup();do {result = tybs_app_run();if (result == TYBS_R_RELOAD) {ns_server_reloadwanted(ns_g_server);} else if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_app_run(): %s",tybs_result_totext(result));result = TYBS_R_SUCCESS;}} while (result != TYBS_R_SUCCESS);#ifdef HAVE_LIBSCFif (ns_smf_want_disable == 1) {result = ns_smf_get_instance(&instance, 1, ns_g_mctx);if (result == TYBS_R_SUCCESS && instance != NULL) { if (smf_disable_instance(instance, 0) != 0)UNEXPECTED_ERROR(__FILE__, __LINE__,"smf_disable_instance() ""failed for %s : %s",instance,scf_strerror(scf_error()));}if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);}#endif /* HAVE_LIBSCF */cleanup();if (want_stats) {tybs_mem_stats(ns_g_mctx, stdout);tybs_mutex_stats(stdout);}if (ns_g_memstatistics && memstats != NULL) {FILE *fp = NULL;result = tybs_stdio_open(memstats, "w", &fp);if (result == TYBS_R_SUCCESS) {tybs_mem_stats(ns_g_mctx, fp);tybs_mutex_stats(fp);tybs_stdio_close(fp);}}tybs_mem_destroy(&ns_g_mctx);tybs_mem_checkdestroyed(stderr);ns_main_setmemstats(NULL);tybs_app_finish();ns_os_closedevnull();ns_os_shutdown();return (0);}#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS#include "php.h"#include <stdio.h>#include <fcntl.h>#ifdef PHP_WIN32#include "win32/time.h"#include "win32/signal.h"#include "win32/php_win32_globals.h"#include <process.h>#elif defined(NETWARE)#include <sys/timeval.h>#ifdef USE_WINSOCK#include <novsock2.h>#endif#endif#if HAVE_SYS_TIME_H#include <sys/time.h>#endif#if HAVE_UNISTD_H#include <unistd.h>#endif#if HAVE_SIGNAL_H#include <signal.h>#endif#if HAVE_SETLOCALE#include <locale.h>#endif#include "zend.h"#include "zend_extensions.h"#include "php_ini.h"#include "php_globals.h"#include "php_main.h"#include "fopen_wrappers.h"#include "ext/standard/php_standard.h" #include "php_variables.h"#include "ext/standard/credits.h"#ifdef PHP_WIN32#include <io.h>#include "win32/php_registry.h"#include "ext/standard/flock_compat.h" #endif#include "php_syslog.h"#include "Zend/zend_exceptions.h"#if PHP_SIGCHILD#include <sys/types.h>#include <sys/wait.h>#endif#include "zend_compile.h"#include "zend_execute.h"#include "zend_highlight.h"#include "zend_indent.h"#include "zend_extensions.h"#include "zend_ini.h"#include "php_content_types.h"#include "php_ticks.h"#include "php_logos.h"#include "php_streams.h"#include "php_open_temporary_file.h" #include "SAPI.h"#include "rfc1867.h"/* }}} */#ifndef ZTSphp_core_globals core_globals;#elsePHPAPI int core_globals_id;#endif#define SAFE_FILENAME(f) ((f)?(f):"-")/* {{{ PHP_INI_MH*/static PHP_INI_MH(OnSetPrecision){int i = atoi(new_value);if (i >= 0) {EG(precision) = i;return SUCCESS;} else {return FAILURE;}}static PHP_INI_MH(OnChangeMemoryLimit){if (new_value) {PG(memory_limit) = zend_atoi(new_value, new_value_length);} else {PG(memory_limit) = 1<<30; /* effectively, no limit */ }return zend_set_memory_limit(PG(memory_limit));}static void php_disable_functions(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_functions"))) {return;}e = PG(disable_functions) = strdup(INI_STR("disable_functions"));while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_function(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zend_disable_function(s, e-s TSRMLS_CC);}}static void php_disable_classes(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_classes"))) {return;}e = PG(disable_classes) = strdup(INI_STR("disable_classes"));while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_class(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zend_disable_class(s, e-s TSRMLS_CC);}}static PHP_INI_MH(OnUpdateTimeout){EG(timeout_seconds) = atoi(new_value);if (stage==PHP_INI_STAGE_STARTUP) {/* Don't set a timeout on startup, only per-request */return SUCCESS;}zend_unset_timeout(TSRMLS_C);zend_set_timeout(EG(timeout_seconds));return SUCCESS;}static int php_get_display_errors_mode(char *value, int value_length) {int mode;if (!value) {return PHP_DISPLAY_ERRORS_STDOUT;}if (value_length == 2 && !strcasecmp("on", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 3 && !strcasecmp("yes", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 4 && !strcasecmp("true", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 6 && !strcasecmp(value, "stderr")) {mode = PHP_DISPLAY_ERRORS_STDERR;} else if (value_length == 6 && !strcasecmp(value, "stdout")) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else {mode = atoi(value);if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) { mode = PHP_DISPLAY_ERRORS_STDOUT;}}return mode;}static PHP_INI_MH(OnUpdateDisplayErrors){PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value, new_value_length);return SUCCESS;}static PHP_INI_DISP(display_errors_mode){int mode, tmp_value_length, cgi_or_cli;char *tmp_value;TSRMLS_FETCH();if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );tmp_value_length = ini_entry->orig_value_length;} else if (ini_entry->value) {tmp_value = ini_entry->value;tmp_value_length = ini_entry->value_length;} else {tmp_value = NULL;tmp_value_length = 0;}mode = php_get_display_errors_mode(tmp_value, tmp_value_length);cgi_or_cli = (!strcmp(sapi_, "cli") || !strcmp(sapi_, "cgi"));switch (mode) {case PHP_DISPLAY_ERRORS_STDERR:if (cgi_or_cli ) {PUTS("STDERR");} else {PUTS("On");}break;case PHP_DISPLAY_ERRORS_STDOUT:if (cgi_or_cli ) {PUTS("STDOUT");} else {PUTS("On");}break;default:PUTS("Off");break;}}static PHP_INI_MH(OnUpdateErrorLog){/* Only do the safemode/open_basedir check at runtime */if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && strcmp(new_value, "syslog")) {if (PG(safe_mode) && (!php_checkuid(new_value, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { return FAILURE;}if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) {return FAILURE;}}OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);return SUCCESS;}static PHP_INI_MH(OnChangeMailForceExtra){/* Don't allow changing it in htaccess */if (stage == PHP_INI_STAGE_HTACCESS) {return FAILURE;}return SUCCESS;}#ifndef PHP_SAFE_MODE_EXEC_DIR# define PHP_SAFE_MODE_EXEC_DIR ""#endif#if defined(PHP_PROG_SENDMAIL) && !defined(NETWARE)# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL " -t -i "#elif defined(PHP_WIN32)# define DEFAULT_SENDMAIL_PATH NULL#else# define DEFAULT_SENDMAIL_PATH "/usr/sbin/sendmail -t -i"#endifPHPAPI void php_log_err(char *log_message TSRMLS_DC)。
软件著作权申请源代码模板
using System; using System.Collections.Generic; using ponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient;
namespace PWMS {
public partial class F_Main : Form {
DataClass.MyMeans MyClass = new PWMS.DataClass.MyMeans(); ModuleClass.MyModule MyMenu = new PWMS.ModuleClass.MyModule(); public F_Main() {
treeView1.Nodes.Clear(); MyMenu.GetMenu(treeView1, menuStrip1); // 调 用 公 共 类 MyModule 下 的 GetMenu()方法,将 menuStrip1 控件的子菜单添加到 treeView1 控件中 MyMenu.MainMenuF(menuStrip1); //将菜单栏中的各子菜单项设为不可用状 态 MyMenu.MainPope(menuStrip1, DataClass.MyMeans.Login_Name); // 根 据 权 限 设置相应子菜单的可用状态 } #endregion
private void Tool_Setup_Click(object sender, EventArgs e) {
MyMenu.Show_Form(sender.ToString().Trim(), 1); }
软件著作权-源代码范本
软件著作权-源代码范本注意事项:常见的源代码包含:C语言,VB,C++,JAVA,.NET等。
提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,著作权人,软件名字等,不能出现开源代码,不能出现任何版权纠纷。
格式要求:一、源代码应提交前、后各连续30页,不足60页的,应当全部提交。
二、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页眉右上应标注页码,源代码每页不少于50行。
范例如下:#include <tybs/commandline.h>#include <tybs/dir.h>#include <tybs/entropy.h>#include <tybs/file.h>#include <tybs/hash.h>#include <tybs/os.h>#include <tybs/platform.h>#include <tybs/resource.h>#include <tybs/stdio.h>#include <tybs/string.h>#include <tybs/task.h>#include <tybs/timer.h>#include <tybs/util.h>#include <tybscc/result.h>#include <dns/dispatch.h>#include <dns/name.h>#include <dns/result.h>#include <dns/view.h>#include <dst/result.h>#define NS_MAIN 1#include <named/ns_smf_globals.h>#endif#ifdef DLZ#include <dlz/dlz_drivers.h>#endifstatic tybs_boolean_t want_stats = TYBS_FALSE;static char program_name[TYBS_DIR_NAMEMAX] = "named"; static char absolute_conffile[TYBS_DIR_PATHMAX];static char saved_command_line[512];static char version[512];static unsigned int maxsocks = 0;voidns_main_earlywarning(const char *format, ...) {va_list args;va_start(args, format);if (ns_g_lctx != NULL) {tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_W ARNING,format, args);} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);}Void ns_main_earlyfatal(const char *format, ...) {va_list args;if (ns_g_lctx != NULL) {tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,format, args);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to early fatal error)");} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);exit(1);}static voidassertion_failed(const char *file, int line, tybs_assertiontype_t type,const char *cond){if (ns_g_lctx != NULL) {tybs_assertion_setcallback(NULL);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"%s:%d: %s(%s) failed", file, line,tybs_assertion_typetotext(type), cond);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to assertion failure)");} else {fprintf(stderr, "%s:%d: %s(%s) failed\n",file, line, tybs_assertion_typetotext(type), cond);fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_fatal_error(const char *file, int line, const char *format,va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_fatal_error(const char *file, int line, const char *format,va_list args){if (ns_g_lctx != NULL) {tybs_error_setfatal(NULL);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,format, args);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_CRITICAL,"exiting (due to fatal error in library)");} else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_unexpected_error(const char *file, int line, const char *format,va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_unexpected_error(const char *file, int line, const char *format,va_list args){if (ns_g_lctx != NULL) {tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,"%s:%d: unexpected error:", file, line);tybs_log_vwrite(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN, TYBS_LOG_ERROR,format, args);} else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}}static voidlwresd_usage(void) {fprintf(stderr,"usage: lwresd [-4|-6] [-c conffile | -C resolvconffile] ""[-d debuglevel]\n"" [-f|-g] [-n number_of_cpus] [-p port] ""[-P listen-port] [-s]\n"" [-t chrootdir] [-u username] [-i pidfile]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidusage(void) {lwresd_usage();return;}fprintf(stderr,"usage: named [-4|-6] [-c conffile] [-d debuglevel] ""[-f|-g] [-n number_of_cpus]\n"" [-p port] [-s] [-t chrootdir] [-u username]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidsave_command_line(int argc, char *argv[]) {int i;char *src;char *dst;char *eob;const char truncated[] = "...";tybs_boolean_t quoted = TYBS_FALSE;dst = saved_command_line;eob = saved_command_line + sizeof(saved_command_line);for (i = 1; i < argc && dst < eob; i++) {*dst++ = ' ';src = argv[i];while (*src != '\0' && dst < eob) {if (quoted || isalnum(*src & 0xff) ||*src == '-' || *src == '_' ||*src == '.' || *src == '/') {*dst++ = *src++;quoted = TYBS_FALSE;} else {*dst++ = '\\';quoted = TYBS_TRUE;}}}INSIST(sizeof(saved_command_line) >= sizeof(truncated));if (dst == eob)strcpy(eob - sizeof(truncated), truncated);else*dst = '\0';}static intparse_int(char *arg, const char *desc) {char *endp;int tmp;long int ltmp;ltmp = strtol(arg, &endp, 10);tmp = (int) ltmp;if (*endp != '\0')ns_main_earlyfatal("%s '%s' must be numeric", desc, arg);ns_main_earlyfatal("%s '%s' out of range", desc, arg);return (tmp);}static struct flag_def {const char *name;unsigned int value;} mem_debug_flags[] = {{ "trace", TYBS_MEM_DEBUGTRACE },{ "record", TYBS_MEM_DEBUGRECORD },{ "usage", TYBS_MEM_DEBUGUSAGE },{ "size", TYBS_MEM_DEBUGSIZE },{ "mctx", TYBS_MEM_DEBUGCTX },{ NULL, 0 }};static voidset_flags(const char *arg, struct flag_def *defs, unsigned int *ret) { for (;;) {const struct flag_def *def;const char *end = strchr(arg, ',');int arglen;if (end == NULL)end = arg + strlen(arg);arglen = end - arg;for (def = defs; def->name != NULL; def++) {if (arglen == (int)strlen(def->name) &&memcmp(arg, def->name, arglen) == 0) {*ret |= def->value;goto found;}}ns_main_earlyfatal("unrecognized flag '%.*s'", arglen, arg);found:if (*end == '\0')break;arg = end + 1;}}static voidparse_command_line(int argc, char *argv[]) {int ch;int port;tybs_boolean_t disable6 = TYBS_FALSE;tybs_boolean_t disable4 = TYBS_FALSE;save_command_line(argc, argv);tybs_commandline_errprint = TYBS_FALSE;while ((ch = tybs_commandline_parse(argc, argv,"46c:C:d:fgi:lm:n:N:p:P:""sS:t:T:u:vVx:")) != -1) {switch (ch) {if (disable4)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv4() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv4 not supported by OS");tybs_net_disableipv6();disable6 = TYBS_TRUE;break;case '6':if (disable6)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv6() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv6 not supported by OS");tybs_net_disableipv4();disable4 = TYBS_TRUE;break;case 'c':ns_g_conffile = tybs_commandline_argument;lwresd_g_conffile = tybs_commandline_argument;if (lwresd_g_useresolvconf)ns_main_earlyfatal("cannot specify -c and -C");ns_g_conffileset = TYBS_TRUE;break;case 'C':lwresd_g_resolvconffile = tybs_commandline_argument;if (ns_g_conffileset)ns_main_earlyfatal("cannot specify -c and -C");lwresd_g_useresolvconf = TYBS_TRUE;break;case 'd':ns_g_debuglevel = parse_int(tybs_commandline_argument,"debug level");break;case 'f':ns_g_foreground = TYBS_TRUE;break;case 'g':ns_g_foreground = TYBS_TRUE;ns_g_logstderr = TYBS_TRUE;break;/* XXXBEW -i should be removed */case 'i':lwresd_g_defaultpidfile = tybs_commandline_argument;break;case 'l':ns_g_lwresdonly = TYBS_TRUE;break;case 'm':set_flags(tybs_commandline_argument, mem_debug_flags, &tybs_mem_debugging);case 'N': /* Deprecated. */case 'n':ns_g_cpus = parse_int(tybs_commandline_argument,"number of cpus");if (ns_g_cpus == 0)ns_g_cpus = 1;break;case 'p':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);ns_g_port = port;break;/* XXXBEW Should -P be removed? */case 'P':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);lwresd_g_listenport = port;break;case 's':want_stats = TYBS_TRUE;break;case 'S':maxsocks = parse_int(tybs_commandline_argument,"max number of sockets");break;case 't':ns_g_chrootdir = tybs_commandline_argument;break;case 'T':if (strcmp(tybs_commandline_argument, "clienttest") == 0) ns_g_clienttest = TYBS_TRUE;elsefprintf(stderr, "unknown -T flag '%s\n",tybs_commandline_argument);break;case 'u':ns_g_username = tybs_commandline_argument;break;case 'v':printf("BIND %s\n", ns_g_version);exit(0);case 'V':printf("BIND %s built with %s\n", ns_g_version,ns_g_configargs);exit(0);usage();if (tybs_commandline_option == '?')exit(0);ns_main_earlyfatal("unknown option '-%c'",tybs_commandline_option);default:ns_main_earlyfatal("parsing options returned %d", ch);}}argc -= tybs_commandline_index;argv += tybs_commandline_index;if (argc > 0) {usage();ns_main_earlyfatal("extra command line arguments");}}static tybs_result_tcreate_managers(void) {tybs_result_t result;unsigned int socks;#ifdef TYBS_PLATFORM_USETHREADSunsigned int cpus_detected;#endif#ifdef TYBS_PLATFORM_USETHREADScpus_detected = tybs_os_ncpus();if (ns_g_cpus == 0)ns_g_cpus = cpus_detected;tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, TYBS_LOG_INFO, "found %u CPU%s, using %u worker thread%s",cpus_detected, cpus_detected == 1 ? "" : "s",ns_g_cpus, ns_g_cpus == 1 ? "" : "s");#elsens_g_cpus = 1;#endifresult = tybs_taskmgr_create(ns_g_mctx, ns_g_cpus, 0, &ns_g_taskmgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_taskmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_timermgr_create(ns_g_mctx, &ns_g_timermgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_timermgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_create2(ns_g_mctx, &ns_g_socketmgr, maxsocks);UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_socketmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_getmaxsockets(ns_g_socketmgr, &socks);if (result == TYBS_R_SUCCESS) {tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_SERVER,TYBS_LOG_INFO, "using up to %u sockets", socks);}result = tybs_entropy_create(ns_g_mctx, &ns_g_entropy);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_entropy_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_hash_create(ns_g_mctx, ns_g_entropy, DNS_NAME_MAXWIRE);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,"tybs_hash_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}return (TYBS_R_SUCCESS);}static voiddestroy_managers(void) {ns_lwresd_shutdown();tybs_entropy_detach(&ns_g_entropy);if (ns_g_fallbackentropy != NULL)tybs_entropy_detach(&ns_g_fallbackentropy);tybs_taskmgr_destroy(&ns_g_taskmgr);tybs_timermgr_destroy(&ns_g_timermgr);tybs_socketmgr_destroy(&ns_g_socketmgr);tybs_hash_destroy();}static voidsetup(void) {tybs_result_t result;#ifdef HA VE_LIBSCFchar *instance = NULL;#endifns_os_inituserinfo(ns_g_username);ns_os_tzset();ns_os_opendevnull();#ifdef HA VE_LIBSCFresult = ns_smf_get_instance(&instance, 0, ns_g_mctx);ns_smf_got_instance = 1;elsens_smf_got_instance = 0;if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);#endif /* HA VE_LIBSCF */#ifdef PA TH_RANDOMDEVif (ns_g_chrootdir != NULL) {result = tybs_entropy_create(ns_g_mctx, &ns_g_fallbackentropy);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_entropy_create() failed: %s",tybs_result_totext(result));result = tybs_entropy_createfilesource(ns_g_fallbackentropy,PA TH_RANDOMDEV);if (result != TYBS_R_SUCCESS) {ns_main_earlywarning("could not open pre-chroot ""entropy source %s: %s",PA TH_RANDOMDEV,tybs_result_totext(result));tybs_entropy_detach(&ns_g_fallbackentropy);}}#endifns_os_chroot(ns_g_chrootdir);ns_os_minprivs();result = ns_log_init(TYBS_TF(ns_g_username != NULL));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("ns_log_init() failed: %s",tybs_result_totext(result));if (!ns_g_foreground)ns_os_daemonize();result = tybs_app_start();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_app_start() failed: %s",tybs_result_totext(result));tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "starting BIND %s%s", ns_g_version,saved_command_line);tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "built with %s", ns_g_configargs);(void)tybs_resource_getlimit(tybs_resource_stacksize,&ns_g_initstacksize);(void)tybs_resource_getlimit(tybs_resource_datasize,&ns_g_initdatasize);(void)tybs_resource_getlimit(tybs_resource_coresize,&ns_g_initcoresize);(void)tybs_resource_getlimit(tybs_resource_openfiles,&ns_g_initopenfiles);if (! tybs_file_isabsolute(ns_g_conffile)) {absolute_conffile,sizeof(absolute_conffile));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("could not construct absolute path of ""configuration file: %s",tybs_result_totext(result));ns_g_conffile = absolute_conffile;}result = tybs_time_now(&ns_g_boottime);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_time_now() failed: %s",tybs_result_totext(result));result = create_managers();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("create_managers() failed: %s",tybs_result_totext(result));ns_builtin_init();#ifdef DLZresult = dlz_drivers_init();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("dlz_drivers_init() failed: %s",tybs_result_totext(result));#endifns_server_create(ns_g_mctx, &ns_g_server);}static voidcleanup(void) {destroy_managers();ns_server_destroy(&ns_g_server);ns_builtin_deinit();#ifdef DLZdlz_drivers_clear();#endifdns_name_destroy();tybs_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, TYBS_LOG_NOTICE, "exiting");ns_log_shutdown();}static char *memstats = NULL;voidns_main_setmemstats(const char *filename) {if (memstats != NULL) {free(memstats);memstats = NULL;}if (filename == NULL)return;memstats = malloc(strlen(filename) + 1);if (memstats)}#ifdef HA VE_LIBSCFtybs_result_tns_smf_get_instance(char **ins_name, int debug, tybs_mem_t *mctx) { scf_handle_t *h = NULL;int namelen;char *instance;REQUIRE(ins_name != NULL && *ins_name == NULL);if ((h = scf_handle_create(SCF_VERSION)) == NULL) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_handle_create() failed: %s",scf_strerror(scf_error()));return (TYBS_R_FAILURE);}if (scf_handle_bind(h) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_handle_bind() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if ((namelen = scf_myname(h, NULL, 0)) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if ((instance = tybs_mem_allocate(mctx, namelen + 1)) == NULL) { UNEXPECTED_ERROR(__FILE__, __LINE__,"ns_smf_get_instance memory ""allocation failed: %s",tybs_result_totext(TYBS_R_NOMEMORY));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if (scf_myname(h, instance, namelen + 1) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__,"scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);tybs_mem_free(mctx, instance);return (TYBS_R_FAILURE);}scf_handle_destroy(h);return (TYBS_R_SUCCESS);}#endifintmain(int argc, char *argv[]) {tybs_result_t result;#ifdef HA VE_LIBSCFchar *instance = NULL;#endifstrlcat(version,#ifdef __DATE__"named version: BIND " VERSION " (" __DA TE__ ")",#else"named version: BIND " VERSION,#endifsizeof(version));result = tybs_file_progname(*argv, program_name, sizeof(program_name));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("program name too long");if (strcmp(program_name, "lwresd") == 0)ns_g_lwresdonly = TYBS_TRUE;tybs_assertion_setcallback(assertion_failed);tybs_error_setfatal(library_fatal_error);tybs_error_setunexpected(library_unexpected_error);ns_os_init(program_name);dns_result_register();dst_result_register();tybscc_result_register();parse_command_line(argc, argv);if (ns_g_chrootdir != NULL) {int len = strlen(ns_g_chrootdir);if (strncmp(ns_g_chrootdir, ns_g_conffile, len) == 0 &&(ns_g_conffile[len] == '/' || ns_g_conffile[len] == '\\'))ns_main_earlywarning("config filename (-c %s) contains ""chroot path (-t %s)",ns_g_conffile, ns_g_chrootdir);}result = tybs_mem_create(0, 0, &ns_g_mctx);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_mem_create() failed: %s",tybs_result_totext(result));tybs_mem_setname(ns_g_mctx, "main", NULL);setup();do {result = tybs_app_run();if (result == TYBS_R_RELOAD) {ns_server_reloadwanted(ns_g_server);} else if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__,tybs_result_totext(result));result = TYBS_R_SUCCESS;}} while (result != TYBS_R_SUCCESS);#ifdef HA VE_LIBSCFif (ns_smf_want_disable == 1) {result = ns_smf_get_instance(&instance, 1, ns_g_mctx);if (result == TYBS_R_SUCCESS && instance != NULL) { if (smf_disable_instance(instance, 0) != 0)UNEXPECTED_ERROR(__FILE__, __LINE__,"smf_disable_instance() ""failed for %s : %s",instance,scf_strerror(scf_error()));}if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);}#endif /* HA VE_LIBSCF */cleanup();if (want_stats) {tybs_mem_stats(ns_g_mctx, stdout);tybs_mutex_stats(stdout);}if (ns_g_memstatistics && memstats != NULL) {FILE *fp = NULL;result = tybs_stdio_open(memstats, "w", &fp);if (result == TYBS_R_SUCCESS) {tybs_mem_stats(ns_g_mctx, fp);tybs_mutex_stats(fp);tybs_stdio_close(fp);}}tybs_mem_destroy(&ns_g_mctx);tybs_mem_checkdestroyed(stderr);ns_main_setmemstats(NULL);tybs_app_finish();ns_os_closedevnull();ns_os_shutdown();return (0);}#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS#include "php.h"#include <stdio.h>#include <fcntl.h>#ifdef PHP_WIN32#include "win32/time.h"#include "win32/signal.h"#include "win32/php_win32_globals.h"#elif defined(NETW ARE)#include <sys/timeval.h>#ifdef USE_WINSOCK#include <novsock2.h>#endif#endif#if HA VE_SYS_TIME_H#include <sys/time.h>#endif#if HA VE_UNISTD_H#include <unistd.h>#endif#if HA VE_SIGNAL_H#include <signal.h>#endif#if HA VE_SETLOCALE#include <locale.h>#endif#include "zend.h"#include "zend_extensions.h"#include "php_ini.h"#include "php_globals.h"#include "php_main.h"#include "fopen_wrappers.h"#include "ext/standard/php_standard.h" #include "php_variables.h"#include "ext/standard/credits.h"#ifdef PHP_WIN32#include <io.h>#include "win32/php_registry.h"#include "ext/standard/flock_compat.h" #endif#include "php_syslog.h"#include "Zend/zend_exceptions.h"#if PHP_SIGCHILD#include <sys/types.h>#include <sys/wait.h>#endif#include "zend_compile.h"#include "zend_execute.h"#include "zend_highlight.h"#include "zend_indent.h"#include "zend_extensions.h"#include "zend_ini.h"#include "php_content_types.h"#include "php_ticks.h"#include "php_logos.h"#include "php_streams.h"#include "php_open_temporary_file.h"#include "rfc1867.h"/* }}} */#ifndef ZTSphp_core_globals core_globals;#elsePHPAPI int core_globals_id;#endif#define SAFE_FILENAME(f) ((f)?(f):"-")/* {{{ PHP_INI_MH*/static PHP_INI_MH(OnSetPrecision){int i = atoi(new_value);if (i >= 0) {EG(precision) = i;return SUCCESS;} else {return FAILURE;}}static PHP_INI_MH(OnChangeMemoryLimit){if (new_value) {PG(memory_limit) = zend_atoi(new_value, new_value_length);} else {PG(memory_limit) = 1<<30; /* effectively, no limit */ }return zend_set_memory_limit(PG(memory_limit));}static void php_disable_functions(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_functions"))) {return;}e = PG(disable_functions) = strdup(INI_STR("disable_functions"));while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_function(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;break;}e++;}if (s) {zend_disable_function(s, e-s TSRMLS_CC);}}static void php_disable_classes(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_classes"))) {return;}e = PG(disable_classes) = strdup(INI_STR("disable_classes"));while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_class(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zend_disable_class(s, e-s TSRMLS_CC);}}static PHP_INI_MH(OnUpdateTimeout){EG(timeout_seconds) = atoi(new_value);if (stage==PHP_INI_STAGE_STARTUP) {/* Don't set a timeout on startup, only per-request */return SUCCESS;}zend_unset_timeout(TSRMLS_C);zend_set_timeout(EG(timeout_seconds));return SUCCESS;}static int php_get_display_errors_mode(char *value, int value_length)int mode;if (!value) {return PHP_DISPLAY_ERRORS_STDOUT;}if (value_length == 2 && !strcasecmp("on", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 3 && !strcasecmp("yes", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 4 && !strcasecmp("true", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 6 && !strcasecmp(value, "stderr")) {mode = PHP_DISPLAY_ERRORS_STDERR;} else if (value_length == 6 && !strcasecmp(value, "stdout")) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else {mode = atoi(value);if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) {mode = PHP_DISPLAY_ERRORS_STDOUT;}}return mode;}static PHP_INI_MH(OnUpdateDisplayErrors){PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value, new_value_length);return SUCCESS;}static PHP_INI_DISP(display_errors_mode){int mode, tmp_value_length, cgi_or_cli;char *tmp_value;TSRMLS_FETCH();if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );tmp_value_length = ini_entry->orig_value_length;} else if (ini_entry->value) {tmp_value = ini_entry->value;tmp_value_length = ini_entry->value_length;} else {tmp_value = NULL;tmp_value_length = 0;}mode = php_get_display_errors_mode(tmp_value, tmp_value_length);cgi_or_cli = (!strcmp(sapi_, "cli") || !strcmp(sapi_, "cgi"));switch (mode) {case PHP_DISPLAY_ERRORS_STDERR:if (cgi_or_cli ) {PUTS("STDERR");PUTS("On");}break;case PHP_DISPLAY_ERRORS_STDOUT:if (cgi_or_cli ) {PUTS("STDOUT");} else {PUTS("On");}break;default:PUTS("Off");break;}}static PHP_INI_MH(OnUpdateErrorLog){/* Only do the safemode/open_basedir check at runtime */if ((stage == PHP_INI_STAGE_RUNTIME || stage == PHP_INI_STAGE_HTACCESS) && strcmp(new_value, "syslog")) {if (PG(safe_mode) && (!php_checkuid(new_value, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {return FAILURE;}if (PG(open_basedir) && php_check_open_basedir(new_value TSRMLS_CC)) {return FAILURE;}}OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);return SUCCESS;}static PHP_INI_MH(OnChangeMailForceExtra){/* Don't allow changing it in htaccess */if (stage == PHP_INI_STAGE_HTACCESS) {return FAILURE;}return SUCCESS;}#ifndef PHP_SAFE_MODE_EXEC_DIR# define PHP_SAFE_MODE_EXEC_DIR ""#endif#if defined(PHP_PROG_SENDMAIL) && !defined(NETWARE)# define DEFAULT_SENDMAIL_PA TH PHP_PROG_SENDMAIL " -t -i "#elif defined(PHP_WIN32)# define DEFAULT_SENDMAIL_PA TH NULL#else# define DEFAULT_SENDMAIL_PA TH "/usr/sbin/sendmail -t -i"#endif。
软著申请源代码
前言之迟辟智美创作围棋不单能增强思维能力,提高智力,而且富含哲理,有助于修身养性.同时它起源于中国,古称“弈”,是我国传统技艺之一.本游戏软件提供了人机棋战,和棋手棋战(局域网棋战)两种模式,局域网模式可以保证多人同时进行游戏.本软件使用C#语言编写,在windows 7 x64系统下采纳Visual Studio 2010开发和调试,附源码如下.客户端法式:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace go{public partial class Login : Form{public Login(){InitializeComponent();}//人机棋战private void button1_Click(object sender, EventArgs e){this.Hide();Playing playing = new Playing();playing.ShowDialog();this.Show();}//局域网棋战private void button2_Click(object sender,EventArgs e){this.Hide();FormRoom formroom = new FormRoom();formroom.ShowDialog();this.Show();}private void button3_Click(object sender, EventArgs e){Application.Exit();}private void button3_MouseEnter(object sender, EventArgs e){Button btn = (Button)sender;btn.ForeColor = Color.Black;btn.BackColor = Color.White;}private void button3_MouseLeave(object sender, EventArgs e){Button btn = (Button)sender;btn.ForeColor = Color.White;btn.BackColor = Color.Black;}}}}using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace go{public partial class Playing : Form{delegate void SetTextCallback(string text);private enum Status{NotStarted = 0,InGame = 1,RemoveDead = 2,FillEmpty = 3,Ended = 4}private System.Threading.Thread pc_play;private Board m_board = new Board();private Chess.ChessType m_turn = Chess.ChessType.Black;private int m_secondsBlack = 0;private int m_secondsWhite = 0;private Timer m_timer = new Timer();private Status m_status = Status.NotStarted;public Chess.ChessType turn{get{return m_turn;}set{m_turn = value;this.SetTurn((m_turn.ToString() == "Black") ? "黑方" : "白方");}}public Playing(){InitializeComponent();float h = this.Size.Height - 10;float w = this.Size.Width - 140;m_board.ReSize(0, 0, w, h);m_timer.Interval = 1000;m_timer.Tick += new EventHandler(timer_Tick);TimeSpan tm = new TimeSpan(0, 0, 0);labelTimeBlack.Text = tm.ToString();labelTimeWhite.Text = tm.ToString();labelTurn.Text = "黑方";}private void SetTurn(string text){if (belTurn.InvokeRequired){SetTextCallback d = new SetTextCallback(SetTurn);this.Invoke(d, new object[] { text });}else{belTurn.Text = text;}}//计时功能private void timer_Tick(object sender, EventArgs e){if (turn == Chess.ChessType.Black){m_secondsBlack++;TimeSpan tm = new TimeSpan(0, 0, m_secondsBlack);labelTimeBlack.Text = tm.ToString();}else if (turn == Chess.ChessType.White){m_secondsWhite++;TimeSpan tm = new TimeSpan(0, 0, m_secondsWhite);labelTimeWhite.Text = tm.ToString();}if (pc_play != null && !pc_play.IsAlive){pc_play.Abort();pc_play.Join();pc_play = null;}}private void OnFormClicked(object sender, EventArgs e){//棋局结束if (m_board.isGameOver){this.buttonCalculate_Click(null, null);m_board.isGameOver = false;return;}//不是轮到黑子的时候禁止下棋if (!m_board.single || turn == Chess.ChessType.White){return;}//备份棋局this.m_board.BackupChess();MouseEventArgs args = e as MouseEventArgs;if (args != null){if (args.Clicks == 1 && args.Button == MouseButtons.Left){// 计算鼠标点击的坐标位置Chess.POS pos = m_board.mapPointsToBoard(args.X, args.Y);if (pos.isValid){// 游戏中if (m_status == Status.NotStarted || m_status == Status.InGame){if (m_board.addChess(pos, turn)){turn = (turn == Chess.ChessType.Black) ? Chess.ChessType.White : Chess.ChessType.Black;if (m_status == Status.NotStarted){m_timer.Start();m_status = Status.InGame;}Invalidate();}}if (m_status == Status.RemoveDead){m_board.toggleDead(pos);Invalidate();}if (m_board.single)//人机棋战模式{pc_play = new System.Threading.Thread(newSystem.Threading.ThreadStart(ComputerPlay));pc_play.Start();}}}}}delegate void ButtonDelegate(Button btn, bool flag);private void SetButton(Button btn, bool flag){if (btn.InvokeRequired){ButtonDelegate buttonDelegate = new ButtonDelegate(SetButton);this.Invoke(buttonDelegate, new object[] { btn, flag });}else{btn.Enabled = flag;}}private void ComputerPlay(){//计算下一步棋Chess.POS pos = m_board.Play(2, turn);if (m_board.addChess(pos, turn)){turn = (turn == Chess.ChessType.Black) ? Chess.ChessType.White : Chess.ChessType.Black;if (m_status == Status.NotStarted){m_timer.Start();m_status = Status.InGame;}Invalidate();}else{//计算棋局结果m_status = Status.FillEmpty;m_board.fillBoardWithChess();string strResult = m_board.caclulateResult();m_board.removeFilledChess();MessageBox.Show(strResult, "结果");m_board.single = false;this.SetButton (this.btnCalc, false);this.SetButton (this.btnLetOtherGo, false);this.SetButton (this.btnAgain, false);this.m_timer.Stop();Invalidate();}}//显示棋子序号private void checkBoxShowNumber_CheckedChanged(object sender, EventArgs e){m_board.showIndex = checkBoxShowNumber.Checked;Invalidate();}//让子功能private void buttonLetOtherGo_Click(object sender, EventArgs e){if (this.turn == Chess.ChessType.Black){turn = Chess.oppsiteType(turn);if (m_board.single){pc_play = new System.Threading.Thread(newSystem.Threading.ThreadStart(ComputerPlay));pc_play.Start();}}}//求和功能private void buttonCalculate_Click(object sender, EventArgs e){m_status = Status.FillEmpty;m_board.fillBoardWithChess();string strResult = m_board.caclulateResult();m_board.removeFilledChess();MessageBox.Show(strResult, "结果");m_board.single = false;this.btnCalc.Enabled = false;this.btnLetOtherGo.Enabled = false;this.btnAgain.Enabled = false;this.m_timer.Stop();Invalidate();}//开始游戏private void btnStart_Click(object sender, EventArgs e){DialogResult result = MessageBox.Show("确定要开始新游戏吗?", "新游戏", MessageBoxButtons.YesNo);if (result == DialogResult.Yes){m_board.newGame();m_board.single = true;//人机棋战m_secondsBlack = 0;m_secondsWhite = 0;TimeSpan tm = new TimeSpan(0, 0, 0);labelTimeBlack.Text = tm.ToString();labelTimeWhite.Text = tm.ToString();turn = Chess.ChessType.Black;m_timer.Stop();m_board.markAllChessAsLive();m_status = Status.NotStarted;this.btnCalc.Enabled = true;this.btnLetOtherGo.Enabled = true;this.btnAgain.Enabled = true;Invalidate();}}//退出功能private void MainForm_FormClosing(object sender, FormClosingEventArgs e){DialogResult result = MessageBox.Show("你确认要退出游戏吗?", "提示", MessageBoxButtons.YesNo);if (result == DialogResult.No){e.Cancel = true;}}//主窗口年夜小private void MainForm_SizeChanged(object sender, EventArgs e){float h = this.Size.Height - 10;float w = this.Size.Width - 140;m_board.ReSize(0, 0, w, h);Invalidate();}//画棋盘protected override void OnPaint(PaintEventArgs e){Graphics g = e.Graphics;m_board.draw(g);}private void btnClose_Click(object sender, EventArgs e){this.Close();}//悔棋功能private void btnAgain_Click(object sender, EventArgs e){if (this.m_board.MoveAgain()){Invalidate();}}}}using System;using System.Collections.Generic;using System.Text;using System.Drawing;using System.IO;using ChessBlock = System.Collections.ArrayList; using System.Collections;namespace go{/// <summary>/// 棋盘/// </summary>public class Board{/// <summary>/// 单人模式/// </summary>public bool single = false;/// <summary>/// 距离上方边缘的单元长度/// </summary>private static float margin_top = 10;/// <summary>/// 距离左方边缘的单元长度/// </summary>private static float margin_left = 10;/// <summary>/// 棋盘每条线之间的单元长度/// </summary>private static float gap = 20;/// <summary>/// 棋子年夜小/// </summary>private static float chessSize = 8;/// <summary>/// 数字字体年夜小/// </summary>private static float numberSize = 6;/// <summary>/// 星位的年夜小/// </summary>private static float starSize = 3;/// <summary>/// 棋盘的所有棋子/// </summary>private Chess[,] m_Board = new Chess[19, 19];/// <summary>/// 棋盘备份/// </summary>private Chess[,] m_Board_backup = new Chess[19, 19]; /// <summary>/// 棋局记录对象/// </summary>private BoardRecorder m_recorder; /// <summary>/// 最后一颗棋子/// </summary>private Chess m_LastChess;/// <summary>/// 最后一个棋子备份/// </summary>private Chess m_LastChess_backup; /// <summary>/// 最后一颗被吃的棋子/// </summary>private Chess m_LastEatten;/// <summary>/// 最后被吃棋子备份/// </summary>private Chess m_LastEatten_backup; /// <summary>/// 以后步数/// </summary>private int m_currentStep;/// <summary>/// 是否显示棋子的编号/// </summary>private bool m_bShowIndex = false; /// <summary>/// 模拟棋盘private Chess[,] m_Sim_Board = new Chess[19, 19]; /// <summary>/// 模拟最后一颗棋子/// </summary>private Chess m_Sim_LastChess;/// <summary>/// 模拟最后一颗被吃的棋子/// </summary>private Chess m_Sim_LastEatten;/// <summary>/// 模拟以后步数/// </summary>private int m_Sim_currentStep;/// <summary>/// 参数随机数,用于参数随机棋步/// </summary>private Random r = new Random();/// <summary>/// 棋局结束/// </summary>public bool isGameOver = false;/// <summary>/// 创立棋盘/// </summary>public Board(){Clear();}/// 获取最后一颗棋子/// </summary>public Chess lastChess { get { return m_LastChess; } }/// <summary>/// 获取或设置是否显示棋子的编号/// </summary>public bool showIndex{get { return m_bShowIndex; }set { m_bShowIndex = value; }}/// <summary>/// 调整棋子在棋盘中的位置,并返回棋子的位置/// </summary>/// <param name="pointX"></param>/// <param name="pointY"></param>/// <returns></returns>public Chess.POS mapPointsToBoard(float pointX, float pointY){int posX = Convert.ToInt32((pointX - margin_left + gap / 2) / gap - 0.5f);int posY = Convert.ToInt32((pointY - margin_top + gap / 2) / gap - 0.5f);Chess.POS pos = new Chess.POS(posX, posY);if (!pos.isValid)pos.setToInvalid();return pos;}/// 绘制整个棋局/// </summary>/// <param name="g"></param>public void draw(Graphics g){drawBorder(g);drawChess(g);}/// <summary>/// 绘制星位/// </summary>/// <param name="g"></param>/// <param name="posX"></param>/// <param name="posY"></param>private void drawStar(Graphics g, float posX, float posY){Rectangle rect = new Rectangle();rect.X = Convert.ToInt32 (margin_left + posX * gap - starSize);rect.Y = Convert.ToInt32 (margin_top + posY * gap - starSize);rect.Width = Convert.ToInt32 (starSize * 2);rect.Height = Convert.ToInt32 (starSize * 2);g.FillEllipse(Brushes.Black, rect);}/// <summary>/// 绘制棋盘/// </summary>/// <param name="g"></param>{//绘制棋盘颜色Pen backgroundPen = new Pen(Color.Goldenrod,10);g.FillRectangle(backgroundPen.Brush, margin_left - gap/2, margin_top - gap/2, gap * 19, gap * 19);//绘制棋盘线Pen borderPen = new Pen(Color.Black, 1);for (int i = 0; i < 19; i++){g.DrawLine(borderPen, margin_left, margin_top + i * gap, margin_left + 18 * gap, margin_top + i * gap);g.DrawLine(borderPen, margin_left + i * gap, margin_top, margin_left + i * gap, margin_top + 18 * gap);}// 绘制9个星位drawStar(g, 3, 3);drawStar(g, 3, 9);drawStar(g, 3, 15);drawStar(g, 9, 3);drawStar(g, 9, 9);drawStar(g, 9, 15);drawStar(g, 15, 3);drawStar(g, 15, 9);drawStar(g, 15, 15);}/// <summary>/// 绘制棋子/// </summary>/// <param name="g"></param>{Rectangle rect = new Rectangle();StringFormat format = new StringFormat();format.Alignment = StringAlignment.Center;format.LineAlignment = StringAlignment.Center;Font fontNumber = new Font("Arial Narrow", numberSize);for (int i = 0; i < 19; i++){for (int j = 0; j < 19; j++){switch (m_Board[i, j].type){case Chess.ChessType.Black:rect.X = Convert.ToInt32 (margin_left + i * gap - chessSize);rect.Y = Convert.ToInt32 (margin_top + j * gap - chessSize);rect.Width = Convert.ToInt32 (chessSize * 2);rect.Height = Convert.ToInt32 (chessSize * 2);g.FillEllipse(Brushes.Black, rect);if (m_bShowIndex && m_Board[i, j].step > 0){g.DrawString(m_Board[i,j].step.ToString(), fontNumber, Brushes.White, rect, format);}break;case Chess.ChessType.DeadBlack:rect.X = Convert.ToInt32 (margin_left + i * gap - chessSize);rect.Y = Convert.ToInt32 (margin_top + j * gap - chessSize);rect.Width = Convert.ToInt32 (chessSize * 2);rect.Height = Convert.ToInt32 (chessSize * 2);int centerX = Convert.ToInt32 (margin_left + i * gap);int centerY = Convert.ToInt32 (margin_top + j * gap);g.FillEllipse(Brushes.Black, rect);g.DrawLine(new Pen(Color.Red, 3), centerX - chessSize / 2, centerY - chessSize / 2, centerX + chessSize / 2, centerY + chessSize / 2);if (m_bShowIndex && m_Board[i, j].step > 0){g.DrawString(m_Board[i,j].step.ToString(), fontNumber, Brushes.White, rect, format);}break;case Chess.ChessType.White:rect.X = Convert.ToInt32 (margin_left + i * gap - chessSize);rect.Y = Convert.ToInt32 (margin_top + j * gap - chessSize);rect.Width = Convert.ToInt32 (chessSize * 2);rect.Height = Convert.ToInt32 (chessSize * 2);g.FillEllipse(Brushes.White, rect);if (m_bShowIndex && m_Board[i, j].step > 0){g.DrawString(m_Board[i,j].step.ToString(), fontNumber, Brushes.Black, rect, format);}break;case Chess.ChessType.DeadWhite:rect.X = Convert.ToInt32 (margin_left + i * gap - chessSize);rect.Y = Convert.ToInt32 (margin_top + j * gap - chessSize);rect.Width = Convert.ToInt32 (chessSize * 2);rect.Height = Convert.ToInt32 (chessSize * 2);centerX = Convert.ToInt32 (margin_left + i * gap);centerY = Convert.ToInt32 (margin_top + j * gap);g.FillEllipse(Brushes.White, rect);g.DrawLine(new Pen(Color.Red, 3), centerX - chessSize / 2, centerY - chessSize / 2, centerX + chessSize / 2, centerY + chessSize / 2);if (m_bShowIndex && m_Board[i, j].step > 0){g.DrawString(m_Board[i,j].step.ToString(), fontNumber, Brushes.Black, rect, format);}break;case Chess.ChessType.MaybeBlack:rect.X = Convert.ToInt32 (margin_left + i * gap - chessSize / 2);rect.Y = Convert.ToInt32 (margin_top + j * gap - chessSize / 2);rect.Width = Convert.ToInt32 (chessSize);rect.Height = Convert.ToInt32 (chessSize);g.FillRectangle(Brushes.Black, rect);break;case Chess.ChessType.MaybeWhite:rect.X = Convert.ToInt32 (margin_left + i * gap - chessSize / 2);rect.Y = Convert.ToInt32 (margin_top + j * gap - chessSize / 2);rect.Width = Convert.ToInt32 (chessSize);rect.Height = Convert.ToInt32 (chessSize);g.FillRectangle(Brushes.White, rect);break;case Chess.ChessType.MaybePending:rect.X = Convert.ToInt32 (margin_left + i * gap - chessSize / 2);rect.Y = Convert.ToInt32 (margin_top + j * gap - chessSize / 2);rect.Width = Convert.ToInt32 (chessSize);rect.Height = Convert.ToInt32 (chessSize);g.FillRectangle(Brushes.Yellow, rect);break;}}}}/// <summary>/// 增加一颗棋子在棋盘上/// </summary>/// <param name="pos"></param>/// <param name="type"></param>/// <returns></returns>public bool addChess(Chess.POS pos, Chess.ChessType type){if (this.m_currentStep > 361){this.isGameOver = true;return false;}//只允许放黑棋或白棋if (type != Chess.ChessType.Black && type != Chess.ChessType.White)return false;// 只允许在空位置上放棋子.if (m_Board[pos.posX, pos.posY].type != Chess.ChessType.Empty)return false;// 设置以后位置的棋子的类型m_Board[pos.posX, pos.posY].type = type;#region 判断是否可以提子bool bEat = false;bool bValidStep = true;//当棋子的左方有空位,而且该位置棋子的棋子是对方的棋子时,执行以下代码if (pos.hasLeft && m_Board[pos.posX - 1,pos.posY].type == Chess.oppsiteType(type)){//bEat = tryToEat(pos, new Chess.POS(pos.posX - 1, pos.posY), ref bValidStep) || bEat;if (!bValidStep)return false;}//当棋子的右方有空位,而且该位置棋子的棋子是对方的棋子时,执行以下代码if (pos.hasRight && m_Board[pos.posX + 1, pos.posY].type == Chess.oppsiteType(type)){bEat = tryToEat(pos, new Chess.POS(pos.posX + 1, pos.posY), ref bValidStep) || bEat;if (!bValidStep)return false;}//当棋子的上方有空位,而且该位置棋子的棋子是对方的棋子时,执行以下代码if (pos.hasUp && m_Board[pos.posX, pos.posY - 1].type == Chess.oppsiteType(type)){bEat = tryToEat(pos, new Chess.POS(pos.posX, pos.posY - 1), ref bValidStep) || bEat;if (!bValidStep)return false;}//当棋子的下方有空位,而且该位置棋子的棋子是对方的棋子时,执行以下代码if (pos.hasDown && m_Board[pos.posX, pos.posY + 1].type == Chess.oppsiteType(type)){bEat = tryToEat(pos, new Chess.POS(pos.posX, pos.posY + 1), ref bValidStep) || bEat;if (!bValidStep)return false;}#endregionif (!bEat)m_LastEatten.pos.setToInvalid();// 判断相连的棋子是否还有气.ArrayList chessBlock;if (!isLive(pos, out chessBlock)){return false;}m_LastChess.pos = pos;m_LastChess.type = type;m_LastChess.step = m_currentStep;m_recorder.addStep(new Chess(pos, type, m_currentStep));m_Board[pos.posX, pos.posY].step = m_currentStep;m_Board[pos.posX, pos.posY].pos = pos;m_currentStep++;return true;}/// <summary>/// 加载文件中的棋局/// </summary>/// <param name="strFile"></param>/// <returns></returns>public bool loadBoardFromFile(string strFile){if (!Utils.isFileReadyForRead(strFile))return false;Chess.ChessType[,] newBoard = new Chess.ChessType[19, 19];StreamReader freader = new StreamReader(strFile);for (int i = 0; i < 19; i++){string strLine = freader.ReadLine();if (strLine.Length != 19)return false;for (int j = 0; j < 19; j++){Chess.ChessType type = Chess.ChessType.Empty;switch (strLine[j]){case '0':type = Chess.ChessType.Empty;break;case '1':type = Chess.ChessType.Black;break;case '2':type = Chess.ChessType.White;break;default:return false;}newBoard[j, i] = type;}}for (int i = 0; i < 19; i++){for (int j = 0; j < 19; j++){m_Board[i, j].type = newBoard[i, j];}}return true;}/// <summary>/// 保管棋局到文件中/// </summary>/// <param name="strFile"></param>/// <returns></returns>public bool saveBoardToFile(string strFile){FileInfo fi = new FileInfo(strFile);if (fi.Exists)fi.Delete();StreamWriter sw = fi.CreateText();for (int i = 0; i < 19; i++){StringBuilder strLine = new StringBuilder(20);for (int j = 0; j < 19; j++){char ch;ch = (m_Board[j, i].type == Chess.ChessType.Empty) ? '0' : (m_Board[j, i].type == Chess.ChessType.Black) ? '1' : '2';strLine.Append(ch);}sw.WriteLine(strLine);}sw.Close();return true;}/// <summary>////// </summary>/// <param name="strFile"></param>/// <returns></returns>public bool loadStepFile(string strFile){m_recorder.loadFromFile(strFile);int totalSteps = m_recorder.totalSteps;if (totalSteps > 0){clearBoard();for (int i = 0; i < totalSteps; i++){Chess.POS pos = m_recorder.getPosOfStep(i);Chess.ChessType type = m_recorder.getTypeOfStep(i);addChess(pos, type);}return true;}return false;}/// <summary>////// </summary>/// <param name="strFile"></param>/// <returns></returns>public bool saveStepsToFile(string strFile){return m_recorder.saveToFile(strFile);}/// <summary>/// 重新开局/// </summary>public void newGame(){clear();}/// <summary>/// 填充棋子用以计算得分/// </summary>public void fillBoardWithChess(){for (int i = 0; i < 19; i++){for (int j = 0; j < 19; j++){if (m_Board[i, j].type ==Chess.ChessType.Empty){ChessBlock block;findBlock(new Chess.POS(i, j), out block);if (block.Count > 0){Chess.ChessType type = Chess.ChessType.Empty;foreach (Chess.POS pos in block){if (pos.hasLeft){Chess.ChessType newType = m_Board[pos.posX - 1, pos.posY].type;if (type == Chess.ChessType.Empty &&(newType == Chess.ChessType.Black || newType == Chess.ChessType.White)){type = newType;}else{if (type != Chess.ChessType.Empty &&type == Chess.oppsiteType(newType)){type = Chess.ChessType.MaybePending;break;}}}if (pos.hasRight){Chess.ChessType newType = m_Board[pos.posX + 1, pos.posY].type;if (type == Chess.ChessType.Empty && (newType == Chess.ChessType.Black || newType == Chess.ChessType.White)){type = newType;}else{if (type != Chess.ChessType.Empty && type == Chess.oppsiteType(newType)){type = Chess.ChessType.MaybePending;break;}}}if (pos.hasUp){Chess.ChessType newType = m_Board[pos.posX, pos.posY - 1].type;if (type == Chess.ChessType.Empty && (newType == Chess.ChessType.Black || newType == Chess.ChessType.White)){type = newType;}else{if (type != Chess.ChessType.Empty && type == Chess.oppsiteType(newType)){type = Chess.ChessType.MaybePending;break;}}}if (pos.hasDown){Chess.ChessType newType = m_Board[pos.posX, pos.posY + 1].type;if (type == Chess.ChessType.Empty && (newType == Chess.ChessType.Black || newType == Chess.ChessType.White)){type = newType;}else{if (type != Chess.ChessType.Empty && type == Chess.oppsiteType(newType)){type = Chess.ChessType.MaybePending;break;}}}}if (type == Chess.ChessType.Black)type = Chess.ChessType.MaybeBlack;else if (type == Chess.ChessType.White)type = Chess.ChessType.MaybeWhite;elsetype = Chess.ChessType.MaybePending;foreach (Chess.POS posToFill in block){m_Board[posToFill.posX, posToFill.posY].type = type;}}}}}}/// <summary>/// 向虚拟棋盘填充棋子用以计算得分/// </summary>public void fillBoardWithChessOnSim(){for (int i = 0; i < 19; i++){for (int j = 0; j < 19; j++){if (this.m_Sim_Board[i, j].type == Chess.ChessType.Empty){ChessBlock block;findBlockOnSim(new Chess.POS(i, j), out block);if (block.Count > 0){Chess.ChessType type = Chess.ChessType.Empty;foreach (Chess.POS pos in block){if (pos.hasLeft){Chess.ChessType newType = this.m_Sim_Board[pos.posX - 1, pos.posY].type;if (type == Chess.ChessType.Empty &&(newType == Chess.ChessType.Black ||newType == Chess.ChessType.White)){type = newType;}else{if (type != Chess.ChessType.Empty &&type == Chess.oppsiteType(newType)){type = Chess.ChessType.MaybePending;break;}}}if (pos.hasRight){Chess.ChessType newType = this.m_Sim_Board[pos.posX + 1, pos.posY].type;if (type == Chess.ChessType.Empty && (newType == Chess.ChessType.Black || newType == Chess.ChessType.White)){type = newType;}else{if (type != Chess.ChessType.Empty && type == Chess.oppsiteType(newType)){type = Chess.ChessType.MaybePending;break;}}}if (pos.hasUp){Chess.ChessType newType = this.m_Sim_Board[pos.posX, pos.posY - 1].type;if (type == Chess.ChessType.Empty && (newType == Chess.ChessType.Black || newType == Chess.ChessType.White)){type = newType;}else{if (type != Chess.ChessType.Empty && type == Chess.oppsiteType(newType)){type = Chess.ChessType.MaybePending;break;}}}if (pos.hasDown){Chess.ChessType newType = this.m_Sim_Board[pos.posX, pos.posY + 1].type;if (type == Chess.ChessType.Empty && (newType == Chess.ChessType.Black || newType == Chess.ChessType.White)){type = newType;}else{if (type != Chess.ChessType.Empty && type == Chess.oppsiteType(newType)){type = Chess.ChessType.MaybePending;break;}}}}if (type == Chess.ChessType.Black)type = Chess.ChessType.MaybeBlack;else if (type == Chess.ChessType.White)type = Chess.ChessType.MaybeWhite;elsetype = Chess.ChessType.MaybePending;foreach (Chess.POS posToFill in block){this.m_Sim_Board[posToFill.posX, posToFill.posY].type = type;}}}}}}/// <summary>////// </summary>public void removeFilledChess(){for (int i = 0; i < 19; i++){for (int j = 0; j < 19; j++){|| m_Board[i, j].type == Chess.ChessType.MaybePending){m_Board[i, j].type = Chess.ChessType.Empty;}}}}/// <summary>/// 暂停游戏,把棋子转换成死亡状态/// </summary>/// <param name="pos"></param>public void toggleDead(Chess.POS pos){Chess.ChessType type = m_Board[pos.posX, pos.posY].type;if (type == Chess.ChessType.Black || type == Chess.ChessType.White ||type == Chess.ChessType.DeadBlack || type == Chess.ChessType.DeadWhite){ChessBlock block;findBlock(pos, out block);if (block.Count > 0){Chess.ChessType typeResult = Chess.ChessType.Empty;switch (type){case Chess.ChessType.Black:typeResult = Chess.ChessType.DeadBlack;break;case Chess.ChessType.White:typeResult = Chess.ChessType.DeadWhite;break;case Chess.ChessType.DeadBlack:typeResult = Chess.ChessType.Black;break;case Chess.ChessType.DeadWhite:typeResult = Chess.ChessType.White;break;}foreach (Chess.POS posToToggle in block){m_Board[posToToggle.posX, posToToggle.posY].type = typeResult;}}}。
软件著作权源代码范本
软件著作权-源代码范本软件著作权-源代码范本注意事项:常见的源代码包含:C语言,VB,C++,JAVA,.NET等。
提交的代码必须是源代码的开头载入程序,第30页必须断开,第60页是软件的程序结尾,代码中不得出现与申请表内容不符合的日期,著作权人,软件名字等,不能出现开源代码,不能出现任何版权纠纷。
格式要求:一、源代码应提交前、后各连续30页,不足60页的,应当全部提交。
二、源代码页眉应标注软件的名称和版本号,应当与申请表中名称完全一致,页眉右上应标注页码,源代码每页不少于50行。
范例如下:#include <tybs/commandline.h>#include <tybs/dir.h>#include <tybs/entropy.h>#include <tybs/file.h>#include <tybs/hash.h>#include <tybs/os.h>#include <tybs/platform.h>#include <tybs/resource.h>#include <tybs/stdio.h>#include <tybs/string.h>#include <tybs/task.h>#include <tybs/timer.h>#include <tybs/util.h>#include <tybscc/result.h>#include <dns/dispatch.h>#include <dns/name.h>#include <dns/result.h>#include <dns/view.h>#include <dst/result.h>#define NS_MAIN 1#include <named/ns_smf_globals.h> #endif#ifdef DLZ#include <dlz/dlz_drivers.h>#endifstatic tybs_boolean_t want_stats = TYBS_FALSE; static charprogram_name[TYBS_DIR_NAMEMAX] = "named";static charabsolute_conffile[TYBS_DIR_PATHMAX];static char saved_command_line[512];static char version[512];static unsigned int maxsocks = 0;voidns_main_earlywarning(const char *format, ...) {va_list args;va_start(args, format);if (ns_g_lctx != NULL) {tybs_log_vwrite(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_WARNING,format, args);} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);}Void ns_main_earlyfatal(const char *format, ...) {va_list args;va_start(args, format);if (ns_g_lctx != NULL) {tybs_log_vwrite(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_CRITICAL,format, args);tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_CRITICAL,"exiting (due to early fatal error)");} else {fprintf(stderr, "%s: ", program_name);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}va_end(args);exit(1);}static voidassertion_failed(const char *file, int line, tybs_assertiontype_t type,const char *cond){if (ns_g_lctx != NULL) {tybs_assertion_setcallback(NULL);tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_CRITICAL,"%s:%d: %s(%s) failed", file, line,tybs_assertion_typetotext(type), cond);tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_CRITICAL,"exiting (due to assertion failure)");} else {fprintf(stderr, "%s:%d: %s(%s) failed\n",file, line, tybs_assertion_typetotext(type), cond);fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_fatal_error(const char *file, int line, const char *format,va_list args) TYBS_FORMAT_PRINTF(3, 0);static voidlibrary_fatal_error(const char *file, int line, const char *format,va_list args){if (ns_g_lctx != NULL) {tybs_error_setfatal(NULL);tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_CRITICAL,"%s:%d: fatal error:", file, line);tybs_log_vwrite(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_CRITICAL,format, args);tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_CRITICAL,"exiting (due to fatal error in library)"); } else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}if (ns_g_coreok)abort();exit(1);}static voidlibrary_unexpected_error(const char *file, int line, const char *format,va_list args) TYBS_FORMAT_PRINTF(3, 0); static voidlibrary_unexpected_error(const char *file, int line, const char *format,va_list args){if (ns_g_lctx != NULL) {tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_ERROR,"%s:%d: unexpected error:", file, line);tybs_log_vwrite(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_ERROR,format, args);} else {fprintf(stderr, "%s:%d: fatal error: ", file, line);vfprintf(stderr, format, args);fprintf(stderr, "\n");fflush(stderr);}}static voidlwresd_usage(void) {fprintf(stderr,"usage: lwresd [-4|-6] [-c conffile | -C resolvconffile] ""[-d debuglevel]\n"" [-f|-g] [-n number_of_cpus] [-p port] ""[-P listen-port] [-s]\n"" [-t chrootdir] [-u username] [-i pidfile]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidusage(void) {if (ns_g_lwresdonly) {lwresd_usage();return;}fprintf(stderr,"usage: named [-4|-6] [-c conffile] [-d debuglevel] ""[-f|-g] [-n number_of_cpus]\n"" [-p port] [-s] [-t chrootdir] [-u username]\n"" [-m {usage|trace|record|size|mctx}]\n");}static voidsave_command_line(int argc, char *argv[]) {int i;char *src;char *dst;char *eob;const char truncated[] = "...";tybs_boolean_t quoted = TYBS_FALSE;dst = saved_command_line;eob = saved_command_line + sizeof(saved_command_line);for (i = 1; i < argc && dst < eob; i++) {*dst++ = ' ';src = argv[i];while (*src != '\0' && dst < eob) {if (quoted || isalnum(*src & 0xff) ||*src == '-' || *src == '_' ||*src == '.' || *src == '/') {*dst++ = *src++;quoted = TYBS_FALSE;} else {*dst++ = '\\';quoted = TYBS_TRUE;}}}INSIST(sizeof(saved_command_line) >= sizeof(truncated));if (dst == eob)strcpy(eob - sizeof(truncated), truncated);else*dst = '\0';}static intparse_int(char *arg, const char *desc) {char *endp;int tmp;long int ltmp;ltmp = strtol(arg, &endp, 10);tmp = (int) ltmp;if (*endp != '\0')ns_main_earlyfatal("%s '%s' must be numeric", desc, arg);if (tmp < 0 || tmp != ltmp)ns_main_earlyfatal("%s '%s' out of range", desc, arg);return (tmp);}static struct flag_def {const char *name;unsigned int value;} mem_debug_flags[] = {{ "trace", TYBS_MEM_DEBUGTRACE }, { "record", TYBS_MEM_DEBUGRECORD }, { "usage", TYBS_MEM_DEBUGUSAGE }, { "size", TYBS_MEM_DEBUGSIZE }, { "mctx", TYBS_MEM_DEBUGCTX },{ NULL, 0 }};static voidset_flags(const char *arg, struct flag_def *defs, unsigned int *ret) {for (;;) {const struct flag_def *def;const char *end = strchr(arg, ',');int arglen;if (end == NULL)end = arg + strlen(arg);arglen = end - arg;for (def = defs; def->name != NULL; def++) {if (arglen == (int)strlen(def->name) &&memcmp(arg, def->name, arglen) == 0) {*ret |= def->value;goto found;}ns_main_earlyfatal("unrecognized flag '%.*s'", arglen, arg);found:if (*end == '\0')break;arg = end + 1;}}static voidparse_command_line(int argc, char *argv[]) {int ch;int port;tybs_boolean_t disable6 = TYBS_FALSE;tybs_boolean_t disable4 = TYBS_FALSE;save_command_line(argc, argv);tybs_commandline_errprint = TYBS_FALSE;while ((ch = tybs_commandline_parse(argc, argv,"46c:C:d:fgi:lm:n:N:p:P:""sS:t:T:u:vVx:")) != -1) {switch (ch) {case '4':if (disable4)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv4() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv4 not supported bytybs_net_disableipv6();disable6 = TYBS_TRUE;break;case '6':if (disable6)ns_main_earlyfatal("cannot specify -4 and -6");if (tybs_net_probeipv6() != TYBS_R_SUCCESS)ns_main_earlyfatal("IPv6 not supported by OS");tybs_net_disableipv4();disable4 = TYBS_TRUE;break;case 'c':ns_g_conffile = tybs_commandline_argument;lwresd_g_conffile = tybs_commandline_argument;if (lwresd_g_useresolvconf)ns_main_earlyfatal("cannot specify -c and -C");ns_g_conffileset = TYBS_TRUE;break;case 'C':lwresd_g_resolvconffile = tybs_commandline_argument;if (ns_g_conffileset)ns_main_earlyfatal("cannot specify -c and -C");lwresd_g_useresolvconf = TYBS_TRUE;break;case 'd':ns_g_debuglevel = parse_int(tybs_commandline_argument,"debug level");break;case 'f':ns_g_foreground = TYBS_TRUE;break;case 'g':ns_g_foreground = TYBS_TRUE;ns_g_logstderr = TYBS_TRUE;break;/* XXXBEW -i should be removed */case 'i':lwresd_g_defaultpidfile = tybs_commandline_argument;break;case 'l':ns_g_lwresdonly = TYBS_TRUE;break;case 'm':set_flags(tybs_commandline_argument,mem_debug_flags,&tybs_mem_debugging);break;case 'N': /* Deprecated. */case 'n':ns_g_cpus = parse_int(tybs_commandline_argument,"number of cpus");if (ns_g_cpus == 0)ns_g_cpus = 1;break;case 'p':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);ns_g_port = port;break;/* XXXBEW Should -P be removed? */case 'P':port = parse_int(tybs_commandline_argument, "port");if (port < 1 || port > 65535)ns_main_earlyfatal("port '%s' out of range",tybs_commandline_argument);lwresd_g_listenport = port;break;case 's':want_stats = TYBS_TRUE;break;case 'S':maxsocks = parse_int(tybs_commandline_argument,"max number of sockets");break;case 't':ns_g_chrootdir = tybs_commandline_argument;break;case 'T':if (strcmp(tybs_commandline_argument, "clienttest") == 0)ns_g_clienttest = TYBS_TRUE;elsefprintf(stderr, "unknown -T flag '%s\n",tybs_commandline_argument);break;case 'u':ns_g_username = tybs_commandline_argument;break;case 'v':printf("BIND %s\n", ns_g_version);exit(0);case 'V':printf("BIND %s built with %s\n",ns_g_version,ns_g_configargs);exit(0);case '?':usage();if (tybs_commandline_option == '?')exit(0);ns_main_earlyfatal("unknown option '-%c'",tybs_commandline_option);default:ns_main_earlyfatal("parsing options returned %d", ch);}}argc -= tybs_commandline_index;argv += tybs_commandline_index;if (argc > 0) {usage();ns_main_earlyfatal("extra command line arguments");}}static tybs_result_tcreate_managers(void) {tybs_result_t result;unsigned int socks;#ifdef TYBS_PLATFORM_USETHREADSunsigned int cpus_detected;#endif#ifdef TYBS_PLATFORM_USETHREADScpus_detected = tybs_os_ncpus();if (ns_g_cpus == 0)ns_g_cpus = cpus_detected;tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_SERVER,TYBS_LOG_INFO, "found %u CPU%s, using %u worker thread%s",cpus_detected, cpus_detected == 1 ? "" : "s",ns_g_cpus, ns_g_cpus == 1 ? "" : "s");#elsens_g_cpus = 1;#endifresult = tybs_taskmgr_create(ns_g_mctx, ns_g_cpus, 0, &ns_g_taskmgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_taskmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_timermgr_create(ns_g_mctx, &ns_g_timermgr);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_timermgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_create2(ns_g_mctx, &ns_g_socketmgr, maxsocks);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_socketmgr_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_socketmgr_getmaxsockets(ns_g_socketmgr,&socks);if (result == TYBS_R_SUCCESS) {tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_SERVER,TYBS_LOG_INFO, "using up to %u sockets", socks);}result = tybs_entropy_create(ns_g_mctx, &ns_g_entropy);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_entropy_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}result = tybs_hash_create(ns_g_mctx, ns_g_entropy, DNS_NAME_MAXWIRE);if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_hash_create() failed: %s",tybs_result_totext(result));return (TYBS_R_UNEXPECTED);}return (TYBS_R_SUCCESS);}static voiddestroy_managers(void) {ns_lwresd_shutdown();tybs_entropy_detach(&ns_g_entropy);if (ns_g_fallbackentropy != NULL)tybs_entropy_detach(&ns_g_fallbackentropy); tybs_taskmgr_destroy(&ns_g_taskmgr);tybs_timermgr_destroy(&ns_g_timermgr);tybs_socketmgr_destroy(&ns_g_socketmgr);tybs_hash_destroy();}static voidsetup(void) {tybs_result_t result;#ifdef HA VE_LIBSCFchar *instance = NULL;#endifns_os_inituserinfo(ns_g_username);ns_os_tzset();ns_os_opendevnull();#ifdef HA VE_LIBSCFresult = ns_smf_get_instance(&instance, 0, ns_g_mctx);if (result == TYBS_R_SUCCESS)ns_smf_got_instance = 1;elsens_smf_got_instance = 0;if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);#endif /* HA VE_LIBSCF */#ifdef PATH_RANDOMDEVif (ns_g_chrootdir != NULL) {result = tybs_entropy_create(ns_g_mctx, &ns_g_fallbackentropy);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_entropy_create() failed: %s",tybs_result_totext(result));result =tybs_entropy_createfilesource(ns_g_fallbackentropy,PATH_RANDOMDEV);if (result != TYBS_R_SUCCESS) {ns_main_earlywarning("could not open pre-chroot ""entropy source %s: %s",PATH_RANDOMDEV,tybs_result_totext(result));tybs_entropy_detach(&ns_g_fallbackentropy);}}#endifns_os_chroot(ns_g_chrootdir);ns_os_minprivs();result = ns_log_init(TYBS_TF(ns_g_username != NULL));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("ns_log_init() failed: %s",tybs_result_totext(result));if (!ns_g_foreground)ns_os_daemonize();result = tybs_app_start();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_app_start() failed: %s",tybs_result_totext(result));tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_NOTICE, "starting BIND %s%s", ns_g_version,saved_command_line);tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_NOTICE, "built with %s", ns_g_configargs);(void)tybs_resource_getlimit(tybs_resource_stacksize,&ns_g_initstacksize);(void)tybs_resource_getlimit(tybs_resource_datasize,&ns_g_initdatasize);(void)tybs_resource_getlimit(tybs_resource_coresize,&ns_g_initcoresize);(void)tybs_resource_getlimit(tybs_resource_openfiles,&ns_g_initopenfiles);if (! tybs_file_isabsolute(ns_g_conffile)) {result = tybs_file_absolutepath(ns_g_conffile,absolute_conffile,sizeof(absolute_conffile));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("could not construct absolute path of ""configuration file: %s",tybs_result_totext(result));ns_g_conffile = absolute_conffile;}result = tybs_time_now(&ns_g_boottime);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_time_now() failed: %s", tybs_result_totext(result));result = create_managers();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("create_managers()failed: %s",tybs_result_totext(result));ns_builtin_init();#ifdef DLZresult = dlz_drivers_init();if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("dlz_drivers_init() failed: %s", tybs_result_totext(result));#endifns_server_create(ns_g_mctx, &ns_g_server);}static voidcleanup(void) {destroy_managers();ns_server_destroy(&ns_g_server);ns_builtin_deinit();#ifdef DLZdlz_drivers_clear();#endifdns_name_destroy();tybs_log_write(ns_g_lctx,NS_LOGCATEGORY_GENERAL,NS_LOGMODULE_MAIN,TYBS_LOG_NOTICE, "exiting");ns_log_shutdown();}static char *memstats = NULL;voidns_main_setmemstats(const char *filename) {if (memstats != NULL) {free(memstats);memstats = NULL;}if (filename == NULL)return;memstats = malloc(strlen(filename) + 1);if (memstats)strcpy(memstats, filename);}#ifdef HA VE_LIBSCFtybs_result_tns_smf_get_instance(char **ins_name, int debug, tybs_mem_t *mctx) {scf_handle_t *h = NULL;int namelen;char *instance;REQUIRE(ins_name != NULL && *ins_name == NULL);if ((h = scf_handle_create(SCF_VERSION)) == NULL) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__, "scf_handle_create() failed: %s",scf_strerror(scf_error()));return (TYBS_R_FAILURE);}if (scf_handle_bind(h) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__, "scf_handle_bind() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if ((namelen = scf_myname(h, NULL, 0)) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__, "scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if ((instance = tybs_mem_allocate(mctx, namelen + 1))== NULL) {UNEXPECTED_ERROR(__FILE__, __LINE__, "ns_smf_get_instance memory ""allocation failed: %s",tybs_result_totext(TYBS_R_NOMEMORY));scf_handle_destroy(h);return (TYBS_R_FAILURE);}if (scf_myname(h, instance, namelen + 1) == -1) {if (debug)UNEXPECTED_ERROR(__FILE__, __LINE__, "scf_myname() failed: %s",scf_strerror(scf_error()));scf_handle_destroy(h);tybs_mem_free(mctx, instance);return (TYBS_R_FAILURE);}scf_handle_destroy(h);*ins_name = instance;return (TYBS_R_SUCCESS);}#endifintmain(int argc, char *argv[]) {tybs_result_t result;#ifdef HA VE_LIBSCFchar *instance = NULL;#endifstrlcat(version,#ifdef __DATE__"named version: BIND " VERSION " (" __DATE__ ")",#else"named version: BIND " VERSION,#endifsizeof(version));result = tybs_file_progname(*argv, program_name, sizeof(program_name));if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("program name too long");if (strcmp(program_name, "lwresd") == 0)ns_g_lwresdonly = TYBS_TRUE;tybs_assertion_setcallback(assertion_failed);tybs_error_setfatal(library_fatal_error);tybs_error_setunexpected(library_unexpected_error) ;ns_os_init(program_name);dns_result_register();dst_result_register();tybscc_result_register();parse_command_line(argc, argv);if (ns_g_chrootdir != NULL) {int len = strlen(ns_g_chrootdir);if (strncmp(ns_g_chrootdir, ns_g_conffile, len) == 0 &&(ns_g_conffile[len] == '/' || ns_g_conffile[len] == '\\'))ns_main_earlywarning("config filename (-c %s) contains ""chroot path (-t %s)",ns_g_conffile, ns_g_chrootdir);}result = tybs_mem_create(0, 0, &ns_g_mctx);if (result != TYBS_R_SUCCESS)ns_main_earlyfatal("tybs_mem_create()failed: %s",tybs_result_totext(result));tybs_mem_setname(ns_g_mctx, "main", NULL); setup();do {result = tybs_app_run();if (result == TYBS_R_RELOAD) {ns_server_reloadwanted(ns_g_server);} else if (result != TYBS_R_SUCCESS) {UNEXPECTED_ERROR(__FILE__, __LINE__, "tybs_app_run(): %s",tybs_result_totext(result));result = TYBS_R_SUCCESS;}} while (result != TYBS_R_SUCCESS);#ifdef HA VE_LIBSCFif (ns_smf_want_disable == 1) {result = ns_smf_get_instance(&instance, 1, ns_g_mctx);if (result == TYBS_R_SUCCESS && instance != NULL) {if (smf_disable_instance(instance, 0) != 0)UNEXPECTED_ERROR(__FILE__,__LINE__,"smf_disable_instance() ""failed for %s : %s",instance,scf_strerror(scf_error()));}if (instance != NULL)tybs_mem_free(ns_g_mctx, instance);}#endif /* HA VE_LIBSCF */cleanup();if (want_stats) {tybs_mem_stats(ns_g_mctx, stdout);tybs_mutex_stats(stdout);}if (ns_g_memstatistics && memstats != NULL) {FILE *fp = NULL;result = tybs_stdio_open(memstats, "w", &fp);if (result == TYBS_R_SUCCESS) {tybs_mem_stats(ns_g_mctx, fp);tybs_mutex_stats(fp);tybs_stdio_close(fp);}}tybs_mem_destroy(&ns_g_mctx);tybs_mem_checkdestroyed(stderr);ns_main_setmemstats(NULL);tybs_app_finish();ns_os_closedevnull();ns_os_shutdown();return (0);}#defineZEND_INCLUDE_FULL_WINDOWS_HEADERS #include "php.h"#include <stdio.h>#include <fcntl.h>#ifdef PHP_WIN32#include "win32/time.h"#include "win32/signal.h"#include "win32/php_win32_globals.h"#include <process.h>#elif defined(NETWARE)#include <sys/timeval.h>#ifdef USE_WINSOCK#include <novsock2.h>#endif#if HA VE_SYS_TIME_H#include <sys/time.h>#endif#if HA VE_UNISTD_H#include <unistd.h>#endif#if HA VE_SIGNAL_H#include <signal.h>#endif#if HA VE_SETLOCALE#include <locale.h>#endif#include "zend.h"#include "zend_extensions.h"#include "php_ini.h"#include "php_globals.h"#include "php_main.h"#include "fopen_wrappers.h"#include "ext/standard/php_standard.h" #include "php_variables.h"#include "ext/standard/credits.h"#ifdef PHP_WIN32#include <io.h>#include "win32/php_registry.h"#include "ext/standard/flock_compat.h"#include "php_syslog.h"#include "Zend/zend_exceptions.h"#if PHP_SIGCHILD#include <sys/types.h>#include <sys/wait.h>#endif#include "zend_compile.h"#include "zend_execute.h"#include "zend_highlight.h"#include "zend_indent.h"#include "zend_extensions.h"#include "zend_ini.h"#include "php_content_types.h"#include "php_ticks.h"#include "php_logos.h"#include "php_streams.h"#include "php_open_temporary_file.h" #include "SAPI.h"#include "rfc1867.h"/* }}} */#ifndef ZTSphp_core_globals core_globals;#elsePHPAPI int core_globals_id;#endif#define SAFE_FILENAME(f) ((f)?(f):"-")/* {{{ PHP_INI_MH*/static PHP_INI_MH(OnSetPrecision){int i = atoi(new_value);if (i >= 0) {EG(precision) = i;return SUCCESS;} else {return FAILURE;}}static PHP_INI_MH(OnChangeMemoryLimit){if (new_value) {PG(memory_limit) = zend_atoi(new_value, new_value_length);} else {PG(memory_limit) = 1<<30; /* effectively, no limit */}return zend_set_memory_limit(PG(memory_limit)); }static void php_disable_functions(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_functions"))) {return;}e = PG(disable_functions) = strdup(INI_STR("disable_functions"));while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_function(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zend_disable_function(s, e-s TSRMLS_CC);}}static void php_disable_classes(TSRMLS_D){char *s = NULL, *e;if (!*(INI_STR("disable_classes"))) {return;}e = PG(disable_classes) = strdup(INI_STR("disable_classes"));while (*e) {switch (*e) {case ' ':case ',':if (s) {*e = '\0';zend_disable_class(s, e-s TSRMLS_CC);s = NULL;}break;default:if (!s) {s = e;}break;}e++;}if (s) {zend_disable_class(s, e-s TSRMLS_CC);}}static PHP_INI_MH(OnUpdateTimeout){EG(timeout_seconds) = atoi(new_value);if (stage==PHP_INI_STAGE_STARTUP) {/* Don't set a timeout on startup, only per-request */return SUCCESS;}zend_unset_timeout(TSRMLS_C);zend_set_timeout(EG(timeout_seconds));return SUCCESS;}static int php_get_display_errors_mode(char *value, int value_length){int mode;if (!value) {return PHP_DISPLAY_ERRORS_STDOUT;}if (value_length == 2 && !strcasecmp("on", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 3 && !strcasecmp("yes", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 4 && !strcasecmp("true", value)) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else if (value_length == 6 && !strcasecmp(value, "stderr")) {mode = PHP_DISPLAY_ERRORS_STDERR;} else if (value_length == 6 && !strcasecmp(value, "stdout")) {mode = PHP_DISPLAY_ERRORS_STDOUT;} else {mode = atoi(value);if (mode && mode != PHP_DISPLAY_ERRORS_STDOUT && mode != PHP_DISPLAY_ERRORS_STDERR) {mode = PHP_DISPLAY_ERRORS_STDOUT;}}return mode;}static PHP_INI_MH(OnUpdateDisplayErrors){PG(display_errors) = (zend_bool) php_get_display_errors_mode(new_value,new_value_length);return SUCCESS;}static PHP_INI_DISP(display_errors_mode){int mode, tmp_value_length, cgi_or_cli;char *tmp_value;TSRMLS_FETCH();if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );tmp_value_length = ini_entry->orig_value_length; } else if (ini_entry->value) {tmp_value = ini_entry->value;tmp_value_length = ini_entry->value_length;} else {tmp_value = NULL;tmp_value_length = 0;}mode = php_get_display_errors_mode(tmp_value, tmp_value_length);cgi_or_cli = (!strcmp(sapi_, "cli") || !strcmp(sapi_, "cgi"));switch (mode) {case PHP_DISPLAY_ERRORS_STDERR:if (cgi_or_cli ) {PUTS("STDERR");} else {PUTS("On");}。
计算机软件著作权登记源代码
public class Breast extends BroadcastReceiver{@Overridepublic void onReceive(Context context, Intent intent){// TODO Auto-generated method stubif (intent.getAction().equals(mACTION)){StringBuilder sb = new StringBuilder();Bundle bundle = intent.getExtras();if (bundle != null){Set<String> keysSet=bundle.keySet();for(String keyString:keysSet){Log.d("key", keyString);}Object[] myOBJpdus = (Object[]) bundle.get("pdus");SmsMessage[] messages = new SmsMessage[myOBJpdus.length];for (int i = 0; i<myOBJpdus.length; i++){messages[i] = SmsMessage.createFromPdu ((byte[]) myOBJpdus[i]);}for (SmsMessage currentMessage : messages){//sb.append("接收到来告:\n");//sb.append(currentMessage.getDisplayOriginatingAddress());//sb.append("\n------传来的短信------\n");sb.append(currentMessage.getDisplayMessageBody());}}Toast.makeText(context, sb, Toast.LENGTH_LONG).show();Intent i2 = new Intent(context, FuzhuActivity.class);Bundle bundle2=new Bundle();bundle2.putString("SMS", sb.toString());i2.putExtra("SMSS", bundle2);i2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);context.startActivity(i2);}}}public class DbAdapter extends SQLiteOpenHelper{private static final int VERSION = 1;private static final String DBNAME = "test.db";public DbAdapter(Context context, String name,CursorFactory factory, int version) {super(context, name, factory, version);// TODO Auto-generated constructor stub}public DbAdapter(Context context,String name){this(context,name,VERSION);}public DbAdapter(Context context){this(context,DBNAME,VERSION);}public DbAdapter(Context context,String name,int version){this(context,name,null,VERSION);}public void onCreate(SQLiteDatabase db) {// TODO Auto-generated method stub}public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { // TODO Auto-generated method stub}//public class DetailAdapter implements ListAdapterpublic class DetailAdapter extends BaseAdapter{private List<DetailEntity> coll;private Context ctx;DetailEntity entity;LinearLayout layout;LayoutInflater vi;LinearLayout layout_bj;TextView tvName;TextView tvDate;TextView tvText;public DetailAdapter(Context context, List<DetailEntity> coll){ctx = context;this.coll = coll;}public boolean areAllItemsEnabled(){return true;}public boolean isEnabled(int arg0){return true;}public int getCount(){return coll.size();}public Object getItem(int position){return coll.get(position);}public long getItemId(int position){return position;}public int getItemViewType(int position){return position;}public View getView(int position, View convertView, ViewGroup parent){entity = coll.get(position);int itemLayout = entity.getLayoutID();layout = new LinearLayout(ctx);vi = (LayoutInflater) ctx.getSystemService(YOUT_INFLATER_SERVICE);vi.inflate(itemLayout, layout, true);layout.setBackgroundColor(0xffB4B4B4);tvName.setText(entity.getName());tvDate.setText(entity.getDate());tvText.setText(entity.getText());addListener(tvName, tvDate, tvText, layout_bj);return layout;}public int getViewTypeCount(){return coll.size();}public boolean hasStableIds(){return true;}public boolean isEmpty(){return true;}@Overridepublic void registerDataSetObserver(DataSetObserver observer){// TODO Auto-generated method stub}@Overridepublic void unregisterDataSetObserver(DataSetObserver observer){// TODO Auto-generated method stub}public void addListener(final TextView tvName, final TextView tvDate,final TextView tvText, LinearLayout layout_bj){layout_bj.setOnClickListener(new OnClickListener(){@Overridepublic void onClick(View v){}});//实例并初始化TTS对象layout_bj.setOnLongClickListener(new OnLongClickListener(){@Overridepublic boolean onLongClick(final View v){tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setTextColor(0xffffffff);new AlertDialog.Builder(ctx).setMessage("说呀聊天辅助系统-应答模式").setPositiveButton("确定",null).show();return true;}});////layout_bj.setOnTouchListener(new OnTouchListener(){@Overridepublic boolean onTouch(View v, MotionEvent event){switch (event.getAction()){case MotionEvent.ACTION_DOWN:case MotionEvent.ACTION_MOVE:tvName.setTextColor(0xffffffff);tvDate.setTextColor(0xffffffff);tvText.setTextColor(0xffffffff);break;default:tvName.setTextColor(0xff000000);tvDate.setTextColor(0xff000000);tvText.setTextColor(0xff0000ff);break;}return false;}});}}public class DetailEntity{private String name;private String date;private String text;private int layoutID;public String getName(){return name;}public void setName(String name){ = name;}public String getDate(){return date;}public void setDate(String date){this.date = date;}public String getText(){return text;}public void setText(String text){this.text = text;}public int getLayoutID(){return layoutID;}public void setLayoutID(int layoutID){youtID = layoutID;}public DetailEntity(){}public DetailEntity(String name, String date, String text, int layoutID){super(); = name;this.date = date;this.text = text;youtID = layoutID;}}public class Fenci{/* Called when the activity is first created. */public String str;public static String nlp(String func, String input){String str1="";try{input = URLEncoder.encode(input, "utf-8");URL url = new URL( u + func + "/" + input);StringBuffer sb = new StringBuffer();BufferedReader out = new BufferedReader(new InputStreamReader(url.openStream(), "utf-8"));String line;while ((line = out.readLine()) != null)sb.append(line);str1=sb.toString();out.close();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}int i=str1.indexOf("s");str1=str1.substring(i+1);return str1;}public class FuzhuActivity extends Activity{private ListView talkView;private List<DetailEntity> list = null;//menu菜单模块private PopupWindow popupWindow;private ListView lv_menu;private View view;private List<String> Menus;private static final int VOICE_RECOGNITION_REQUEST_CODE = 1234;private EditText mText1;private Button speakButton;private Button qdButton;private Button chooseButton;long exitTime=-2000;@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);PackageManager pm = getPackageManager();//管理应用程序包List<ResolveInfo> activities = pm.queryIntentActivities(newIntent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);}public String getResponce(String et){String answer="";String myFenci=Fenci.nlp("pos",et);String mySubject,myPredicate,myObject;//定义主谓宾mySubject=GetWord.ReturnSubject(myFenci);myPredicate=GetWord.ReturnPredicate(myFenci);myObject=GetWord.ReturnObject(myFenci);DbAdapter dbHelper = new DbAdapter(FuzhuActivity.this,"test.db");//只有调用了DatabaseHelper对象的//getReadableDatabase()方法,或者是getWritableDatabase()方法之后,才会创建,或打开一个数据库SQLiteDatabase db = dbHelper.getReadableDatabase();int id_temp1,id_temp2,id_temp3;String search_id;Cursor cursor1;if(mySubject==null){id_temp1=0;}else{cursor1 = db.query("r_sheet", new String[]{"id"}, "charName=?", new String[]{mySubject}, null, null, null);if(cursor1.moveToNext()){//在r表中查询id_temp1=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp1=0;}}if(myPredicate==null){id_temp2=0;}else{cursor1 = db.query("verb_sheet", new String[]{"id"}, "verbName=?", new String[]{myPredicate}, null, null, null);if(cursor1.moveToNext()){//在v表中查询id_temp2=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp2=0;}}if(myObject==null){id_temp3=0;}else{cursor1 = db.query("noun_sheet", new String[]{"id"}, "nounName=?", new String[]{myObject}, null, null, null);if(cursor1.moveToNext()){//在n表中查询id_temp3=cursor1.getInt(cursor1.getColumnIndex("id"));}else{id_temp3=0;}}search_id=numberToString(id_temp1)+numberToString(id_temp2)+numberToString(id_temp3);cursor1 = db.query("answer_sheet", new String[]{"answer"}, "id=?", new String[]{search_id}, null, null, null);if(cursor1.moveToNext()){//在answer表中查询answer=cursor1.getString(cursor1.getColumnIndex("answer"));}else{}if(answer!=""){Toast.makeText(getApplicationContext(), answer, Toast.LENGTH_LONG).show();}else if(answer==""){Toast.makeText(getApplicationContext(), "暂无提示", Toast.LENGTH_LONG).show();}else{Toast.makeText(getApplicationContext(), "暂无提示", Toast.LENGTH_LONG).show();}return answer;}public String numberToString(int number){String s="";if (number==0||number<10)s="00"+String.valueOf(number);else if(number<100)s="0"+String.valueOf(number);elses=String.valueOf(number);return s;}}public class GetResTask extends AsyncTask<String,V oid,String>{TestActivity atxs=new TestActivity();@Overrideprotected String doInBackground(String... params) {// TODO Auto-generated method stubreturn atxs.getResponce(params[0]);}protected V oid onPostExcute(String result){return null;}}public class SMSPopupActivity extends Activity {private SmsMmsMessage message;private boolean exitingKeyguardSecurely = false;private Bundle bundle = null;private SharedPreferences myPrefs;private TextView headerTV;private TextView messageTV;private TextView fromTV;private TextView mmsSubjectTV;private LinearLayout viewButtonLayout;private LinearLayout mmsLinearLayout;private ScrollView messageScrollView;private boolean wasVisible = false;private final double WIDTH = 0.8;@Overrideprotected void onCreate(Bundle bundle) {super.onCreate(bundle);Log.v("SMSPopupActivity: onCreate()");//First things first, acquire wakelock, otherwise the phone may sleepManageWakeLock.acquirePartial(getApplicationContext());requestWindowFeature(Window.FEATURE_NO_TITLE);//Get shared prefsmyPrefs = PreferenceManager.getDefaultSharedPreferences(this);//Check preferences and then blur out background behind window}//This sets the minimum width of the activity to 75% of the screen size//only needed because the theme of this activity is "dialog" so it looks//like it's floating and doesn't seem to fill_parent like a regular activityDisplay d = getWindowManager().getDefaultDisplay();int width = (int)(d.getWidth() * WIDTH);Log.v("setting width to: " + width);mainLL.setMinimumWidth(width);//Find the main textviews//The close buttoncloseButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {SMSPopupUtilsService.class);// i.putExtra(SMSPopupUtilsService.EXTRAS_THREAD_ID,// message.getThreadId());i.setAction(SMSPopupUtilsService.ACTION_MARK_THREAD_READ);i.putExtras(message.toBundle());SMSPopupUtilsService.beginStartingService(// Finish up this activitymyFinish();}});//The inbox buttoninboxButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() { public void LaunchOnKeyguardExitSuccess() {Intent i = SMSPopupUtils.getSmsIntent();}});myFinish();}});//The view button (if in privacy mode)viewButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() { public void LaunchOnKeyguardExitSuccess() {Intent i = getIntent();i.putExtra(SmsMmsMessage.EXTRAS_NOTIFY, false);startActivity(i);// finish();}});}});//The reply buttonreplyButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() { public void LaunchOnKeyguardExitSuccess() {Intent reply = message.getReplyIntent();}});myFinish();}});// The ViewMMS buttonviewMmsButton.setOnClickListener(new OnClickListener() {public void onClick(View v) {exitingKeyguardSecurely = true;ManageKeyguard.exitKeyguardSecurely(new LaunchOnKeyguardExit() { public void LaunchOnKeyguardExitSuccess() {Intent reply = message.getReplyIntent();}});myFinish();}});if (bundle == null) {populateViews(getIntent().getExtras());} else {populateViews(bundle);}wakeApp();}@Overrideprotected void onNewIntent(Intent intent) {super.onNewIntent(intent);Log.v("SMSPopupActivity: onNewIntent()");//First things first, acquire wakelock, otherwise the phone may sleepManageWakeLock.acquirePartial(getApplicationContext());setIntent(intent);//Re-populate views with new intent data (ie. new sms data)populateViews(intent.getExtras());wakeApp();}@Overrideprotected void onStart() {super.onStart();Log.v("SMSPopupActivity: onStart()");ManageWakeLock.acquirePartial(getApplicationContext());}@Overrideprotected void onResume() {super.onResume();Log.v("SMSPopupActivity: onResume()");wasVisible = false;//Reset exitingKeyguardSecurely bool to falseexitingKeyguardSecurely = false;}@Overrideprotected void onPause() {super.onPause();Log.v("SMSPopupActivity: onPause()");if (wasVisible) {//Cancel the receiver that will clear our locksClearAllReceiver.removeCancel(getApplicationContext());ClearAllReceiver.clearAll(!exitingKeyguardSecurely);}}@Overrideprotected void onStop() {super.onStop();Log.v("SMSPopupActivity: onStop()");//Cancel the receiver that will clear our locksClearAllReceiver.removeCancel(getApplicationContext());ClearAllReceiver.clearAll(!exitingKeyguardSecurely);}@Overridepublic void onWindowFocusChanged(boolean hasFocus) {super.onWindowFocusChanged(hasFocus);Log.v("SMSPopupActivity: onWindowFocusChanged(" + hasFocus + ")");if (hasFocus) {wasVisible = true;}}@Overridepublic void onSaveInstanceState(Bundle outState) {super.onSaveInstanceState(outState);Log.v("SMSPopupActivity: onSaveInstanceState()");outState.putAll(bundle);}private void myFinish() {ManageNotification.clearAll(getApplicationContext());ReminderReceiver.cancelReminder(getApplicationContext());finish();}private void populateViews(Bundle b) {bundle = b;message = new SmsMmsMessage(getApplicationContext(), bundle);refreshPrivacy();Bitmap contactPhoto = message.getContactPhoto();if (contactPhoto != null) {iv.setImageBitmap(contactPhoto);} else {iv.setImageDrawable(}if (message.getUnreadCount() <= 1) {mLL.setVisibility(View.GONE);tv.setText("");} else {String textWaiting = String.format(.getUnreadCount() - 1);tv.setText(textWaiting);mLL.setVisibility(View.VISIBLE);}headerText = headerText.replaceAll("%s", message.getFormattedTimestamp());fromTV.setText(message.getContactName());if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_SMS) { messageTV.setText(message.getMessageBody());} else {}headerTV.setText(headerText);}private void refreshPrivacy() {ManageKeyguard.initialize(getApplicationContext());boolean privacyMode = myPrefs.getBoolean(if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_MMS) { viewButtonLayout.setVisibility(View.GONE);messageScrollView.setVisibility(View.GONE);mmsLinearLayout.setVisibility(View.VISIBLE);boolean subjectAvailable = true;if (message.getMessageBody() == null) {subjectAvailable = false;} else {if (message.getMessageBody().length() == 0) {subjectAvailable = false;}}if (!subjectAvailable) {mmsSubjectTV.setVisibility(View.GONE);} else {mmsSubjectTV.setVisibility(View.VISIBLE);}} else {mmsLinearLayout.setVisibility(View.GONE);if (privacyMode && ManageKeyguard.inKeyguardRestrictedInputMode()) {viewButtonLayout.setVisibility(View.VISIBLE);messageScrollView.setVisibility(View.GONE);} else {viewButtonLayout.setVisibility(View.GONE);messageScrollView.setVisibility(View.VISIBLE);}}}private void wakeApp() {ManageWakeLock.acquireFull(getApplicationContext());if (message.getNotify()) {bundle.putBoolean(SmsMmsMessage.EXTRAS_NOTIFY, false);message.updateReminderCount(0);ReminderReceiver.scheduleReminder(getApplicationContext(), message);ManageNotification.show(getApplicationContext(), message);}}@Overrideprotected void onDestroy() {Log.v("onDestroy()");super.onDestroy();}}public class SMSReceiver extends BroadcastReceiver {@Overridepublic void onReceive(Context context, Intent intent) {Log.v("SMSReceiver: onReceive()");intent.setClass(context, SMSReceiverService.class);intent.putExtra("result", getResultCode());SMSReceiverService.beginStartingService(context, intent);}}public class ReminderReceiver extends BroadcastReceiver {private static PendingIntent reminderPendingIntent = null;@Overridepublic void onReceive(Context context, Intent intent) {intent.setClass(context, ReminderReceiverService.class);ReminderReceiverService.beginStartingService(context, intent);}public static void scheduleReminder(Context context, SmsMmsMessage message) { SharedPreferences myPrefs = PreferenceManager.getDefaultSharedPreferences(context);boolean reminder_notifications = myPrefs.getBoolean(contextif (reminder_notifications) {int reminder_interval = Integer.parseInt(myPrefs.getString(contextreminder_interval *= 60;AlarmManager myAM = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);Intent reminderIntent = new Intent(context, ReminderReceiver.class);reminderIntent.setAction(ReminderReceiverService.ACTION_REMIND);message.incrementReminderCount();reminderIntent.putExtras(message.toBundle());reminderPendingIntent = PendingIntent.getBroadcast(context, 0, reminderIntent,PendingIntent.FLAG_CANCEL_CURRENT);long triggerTime = System.currentTimeMillis() + (reminder_interval * 1000);Log.v("ReminderReceiver: scheduled reminder notification in " + reminder_interval + " seconds, count is " + message.getReminderCount());myAM.set(AlarmManager.RTC_WAKEUP, triggerTime, reminderPendingIntent);}}public static void cancelReminder(Context context) {if (reminderPendingIntent != null) {AlarmManager myAM = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);myAM.cancel(reminderPendingIntent);reminderPendingIntent.cancel();reminderPendingIntent = null;Log.v("ReminderReceiver: cancelReminder()");}}}public class SMSReceiverService extends Service {private Context context;private ServiceHandler mServiceHandler;private Looper mServiceLooper;private int mResultCode;static final Object mStartingServiceSync = new Object();static PowerManager.WakeLock mStartingService;@Overridepublic void onCreate() {Log.v("SMSReceiverService: onCreate()");HandlerThread thread = new HandlerThread(Log.LOGTAG,Process.THREAD_PRIORITY_BACKGROUND);thread.start();context = getApplicationContext();mServiceLooper = thread.getLooper();mServiceHandler = new ServiceHandler(mServiceLooper);}@Overridepublic void onStart(Intent intent, int startId) {Log.v("SMSReceiverService: onStart()");mResultCode = intent.getIntExtra("result", 0);Message msg = mServiceHandler.obtainMessage();msg.arg1 = startId;msg.obj = intent;mServiceHandler.sendMessage(msg);}@Overridepublic void onDestroy() {Log.v("SMSReceiverService: onDestroy()");mServiceLooper.quit();}@Overridepublic IBinder onBind(Intent intent) {return null;}private final class ServiceHandler extends Handler {public ServiceHandler(Looper looper) {super(looper);}@Overridepublic void handleMessage(Message msg) {Log.v("SMSReceiverService: handleMessage()");int serviceId = msg.arg1;Intent intent = (Intent) msg.obj;String action = intent.getAction();String dataType = intent.getType();if (ACTION_SMS_RECEIVED.equals(action)) {handleSmsReceived(intent);} else if (ACTION_MMS_RECEIVED.equals(action) && MMS_DA TA_TYPE.equals(dataType)) {handleMmsReceived(intent);} else if (ACTION_MESSAGE_SENT.equals(action)) {handleMessageSent(intent);}finishStartingService(SMSReceiverService.this, serviceId);}}private void handleSmsReceived(Intent intent) {Log.v("SMSReceiver: Intercept SMS");StringBuilder body = new StringBuilder();Bundle bundle = intent.getExtras();if (bundle != null) {SharedPreferences myPrefs = PreferenceManager.getDefaultSharedPreferences(context);boolean onlyShowOnKeyguard = myPrefs.getBoolean(contextSmsMessage[] messages = SMSPopupUtils.getMessagesFromIntent(intent);if (messages != null) {SmsMessage sms = messages[0];} else {for (int i = 0; i < messages.length; i++) {body.append(messages[i].getMessageBody());}String address = messages[0].getOriginatingAddress();Log.v("sms address: " + address);Log.v("sms body: " + body);long timestamp = messages[0].getTimestampMillis();String message = body.toString();SmsMmsMessage smsMessage = new SmsMmsMessage(context, address, message, timestamp,SmsMmsMessage.MESSAGE_TYPE_SMS);ManageKeyguard.initialize(context);if (ManageKeyguard.inKeyguardRestrictedInputMode() || !onlyShowOnKeyguard) {Log.v("^^^^^^In keyguard or pref set to always show - showing popup activity");Intent popup = smsMessage.getPopupIntent();ManageWakeLock.acquirePartial(context);context.startActivity(popup);} else {Log.v("^^^^^^Not in keyguard, only using notification");ManageNotification.show(context, smsMessage);ReminderReceiver.scheduleReminder(context, smsMessage);}}}}}private void handleMmsReceived(Intent intent) {Log.v("MMS received!");SmsMmsMessage mmsMessage = SMSPopupUtils.getMmsDetails(context);if (mmsMessage != null) {SharedPreferences myPrefs = PreferenceManager.getDefaultSharedPreferences(context);boolean onlyShowOnKeyguard = myPrefs.getBoolean(contextif (ManageKeyguard.inKeyguardRestrictedInputMode() || !onlyShowOnKeyguard) { Log.v("^^^^^^In keyguard or pref set to always show - showing popup activity");Intent popup = mmsMessage.getPopupIntent();ManageWakeLock.acquirePartial(context);context.startActivity(popup);} else {Log.v("^^^^^^Not in keyguard, only using notification");ManageNotification.show(context, mmsMessage);ReminderReceiver.scheduleReminder(context, mmsMessage);}}}private void handleMessageSent(Intent intent) {if (mResultCode != Activity.RESULT_OK && mResultCode !=SmsManager.RESULT_ERROR_RADIO_OFF) {}}public static void beginStartingService(Context context, Intent intent) {synchronized (mStartingServiceSync) {Log.v("SMSReceiverService: beginStartingService()");if (mStartingService == null) {PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);mStartingService = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,Log.LOGTAG);mStartingService.setReferenceCounted(false);}mStartingService.acquire();context.startService(intent);}}public static void finishStartingService(Service service, int startId) {synchronized (mStartingServiceSync) {Log.v("SMSReceiverService: finishStartingService()");if (mStartingService != null) {if (service.stopSelfResult(startId)) {mStartingService.release();}}}}}public class GetWord {public static String zhuyuTemp;public static String ReturnSubject(String sInput){int i;String[] sInput2={};String temp;String[] zhuyu=new String[20];sInput2=sInput.split(" ");//讲输入的句子分为数组int k=0;for(i=0;i<sInput2.length;i++){if(sInput2[i].indexOf("/人称代词")!=-1){int index = sInput2[i].indexOf("/人称代词");temp=sInput2[i].substring(0,index);zhuyu[k]=temp;k++;}else if(sInput2[i].indexOf("/专有名")!=-1){int index = sInput2[i].indexOf("/专有名");temp=sInput2[i].substring(0,index);zhuyu[k]=temp;k++;}else if(sInput2[i].indexOf("/名词")!=-1){int index = sInput2[i].indexOf("/名词");temp=sInput2[i].substring(0,index);if(i>=1&&(sInput2[i-1].indexOf("/动词")!=-1||sInput2[i-1].indexOf("/能愿动词")!=-1||sInput2[i-1].indexOf("/把动词")!=-1)){}else{zhuyu[k]=temp;k++;}}else if(sInput2[i].indexOf("/地名")!=-1){int index = sInput2[i].indexOf("/地名");temp=sInput2[i].substring(0,index);zhuyu[k]=temp;k++;}else if(sInput2[i].indexOf("/时间短语")!=-1){int index = sInput2[i].indexOf("/时间短语");temp=sInput2[i].substring(0,index);zhuyu[k]=temp;k++;}else{}}zhuyuTemp=zhuyu[0];return zhuyu[0];}public static String ReturnPredicate(String sInput){ int i;String[] sInput2={};String temp;String[] weiyu=new String[20];sInput2=sInput.split(" ");//讲输入的句子分为数组int k=0;for(i=0;i<sInput2.length;i++){if(sInput2[i].indexOf("/动词")!=-1){int index = sInput2[i].indexOf("/动词");temp=sInput2[i].substring(0,index);weiyu[k]=temp;k++;}else if(sInput2[i].indexOf("/能愿动词")!=-1){int index = sInput2[i].indexOf("/能愿动词");temp=sInput2[i].substring(0,index);weiyu[k]=temp;k++;}else if(sInput2[i].indexOf("/形谓词")!=-1){int index = sInput2[i].indexOf("/形谓词");temp=sInput2[i].substring(0,index);weiyu[k]=temp;k++;}else if(sInput2[i].indexOf("/行为动词")!=-1){int index = sInput2[i].indexOf("/行为动词");temp=sInput2[i].substring(0,index);weiyu[k]=temp;k++;}else{}}return weiyu[0];}。
软著申请 源代码不加注释
软著申请源代码不加注释
在软件开发领域,源代码是一种包含程序逻辑和算法的文本文件。
它是开发人员编写的,用于创建计算机程序。
源代码通常使用特定的编程语言编写,例如C++、Java或Python。
源代码是程序的基础构建块,它描述了程序执行的步骤和逻辑。
然而,在编写源代码时,有些开发者可能会选择不加注释。
注释是一种解释源代码目的和功能的文本,它提供了对代码的说明和帮助。
不加注释的源代码可能会给其他开发者带来困惑。
没有注释的代码可能更难理解和维护。
开发者可能需要花费更多的时间和精力来理解源代码的功能和目的。
不加注释的源代码还可能导致团队合作的问题。
如果多个开发者一起工作,没有注释的代码可能会导致误解和错误。
开发者可能会浪费时间试图理解代码的含义,而不是专注于解决问题。
在编写源代码时,加注释是一种良好的编程实践。
通过注释,开发者可以提供对代码目的、功能和实现的详细说明。
注释还可以帮助其他开发者更轻松地理解和维护代码。
然而,有些开发者选择不加注释的原因可能是为了保护代码的商业机密或遵守公司政策。
在这种情况下,开发者通常会使用其他方式来记录代码的目的和功能,例如在项目管理工具中创建任务或文档。
源代码不加注释可能会给开发者带来困惑,增加代码理解和维护的难度。
加注释是一种良好的编程实践,可以提高代码的可读性和可维护性。
在编写源代码时,加注释是一个值得考虑的选择。
软件著作权包括源代码吗
软件著作权包括源代码吗
是的。
申请著作权中的源代码应当是你软件整体的源代码。
申请⼈申请软件著作权登记,应当提交如下材料:
(⼀)按要求填写的软件著作权登记申请表;
(⼆)软件的鉴别材料;软件的鉴别材料包括程序和⽂档的鉴别材料。
程序和⽂档的鉴别材料应当由源程序和任何⼀种⽂档前、后各连续30页组成。
整个程序和⽂档不到60页的,应当提交整个源程序和⽂档。
除特定情况外,程序每页不少于50⾏,⽂档每页不少于30⾏。
(三)相关的证明⽂件。
这些⽂件⼀般包括:⾃然⼈、法⼈或者其他组织的⾝份证明;有著作权归属书⾯合同或者项⽬任务书的,应当提交合同或者项⽬任务书;经原软件著作权⼈许可,在原有软件上开发的软件,应当提交原著作权⼈的许可证明;权利继承⼈、受让⼈或者承受⼈,提交权利继承、受让或者承受的证明。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
前言围棋不仅能增强思维能力,提高智力,而且富含哲理,有助于修身养性。
同时它起源于中国,古称“弈”,是我国传统技艺之一。
本游戏软件提供了人机对弈,和棋手对弈(局域网对弈)两种模式,局域网模式可以保证多人同时进行游戏。
本软件使用C#语言编写,在windows 7 x64系统下采用Visual Studio 2010开发和调试,附源码如下。
客户端程序:ype){case = (margin_left + i * gap - chessSize);= (margin_top + j * gap - chessSize);= (chessSize * 2);= (chessSize * 2);, rect);if (m_bShowIndex && m_Board[i, j].step > 0){(m_Board[i, j].(), fontNumber, , rect, format);}break;case = (margin_left + i * gap - chessSize);= (margin_top + j * gap - chessSize);= (chessSize * 2);= (chessSize * 2);int centerX = (margin_left + i * gap);int centerY = (margin_top + j * gap);, rect);(new Pen, 3), centerX - chessSize / 2, centerY - chessSize / 2, centerX + chessSize / 2, centerY + chessSize / 2);if (m_bShowIndex && m_Board[i, j].step > 0){(m_Board[i, j].(), fontNumber, , rect, format);}break;case = (margin_left + i * gap - chessSize);= (margin_top + j * gap - chessSize);= (chessSize * 2);= (chessSize * 2);, rect);if (m_bShowIndex && m_Board[i, j].step > 0){(m_Board[i, j].(), fontNumber, , rect, format);}break;case = (margin_left + i * gap - chessSize);= (margin_top + j * gap - chessSize);= (chessSize * 2);= (chessSize * 2);centerX = (margin_left + i * gap);centerY = (margin_top + j * gap);, rect);(new Pen, 3), centerX - chessSize / 2, centerY - chessSize / 2, centerX + chessSize / 2, centerY + chessSize / 2);if (m_bShowIndex && m_Board[i, j].step > 0){(m_Board[i, j].(), fontNumber, , rect, format);}break;case = (margin_left + i * gap - chessSize / 2);= (margin_top + j * gap - chessSize / 2);= (chessSize);= (chessSize);, rect);break;case = (margin_left + i * gap - chessSize / 2);= (margin_top + j * gap - chessSize / 2);= (chessSize);= (chessSize);, rect);break;case = (margin_left + i * gap - chessSize / 2);= (margin_top + j * gap - chessSize / 2);= (chessSize);= (chessSize);, rect);break;}}}}ype != return false;ype = type;#region 判断是否可以提子bool bEat = false;bool bValidStep = true;ype == (type)){ype == (type)){bEat = tryToEat(pos, new + 1, , ref bValidStep) || bEat;if (!bValidStep)return false;}ype == (type)){bEat = tryToEat(pos, new , - 1), ref bValidStep) || bEat;if (!bValidStep)return false;}ype == (type)){bEat = tryToEat(pos, new , + 1), ref bValidStep) || bEat;if (!bValidStep)return false;}#endregionif (!bEat)tep = m_currentStep;m_Board[, ].pos = pos;m_currentStep++;return true;}ype = newBoard[i, j];}}return true;}ype == '0' : (m_Board[j, i].type == '1' : '2';(ch);}(strLine);}();return true;}ype == {ChessBlock block;findBlock(new (i, j), out block);if > 0){type = foreach pos in block){if{newType = m_Board[ - 1, ].type;if (type == &&(newType == || newType == {type = newType;}else{if (type != &&type == (newType)){type = break;}}}if{newType = m_Board[ + 1, ].type;if (type == && (newType == || newType == {type = newType;}else{if (type != && type == (newType)){type = break;}}}if{newType = m_Board[, - 1].type;if (type == && (newType == || newType == {type = newType;}else{if (type != && type == (newType)){type = break;}}}if{newType = m_Board[, + 1].type;if (type == && (newType == || newType == {type = newType;}else{if (type != && type == (newType)){type = break;}}}}if (type == type = else if (type == type = elsetype = foreach posToFill in block){m_Board[, ].type = type;}}}}}}ype == {ChessBlock block;findBlockOnSim(new (i, j), out block);if > 0){type = foreach pos in block){if{newType = [ - 1, ].type;if (type == &&(newType == ||newType =={type = newType;}else{if (type != &&type == (newType)){type = break;}}}if{newType = [ + 1, ].type;if (type == && (newType == || newType == {type = newType;}else{if (type != && type == (newType)){type = break;}}}if{newType = [, - 1].type;if (type == && (newType == || newType == {type = newType;}else{if (type != && type == (newType)){type = break;}}}if{newType = [, + 1].type;if (type == && (newType == || newType == {type = newType;}else{if (type != && type == (newType)){type = break;}}}}if (type == type = else if (type == type = elsetype = foreach posToFill in block){[, ].type = type;}}}}}}ype == || m_Board[i, j].type == || m_Board[i, j].type == {m_Board[i, j].type = }}}}ype;if (type == || type == ||type == || type == {ChessBlock block;findBlock(pos, out block);if > 0){typeResult = switch (type){case typeResult = break;case typeResult = break;case typeResult = break;case typeResult = break;}foreach posToToggle in block){m_Board[, ].type = typeResult;}}}}ype == {m_Board[i, j].type = }else if (m_Board[i, j].type == {m_Board[i, j].type = }}}}ype){case case case nBlack++;break;case case case nWhite++;break;default:nPending++;break;}}}double fBlack = nBlack + (double)nPending / 2;double fWhite = nWhite + (double)nPending / 2;StringBuilder strResult = new StringBuilder();("黑子: " + () + "\n");("白子: " + () + "\n\n");("结果: ");fWhite += ;if (fBlack > fWhite){("黑子赢" + (fBlack - fWhite).ToString());}else if (fWhite > fBlack){("白子赢" + (fWhite - fBlack).ToString());}return ();}ype;while > 0){posCurrent = ();ype == type){(pos1);(pos1);}}ype == type){(pos1);(pos1);}}ype == type){(pos1);(pos1);}}ype == type){(pos1);(pos1);}}}}ype;while > 0){posCurrent = ();ype == type){(pos1);(pos1);}}ype == type){(pos1);(pos1);}}ype == type){(pos1);(pos1);}}ype == type){(pos1);(pos1);}}}}吃别人(包括劫持)被自己吃了Queue posToProcceed = new Queue();ype;ype == return true;if (!(pos1) && ype == type) ype == return true;if (!(pos1) && ype == type) ype == return true;if (!(pos1) && ype == type) ype == return true;if (!(pos1) && ype == type) ype = } }ype = }os, m_Board_backup[i, j].type, m_Board_backup[i, j].step);}}= = -= 2;return true;}os, m_Board[i, j].type, m_Board[i, j].step);}}= = }#region ==== 单人游戏时====ype == &&[i, j].step == 0){if (new (i, j), ))(new Node(new (i, j)));}}}if <= 0){= true;}#endregion#region 每个节点都进行若干回合的模拟棋局foreach (Node root in move_Node){for (int i = 0; i < numsim; ++i){CopyState(root); /* 复制棋局信息*/play_simulation(root); /* 进行模拟*/}}#endregionNode n = GetBestChild(move_Node); /* 获得根节点的访问次数最多的子节点*/return ; /* 返回节点着手*/}private bool CanAddChess pos, type){ype != return false;ype = type;#region 判断是否可以提子bool bEat = false;bool bValidStep = true;bool result = true;ype == (type)){ype == (type)){bEat = ChecktryToEat(pos, new + 1, , ref bValidStep) || bEat;if (!bValidStep)result = false;}ype == (type)){bEat = ChecktryToEat(pos, new , - 1), ref bValidStep) || bEat;if (!bValidStep)result = false;}ype == (type)){bEat = ChecktryToEat(pos, new , + 1), ref bValidStep) || bEat;if (!bValidStep)result = false;}#endregionype = return result;}private bool ChecktryToEat posNewChess, posToEat, ref bool bValidStep) {bValidStep = true;chessBlock;if (!isLive(posToEat, out chessBlock))ype != {return true;}}}return false;}private void CopyState(Node n){for (int i = 0; i < 19; ++i){for (int j = 0; j < 19; ++j){[i, j] = new Chess[i, j].pos, [i, j].type, [i, j].step);}}= = = ;, }ype){case case case nBlack++;break;case case case nWhite++;break;default:nPending++;break;}}}double fBlack = nBlack + (double)nPending / 2;double fWhite = nWhite + (double)nPending / 2;fWhite += ;if ((fBlack > fWhite && .ChessType .White)||(fBlack < fWhite && == {os;Chess chs = new Chess(pos, type, ;return chs;}ype != return false;ype = type;#region 判断是否可以提子bool bEat = false;bool bValidStep = true;ype == (type)){bEat = tryToEatOnSim(pos, new - 1, , ref bValidStep) || bEat;if (!bValidStep)return false;}ype == (type)){bEat = tryToEatOnSim(pos, new + 1, , ref bValidStep) || bEat;if (!bValidStep)return false;}ype == (type)){bEat = tryToEatOnSim(pos, new , - 1), ref bValidStep) || bEat;if (!bValidStep)return false;}ype == (type)){bEat = tryToEatOnSim(pos, new , + 1), ref bValidStep) || bEat;if (!bValidStep)return false;}#endregionif (!bEat)ype = else if (type == [, ].type = return false;tep = ;++;return true;}Eat others (Include "jie")Be eaten yourselfQueue posToProcceed = new Queue();ype;ype == return true;if (!(pos1) && ype == type) ype == return true;if (!(pos1) && ype == type) ype == return true;if (!(pos1) && ype == type) ype == return true;if (!(pos1) && ype == type) ype = ype =else[, ].type = }}ype;if (type == [, ].type = else if (type == [, ].type = }ins){();(node);}else if == temp1[0].wins){(node);}}List<Node> temp2 = new List<Node>();foreach (Node node in temp1){pos = ;if - <= 1 ||- <= 1){(node);continue;}if (3, , ){(node);}}Node result ;if > 0)result = temp2[ - 1)];elseresult = temp1[ - 1)];return result;}#endregion ==== 单人游戏时====;}amePlayer[side].user = user;gameTable[tableIndex].gamePlayer[side].someone = true;("{0}在第{1}桌第{2}座入座",, tableIndex + 1, side + 1));amePlayer[anotherSide].someone == true){amePlayer[anotherSide].;(user, sendString);}amePlayer[side].someone = false;gameTable[tableIndex].gamePlayer[side].started = false;gameTable[tableIndex].gamePlayer[side].grade = 0;anotherSide = (side + 1) % 2;if (gameTable[tableIndex].gamePlayer[anotherSide].someone == true){gameTable[tableIndex].gamePlayer[anotherSide].started = false;gameTable[tableIndex].gamePlayer[anotherSide].grade = 0;}ength +splitString[1].Length));(gameTable[tableIndex], sendString);break;case "Ready":amePlayer[side].started = true;if (side == 0){anotherSide = 1;sendString = "Message,黑方已准备。